【问题标题】:highchart center align tspan inside text tag文本标签内的highchart中心对齐tspan
【发布时间】:2018-03-26 20:51:02
【问题描述】:

我想在highchart的text标签内对齐tspan中心。

我创建了一个 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]
        ]
    }]
});

您可以看到“Finalized”和“846”是左对齐的,有没有办法将“846”与“Finalized”文本居中对齐?

【问题讨论】:

    标签: html css highcharts polygon tspan


    【解决方案1】:

    更新你的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演示

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-04
      • 2018-09-16
      • 1970-01-01
      • 1970-01-01
      • 2012-05-24
      • 2013-02-09
      • 1970-01-01
      相关资源
      最近更新 更多