仅为混合图表中的特定图表类型启用数据标签

时间:2019-02-20 15:07:06

标签: javascript apexcharts

我试图仅显示混合/组合图表类型(折线和条形图)中折线图的数据标签,但我找不到为条形系列禁用它的方法。

it is possible to visualize the code in this link 这是我现有的代码。

var options = {
      chart: {
        height: 310,
        type: 'line',
        stacked: false,
      },
      series: [{
        name: 'Series Column',
        type: 'column',
        data: [23, 11, 22, 27, 13, 22, 37, 21, 44, 22, 30]
      }, {
        name: 'Series Area',
        type: 'area',
        data: [44, 55, 41, 67, 22, 43, 21, 41, 56, 27, 43]
      }, {
        name: 'Series Line',
        type: 'line',
        data: [30, 25, 36, 30, 45, 35, 64, 52, 59, 36, 39]
      }],           
      markers: {
        size: 0
      },
      dataLabels: {
        enabled: true
      },
      xaxis: {
        type:'datetime'
      },
      yaxis: {
        title: {
          text: 'Points',
        },
        min: 0
      },
      

    }

    var chart = new ApexCharts(
      document.querySelector("#chart"),
      options
    );

    chart.render();

是否可以关闭混合图表中特定系列的数据标签?

1 个答案:

答案 0 :(得分:0)

当前,没有选项可以顺次打开/关闭数据标签。所有系列均启用。 我正在打开issue on GitHub以便在下一个版本中实现它。

编辑:v3.5.0中提供了一个新选项enabledOnSeries。您可以像

那样使用它
options = {
  dataLabels: {
    enabled: true,
    enabledOnSeries: [1, 2]
  }
}

上面只会显示索引为1,2的系列的数据标签,并禁用索引为0的系列的数据标签(在您的示例中为列系列)

免责声明:我是ApexCharts的作者。