Skip to content

feat(analysis): add TradingView-style price scale interaction to the … - #11

Open
Impulssi wants to merge 1 commit into
froooze:testfrom
Impulssi:feat/tradingview-chart-interactions
Open

feat(analysis): add TradingView-style price scale interaction to the …#11
Impulssi wants to merge 1 commit into
froooze:testfrom
Impulssi:feat/tradingview-chart-interactions

Conversation

@Impulssi

@Impulssi Impulssi commented Aug 24, 2026

Copy link
Copy Markdown

…chart exporter

The exported HTML chart locked the price (y) scale to auto-fit, which made zoomed-in inspection awkward: axis ticks were sparse, prices used an uneven precision format, and the last price was not visible on the axis. The chart also clipped panning to the data edges, so there was no empty grid space around the series like TradingView shows.

Price scale interaction

  • Wheel or drag on the price axis zooms/shrinks the visible price band (manual scale); double-click on the axis restores auto-fit.
  • Vertical drag inside the chart pans the price scale and activates the manual mode, mirroring the existing horizontal time pan.
  • Manual range is clamped to sensible bounds derived from the data (floor ~35% below data min, ceil ~1.6x data max, max span ~1.6x the data price range) so the scale cannot collapse to a sliver or run away.
  • The manual scale resets on chart rebuild, price-scale toggle and pair orientation flip, where the unit changes and the old range is invalid.

Axis and price marker

  • Price axis moved to the right side and tick spacing tightened so more price levels appear at every zoom level.
  • Adaptive decimal formatting on axis values based on the tick step.
  • TradingView-style last-price marker: colored label pinned to the price axis plus a dashed crosshair line through the chart, log-scale aware.

Time axis breathing room

  • Wheel zoom-out now allows up to ~2.5x the data span and clampRange permits up to ~75% of the data span as empty padding on each side, so zooming out reveals the grid around the series instead of hard-clamping to the candles.

Testing Notes

  • npm run typecheck clean; full suite run on Windows shows the same pre-existing environment failures with and without this change.
  • Chart verified manually with 6-month and full-history (2021->2026) BTS/XBTSX.USDT LP datasets.

Note: I'm new to this codebase and worked through this change with an AI
coding assistant (opencode). The bug was hit on my own live instance and
all measurements / reproduction steps are mine — but please flag anything
in the code that looks off and I'll dig in and follow up.

@Impulssi
Impulssi force-pushed the feat/tradingview-chart-interactions branch from 8e731d7 to 7c10107 Compare August 26, 2026 06:01
…chart exporter

The exported HTML chart locked the price (y) scale to auto-fit, which made
zoomed-in inspection awkward: axis ticks were sparse, prices used an uneven
precision format, and the last price was not visible on the axis. The chart
also clipped panning to the data edges, so there was no empty grid space
around the series like TradingView shows.

## Price scale interaction
- Wheel or drag on the price axis zooms/shrinks the visible price band
  (manual scale); double-click on the axis restores auto-fit.
- Vertical drag inside the chart pans the price scale and activates the
  manual mode, mirroring the existing horizontal time pan.
- Manual range is clamped to sensible bounds derived from the data
  (floor ~35% below data min, ceil ~1.6x data max, max span ~1.6x the
  data price range) so the scale cannot collapse to a sliver or run away.
- The manual scale resets on chart rebuild, price-scale toggle and pair
  orientation flip, where the unit changes and the old range is invalid.

## Axis and price marker
- Price axis moved to the right side and tick spacing tightened so more
  price levels appear at every zoom level.
- Adaptive decimal formatting on axis values based on the tick step.
- TradingView-style last-price marker: colored label pinned to the price
  axis plus a dashed crosshair line through the chart, log-scale aware.

## Time axis breathing room
- Wheel zoom-out now allows up to ~2.5x the data span and clampRange
  permits up to ~75% of the data span as empty padding on each side, so
  zooming out reveals the grid around the series instead of hard-clamping
  to the candles.

## Testing Notes
- npm run typecheck clean; full suite run on Windows shows the same
  pre-existing environment failures with and without this change.
- Chart verified manually with 6-month and full-history (2021->2026)
  BTS/XBTSX.USDT LP datasets.
@Impulssi
Impulssi force-pushed the feat/tradingview-chart-interactions branch from 7c10107 to 6cbac5b Compare August 26, 2026 06:34
froooze added a commit that referenced this pull request Aug 26, 2026
…orter

The tradingview_uplot_chart_generator was the only uPlot fork without
price-axis interaction: no Y zoom, no manual scale, and a last-price
marker was missing, making grid-range review against real candle data
harder than in TradingView itself. Ported from upstream contribution
#11 (same content as bitshares#3), reworked for
the local zoom-pan dedupe (94c320b): shared UPLOT_SHARED_SCRIPT stays
untouched; page-local hoisted overrides win via function hoisting.

## Price-axis interaction
- Wheel over the right price gutter zooms Y around the cursor
  (0.91/1.10 factors); vertical axis drag sets a manual range
  (multiplicative on log scale, additive otherwise); double-click on
  the axis restores auto-fit through the existing visiblePriceRange
  callback
- Axis hit-testing uses chart.bbox geometry with pxRatio conversion —
  uPlot's .u-over overlay spans the full canvas including gutters, so
  overlay-rect hit-testing could not detect axis gestures reliably

## Auto-fit preservation
- Body drag remains pure time pan (no directional lock); manualYRange
  resets when dataset/timeframe/pair changes (candle-key guard) so the
  scale never silently latches manual mode — the earlier body-Y-pan
  variant of this port did exactly that, freezing auto-scaling

## Marker and axes
- Last-price marker: dashed line plus right-aligned price label colored
  by direction (#26a69a/#ef5350), hidden when out of range
- Price/volume axes fixed to 84px width with larger fonts so both panes
  stay aligned; adaptive tick decimals via fmtPriceAxis

## Docs
- CHANGELOG: six entries covering all post-v1.4.22 commits (Kibana
  proxy-reset resilience, CSS/zoom-pan dedupe, bot-fitting lifecycle
  backtests, research-tool alignment, folder-audit fixes)
- docs/EVOLUTION.md: Phase-9 post-v1.4.22 sentence, test count 238,
  commit total 2084

Risk notes: emitted page scripts live inside template literals, so tsc
cannot validate them; static reference scan reports only uPlot as an
external symbol and exactly one definition per feature function.

Testing Notes:
- npm run typecheck
- node dist/tests/test_kibana_candles.js
- generated tradingview_xrp-bts_OLD.html vs _NEW.html comparison charts
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