Conversation
…abels for sub-1 prices
|
The Y-axis supports dragging and zooming; however, if negative values appear, |
|
Hi, thanks for checking this — your case is real, let me address it directly.
You are right: with this PR, log10(negative) = NaN, and the axis goes
Old mapping for a negative price p: -log10(|p|). Example — two prices, one position:
Same position for 10 and -0.1. Crosshair and overlays cannot tell
So the label shows "-117" for a 0.0085 price. Every coin under $1 Live example — ARBUSDT 15m, price ≈ 0.168, but the log axis shows
Instead of keeping the broken mapping, clamp from/to to positive
If you agree with the clamp approach, I will add it to this PR. |

Problem
The built-in
logarithmy-axis template maps values through a sign-guarded symlog:For any price in (0, 1) — e.g. an altcoin trading at 0.0000123 —
log10(value)is negative, so the real-space coordinate is negative while the price is positive. The inverse functions then take that negative real value to mean "negative price" and return-index10(|real|), a huge negative number.Verified against current main (replicating
YAxis.createRangeImp+createTicksImpwith the template installed), visible range[0.000008, 0.000023]:displayFrom/displayToafter range gapCrosshairHorizontalLabelView.getText→convertFromPixel)OverlayView→convertFromPixel)chart.convertFromPixel()APIAny instrument priced below 1 is affected (a
[0.081, 0.119]range renders ticks-12.6 … -9.6). Prices above 1 work becauselog10(v) > 0keeps the sign guard on the consistent branch.The symlog is also not injective:
valueToRealValue(10) === valueToRealValue(-0.1) === 1, so no sign-guard variant can be made invertible — the guards cannot be repaired, only removed.Fix
Make the template a pure logarithmic axis:
real = log10(value),value = index10(real), unconditionally. 4 functions +createRange, one file.After the fix, same scenarios: tick labels
0.000009, 0.000012, …, crosshair0.0000143, overlay round-trip exact (0.0000155 → 0.0000155). Prices above 1 are bit-for-bit unaffected (the sign guards were already taking the positive branch there).Behavior note
Ranges containing values ≤ 0 previously rendered through the quasi-symlog (approximately correct only for purely negative ranges, wrong for mixed ones: a
[-5, 100]range produced tick labels0, 40, 80…). After the fix such ranges produceNaNcoordinates — the axis renders no ticks instead of wrong ones, matching the mathematical domain of a log scale (same behavior as other charting libraries, e.g. TradingView treats non-positive values as invalid on log scale).