0

I am trying to add a dataset to my Chart in order to compare values. I already have the red one and I want to add the blue one as you can see on this picture : Chart

The problem I have is that as you can see on the picture, the blue line is way higher than the red one but if we watch the values, the blue line should be bellow the red line... Does anybody know why my blue line is that way ?

Here is my code :

datasets: [{
                backgroundColor: window.chartColors.red,
                borderColor: window.chartColors.red,
                data: [
                    {% if history|length > 0 %}
                    {{ history['values']|join(',') }}
                    {% endif %}
                ],
                fill: false,
            },
            {
                backgroundColor: window.chartColors.blue,
                borderColor: window.chartColors.blue,
                data: [
                    {% if history|length > 0 %}
                    {{ history['valuesSecteur']|join(',') }}
                    {% endif %}
                ],
                fill: false,
            }]

EDIT I also wanted to add that the data for the blue line is 8 times the value 2.5 so I don't understand why the line is not straight. It is actually copying the red line...

2
  • what are the data values you are passing in data field ? Commented Jan 13, 2022 at 8:33
  • It's an array with all the values to display. Like [2.315, 2.315, 2.315, 2.19, .....] @RiyazPanarwala Commented Jan 13, 2022 at 8:41

1 Answer 1

1

Okay I managed to fix it !

It was in the Chart options in 'scales'.

options: {
            scales: {
                xAxes: [{
                    ...
                }],
                yAxes: [{
                    ...
                    },
                    stacked: false,
                    ticks: {
                        ...
                    }
                }]
            }
        }

stacked was set to true and that's why it was broken. It should be at false.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.