选择Point.select事件中的第二个点 [英] HIghcharts, Selecting a second Point within the Point.select event
问题描述
$(function () {
var chart = {
plotOptions: {
series: {
point: {
'events' : {
select: function(){
var pId = this.series.data.indexOf(this);
var chart1 = $('#container').highcharts();
var chart2 = $('#container2').highcharts();
//These are the extra selects I want to happen
//chart1.series[0].data[5].select(true,true);
//chart2.series[0].data[pId].select();
}
}
}
}
},
series: [{
data: [29.9, 71.5, 106.4,
129.2, 144.0, 176.0,
135.6, 148.5, 216.4,
194.1, 95.6, 54.4]
}]
};
$('#container').highcharts(chart);
$('#container2').highcharts(chart);
var chart = $('#container').highcharts();
i = 0;
$('#button').click(function() {
if (i == chart.series[0].data.length)
i = 0;
chart.series[0].data[i].select();
i++;
});
});
http://jsfiddle.net/rphne/
您可以看到我在尝试实现那里。基本上,我想在同一个图表上选择一个点,以及在选择事件发生后第二个图上的点。
You can see what I'm trying to achieve there. Essentially, I want to select a point on the same graph, as well as a point on a second graph after the select event occurs.
在上面的例子中,选择图表1和图表2上的同一点,以及在自己上选择第二个点的图表。
In the example above, it should select the same point on chart 1 and chart 2, as well as chart1 selecting a second point on itself.
我想做一个.Select(true,true)累加,但是这在select事件中完成时失败。我相信我正在寻找一个回调事件类型的东西,所以,在Select成功完成后,我可以做我额外的选择。
I figured just doing a .Select(true,true) would accumulate, however this fails when done within the select event. I believe I'm looking for a callback event kind of thing, so that after the Select has successfully completed, I can then do my extra selects.
任何建议? / p>
Any advice?
推荐答案
在按钮动作中,从一个图表中只选择一个点,因为使用 chart.series [ 0] .data [i] .select();
。只需要为第二个图表添加相同的操作。
In the button action you select only one point from one chart, because use use chart.series[0].data[i].select();
in first object. Only what you need is add the same action for second chart.
编辑:
您也可以使用setState()函数同步两者图表。
http://jsfiddle.net/rphne/6/
这篇关于选择Point.select事件中的第二个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!