2015-05-14 35 views

回答

0

綁定legendItemClick事件並在餅圖中隱藏連接的切片。演示:http://jsfiddle.net/x8ygvwbx/1/

plotOptions: { 
     series: { 
      events: { 
       legendItemClick: function(e) { 
        var vis = this.visibility, 
         name = this.name, 
         pie = this.chart.get("my-pie"), // set pie's ID 
         index = pie.options.legendNames.indexOf(name); // get index of names 

        pie.points[index].setVisible(vis); //change visibility 
       } 
      } 
     } 
    }, 

和舉例餡餅選項:

{ 
     id: "my-pie", // ID 
     type: 'pie', 
     name: 'Total consumption', 
     legendNames: ["Jane", "John", "Joe"], //NAMES 
     data: [{ 
      name: 'Jane', 
      y: 13, 
      color: Highcharts.getOptions().colors[0] // Jane's color 
     }, { 
      name: 'John', 
      y: 23, 
      color: Highcharts.getOptions().colors[1] // John's color 
     }, { 
      name: 'Joe', 
      y: 19, 
      color: Highcharts.getOptions().colors[2] // Joe's color 
     }] 
    }