如何在高图包装的气泡中增加系列数据标签

时间:2019-06-12 17:40:57

标签: highcharts

使用高图提供的样本(减少一些数据以便于观察)https://jsfiddle.net/mevbg82z/2/

我正在尝试使气泡标签(“美国”,“加拿大”,“墨西哥”,“巴西”)变大。

我看过关于packedbubble的系列API,但是还没有找到通过选项https://api.highcharts.com/highcharts/series.packedbubble

增加气泡中文本大小的方法。

我发现做到这一点的唯一方法是编写css,它不处理缩放,不居中并且通常看起来很笨拙...

.highcharts-data-label text tspan {
    font-size: 24px
}

增加这些标签尺寸的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

好像您可以在fontSize内设置plotOptions.packedbubble.dataLabels

plotOptions: {
    packedbubble: {
        minSize: '20%',
        maxSize: '100%',
        zMin: 0,
        zMax: 1000,
        layoutAlgorithm: {
            gravitationalConstant: 0.05,
            splitSeries: true,
            seriesInteraction: false,
            dragBetweenSeries: true,
            parentNodeLimit: true
        },
        dataLabels: {
            enabled: true,
            format: '{point.name}',
            filter: {
                property: 'y',
                operator: '>',
                value: 250
            },
            style: {
                color: 'black',
                textOutline: 'none',
                fontWeight: 'normal',
                fontSize: '24px'
            }
        }
    }
},