简体   繁体   中英

How to display custom text for a specific category in pie chart tool tip

I have a pie chart and I want to display custom text specifically for a specific category when the user hovers over the category.

JS Fiddle Link: https://jsfiddle.net/mewohraz/1/

tooltip: {
    pointFormat: '{point.custom} (point.category == 'Internet Explorer) ? 'display customtext'
},

eg when the user hovers over Internet Explorer, I want to display a bullet list of versions. The text will be hard coded so it's not coming from data series.

How do I do this?

You can user the formatter function of the tooltip option to defined your own text : tooltip.formatter

tooltip: {
    formatter: function(){
        if(this.point.name == "Internet Explorer")
            return "my custom text" ;
        else
            return '<span style="color: ' + this.point.color + '">' + this.point.name + '</span><br/>' + this.point.custom ;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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