在SVG不能爲圖像中設置邊界,你需要創建圖像周圍的矩形:http://jsfiddle.net/xuL76rkL/1/
例如,你可以使用load
和redraw
事件來管理這些rects,代碼:
var H = Highcharts;
function drawBorder() {
var chart = this;
H.each(chart.series[1].points, function(p) {
var bbox,
rect,
fontSize = 13, // it's used as default font size offet, even for the images
dim = 32; //width and height for the image
if(p.graphic) {
if(p.rectangle) {
p.rectangle.destroy();
}
bbox = p.graphic.getBBox();
rect = chart.renderer.rect(p.plotX - dim/2, p.plotY - dim/2 - fontSize, dim, dim).attr({
"stroke": "black",
"stroke-width": 2,
"fill": "transparent"
}).add(chart.series[1].markerGroup);
p.rectangle = rect;
}
});
}
$('#container').highcharts('StockChart', {
chart: {
events: {
load: drawBorder,
redraw: drawBorder
}
},
...
});
你必須讓你的HTML至少.. – makshh
你可以試着抓住負載/重繪圖表事件,然後使用渲染器添加自定義圖像。 (http://api.highcharts.com/highcharts#Renderer.image) –