2

私はこの例に取り組んでいます: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;
        }
    }
4

2 に答える 2

5

seriesを使用してデータを取得できますthis.series.someAttr
したがって、次のようにします。

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

デモ

于 2012-09-03T23:57:47.753 に答える
0

これを試して:

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;
        }
    }
于 2012-09-04T11:55:59.100 に答える