【问题标题】:Chart.js How should I do to make vertical dotted lineChart.js 如何制作垂直虚线
【发布时间】:2020-11-24 16:18:11
【问题描述】:

我目前正在练习使用 Chart.js 制作图表。 问题是我想制作一个如下图: enter image description here

我能够制作水平虚线,但我不知道如何处理垂直虚线。 我写到现在的代码如下:

    var ctx = document.getElementById('myChart').getContext('2d');
    var chart = new Chart(ctx, {
    type: 'line',

    data: {
        labels: ['0', '1', '2', '3', '4', '5', '6'],
        datasets: [{
            label: 'My First dataset',
            backgroundColor: 'transparent',
            borderColor: 'rgb(0, 0, 0)',
            data: [0, 10, 20, 30, 40, 50, 60]
        },{
            label: 'My First dataset2',
            backgroundColor: 'transparent',
            borderColor: 'rgb(0, 0, 0)',
            data: [60, 50, 40, 30, 20, 10, 0]
        },{
            backgroundColor: 'transparent',
            borderColor: 'rgb(0,0,0)',
            data: [30, 30, 30, 30],
            borderDash: [10, 5]
        }]
    },

    // Configuration options go here
    options: {
        title:{
            display: true,
            text: 'Demand and Supply'
        },
        legend:{
            display: false
        }
    }
    });

【问题讨论】:

    标签: javascript html graph chart.js


    【解决方案1】:

    我只是有一个外部示例,希望对您有所帮助!

    [http://jsfiddle.net/dbyze2ga/257][1]
    

    【讨论】:

      猜你喜欢
      • 2015-07-27
      • 1970-01-01
      • 1970-01-01
      • 2017-07-15
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 2018-04-20
      相关资源
      最近更新 更多