小编Ebr*_*ami的帖子

Chartjs隐藏数据点标签

我使用chartjs创建了图形。它工作正常,唯一的问题是它在每个点上都显示了数据标签(数字)。我想隐藏它们,但找不到方法。谁能帮我解决这个问题?我尝试将pointRadius设置为0,但是它没有执行我想要的操作。

另外,如果我无法隐藏它们,是否可以更改它们的颜色?

图表图像

const ctx = document.getElementById('timelineChart');

        const chartColors = {
            red: '#C82846',
            green: '#7DC36E',
            blue: '#249FBA',
            darkblue: '#249FBA'
        };

        const config = {
            plugins: [new BandsPlugin()],
            type: 'bar',
            data: {
                labels: ["January", "February", "March", "April", "May", "June", "April", "May", "June", "July",
                         "January", "February", "March", "April", "May", "June", "July"],
                datasets: [
                    {
                        borderColor: chartColors.green,
                        fill: false,
                        type: 'line',
                        id: 'y-axis-1',
                        pointRadius: 0,
                        data: [
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(),
                            this.randomPositiveFactor(), …
Run Code Online (Sandbox Code Playgroud)

chart.js

2
推荐指数
1
解决办法
2823
查看次数

标签 统计

chart.js ×1