Add additional data to a Highcharts series for use in formatters

Eli Stevens picture Eli Stevens · Jan 6, 2012 · Viewed 19.8k times · Source

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.

Answer

eolsson picture eolsson · Jan 6, 2012

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