繁体   English   中英

如何在径向图表的中心添加文本和/或将 dataLabels 对齐到条形图的末尾?

[英]How do I add text in the center of a radial chart and/or align the dataLabels to the end of the bars?

到目前为止我拥有的简单径向图的代码: https ://jsfiddle.net/du4jxzwn/20/

       series: {
            dataLabels: {
                enabled: true,
                align: 'right',
                color: '#FFFFFF',
                x: -10,
                rotation: '270',
            },
            pointPadding: 0.025,
            groupPadding: 0
        }

我希望文本与栏的末尾对齐。 我还想在图表的中心添加一些文本,如此处所示 有没有办法使用Javascript来做到这一点?

在系列中,如果您将点保存为对象,则可以在那里编辑 dataLabels 参数并对齐它。

  series: [{
    data: [{
      x: 0,
      y: 29.9,
      dataLabels: {
        enabled: true,
        allowOverlap: true,
        format: 'Financal',
        color: '#000',
        rotation: '280',
        x: 2,
        y: 15
      }
    }, {
      x: 1,
      y: 71.5
    }, {
      x: 2,
      y: 106.4
    }]
  }]

您还可以通过像这里这样的事件编辑点并在它们上执行更新方法以更改某些内容,例如值。

events: {
  load: function() {

    let chart = this,
      series = chart.series[0],
      point = series.data[0],
      dataLabel = point.dataLabel;

    console.log(point);

    point.update({
      y: 33,
    })
  },
},

演示: https ://jsfiddle.net/BlackLabel/kjfn5pvc/1/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM