MengqiYao0703 opened a new issue, #21834:
URL: https://github.com/apache/echarts/issues/21834
### What problem does this feature solve?
## Feature Request
### Problem
The automatic axis name/label overlap avoidance introduced in #21059 is
useful, but makes precise manual positioning difficult.
Currently, `nameGap` is applied **before** automatic overlap resolution. If
the requested position still overlaps axis labels, ECharts moves the axis name
to avoid the collision.
As a result, different `nameGap` values can produce the same final position.
Only values beyond the automatically calculated overlap boundary visibly affect
the position.
Since that boundary depends on label dimensions, fonts, rotation, and data,
application developers cannot reliably determine what offset to use.
### Expected Behavior
I would like to keep `nameMoveOverlap: true` while applying a precise
additional offset **after** automatic overlap resolution.
For example, a new option could be introduced:
```js
yAxis: {
name: 'Axis title',
nameLocation: 'middle',
nameMoveOverlap: true,
nameGap: 10,
nameOffset: 15 // Proposed API
}
```
The proposed `nameOffset` would shift the axis name by 15px relative to its
automatically resolved position.
### Current Limitations
- `nameGap` is applied before collision resolution, so small adjustments can
be absorbed by the automatic movement.
- `nameMoveOverlap: false` restores manual positioning but disables
automatic avoidance.
- `nameTextStyle.textMargin` influences collision spacing but does not
guarantee a precise post-layout offset.
- The automatically computed overlap displacement is not exposed through a
public API.
### Proposal
Introduce a post-overlap offset, either as a signed scalar along the
axis-name movement direction or as `[dx, dy]` in pixels.
Alternatively, exposing the final resolved axis-name position or collision
displacement through a public API could allow applications to implement custom
positioning.
The key requirement is to **combine automatic overlap avoidance with
predictable manual positioning**, without needing to calculate label boundaries
ourselves.
### Related Issues and Implementation
- #21059 — Automatic axis name/label overlap avoidance
- #17902 — Request for access to axis label boundaries
- ECharts v6.1.0, `src/component/axis/AxisBuilder.ts`
Thank you for considering this enhancement!
### What does the proposed API look like?
<html>
<body>
<!--StartFragment--><h3><span>Proposed API</span></h3><p><span>I suggest
introducing a new </span><code><span>nameOffset</span></code><span> option that
is applied </span><strong><span>after automatic axis name/label overlap
resolution</span></strong><span>.</span></p><p><span>For
example:</span></p><pre><code><span>yAxis: {
name: 'Axis Title',
nameLocation: 'middle',
nameMoveOverlap: true,
nameGap: 10,
nameOffset: 15 // Proposed API: additional 15px after auto-layout
}</span></code></pre><h3><span>Expected Behavior</span></h3><p><span>The
positioning process would be:</span></p><ol start="1"><li><p><span>Calculate
the initial axis name position using
</span><code><span>nameGap</span></code><span>.</span></p></li><li><p><span>Automatically
resolve overlaps with axis labels when </span><code><span>nameMoveOverlap:
true</span></code><span>.</span></p></li><li><p><span>Apply
</span><code><span>nameOffset</span></code><span> to the resolved position as
an additional pixel offset.</span></p></li></ol><p><span>The key distinction
is:</span></p><ul><li><p><code><span>nameGap</span></code><span>: Controls the
initial position before overlap
resolution.</span></p></li><li><p><code><span>nameOffset</span></code><span>:
Controls the additional displacement after overlap
resolution.</span></p></li></ul><p><span>For example, if the automatic overlap
resolution places the axis name 60px away from the axis line:</span></p>
nameOffset | Final distance
-- | --
0 | 60px
10 | 70px
20 | 80px
-10 | 50px
<p><span>The negative offset intentionally allows users to move the name
closer, even if that introduces overlap.</span></p><h3><span>Why This Is
Needed</span></h3><p><span>Currently, changing
</span><code><span>nameGap</span></code><span> within the automatically
calculated overlap range may have no visible effect.</span></p><p><span>This
makes precise positioning difficult, especially with dynamic data where axis
label sizes change and the overlap boundary cannot be known in
advance.</span></p><p><span>Setting </span><code><span>nameMoveOverlap:
false</span></code><span> is not an ideal workaround because it disables
automatic collision avoidance entirely.</span></p><p><span>The proposed
</span><code><span>nameOffset</span></code><span> would allow developers to
benefit from automatic layout while retaining predictable, pixel-precise
control over the final axis name position.</span></p><h3><span>Alternative
API</span></h3><p><span>If more flexibility is desired, </span><code><sp
an>nameOffset</span></code><span> could also support a two-dimensional
offset:</span></p><pre><code><span>yAxis: {
nameMoveOverlap: true,
nameOffset: [10, -5] // [dx, dy] in pixels
}</span></code></pre><p><span>This would allow precise positioning in both
directions without relying on internal collision
calculations.</span></p><p><span>The exact API name and shape are open to
discussion. The primary goal is to provide </span><strong><span>a predictable
offset applied after automatic overlap
resolution</span></strong><span>.</span></p><!--EndFragment-->
</body>
</html>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]