首页 > 解决方案 > 不同颜色的chartjs折线图点

问题描述

我正在为 angularjs 使用 chartjs 图,我担心的是折线图上的点我需要根据数据范围为它们赋予不同的颜色。谁能帮助我如何改变fillcolor属性

function drawChart(placeholder, values1, labels1) {
    var plot = $.plot(placeholder,
        [{
                data: values1,
                label: label1,
                lines: {
                    show: true,
                    lineWidth: 2,
                    fill: true,

                },
                points: {
                    show: true,
                    lineWidth: 3,
                    fill: true,
                    fillColor: '#fafafa'
                }

            },
        });

标签: javascriptangularjschart.js

解决方案


我没有足够的细节来知道您的问题是否来自那里,但您的代码语法不正确。

你应该有 :

function drawChart(placeholder, values1, labels1) {
    var plot = $.plot(placeholder,
        [{
            data: values1,
            label: label1,
            lines: {
                show: true,
                lineWidth: 2,
                fill: true,

            },
            points: {
                show: true,
                lineWidth: 3,
                fill: true,
                fillColor: '#fafafa'
            }

        }]
    });
}

推荐阅读