Closed JulienBacquart closed 4 months ago
Thanks, @JulienBacquart : This looks to be a bug. I'll look into it and resolve it in the next release.
Hi @hcpchris
Looking at the code code, I don't think it will work, because of this part:
def distance(self, value):
if not value:
self._distance = None
According to the PEP8 :
Also, beware of writing if x when you really mean if x is not None – e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!
I think you should be using:
if value is None:
self._distance = None
Because if you use:
if not value:
self._distance = None
You will return None
for all cases where value
is equal to [], {}, (), '', 0, False
.
The problem is 0
is a correct value for distance.
The default value is 30 : https://api.highcharts.com/highcharts/plotOptions.pie.dataLabels.distance
So setting distance to 0 has an effect, as you can see here: https://jsfiddle.net/1s972jkr/
I think I run in the same problem in other places:
'tooltip': {
'headerFormat': '',
...,
In my opinion, the empty string should be a valid value to override the default headerFormat
, but this code does nothing.
You have to do something like:
'tooltip': {
'headerFormat': 'null',
...,
Thanks, @JulienBacquart : That's a good catch. Typically, if a false-y value is a valid value I employ the if value is None
pattern, but in this case I failed to consider a distance
value of 0
. I'll patch that in a release of v.1.9.2 later today.
As for the tooltip.headerFormat
, I'll take a closer look at that case and consider it in this release as well. There may be places where we're being overly broad in searching for False-y values, and other cases where we're not being broad enough.
Hi @hcpchris , The first example works fine now, but the second example doesn't.
It's probably because we have different hierarchies, as a parameter for a pie
or a series
:
plotOptions: {
pie: {
dataLabels: {
distance: -100,
plotOptions: {
series: {
dataLabels: [{
distance: 20,
Hi @hcpchris,
From the donut-charts.ipynb demos:
The
distance
keyword for the dataLabels has no effect, whatever the value.Running:
Return:
Where the
distance
keyword is not present.If I look at the data_labels class, I can't see no
distance
keyword. But the JS class seems to have it: https://api.highcharts.com/highcharts/series.pie.dataLabels.distanceTrying to run this JS demo for the pie chart
Result in all labels overlapping because of the
distance
keyword missing: