admin管理员组文章数量:1336631
I have a question.
I am using highchars in my project and i wanna know if it's possible to show an image (in this case i wanna show a google map static image) on the tooltip?
Thanks in advance
I have a question.
I am using highchars in my project and i wanna know if it's possible to show an image (in this case i wanna show a google map static image) on the tooltip?
Thanks in advance
Share Improve this question asked Dec 12, 2011 at 12:33 Miguel TeixeiraMiguel Teixeira 7931 gold badge10 silver badges29 bronze badges 2- I think a question like this has already been asked here: stackoverflow./questions/7399051/…, and was answered by one of the developers at Highsoft. Also check out the api, which doesn't appear to make any provision for your request. highcharts./ref/#tooltip – mg1075 Commented Dec 12, 2011 at 23:28
- I can't answer my question, so i'll leave here my solution. In the tooltip i added useHtml: true. Then in the formatter i've make a function return some html beyond the ones that highcharts supports (in my case <img> tag) – Miguel Teixeira Commented Dec 15, 2011 at 17:51
1 Answer
Reset to default 6You can Use HTML to render the contents of the tooltip instead of SVG. Using HTML allows advanced formatting like tables and images in the tooltip.
Check out the 'formatter' option inside tooltip:
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
tooltip: {
useHTML: true,
headerFormat: '<small>{point.key}</small><table>',
pointFormat: '<tr><td style="color: {series.color}">{series.name}: </td>' +
'<td style="text-align: right"><b>{point.y} EUR</b></td></tr>',
footerFormat: '</table>',
formatter: function() {
return '<img src="http://static.adzerk/Advertisers/bd294ce7ff4c43b6aad4aa4169fb819b.jpg" title="" alt="" border="0" height="250" width="220">';
},
valueDecimals: 2
},
series: [{
name: 'Short',
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
name: 'Long named series',
data: [129.9, 171.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 195.6, 154.4].reverse()
}]
});
});
You can just insert the code of the static Google map image you were talking about.
Hope that helps.
本文标签: javascriptHighcharts tooltip imageStack Overflow
版权声明:本文标题:javascript - Highcharts tooltip image - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742380142a2463939.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论