使用chart.renderer.text
和chart.renderer.rect
根據圖像的位置繪製和定位您自己的自定義工具提示。
這是一個示例代碼段我用於顯示工具提示其使用chart.renderer.image
生成的圖像 -
marker = chart.renderer.image(src, x, y, imageSize, imageSize)
.on('click', function() {`enter code here`
})
.attr({
zIndex: 100
})
.on('mouseover', function() {
//Call back for image mouse hover
//Draw a text relative to Image X and Y
text = chart.renderer.text("Your tooltip Text",X, Y)
.add();
var box = text.getBBox();
//Now draw a box surrounding the tool tip text
textBG = chart.renderer.rect(box.x, box.y,box.width, box.height, 5)
.attr({
fill: '#FFFFEF',
stroke: 'gray',
'stroke-width': 1,
zIndex: 4
})
.add();
})
.on('mouseout', function() {
//Call back for mouse out on the image
//Destroy Both markers text and textBG on mouse out
//Make text and textBG as global functions for access accross functions
text.destroy();
textBG.destroy();
})
.add();
以這種方式可以創建圖像的自定義工具提示。
我使用this鏈接來添加工具提示文本及其背景到圖表的語法。
謝謝。這是一個非常有用的指針。我確實使用它來定製呈現多個圖表標記所需的組件(使用自定義顏色和工具提示+事件行爲和數據)。 – 2014-10-13 21:44:06
如何使用多個渲染圖像?我嘗試它,但工具提示位置總是顯示在最後的圖像位置。 – ISCI 2014-11-28 04:58:25