HIghcharts, Selecting a second Point within the Point.select event

烂漫一生 提交于 2019-12-24 21:27:56

问题


$(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/

http://jsfiddle.net/rphne/5/

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.

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.

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.

Any advice?


回答1:


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.

http://jsfiddle.net/rphne/1/

EDIT: You can also use setState() function to sychronise both charts. http://jsfiddle.net/rphne/6/



来源:https://stackoverflow.com/questions/17233045/highcharts-selecting-a-second-point-within-the-point-select-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!