[Bug] Inverse axis collapses the grid with outerBoundsContain when a tick is near the axis edge
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- data-visualization
Research direction
Start in src/coord/cartesian/Grid.ts, at layOutGridByOuterBounds, and trace how tick-label positions affect the grid bounds. Use the linked reproduction to compare the inverse and non-inverse axis cases; the issue is done when both produce the same grid height without collapsing.
Written by the indexing model from the issue text.
Description
Version
6.1.0
Link to Minimal Reproduction
Steps to Reproduce
- Open the link above. The right y-axis has
inverse: true,min: 0.4498,max: 0.6824, and the grid usesouterBoundsMode: 'same'withouterBoundsContain: 'axisLabel'. - Compare with the same option without
inverse: true.
option = {
grid: { outerBoundsMode: 'same', outerBoundsContain: 'axisLabel' },
xAxis: { type: 'category', data: ['A', 'B', 'C', 'D'] },
yAxis: [
{ type: 'value' },
{ type: 'value', inverse: true, min: 0.4498, max: 0.6824 }
],
series: [
{ type: 'line', data: [10, 20, 30, 40] },
{ type: 'line', yAxisIndex: 1, data: [0.5, 0.55, 0.6, 0.65] }
]
};
Current Behavior
The grid collapses to the bottom of the chart. In a 600×400 container it is 64px tall.
Expected Behavior
The grid is the same height as without inverse: true (229px in a 600×400 container).
Environment
- OS: macOS
- Browser: Chrome
- Framework: React
Any additional comments?
layOutGridByOuterBounds in src/coord/cartesian/Grid.ts computes each label's proportion with axis.scale.normalize(...) but doesn't account for axis.inverse. On the inverted axis above, the 0.45 tick sits ~0.1% from the top edge but is treated as ~0.1% from the bottom, so applyProportion divides its few px of overhang by ~0.001 and the grid shrinks to its minimum.
Flipping the proportion for inverted axes fixes it (we ship this as a local patch):
let proportion = axis.scale.normalize(
getTickValueOutermost(axis.scale, getLabelInner(labelInfo.label).labelInfo.tick)
);
if (axis.inverse) {
proportion = 1 - proportion;
}
proportion = xyIdx === 1 ? 1 - proportion : proportion;
Also reproduces on 6.0.0, and the code is unchanged on master.
- Dominant language
- TypeScript
- Stars
- 67.7k
- Forks
- 19.9k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/echarts
-
[Bug] String formatter templates only replace the first occurrence of `{a}`/`{b}`/`{c}`Possibly taken A pull request linked to this issue is open or already merged. Openen pending
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
en pending
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
en pending
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
[Bug] The zoom cursor in the toolbox area is incorrectPossibly taken @waterWang claimed this 98 days ago. Openbug en pending
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
en pending
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Similar issues
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
lingdojo/kana-dojo#34223 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
bug status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
mastra-ai/mastra#30587 · 1 comment ·
Maintainers usually reply within 1 day
-
area:web p2 product:business triage:active type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
cuadrao-ai/argus#2228 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
embedpdf/embed-pdf-viewer#1098 ·
Maintainers usually reply within 1 day
-
.Needs Triage .Team/Metabot Priority:P3 Type:Bug
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
metabase/metabase#87252 · 1 comment ·
Maintainers usually reply within 1 day