将其他数据添加到Highcharts系列以用于格式化程序 [英] Add additional data to a Highcharts series for use in formatters
问题描述
我的问题与此问题中的OP完全相同:
但接受的答案解释了如何将附加数据添加到点,而不是系列,没有说是否可以处理系列作品。
我希望能够定义一个系列:
系列:[
{hasCustomFlag:true,name:s1,data :[...]},
{hasCustomFlag:false,name:s2,data:[...]},
]
并且能够在格式化函数中使用 point.series.hasCustomFlag
。这是可能的吗?
我不想将数据放在点级别上,因为这意味着我必须重复数据太多次。
是的,这是可能的,额外的配置属性位于选项下
property( this.series
指的是系列实例,而不是配置对象)。请参阅此处参考,并向下滚动到属性部分。
因此,请在格式化程序中使用以下行:
if(this.series.options.hasCustomFlag){ ...}
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.
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
这篇关于将其他数据添加到Highcharts系列以用于格式化程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!