disable hover on special slice of pie chart

你。 提交于 2020-01-06 17:26:19

问题


I know how to disable hover on highcharts, and I edit the answer to disable hove on special slice as this demo, but it doesn't work.

I edit series attribute as the following:

series: [{
  showInLegend: false,
  type: 'pie',
  name: 'Pie Chart',
  data: [
    ['Mobile', 65], // first half of pie
    {
       name: 'Other', 
       y: 35, 
       tooltip: { enabled: false }
    } // second half of pie
  ]

How can I disable hover for special slices on pie charts using highcharts ?


回答1:


You were pretty close with your custom tooltip property idea. I personally rather using custom names as well, therefor instead of adding a tooltip data object, i'd use a custom property named tooltipDisabled:

{name: 'Other', y: 35, tooltipDisabled:true} // second half of pie

And then, using a tooltip formatter function (a callback function called when a point is hoverd, which is totally override-able), I'd discriminate the points with this property:

    tooltip: {
        useHTML:true,
        formatter: function(){
            return this.point.tooltipDisabled ? false : this.point.name +"<br><span style='font-size:18px;vertical-align:middle'>&#8226;</span>"+this.series.name+": <b>"+this.y+"</b>";
        }

returning false, as you have probably guessed, disables the tooltip. (as you can see I also added useHTML:true, so highcharts renders the bullet next to the point name.

See fiddle: http://jsfiddle.net/e7brd9do/2/



来源:https://stackoverflow.com/questions/27341761/disable-hover-on-special-slice-of-pie-chart

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