feat(charts): let LineChart pin the y-axis ceiling - #67
Conversation
Percentage charts read wrong when the axis scales to the data — 59% usage fills the frame like 100% would. An optional yAxisMax pins the ceiling; unset keeps the adaptive axis.
There was a problem hiding this comment.
Code Review
This pull request introduces a new optional yAxisMax prop to the LineChart component, allowing users to pin the y-axis ceiling. The feedback suggests using the nullish coalescing operator (yAxisMax ?? undefined) when assigning this value to the ECharts configuration to safely handle null values and ensure proper auto-scaling fallback.
| yAxis: { | ||
| ...options.yAxis, | ||
| name: yAxisName, | ||
| max: yAxisMax, |
There was a problem hiding this comment.
If yAxisMax is passed as null (which is common when values are fetched from an API or database), passing null directly to ECharts' yAxis.max can lead to unexpected layout/rendering behavior or prevent auto-scaling. Using the nullish coalescing operator ?? undefined ensures that null is safely converted to undefined, allowing ECharts to correctly fall back to its default auto-scaling behavior.
| max: yAxisMax, | |
| max: yAxisMax ?? undefined, |
Percentage charts read wrong when the axis scales to the data — 59% usage fills the frame like 100% would. An optional yAxisMax pins the ceiling; unset keeps the adaptive axis.