Skip to main content

Scales & live values

functions@pond-ts/charts

scaleTradingTimesource

scaleTradingTime(provider: DiscontinuityProvider): TradingTimeScale

Build a TradingTimeScale over the given discontinuity provider. Configure like a d3 scale: scaleTradingTime(provider).domain([t0, t1]).range([0, width]).

scaleBandsource

scaleBand(categories: readonly string[]): ScaleBand

Build a ScaleBand over an ordered list of category names. Configure like a d3 scale: scaleBand(tickers).domain([0, n]).range([0, width]) — the container sets domain([0, n]) from the layer's slot extent and range([0, plotWidth]). categories supplies the labels; the domain drives the geometry, so the two must agree on count (categories.length === n), which they do when both come from the same layer's xCategories() / slot extent.

createLiveValuesource

createLiveValue(initial: number): LiveValue

Create a LiveValue seeded at initial. Hold the returned object, call .set(v) from your data source, and hand it to <YAxisIndicator source={…}> — the pill repositions and relabels on each set without re-rendering the chart.

const price = createLiveValue(0);
ws.onmessage = (e) => price.set(JSON.parse(e.data).last); // outside React
// <YAxisIndicator source={price} color="#4af" format=",.2f" />