Tof
Tof

Reputation: 301

Highcharts bubble chart dataLabels overlapping despite z-index

I have a problem with the bubble chart. In fact, i have some points which have the same coordinates with a different name and maybe a different size (z point). For these points, i have a superposition of labels. The z-index solution doesn't work (https://stackoverflow.com/questions/15843238/highcharts-bubble-chart-datalabels-overlappinghttps://stackoverflow.com/questions/15843238/highcharts-bubble-chart-datalabels-overlapping).

Does anyone know of any solution to this problem ?

I thought to do a label connector like the pie chart but i do not how to do.

My code :

$(function () {
    $('#container').highcharts({
        credits: {
            enabled: false
        },
        chart: {
            type: 'bubble',
            zoomType: 'xy'
        },
        title: {
            text: ''
        },
        subtitle: {
            text: ''
        },
        xAxis: {
                    categories:['R0', 'R1', 'R2','R3', 'R4', 'R5', 'R6']
        },
        yAxis: {
            title: {
                text: ''
            }
        },
        plotOptions: {
                    bubble: {
                        dataLabels: {
                            enabled: true,
                            useHTML: true,
                            //inside: false,
                            //y:-10,
                            //overflow: false,
                            //crop: false,
                            style: { textShadow: 'none',fontSize: '10px',color:'black' },
                            formatter: function() {
                                return "<i>" + this.point.name.split(' ').join('<br>') + "</i>";
                            }
                        },
                        tooltip : {
                                            headerFormat: '<b>{series.name}</b><br>',
                                            pointFormat : 'S : <i>{point.name}</i><br>Y : {point.y}<br>Num : {point.z}'

                                        }
                    }
                },
        series: [
            {
            name:  'Sample1',
            marker: { fillColor: '#89A54E' },
            data: [
            { name:'A',x:2,y:0.0,z:47},
            { name:'Z',x:3,y:1.0,z:35},
            { name:'E',x:4,y:0.5,z:9},
            { name:'R',x:0,y:1.0,z:34},
            { name:'T',x:3,y:0.0,z:37},
            { name:'T',x:2,y:0.0,z:22},
            { name:'p',x:0,y:1.0,z:39},
            { name:'m',x:2,y:0.5,z:47},
            { name:'h',x:0,y:0.5,z:48},
            { name:'l',x:5,y:1.0,z:25},
            ]
            },
            {
            name:  'Sample2',
            marker: { fillColor: '#92A8CD' },
            data: [
            { name:'AB',x:2,y:0.5,z:23},
            { name:'CA',x:6,y:0.5,z:19},
            { name:'OP',x:3,y:0.5,z:21},
            { name:'CP',x:1,y:0.75,z:38},
            { name:'TS',x:3,y:1.0,z:13},
            { name:'SP',x:0,y:1.0,z:43},
            { name:'SE',x:4,y:1.0,z:2},
            { name:'CS',x:6,y:0.5,z:48},
            { name:'CL',x:1,y:0.5,z:5},
            { name:'H',x:1,y:0.0,z:11},
            ]
            }
        ]
    });
});

Upvotes: 1

Views: 2182

Answers (1)

jbgarr
jbgarr

Reputation: 1398

Apparently there is a labelrank property on the Highcharts point objects that can be used to dictate which point labels are on top. It can be used when you're creating your data like this:

data: [{
        x: 1, y: 1, labelrank: 1, name: 'A'
        },{
        x: 1, y: 1, labelrank: 2, name: 'B' 
      }]

Or it can be updated on an individual point to bring that point's dataLabel to the front by doing something like this: chart.series[0].points[0].update({labelrank: 3});

I had a similar issue and created this question on SO that just was answered.

EDIT

They have updated their docs to include series.data.labelrank as well: http://api.highcharts.com/highcharts#series.data.labelrank

Upvotes: 1

Related Questions