@livo-build/charts 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +209 -20
- package/dist/core/chart.d.ts +105 -4
- package/dist/core/chart.js +482 -39
- package/dist/core/feed.js +27 -6
- package/dist/core/format.d.ts +13 -1
- package/dist/core/format.js +38 -3
- package/dist/core/indicators.d.ts +50 -0
- package/dist/core/indicators.js +181 -0
- package/dist/core/ohlc.d.ts +10 -0
- package/dist/core/ohlc.js +30 -0
- package/dist/core/polymarket.d.ts +44 -0
- package/dist/core/polymarket.js +92 -0
- package/dist/core/renderer.d.ts +96 -1
- package/dist/core/renderer.js +534 -64
- package/dist/core/signals.d.ts +63 -0
- package/dist/core/signals.js +234 -0
- package/dist/core/theme.d.ts +5 -1
- package/dist/core/theme.js +33 -12
- package/dist/core/types.d.ts +102 -3
- package/dist/index.d.ts +13 -8
- package/dist/index.js +8 -6
- package/dist/react/HyperliquidChart.d.ts +30 -2
- package/dist/react/HyperliquidChart.js +47 -17
- package/dist/react/PolymarketChart.d.ts +40 -0
- package/dist/react/PolymarketChart.js +95 -0
- package/dist/react/PriceChart.d.ts +54 -4
- package/dist/react/PriceChart.js +66 -27
- package/dist/react/SignalsChart.d.ts +37 -0
- package/dist/react/SignalsChart.js +95 -0
- package/dist/react/ui.d.ts +24 -0
- package/dist/react/ui.js +75 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.js +2 -0
- package/package.json +2 -2
package/dist/core/renderer.d.ts
CHANGED
|
@@ -1,4 +1,59 @@
|
|
|
1
|
-
import type { Candle, ChartTheme, ChartType, Indicator } from "./types";
|
|
1
|
+
import type { Candle, ChartTheme, ChartType, Drawing, Indicator, Oscillator, VolumeProfileConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Width of one candle slot (px). By default the slot is capped at `maxBarWidth` and the
|
|
4
|
+
* series is right-anchored — sparse data stays tight in the corner. With `fitContent`,
|
|
5
|
+
* the cap is dropped so `count` candles spread across the whole plot (fills the
|
|
6
|
+
* container). Dense series are identical either way (plotW/count < maxBarWidth).
|
|
7
|
+
*/
|
|
8
|
+
export declare function slotWidth(plotW: number, count: number, maxBarWidth: number, fitContent?: boolean): number;
|
|
9
|
+
/** Convert a `#rrggbb` color to `rgba(...)` with the given alpha (passes other formats through). */
|
|
10
|
+
export declare function withAlpha(color: string, alpha: number): string;
|
|
11
|
+
/** The visible candle window (which slice is on screen and the per-candle slot width).
|
|
12
|
+
* A negative `view.offset` scrolls past the newest candle into the future: `end` exceeds
|
|
13
|
+
* the data length and `rightGap` counts the empty slots between the newest candle and the
|
|
14
|
+
* right edge (so the user can pull the current price left of the edge / toward center). */
|
|
15
|
+
export declare function windowOf(candles: Candle[], view: Viewport, plotW: number, maxBarWidth: number, fitContent?: boolean): {
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
vis: Candle[];
|
|
19
|
+
n: number;
|
|
20
|
+
count: number;
|
|
21
|
+
rightGap: number;
|
|
22
|
+
cw: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Price ↔ pixel mapping for the price pane, shared by the renderer and the drawing-tool
|
|
26
|
+
* hit-testing so they never drift. Handles the log transform and the padded/zoomed range.
|
|
27
|
+
*/
|
|
28
|
+
export declare function priceScale(vis: Candle[], yZoom: number, logScale: boolean, top: number, priceH: number): {
|
|
29
|
+
yOfPrice: (v: number) => number;
|
|
30
|
+
priceOfY: (y: number) => number;
|
|
31
|
+
fwd: (v: number) => number;
|
|
32
|
+
inv: (s: number) => number;
|
|
33
|
+
sLo: number;
|
|
34
|
+
sRng: number;
|
|
35
|
+
lo: number;
|
|
36
|
+
hi: number;
|
|
37
|
+
};
|
|
38
|
+
/** Time ↔ pixel mapping for the visible window (candle index and arbitrary unix-second time).
|
|
39
|
+
* `rightGap` (empty future slots, see windowOf) shifts the candles left of the right edge. */
|
|
40
|
+
export declare function timeScale(vis: Candle[], n: number, cw: number, plotW: number, interval: number, rightGap?: number): {
|
|
41
|
+
xOf: (j: number) => number;
|
|
42
|
+
xOfTime: (t: number) => number;
|
|
43
|
+
timeOfX: (x: number) => number;
|
|
44
|
+
};
|
|
45
|
+
/** Full pixel↔data projection for the current frame — built from the same input `draw` uses. */
|
|
46
|
+
export interface Projection {
|
|
47
|
+
xOfTime: (t: number) => number;
|
|
48
|
+
timeOfX: (x: number) => number;
|
|
49
|
+
yOfPrice: (p: number) => number;
|
|
50
|
+
priceOfY: (y: number) => number;
|
|
51
|
+
plotW: number;
|
|
52
|
+
priceTop: number;
|
|
53
|
+
priceBottom: number;
|
|
54
|
+
}
|
|
55
|
+
/** Compute the {@link Projection} for interaction/hit-testing without rendering. */
|
|
56
|
+
export declare function computeProjection(input: RenderInput): Projection | null;
|
|
2
57
|
export interface Viewport {
|
|
3
58
|
/** candles visible. */
|
|
4
59
|
count: number;
|
|
@@ -15,6 +70,10 @@ export interface RenderInput {
|
|
|
15
70
|
width: number;
|
|
16
71
|
height: number;
|
|
17
72
|
candles: Candle[];
|
|
73
|
+
/** Candles used for the price series + axis (Heikin-Ashi in `heikin` mode). The Chart
|
|
74
|
+
* controller precomputes this on data/type change; if omitted, `draw` derives it. The
|
|
75
|
+
* RAW `candles` still drive volume, indicators, oscillators and the crosshair readout. */
|
|
76
|
+
priceCandles?: Candle[];
|
|
18
77
|
view: Viewport;
|
|
19
78
|
hover: {
|
|
20
79
|
x: number;
|
|
@@ -26,6 +85,8 @@ export interface RenderInput {
|
|
|
26
85
|
yZoom: number;
|
|
27
86
|
/** max candle slot width in px. */
|
|
28
87
|
maxBarWidth: number;
|
|
88
|
+
/** max candle body / volume-bar width in px (default 40). */
|
|
89
|
+
maxBodyWidth?: number;
|
|
29
90
|
/** volume-panel height in px. */
|
|
30
91
|
volH: number;
|
|
31
92
|
theme: ChartTheme;
|
|
@@ -34,12 +95,46 @@ export interface RenderInput {
|
|
|
34
95
|
indicators?: Indicator[];
|
|
35
96
|
/** precomputed overlay value-series (aligned to `candles`); preferred over `indicators`. */
|
|
36
97
|
overlays?: ResolvedOverlay[];
|
|
98
|
+
/** logarithmic price axis — equal vertical distance = equal % move. */
|
|
99
|
+
logScale?: boolean;
|
|
100
|
+
/** centered text when there are no candles (default "no priced trades yet"; "" = nothing). */
|
|
101
|
+
emptyText?: string;
|
|
102
|
+
/** reference price for the `baseline` chart type (default: the first visible candle's close). */
|
|
103
|
+
baselinePrice?: number;
|
|
104
|
+
/** volume-by-price histogram drawn on the price pane (default off). */
|
|
105
|
+
volumeProfile?: VolumeProfileConfig;
|
|
106
|
+
/** spread candles across the full plot width instead of right-anchoring at a capped slot. */
|
|
107
|
+
fitContent?: boolean;
|
|
108
|
+
/** y-axis price label formatter (default: range-aware {@link formatAxisValue}). */
|
|
109
|
+
priceFormat?: (value: number) => string;
|
|
110
|
+
/** x-axis time label formatter (default {@link formatTime}). */
|
|
111
|
+
timeFormat?: (time: number, interval: number) => string;
|
|
112
|
+
/** number of horizontal price gridlines / labels (default 5). */
|
|
113
|
+
priceTicks?: number;
|
|
114
|
+
/** approximate number of time-axis labels (default 7). */
|
|
115
|
+
timeTicks?: number;
|
|
116
|
+
/** canvas font for axis labels (default "10px ui-monospace, monospace"); color is `theme.axis`. */
|
|
117
|
+
axisFont?: string;
|
|
118
|
+
/** oscillators (RSI / MACD) drawn in stacked sub-panes below the volume panel. */
|
|
119
|
+
oscillators?: Oscillator[];
|
|
120
|
+
/** committed user drawings (trendlines / horizontal lines). */
|
|
121
|
+
drawings?: Drawing[];
|
|
122
|
+
/** in-progress drawing rendered as a live preview (not yet committed). */
|
|
123
|
+
drawPreview?: Drawing | null;
|
|
124
|
+
/** id of the selected drawing (rendered emphasized with anchor handles). */
|
|
125
|
+
selectedDrawing?: string | null;
|
|
37
126
|
}
|
|
38
127
|
/** A resolved indicator overlay: a color and a value-series aligned to the candles. */
|
|
39
128
|
export interface ResolvedOverlay {
|
|
40
129
|
color: string;
|
|
41
130
|
values: (number | null)[];
|
|
42
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Resolve indicator configs into drawable overlay lines. Moving averages / VWAP map 1:1;
|
|
134
|
+
* a `bollinger` indicator expands into three lines (upper / mid / lower), the bands faint.
|
|
135
|
+
* Shared by the Chart controller (precompute) and `draw` (standalone callers).
|
|
136
|
+
*/
|
|
137
|
+
export declare function resolveOverlays(candles: Candle[], indicators: Indicator[]): ResolvedOverlay[];
|
|
43
138
|
/**
|
|
44
139
|
* Pure draw pass: renders grid, axes, the price series (candles or line), a volume
|
|
45
140
|
* panel, the last-price tag and the crosshair + axis labels. Returns the candle under
|