Chartjs-Multi colored line chart angular and primeng

0👍

Below is a hack where you need to define separate datasets for different colors, however, there would be only one point per label, not two. I don’t know if there is built-in support in Chart.js for this requirement. Fiddle -> http://jsfiddle.net/dqonwrLh/2/

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, 10, 3, 5],            
            backgroundColor: 'rgba(255, 99, 132, 0.2)',
            borderColor: 'rgba(255, 99, 132, 0.2)',
            borderWidth: 1
        },
        {
            label: '# of Votes1',
            data: [null, null, null, 5, 8, 5],            
            backgroundColor: 'rgba(54, 162, 235, 0.2)',
            borderColor: 'rgba(54, 162, 235, 0.2)',
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                }
            }]
        },
        legend:{
            display: false
        }
    }
});

Leave a comment