高图中心对齐文本标签内的tspan

时间:2018-03-26 20:51:02

标签: html css highcharts polygon tspan

我想将tspan中心与高图的text标记对齐。

我创建了一个jsfiddle:here

代码

Highcharts.chart('container', {
    chart: {
        type: 'pyramid'
    },
    title: {
        text: 'Sales pyramid',
        x: -50
    },
    plotOptions: {
        series: {
            dataLabels: {
                enabled: true,
                format: '<b>{point.name}</b><br/>{point.y:,.0f}',
                color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black',
                softConnector: true
            },
            center: ['40%', '50%'],
            width: '80%'
        }
    },
    legend: {
        enabled: false
    },
    series: [{
        name: 'Unique users',
        data: [
            ['Website visits',      15654],
            ['Downloads',            4064],
            ['Requested price list', 1987],
            ['Invoice sent',          976],
            ['Finalized',             846]
        ]
    }]
});

as you can see

正如您所见&#34;已完成&#34;和&#34; 846&#34;左对齐,有没有办法对齐&#34; 846&#34;集中到&#34;最终确定&#34;文本吗

1 个答案:

答案 0 :(得分:3)

img更新您的dataLabels

plotOptions: {
    series: {
        dataLabels: {
            useHTML:true,
            enabled: true,
            format: '<b>{point.name}</b><br/><div align="center">{point.y:,.0f}</div>',
            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black',
            softConnector: true
        },
        center: ['40%', '50%'],
        width: '80%'
    }
},

fiddle演示