如何使虚粗线与ChartJS点?可能吗?

问题描述 投票:0回答:1

我尝试在文档,找到此功能。我知道如何设置点或虚线,但他们的组合我不能找到。

enter image description here

javascript chart.js
1个回答
0
投票

虚线可以通过添加此borderDash: [10, 10]属性来折线图每个数据集绘制。你可以看到下面的代码或小提琴 - > http://jsfiddle.net/fcwbjy57/

var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
    type: 'line',
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, 3, 5, 2, 3],
            backgroundColor: 'rgba(255, 99, 132, 0.2)',              
            borderColor: 'rgba(255,99,132,1)',
            borderWidth: 1,
            borderDash: [10, 10],
            fill: false
        },{
            label: '# of Votes1',
            data: [17, 9, 13, 9, 20, 13],
            backgroundColor: 'rgba(54, 162, 235, 0.2)',              
            borderColor: 'rgba(54, 162, 235, 1)',
            borderWidth: 1,
            borderDash: [10, 10],
            fill: false
        },{
            label: '# of Votes2',
            data: [1, 6, 13, 12, 20, 5],
            backgroundColor: 'rgba(255, 206, 86, 0.2)',               
            borderColor: 'rgba(255, 206, 86, 1)',
            borderWidth: 1,
            borderDash: [10, 10],
            fill: false
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                }
            }]
        }
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.