Skip to content

feat(charts): let LineChart pin the y-axis ceiling - #67

Open
gitlawr wants to merge 1 commit into
gpustack:mainfrom
gitlawr:line-chart-yaxis-max
Open

feat(charts): let LineChart pin the y-axis ceiling#67
gitlawr wants to merge 1 commit into
gpustack:mainfrom
gitlawr:line-chart-yaxis-max

Conversation

@gitlawr

@gitlawr gitlawr commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

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.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
max: yAxisMax,
max: yAxisMax ?? undefined,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant