formatting all the markers for the hovering series in a HighCharts scatterplot

≯℡__Kan透↙ 提交于 2019-12-25 15:52:27

问题


I want to change the appearange of all the markers (not only the one pointed) when hovering the series, but the following code (http://jsfiddle.net/fw852fy9/4/) does not work properly. What's wrong?

Highcharts.chart('container', {
        chart: {
            type: 'scatter'
        },
    plotOptions: {
      series: {
        lineWidth:1,
              states: {
                  hover: {
                      lineWidthPlus: 2,
            marker: {
              enabled: true,
              radius:3,
              states: {
                hover: {
                  fillColor:'#FF0000',
                  lineColor:'#00FF00',
                  lineWidth:3,
                  radius:12
                }
              }
            }  
                  }
              },
        marker: {
          enabled: true,
          radius:3,
          states: {
                  hover: {
              fillColor:'#FF0000',
              lineColor:'#00FF00',
              lineWidth:3,
              radius:12
              }
          }
        }
      }  
    },
    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]]
    }]
});

回答1:


Hover state works only for the point which is hovered. If you want to set all the markers to be hovered, you need to change their state programmatically, e.g. on series mouseover/mouseout.

  series: [{
 stickyTracking: false,
events: {
  mouseOver: function() {
    this.data.forEach(p => p.setState('hover'))
  },
  mouseOut: function() {
    this.data.forEach(p => p.setState())
  }
},

example: http://jsfiddle.net/0zu9jmca/



来源:https://stackoverflow.com/questions/44979218/formatting-all-the-markers-for-the-hovering-series-in-a-highcharts-scatterplot

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