简体   繁体   English

如何同步Highchart朝阳行为

[英]How to synchronize the Highchart Sunburst behavior

在此处输入图片说明

As shown in the image, I want to show two sunbursts next to each other. 如图所示,我要显示两个相邻的森伯斯特。 I want to implement it with Highchart and react in such a way where, 我想用Highchart实施它,并以这种方式做出反应,

If user mouse over on any data point on one sunburst, same data point should get highlighted on another chart, while other data points just goes into disabled mode or changes their color to white 如果用户将鼠标悬停在一个旭日形图的任何数据点上,则同一数据点应在另一图表上突出显示,而其他数据点只是进入禁用模式或将其颜色更改为白色

In mouseOver event, by using references to the charts, you can programmatically set 'hover' state at the right point: mouseOver事件中,通过使用对图表的引用,可以在正确的位置以编程方式设置“悬停”状态:

        point: {
          events: {
            mouseOver: function() {
              const chart1 = component.highchartsChart1.current.chart;
              const chart2 = component.highchartsChart2.current.chart;

              function clearState(chart) {
                Highcharts.each(chart.series[0].points, function(p) {
                  p.setState("");
                });
              }

              if (this.series.chart === chart1) {
                clearState(chart2);
                chart2.series[0].points[this.index].setState("hover");
              } else {
                clearState(chart1);
                chart1.series[0].points[this.index].setState("hover");
              }
            }
          }
        }

Live demo: https://codesandbox.io/s/nn54z2234m 现场演示: https : //codesandbox.io/s/nn54z2234m

API: https://api.highcharts.com/class-reference/Highcharts.Point#setState API: https//api.highcharts.com/class-reference/Highcharts.Point#setState

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM