我使用高圖表來呈現堆疊條形圖。堆疊條形圖中的選定系列上的邊框+高圖表
如何獲得邊框堆積條形圖當用戶點擊某個特定的系列?我試過標記選項,但是隻選擇了一個系列,但我希望選擇完整系列。
目前,我得到這樣的: -
不過,我想是這樣的: -
我使用高圖表來呈現堆疊條形圖。堆疊條形圖中的選定系列上的邊框+高圖表
如何獲得邊框堆積條形圖當用戶點擊某個特定的系列?我試過標記選項,但是隻選擇了一個系列,但我希望選擇完整系列。
目前,我得到這樣的: -
不過,我想是這樣的: -
您可以使用渲染器在後臺添加這樣的矩形: 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