簡體   English   中英

柱形圖上的Highcharts工具提示

[英]Highcharts Tooltip At Column Chart

我正在研究此示例: http : //www.highcharts.com/demo/combo

當我將鼠標懸停在一些彩色餅圖上時,即藍色,工具提示是

Jane: 13 fruits

但是,當我將鼠標懸停在第一欄(蘋果上的藍色欄)時,工具提示是:

Apples: 3

它是簡的蘋果。 因此,如何將其更改為:

Jane : 3 apples

有任何想法嗎?

PS

在示例中使用的工具提示格式器是:

    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;
        }
    }

您可以使用this.series.someAttr獲得series數據。
因此,請執行以下操作:

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;
}

演示

嘗試這個:

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;
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM