Chartjs-Can't render two charts on the same page from chart.js

1πŸ‘

βœ…

in you data,

var avgLineChartData = {
        labels: ['1', '1', '1', '1', '1', '1', '1'],
        datasets: [{
            label: 'Avg Temperature (F)',
            borderColor: window.chartColors.green,
            backgroundColor: window.chartColors.green,
            fill: false,
            data: [
                65 - randomScalingFactor(),
                53 - randomScalingFactor(),
                58 - randomScalingFactor(),
                54 - randomScalingFactor(),
                62 - randomScalingFactor(),
                65 - randomScalingFactor(),
                74 - randomScalingFactor()
            ],
            yAxisID: 'y-axis-1',
        }]
    };

you set the yAxisId : 'y-axis-1'. but when you draw the chart, they are id: 'avg-y-axis-1'.

Leave a comment