chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
64.8k stars 11.92k forks source link

Line Chart Graphics is not displaying when yAxisID starts with R or r #11640

Open MuhammedAlmaz opened 10 months ago

MuhammedAlmaz commented 10 months ago

Expected behavior

I used https://www.chartjs.org/docs/latest/samples/line/interpolation.html this sample. The Linear graphic not displaying on sample codes. There is a yAxisID which is starting with R.

Current behavior

The Linear graphic should display on sample codes. There is a yAxisID which is starting with R.

Reproducible sample

https://codepen.io/muhammedalmazzz/pen/MWxbeyM

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

4.4.1

Browser name and version

No response

Link to your project

No response

LeeLenaleee commented 10 months ago

I think this has to do with that it infers it as a radial scale, if you add the following to your scale config it shows correctly (as a temporary fix): axis: 'y',

ramazan: {
        axis: 'y',
        display: true,
        title: {
          display: true,
          text: 'Value'
        },
        suggestedMin: -10,
        suggestedMax: 200
      }
LeeLenaleee commented 10 months ago

Looked in the code, this behaviour is happening because of this method: https://github.com/chartjs/Chart.js/blob/767d64e7a90dbfe94f9c5d159a890054818c1680/src/core/core.config.js#L40C1-L53C2

And then specificly this line: https://github.com/chartjs/Chart.js/blob/767d64e7a90dbfe94f9c5d159a890054818c1680/src/core/core.config.js#L47

It is looking at the first letter of your scale name to determine the axis type. This is not something that can be changed in V4 since it is breaking.

MuhammedAlmaz commented 10 months ago

@LeeLenaleee I guess it is not well way to change type of graph from any to radial. But i got it maybe in the future they can change that. I guess many ppl can make mistake about it. There are many words which is starting from "R"or "r".