28

My question is exactly the same as the OP in this question:

Set Additional Data to highcharts series

But the accepted answer explains how to add additional data to the point, not the series, without saying if it's possible to do with the series or not.

I would like to be able to define a series like:

series: [
    {"hasCustomFlag": true, "name": "s1", "data": [...]},
    {"hasCustomFlag": false, "name": "s2", "data": [...]},
]

and be able to use point.series.hasCustomFlag inside of a formatting function. Is this possible?

I don't want to put the data on the point level, because that means I'd have to duplicate the data far too many times.

Community
  • 1
  • 1
Eli Stevens
  • 1,447
  • 1
  • 12
  • 21

2 Answers2

49

Yes this is possible, the extra configuration properties is located under the options property (this.series refers to the series instance, not the configuration objects). See the reference here and scroll down to properties section.

So instead use this line in the formatter:

if (this.series.options.hasCustomFlag) { ... }

Full example on jsfiddle

leoflower
  • 563
  • 7
  • 13
eolsson
  • 12,567
  • 3
  • 41
  • 43
3

This appears to have been revised with later iterations of HighCharts/HighStocks. The jsfiddle example no longer works. Using the "this.series.options.hasCustomFlag" syntax results in "undefined". The debugger shows the data I'm looking for is in "this.series.userOptions.data" - an unsorted very large array, but the entire series is there - not the specific record data you normally get with this.x or this.y.

Dick
  • 41
  • 2
  • It does still work if you get the proper latest highcharts.js script, like so: http://jsfiddle.net/jNXV8/51/ – Oliboy50 Jul 02 '15 at 16:09
  • I've updated it again to use https to load Highcharts, doesn't work without. https://jsfiddle.net/jNXV8/70/ – jon1467 Jul 13 '18 at 15:57