[英]Highcharts tooltips with embedded sparklines
I want to create a map with tooltips that show some additional data shown in the tooltip as a collection of sparklines.我想创建一个带有工具提示的地图,将工具提示中显示的一些附加数据显示为迷你图的集合。 Basically I want to achieve a similar effect to this map .基本上我想达到与这张地图类似的效果。 I have looked through the Highcharts tooltip formatter documentation but it seems that the HTML code that I can pass to the formatter function is quite limited.我查看了 Highcharts工具提示格式化程序文档,但似乎可以传递给格式化程序函数的 HTML 代码非常有限。
So in nutshell, is there way to embed a sparkline in a Highcharts tooltip or is this not really possible?所以简而言之,有没有办法在 Highcharts 工具提示中嵌入迷你图,或者这真的不可能?
You can create a chart in a tooltip by using a setTimeout
callback function:您可以使用setTimeout
回调函数在工具提示中创建图表:
tooltip: {
useHTML: true,
formatter: function() {
setTimeout(function() {
Highcharts.chart('tooltip-chart', {
...
});
}, 10)
return '<div style="width: 100px; height: 60px;" id="tooltip-chart"></div>';
}
}
Live demo: https://jsfiddle.net/BlackLabel/yqtvr5Lm/现场演示: https : //jsfiddle.net/BlackLabel/yqtvr5Lm/
API Reference: https://api.highcharts.com/highcharts/tooltip.formatter API参考: https : //api.highcharts.com/highcharts/tooltip.formatter
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.