1

我有以下代码:

var chart = new Highcharts.Chart({
    chart: {
        type: 'bubble',
        zoomType: 'xy',
        renderTo: 'municipalgraph'
    },
    title: {
        text: ''
    },
    yAxis: {
        title: {
            text: ''
        }},

    tooltip: {
        formatter: function() {
            return this.point.name + '<br/><b>' + this.x + '</b><br/><b>' + this.y + '</b>'
        }},
    series: [{
        data: [67,78,75],[64,12,10],[30,77,82]]
    }]
});

我想为每个点添加一个名称以在工具提示中显示它。可能吗?

4

1 回答 1

6

您需要用对象替换点数组,例如:

series: [{
        data: [{
            x: 67,
            y: 78,
            z: 20,
            customParam: 'custom text1'
        },{
            x: 14,
            y: 68,
            z: 50,
            customParam: 'custom text2'
        },[20,20,20]]
    }]

并在工具提示中获取参数形式 point.options

tooltip: {
         formatter: function () {
                return this.point.name + '<br/><b>' + this.x + '</b><br/><b>' + this.y + '</b><br/>custom text: '+this.point.options.customParam;
            }
        },

http://jsfiddle.net/JKLzy/2/

于 2013-10-31T10:22:21.220 回答