fix: remove sign-guarded symlog from logarithm axis to fix negative labels for sub-1 prices - #837
Open
NemeZZiZZ wants to merge 1 commit into
Open
fix: remove sign-guarded symlog from logarithm axis to fix negative labels for sub-1 prices#837NemeZZiZZ wants to merge 1 commit into
NemeZZiZZ wants to merge 1 commit into
Conversation
…abels for sub-1 prices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).