我使用高图表来呈现堆叠条形图。堆叠条形图中的选定系列上的边框+高图表
如何获得边框堆积条形图当用户点击某个特定的系列?我试过标记选项,但是只选择了一个系列,但我希望选择完整系列。
目前,我得到这样的: -
不过,我想是这样的: -
我使用高图表来呈现堆叠条形图。堆叠条形图中的选定系列上的边框+高图表
如何获得边框堆积条形图当用户点击某个特定的系列?我试过标记选项,但是只选择了一个系列,但我希望选择完整系列。
目前,我得到这样的: -
不过,我想是这样的: -
您可以使用渲染器在后台添加这样的矩形: http://jsfiddle.net/3Utat/25/
mouseOver: function() {
var chart = this.series.chart,
r = chart.renderer,
shape = this.shapeArgs, // shape args for the points rect element
xAxis = this.series.xAxis,
yAxis = this.series.yAxis,
y = yAxis.toPixels(this.total), // top left y-position of the rect
x = this.plotX + chart.plotLeft - shape.width/2, // point position + left offset + half width
height = yAxis.toPixels(yAxis.min) - y; // bottom - top
if (chart.hoverStack) {
chart.hoverStack.destroy();
}
chart.hoverStack = r.rect(x, y, shape.width, height).attr({
'stroke-width': 6, //border width
'stroke': 'black', //border color
'fill': 'transparent' //transparent fill color
}).add();
},
mouseOut: function() {
if (this.series.chart.hoverStack) {
this.series.chart.hoverStack.destroy();
this.series.chart.hoverStack = false;
}
}
示例使用的是mouseOver
和mouseOut
事件,但在您的情况下,您可以使用click
事件。
至于建议的帕维尔,正确的小提琴边境上选择 堆积条形图是: -
click: function() {
var chart = this.series.chart,
r = chart.renderer,
shape = this.shapeArgs,
xAxis = this.series.xAxis,
yAxis = this.series.yAxis,
y = yAxis.toPixels(this.total),
x = this.plotX - shape.width/2,
height = Math.abs(yAxis.toPixels(yAxis.min) - y);
if (chart.hoverStack) {
chart.hoverStack.destroy();
}
chart.hoverStack = r.rect(x, chart.plotWidth+chart.plotLeft-y, shape.width, height).attr({
'stroke-width': 6,
'stroke': 'black',
fill: 'transparent',
transform: 'translate(' + (chart.plotWidth+chart.plotLeft) + ' ' + (chart.plotHeight+chart.plotTop) + ') rotate(90) scale(-1,1)'
}).add();
}
Waoo,我雷尔ÿ感谢ü的回答。这真的解决了我的问题。虽然,这将需要一点了解你做了什么。我会问你是否觉得理解困难....再次感谢! – 2015-02-24 15:51:23
我猜测是这样的,这就是为什么答案中的代码有相当的评论;)其余来自官方的API(toPixels,destroy,rect,attr,add等方法)。 – 2015-02-24 15:55:44
@ Pawel ..我还没有尝试..,只是问,这可以为堆叠条形图也做一些调整? – 2015-02-24 15:58:57