Show multiple line graphs on the same chart using chart JS

1👍

This is what’s needed

            data: [{
            x: {{ labels2[0] | safe }},
            y: {{ values2[0] | safe }}
            }, {
            x: {{ labels2[1] | safe }},
            y: {{ values2[1] | safe }}
            }, {
            x: {{ labels2[2] | safe }},
            y: {{ values2[2] | safe }}
            }, {
            x: {{ labels2[3] | safe }},
            y: {{ values2[3] | safe }}
            }]

👍:0

If you want multiple line charts on the same graph you will need to put the dataset objects in the datasets array instead of making the chart twice like so:

datasets: [
                    {
                        label: 'Sweep data',
                        data: {{ values | safe }},
                        backgroundColor: ['red'],
                        fill: false,
                        display: true               
                    },
                    {
                        label: 'Peak data',
                        data: {{ values2 | safe }},
                        backgroundColor: ['black'],
                        fill: false,
                        display: true               
                    }
                ]

Leave a comment