我已根据Highcharts文档和此示例创建了自己的主从明细表:www.highcharts/demo/dynamic-master-detail
I have created my own master-detail chart following the Highcharts docs and this example: www.highcharts/demo/dynamic-master-detail
一切正常,但我想添加一个功能:加载图表时,应在主图表中自动选择最后50个数据点,并在详细图表中显示.
Eveything works fine but I would like to add a feature: When the chart is loaded the last 50 data points should automatically be selected in the master chart and thus shown in the detail chart.
我试图手动触发选择事件,但是没有成功.知道如何解决这个问题吗?
I tried to manually trigger the selection event but it did not work out. Any idea how to solve this?
推荐答案您可以在图表加载事件中触发 selection 事件并设置正确的极限值:
You can fire selection event in chart load event and set correct extremes:
chart: { ... events: { load: function() { var points = this.series[0].points, xAxis = this.xAxis[0]; Highcharts.fireEvent(this, 'selection', { xAxis: [{ min: points[points.length - 51].x, max: points[points.length - 1].x }], }); }, selection: function(event) { ... } } }实时演示: jsfiddle/BlackLabel/xy8qug9h/
API: api.highcharts/highcharts/chart.events.load
更多推荐
如何以编程方式设置选择Highchats主细节图表?
发布评论