简体   繁体   中英

Highcharts Tooltip At Column Chart

I am working on this example: http://www.highcharts.com/demo/combo

When I hover to some color pie chart, ie blue the tooltip is

Jane: 13 fruits

However when I hover to first colum (blue one at apples) tooltip is:

Apples: 3

Its Jane's apples. So how can I change it to:

Jane : 3 apples

Any ideas?

PS :

The tooltip formatter used at example is:

    tooltip: {
        formatter: function() {
            var s;
            if (this.point.name) { // the pie chart
                s = ''+
                    this.point.name +': '+ this.y +' fruits';
            } else {
                s = ''+
                    this.x  +': '+ this.y;
            }
            return s;
        }
    }

You can get the series data using this.series.someAttr .
So, do the following:

formatter: function() {
    var s;
    if (this.point.name) { // the pie chart
        s = this.point.name +' '+ this.y +' fruits';
    } else {
        s = this.series.name + ' : ' +
            this.x  +': '+ this.y;
    }
    return s;
}

demo

Try this:

tooltip: {
        formatter: function() {
            var s;
            if (this.point.name) { // the pie chart
                s = ''+
                    this.point.name +': '+ this.y +' fruits';
            } else {
                s = ''+
                    this.series.name  +': '+ this.y+' '+this.x;
            }
            return s;
        }
    }

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