首页 > 解决方案 > Highcharts极地标签textoverflow

问题描述

尝试在 highcharts 7.2.0 中配置极坐标图时,我无法将图表配置为始终在 xAxis 上显示标签。当图表不是极坐标图时,xAxis.labels.styles.textOverflow = 'none' 的配置属性可以正常工作。下面的 jsfiddle 显示如果 xAxis 上的标签与另一个标签发生冲突,它们将自动被删除。我正在寻找配置极坐标图来做与折线图相同的事情。当 chart.polar: true 被移除时,您可以看到带有相互重叠标签的折线图。 https://jsfiddle.net/y6xor7ac/3/

Highcharts.chart('container', {

    chart: {
    // comment this line to show line graph working correctly
        polar: true
    },

    title: {
        text: 'Highcharts Polar Chart'
    },

    subtitle: {
        text: 'Also known as Radar Chart'
    },

    pane: {
        startAngle: 0,
        endAngle: 360
    },

    xAxis: {
        tickInterval: 45,
        min: 0,
        max: 360,
        overflow: 'allow',

        labels: {
            style: {
            textOverflow: 'none'
            },
          format: '{value}° super long text to make it overlap super long text to make it overlap super long text to make it overlap  '
        }
    },

    yAxis: {
        min: 0,
        overflow: 'allow',
        stackLabels: {
        allowOverlap: true
        }
    },

    plotOptions: {
        series: {
            pointStart: 0,
            pointInterval: 45
        },
        column: {
            pointPadding: 0,
            groupPadding: 0
        }
    },

    series: [{
        type: 'column',
        name: 'Column',
        data: [8, 7, 6, 5, 4, 3, 2, 1],
        pointPlacement: 'between'
    }, {
        type: 'line',
        name: 'Line',
        data: [1, 2, 3, 4, 5, 6, 7, 8]
    }, {
        type: 'area',
        name: 'Area',
        data: [1, 8, 2, 7, 3, 6, 4, 5]
    }]
});

标签: highcharts

解决方案


您可以使用内部allowOverlap属性:

xAxis: {
    ...

    labels: {
        allowOverlap: true,
        ...
    }
},

现场演示: https ://jsfiddle.net/BlackLabel/1rkz9sfp/

API 参考: https ://api.highcharts.com/highcharts/xAxis.labels


推荐阅读