chartjs / Chart.js

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

Shorten the distance between Oy axis values #11935

Open CuongSofi opened 2 weeks ago

CuongSofi commented 2 weeks ago

Documentation Is:

Please Explain in Detail...

Screenshot 2024-10-21 at 11 31 59

Can you help me with some solutions to shorten the Oy axis when the values ​​are too far apart?

Your Proposal for Changes

Screenshot 2024-10-21 at 11 54 47

Can you help me shorten the Oy axis distance when my value has not reached 5000, to show the chart more clearly and have the 5000 line right above not too far away. Thanks !

My code: [ { borderColor: dataCrack?.data?.find( (el) => el.key === "colorChart" )?.value, data: generateDataChart(), cubicInterpolationMode: "monotone", lineTension: 3, borderWidth: 2.5, segment: segment, spanGaps: true, tension: 0.5, }, { label:Ngưỡng cao ${dataChart?.station?.split("/")[1]}, data: Array.from({ length: generateDataChart()?.length }, () => Number( dataChart?.dataLow_High && dataChart?.dataLow_High[0]?.value?.split(",")[4] ) ), borderColor: colorHighLow.value, lineTension: 0, borderWidth: 1.5, borderDash: [5, 5], order: 0, },]

Example

No response

LeeLenaleee commented 2 weeks ago

For these kind of questions please head over to Stack overflow.

Chart.js automatically adjusts the scale to your data. Unless you give it a max yourself. Since you have this behavior it seems you are setting a max somewhere in your application.