highcharts-editor icon indicating copy to clipboard operation
highcharts-editor copied to clipboard

Strange behaviour of DataLabel.Format

Open berdeter opened this issue 8 years ago • 7 comments

Create a simple Pie Chart from sample data (single data column with categories)

You can see X is browser name and y is poucentages capture

Select Pie with legend as template capture2

Activate value labels (great but it shows X that you already have in the legend. You want Y) capture3

In advanced mode you see that it is configured to show y (but you see X) capture4

Put an {x} : you lose all labels Put a {y} : you see the Y !!! capture5

Good luck fixing this one. Thanks for all

PS : why are some values shadowed, not all ? Great question ...

berdeter avatar Dec 08 '16 16:12 berdeter

Thanks for reporting! We'll look into this.

About the shadows, I couldn't say, will look into that too.

cvasseng avatar Dec 09 '16 07:12 cvasseng

why are some values shadowed, not all ? Great question ...

Probably the default dataLabels.formatter overrides the format. Also, the pie slices don't have an x value. What you see is {name}.

The black label has a white outline, you just don't see it on the white background. This label color is determined to give max contrast to the slice itself, however this wouldn't be necessary in this case.

TorsteinHonsi avatar Dec 09 '16 07:12 TorsteinHonsi

I've done new tests in this area its more and more surprising.

First I've tricked the sample data so that column 2 is not actually percentages but amounts

capture

Then I adjusted the format to display several fields and the result is quite strange :

capture2

name : not displayed ? x : not displayed but ok it's not relevant y : does display something that seems to actually be a percentage in my data but it is not easy to confirm because the graph does not show names percentage : displays a value that looks like the percentage shown on the graph but has nothing to do with actual percentages (no data is around 53% of the total the graph itself show data coming from the same kind of fantasy as the percentage but has no link with the data

Yet another screenshot with data and pie beside each other ...

capture3

berdeter avatar Dec 12 '16 13:12 berdeter

Yet another sample with the same data that locates the problem more in the area of CSV data import :

image

berdeter avatar Dec 12 '16 13:12 berdeter

The values look correct in Highcharts, except we need to use {point.name}: http://jsfiddle.net/highcharts/rasudxy1/

Also, some number formatting helps readability: http://jsfiddle.net/highcharts/rasudxy1/1/

TorsteinHonsi avatar Dec 12 '16 14:12 TorsteinHonsi

Thank you for the help.

So I there are 3 problems remaining around the editor :

  • CSV import from the editor does some kind of manipulations on numbers. I've tries with JSON and it works fine so I'll use JSON instead of CSV so this is not blocking me anymore
  • Couldn't find a way (from the editor ?) to have both the legend and the data labels on the same pie chart. It is not blocking either as I could display all the information in the data label.
  • The editor shows initially Legend.Format={y} but displays the value of {point.name}. Not a big deal when you know it.

Additionally I don't really undersandwhen you need to perfix by "point." (here you had to do iy for {point.name} but not for{y} and {percentage} but that must be a documentation issue.

Well anyway I can do what I want now...

berdeter avatar Dec 12 '16 16:12 berdeter

The editor shows initially Legend.Format={y} but displays the value of {point.name}. Not a big deal when you know it.

@cvasseng This is probably also something that is set in the template, but not reflected in the GUI.

TorsteinHonsi avatar Dec 13 '16 07:12 TorsteinHonsi