问题描述
我一直在搜索和大量示例,但似乎不能找到我想要的。
I've been searching through the API docs and lots of examples, but can't seem to find what I want.
我有一个图例的饼图。当你点击一个切片,它变成偏移(这是伟大的)。我想在单击图例项目时的此行为。
I have a pie chart with a legend. When you click a slice, it becomes offset (this is great). I would like this behaviour when you click on a legend item.
是否可以通过图例点击实现偏移切片?
Is it possible to achieve an offset slice via legend click?
图例,相关切片变为偏移。
So if you click on an item in the legend, the relevant slice becomes offset.
似乎使用的方法是,例如:
It seems that the method to use is legendItemClick
, eg:
options: {
chart: {
type: 'pie'
},
plotOptions: {
//etc
series: {
point: {
events: {
legendItemClick: function () {
//return false; // this cancels the default action.
console.log(this);
//this.findtheSlice.makeItOffset(); //want to do something like this
}
}
}
}
//etc
}
}
}
href =http://jsfiddle.net/95n2mm02/2/ =nofollow> JSFiddle
Here is a JSFiddle
似乎没有方法可以实现这一点,所以可能需要深入到api。
It seems that there isn't a method available to achieve this so may need to go deep into the api.
任何帮助将非常感谢!
Any help would be very appreciated!
Btw,我使用一个angular指令为highcharts(highcharts-ng)。
Btw, i'm using an angular directive for highcharts (highcharts-ng). There are some subtle differences.
推荐答案
在legendItemClick中,你应该调用 this.slice code>然后返回false。
In the legendItemClick you should call this.slice()
and then return false.
point: {
events: {
legendItemClick: function () {
this.slice();
return false;
}
}
},
示例:
这篇关于Highcharts饼图 - 偏移单个切片上的图例点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!