charts - 如何在chartjs中显示两条重叠线

标签 charts chart.js

我正在尝试创建包含多个数据集的折线图, 但对于某些数据集,值有可能匹配,在这种情况下,线条重叠并显示首先定义的集合,此时绿色和红色重叠,首先定义绿色,因此显示其颜色

img-> https://nimb.ws/b7jvVH

var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line', // also try bar or other graph types

// The data for our dataset
data: {
    labels: $.getMonths(year+'-01-01',year+'-12-31'),
    // Information about the dataset
datasets: [
    {
        label: "Converted",
        borderColor: 'Green',
        data: leadsConvertedAtCountPerMonthPerYear,

    },
    {
        label: "Contacted",
        borderColor: 'red',
        data: leadsContactedAtCountPerMonthPerYear,

    },
    {
        label: "Assigned",
        borderColor: 'royalblue',
        data: leadsAssignedAtCountPerMonthPerYear,

    },


]
},

// Configuration options
options: {
layout: {
  padding: 10,
},
    legend: {
        position: 'bottom',
    },
    title: {
        display: true,
        text: 'Reports for '
    },
    scales: {
        yAxes: [{
            scaleLabel: {
                display: true,
                labelString: 'Precipitation in mm'
            }
        }],
        xAxes: [{
            scaleLabel: {
                display: true,
                labelString: 'Month of the Year'
            }
        }]
    }
}

}); enter image description here

我希望重叠线显示两种颜色

最佳答案

您可以尝试将颜色设置为半透明。例如。使用 rgb(0,128,0,0.5)

代替绿色

关于charts - 如何在chartjs中显示两条重叠线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56772176/

相关文章:

javascript - 仪表图表 - 多个仪表 java

javascript - 如何放大与坐标轴文本保持一致的区域?谷歌图表

java - 在饼图中隐藏小值 MPAndroidChart

javascript - 如何将图表数据加载到附加 Canvas

angularjs - 如何定义 chart.js 时间刻度日期格式

javascript - 如何在 chartjs 中扩展圆环图的切片?

Silverlight 4 工具包、图表和 lineSeries 为空

jquery - Flot 饼图在 firebug : "uncaught exception: Invalid dimensions for plot, width = null, height = null" 中给出错误

jquery - 使用 Chart.js 时 $(...).getContext ("2d") 不是函数

javascript - 如何使用 chart.js 仅绘制图形和 X 轴网格线