简体   繁体   English

Highcharts图中的自定义工具提示

[英]Custom tooltips in Highcharts diagrams

Is there any way to make completely custom tooltips in Highcharts diagrams? 有没有办法在Highcharts图表中完全自定义工具提示? Not just with different data, or with coloured border, but to make it look different (for example, like a bubble with picture in it). 不仅使用不同的数据,还是使用彩色边框,而是使其看起来不同(例如,像带有图片的气泡)。

Try this: 尝试这个:

.... ....

tooltip: {
                useHTML: true,
                formatter: function() { 
                    return 'here the html code';
                }
            },

I've used another post from a different thread, and merged the useHTML section along with it to add an image as part of each tool tip at the top. 我使用了来自不同线程的另一篇文章,并将useHTML部分与它合并,以在顶部添加图像作为每个工具提示的一部分。 I chose BBC logo at the top.. 我在顶部选择了BBC标志..

so, you can use 所以,你可以使用

tooltip: {
    useHTML: true,
    formatter: function() { 
        // Use regular html syntax
        s = '<img src="" />' + 
        return s;
    }
}

Here is the jsfiddle working example 这是jsfiddle工作示例

Using the options/api you can only configure such things as border properties and colors (see tooltip options ). 使用选项/ api,您只能配置边框属性和颜色等内容(请参阅工具提示选项 )。 So without editing the source or going outside the api, no it is not possible. 因此,如果不编辑源代码或者不在api之外,那就不可能了。

Internally the tooltip consists of a SVG group that contains a rectangle with a text inside. 在工具提示内部由一个SVG组组成,该组包含一个内部带有文本的矩形。 If you want to edit the source, have a look in the Chart.js file around line 1898 . 如果要编辑源代码,请查看1898行周围的Chart.js文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM