如何从chartjs中的所需点创建虚线?

时间:2018-04-26 12:18:05

标签: charts

我需要在预设的时间段内制作一条虚线。我怎么能在chartjs中做到这一点?例如,3个月的实线和其他的虚线

example

下面的执行不好



var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
    // The type of chart we want to create
    type: 'line',

    // The data for our dataset
    data: {
        labels: ["January", "February", "March", "April", "May", "June", "July"],
        datasets: [{
            label: "Red",
            borderColor: 'rgb(255, 0, 0)',
            data: [0, 10, 5, 2, 20, 30, 45],
        }, {
            label: "Blue",
            borderColor: 'rgb(0, 0, 255)',
            data: [38, 24, 32],
        }, {
            label: "Blue",
            borderColor: 'rgb(0, 0, 255)',
            data: [null, null, 32, 0, 0, 0, 0],
            borderDash: [5, 5],
        }]
    },

    // Configuration options go here
    options: {}
});

.container {
  width: 640px;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
<div class='container'>
  <canvas id="myChart"></canvas>  
</div>
&#13;
&#13;
&#13;

0 个答案:

没有答案