javascript - Chart.js - 如何删除百分比数据标签?

标签 javascript chart.js

我正在使用 Chart.js,我想删除下图中标有红色圆圈的百分比标签。

Example

我正在使用此代码生成此图表:

const options = {
    responsive: true,
    title: {
        display: false
    },
    legend: {
        display: false
    },
    tooltips: {
        mode: 'index',
        intersect: true
    },
    scales: {
        yAxes: [{
            type: 'linear',
            position: 'left',
            id: 'y-axis-1'
        }, {
            type: 'linear',
            position: 'right',
            id: 'y-axis-2',
            gridLines: {
                drawOnChartArea: false
            }
        }],
    }
};

new Chart(document.getElementById('originalThirdChart').getContext('2d'), {
    type: 'bar',
    data: data,
    options: options
});

我怎样才能做到这一点?提前致谢!

最佳答案

如果您只想删除百分比,只需在选项中添加此行

labels: { render: () => {} }
它看起来像:
options: { 
        plugins: {
          labels: {
            render: () => {}
          }
        }
    }

关于javascript - Chart.js - 如何删除百分比数据标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53013400/

相关文章:

javascript - 在 chart.js 的工具提示中添加自定义标题

javascript - 为什么我的事件监听器回调没有使用正确的状态?

javascript - 如何避免全局变量?

javascript - Chart.js。取值范围很大。最小值不可用

javascript - 条件系列失败 - Chart.js

javascript - 使用 Charts.js 从分组的 JSON 对象绘制多线图

php - How to use 'time'(来自数据库的数据,数据类型: timestamp ) for plotting graph in Chart JS

javascript - jQuery 动画可以工作,但并不总是有效

javascript - React-Native FlatList 不使用自定义 renderItem 重新渲染

javascript - Electron : Confirm and Alert of a website in a webview doesn't show