uplot-plus 0.3.2 → 0.4.0

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.
Files changed (58) hide show
  1. package/README.md +107 -225
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +2427 -2098
  4. package/dist/src/annotations.d.ts.map +1 -1
  5. package/dist/src/axes/layout.d.ts.map +1 -1
  6. package/dist/src/components/Axis.d.ts +0 -3
  7. package/dist/src/components/Axis.d.ts.map +1 -1
  8. package/dist/src/components/BoxWhisker.d.ts +24 -0
  9. package/dist/src/components/BoxWhisker.d.ts.map +1 -0
  10. package/dist/src/components/Candlestick.d.ts +18 -0
  11. package/dist/src/components/Candlestick.d.ts.map +1 -0
  12. package/dist/src/components/Chart.d.ts +1 -1
  13. package/dist/src/components/Chart.d.ts.map +1 -1
  14. package/dist/src/components/Heatmap.d.ts +14 -0
  15. package/dist/src/components/Heatmap.d.ts.map +1 -0
  16. package/dist/src/components/Scale.d.ts +0 -3
  17. package/dist/src/components/Scale.d.ts.map +1 -1
  18. package/dist/src/components/Series.d.ts +0 -3
  19. package/dist/src/components/Series.d.ts.map +1 -1
  20. package/dist/src/components/Sparkline.d.ts.map +1 -1
  21. package/dist/src/components/Vector.d.ts +16 -0
  22. package/dist/src/components/Vector.d.ts.map +1 -0
  23. package/dist/src/components/ZoomRanger.d.ts.map +1 -1
  24. package/dist/src/components/annotations/HLine.d.ts.map +1 -1
  25. package/dist/src/components/annotations/Region.d.ts.map +1 -1
  26. package/dist/src/components/annotations/VLine.d.ts.map +1 -1
  27. package/dist/src/components/annotations/useAnnotationDraw.d.ts +8 -0
  28. package/dist/src/components/annotations/useAnnotationDraw.d.ts.map +1 -0
  29. package/dist/src/core/DataStore.d.ts.map +1 -1
  30. package/dist/src/core/Scale.d.ts +5 -0
  31. package/dist/src/core/Scale.d.ts.map +1 -1
  32. package/dist/src/core/ScaleManager.d.ts.map +1 -1
  33. package/dist/src/hooks/useChartStore.d.ts +6 -4
  34. package/dist/src/hooks/useChartStore.d.ts.map +1 -1
  35. package/dist/src/hooks/useInteraction.d.ts +1 -2
  36. package/dist/src/hooks/useInteraction.d.ts.map +1 -1
  37. package/dist/src/hooks/useRegisterConfig.d.ts +16 -0
  38. package/dist/src/hooks/useRegisterConfig.d.ts.map +1 -0
  39. package/dist/src/index.d.ts +10 -3
  40. package/dist/src/index.d.ts.map +1 -1
  41. package/dist/src/paths/bars.d.ts +2 -0
  42. package/dist/src/paths/bars.d.ts.map +1 -1
  43. package/dist/src/paths/utils.d.ts +0 -5
  44. package/dist/src/paths/utils.d.ts.map +1 -1
  45. package/dist/src/rendering/drawRangeBox.d.ts +29 -0
  46. package/dist/src/rendering/drawRangeBox.d.ts.map +1 -0
  47. package/dist/src/time/timeIncrs.d.ts.map +1 -1
  48. package/dist/src/time/timeSplits.d.ts +1 -1
  49. package/dist/src/time/timeSplits.d.ts.map +1 -1
  50. package/dist/src/types/chart.d.ts +6 -31
  51. package/dist/src/types/chart.d.ts.map +1 -1
  52. package/dist/src/types/index.d.ts +3 -1
  53. package/dist/src/types/index.d.ts.map +1 -1
  54. package/dist/src/types/interaction.d.ts +62 -0
  55. package/dist/src/types/interaction.d.ts.map +1 -0
  56. package/package.json +2 -3
  57. package/dist/src/paths/candlestick.d.ts +0 -35
  58. package/dist/src/paths/candlestick.d.ts.map +0 -1
@@ -0,0 +1,62 @@
1
+ import type { ChartStore } from '../hooks/useChartStore';
2
+ import type { Orientation } from './common';
3
+ /**
4
+ * Context computed by the interaction hook, passed to action matchers and reaction handlers.
5
+ */
6
+ export interface ActionContext {
7
+ /** Plot-relative x coordinate (CSS px from plot left edge) */
8
+ cx: number;
9
+ /** Plot-relative y coordinate (CSS px from plot top edge) */
10
+ cy: number;
11
+ /** Whether (cx, cy) is inside the plot area */
12
+ inPlot: boolean;
13
+ /** For gutter hits: the scale ID that was hit */
14
+ scaleId?: string;
15
+ /** For gutter hits: the axis orientation */
16
+ ori?: Orientation;
17
+ /** The classified action string (e.g. 'leftClick', 'shiftLeftDrag'). Set by the hook before dispatch. */
18
+ action?: string;
19
+ }
20
+ /**
21
+ * Continuation for multi-event gestures (drag, pan, gutter drag).
22
+ * Returned by reaction handlers that need to track mousemove/mouseup.
23
+ */
24
+ export interface DragContinuation {
25
+ onMove: (store: ChartStore, e: Event, ctx: ActionContext) => void;
26
+ onEnd: (store: ChartStore, e: Event, ctx: ActionContext) => void;
27
+ }
28
+ /**
29
+ * Action key: a built-in string name or a custom matcher function.
30
+ *
31
+ * Built-in strings follow the pattern `{modifier?}{Button}{Type}`:
32
+ * - Drag: left/middle/rightDrag, shift/alt/ctrlLeft/Middle/RightDrag
33
+ * - Click: left/middle/rightClick, shift/alt/ctrlLeft/Middle/RightClick
34
+ * - Dblclick: leftDblclick, shift/alt/ctrlLeftDblclick
35
+ * - Gutter: xGutterDrag, yGutterDrag
36
+ * - Wheel: wheel, shiftWheel, altWheel, ctrlWheel
37
+ * - Hover: hover (fired on cursor position change, not when stationary)
38
+ * - Touch: touchDrag, pinch
39
+ * - Keyboard: key{Key}, shift/alt/ctrlKey{Key} — e.g. shiftKeyX, ctrlKeyS, keyEscape
40
+ */
41
+ export type ActionKey = string | ((e: Event, ctx: ActionContext) => boolean);
42
+ /**
43
+ * Reaction value: a built-in string name or a custom handler function.
44
+ *
45
+ * Built-in reaction strings: 'zoomX', 'zoomY', 'zoomXY', 'panX', 'panY', 'panXY', 'reset', 'none'
46
+ *
47
+ * Custom handlers return a DragContinuation for multi-event gestures, or void for one-shot.
48
+ */
49
+ export type ReactionValue = string | ((store: ChartStore, e: Event, ctx: ActionContext) => DragContinuation | void);
50
+ /** A single action→reaction binding. */
51
+ export type ActionEntry = [ActionKey, ReactionValue];
52
+ /** User-facing actions list: array of [action, reaction] tuples (merged with defaults). */
53
+ export type ActionList = ActionEntry[];
54
+ /**
55
+ * Focus reaction factory: dims non-nearest series to the given alpha.
56
+ * Use as a reaction for the 'hover' action:
57
+ * `actions={[['hover', focus(0.15)]]}`
58
+ */
59
+ export declare function focus(alpha?: number): ReactionValue;
60
+ /** Default actions — standard charting interactions out of the box. */
61
+ export declare const DEFAULT_ACTIONS: ActionList;
62
+ //# sourceMappingURL=interaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../../../src/types/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,MAAM,EAAE,OAAO,CAAC;IAChB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,yGAAyG;IACzG,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;IAClE,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;CAClE;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,KAAK,gBAAgB,GAAG,IAAI,CAAC,CAAC;AAEnF,wCAAwC;AACxC,MAAM,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAErD,2FAA2F;AAC3F,MAAM,MAAM,UAAU,GAAG,WAAW,EAAE,CAAC;AAEvC;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,SAAO,GAAG,aAAa,CAIjD;AAED,uEAAuE;AACvE,eAAO,MAAM,eAAe,EAAE,UAQ7B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uplot-plus",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "High-performance React charting library with multi-x-axis support",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -32,8 +32,7 @@
32
32
  "lint": "eslint src/ demo/",
33
33
  "typecheck": "tsc --noEmit",
34
34
  "test": "vitest run",
35
- "build:demo": "vite build demo",
36
- "bench": "vite serve bench --config bench/vite.config.ts"
35
+ "build:demo": "vite build demo"
37
36
  },
38
37
  "peerDependencies": {
39
38
  "react": ">=18.0.0",
@@ -1,35 +0,0 @@
1
- import type { DrawCallback } from '../types/hooks';
2
- import type { ScaleState } from '../types';
3
- export interface CandlestickOpts {
4
- /** X values array */
5
- xValues: ArrayLike<number>;
6
- /** Open values array */
7
- open: ArrayLike<number | null>;
8
- /** High values array */
9
- high: ArrayLike<number | null>;
10
- /** Low values array */
11
- low: ArrayLike<number | null>;
12
- /** Close values array */
13
- close: ArrayLike<number | null>;
14
- /** X scale state — must have min/max set */
15
- xScale: ScaleState;
16
- /** Y scale state — must have min/max set */
17
- yScale: ScaleState;
18
- /** Color for up candles (close >= open) */
19
- upColor?: string;
20
- /** Color for down candles (close < open) */
21
- downColor?: string;
22
- /** Body width as fraction of available space (default 0.6) */
23
- bodyWidth?: number;
24
- /** Wick width in CSS pixels (default 1) */
25
- wickWidth?: number;
26
- }
27
- /**
28
- * Creates a DrawCallback that renders candlestick (OHLC) candles.
29
- * Use with the Chart's `onDraw` prop or `useDrawHook`.
30
- *
31
- * The caller must provide the data arrays and scale states directly
32
- * since DrawCallback only receives { ctx, plotBox, pxRatio }.
33
- */
34
- export declare function drawCandlesticks(opts: CandlestickOpts): DrawCallback;
35
- //# sourceMappingURL=candlestick.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"candlestick.d.ts","sourceRoot":"","sources":["../../../src/paths/candlestick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,WAAW,eAAe;IAC9B,qBAAqB;IACrB,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,wBAAwB;IACxB,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/B,wBAAwB;IACxB,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/B,uBAAuB;IACvB,GAAG,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC9B,yBAAyB;IACzB,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAChC,4CAA4C;IAC5C,MAAM,EAAE,UAAU,CAAC;IACnB,4CAA4C;IAC5C,MAAM,EAAE,UAAU,CAAC;IACnB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,YAAY,CAyDpE"}