ChartJs-饼图-如何删除饼图上的标签 [英] ChartJs - Pie Chart - how to remove labels that are on the pie chart

查看:112
本文介绍了ChartJs-饼图-如何删除饼图上的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 chart.js 中的饼图在应用程序中进行可视化.我正在使用带有 chartjs-plugin-piechart-outlabels 的插件,将标签显示为饼图中的外段.

I am using piechart from chart.js for visualization in my application. I am using a plug-in with it chartjs-plugin-piechart-outlabels to show the labels as out-segments from the pie chart.

一切正常,除了饼图上存在标签,我不希望这样做,因为我将标签显示为段外.

It's all working fine, except that, the labels exists on the pie chart, which I do not want, as I am showing the labels as out-segments.

我浏览了文档,找不到解决方案,还看了一些示例.

I have looked through documentation and couldnt find solution to this, also looked some examples.

public static readonly pieChartOptions: ChartOptions = {
responsive: true,
maintainAspectRatio: false,
legend: {
  display: false
},
tooltips: {
  enabled: true
},
layout: {
  padding: {
    left: 0,
    right: 0,
    top: 70,
    bottom: 0
  }
},
plugins: {
  outlabels: {
    display: true,
    borderWidth: 2,
    lineWidth: 2,
    padding: 3,
    textAlign: 'center',
    stretch: 15,
    font: {
      resizable: true,
      minSize: 12,
      maxSize: 18
    },
    valuePrecision: 1,
    percentPrecision: 2
  }
}

};

推荐答案

您需要关闭示例标签,如下所示:

You need to turn off the sample labels, like this:

options: {
  plugins: {
    datalabels: {
      display: false
    }
    outlabels: {
      display: true
    }
  }
}

这篇关于ChartJs-饼图-如何删除饼图上的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆