气泡图中的点标题(Highcharts)

时间:2013-10-31 08:40:20

标签: highcharts bubble-chart

我有以下代码:

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

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

1 个答案:

答案 0 :(得分: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/