在 highcharts 中,是否可以获取 x 轴标签的确切位置以进行重叠检测?

In highcharts, is it possible get the exact position of x axis labels for overlap detection purpose?

我的数据(折线图)是动态的,有时 x 轴标签重叠。

客户不想做两行或有角度的标签,请问是否可以得到所有x轴标签的精确绘图位置?

然后我可以遍历标签,然后找到每个标签的大小并删除重叠的标签。

您可以获得每个标签的边界框。标签存储在 chart.xAxis[index].tick 对象中。演示:http://jsfiddle.net/oe1vcmqj/4/

    var ticks = $('#ccontainer').highcharts().xAxis[0].ticks,
        tick, el;

    for (tick in ticks) {
        el = ticks[tick];
        console.log(
            tick, 
            ' BoundingBox: ',
            el.label.getBBox(), // bounding box
            ' X:', 
            el.label.attr('x'), // x-attribute
            ' Y:', 
            el.label.attr('y') // y-attribute
        );
    }