[英]Border on selected series in Stacked Bar charts + High Charts
我使用高图表来渲染堆积条形图。
当用户点击特定系列时,如何在堆积条形图上获取边框? 我尝试了标记选项但是只选择了一个系列,但我希望选择完整的系列。
目前我是这样的: -
但是,我想这样: -
您可以使用渲染器在后台添加这样的rect: 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
事件。
正如Pawel所建议的那样,选定的堆积条形图上正确的边框小提琴是: -
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();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.