tickup 1.0.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 (117) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +55 -0
  4. package/dist/branding/TickUpAttribution.d.ts +11 -0
  5. package/dist/branding/TickUpMark.d.ts +15 -0
  6. package/dist/branding/tickupBrandAssets.d.ts +12 -0
  7. package/dist/branding/tickupWatermark.d.ts +28 -0
  8. package/dist/components/Canvas/Axes/XAxis.d.ts +18 -0
  9. package/dist/components/Canvas/Axes/YAxis.d.ts +12 -0
  10. package/dist/components/Canvas/ChartCanvas.d.ts +40 -0
  11. package/dist/components/Canvas/ChartStage.d.ts +5 -0
  12. package/dist/components/Canvas/TickUpStage.d.ts +122 -0
  13. package/dist/components/Canvas/utils/GraphDraw.d.ts +13 -0
  14. package/dist/components/Canvas/utils/GraphHelpers.d.ts +60 -0
  15. package/dist/components/Canvas/utils/drawDrawings.d.ts +4 -0
  16. package/dist/components/Canvas/utils/drawOverlay.d.ts +44 -0
  17. package/dist/components/Canvas/utils/formatters.d.ts +34 -0
  18. package/dist/components/Canvas/utils/generateTicks.d.ts +9 -0
  19. package/dist/components/Canvas/utils/helpers.d.ts +6 -0
  20. package/dist/components/Common/AlertModal.d.ts +13 -0
  21. package/dist/components/Common/AlertModal.styles.d.ts +13 -0
  22. package/dist/components/DefaultData.d.ts +3 -0
  23. package/dist/components/Drawing/AngleShape.d.ts +37 -0
  24. package/dist/components/Drawing/ArrowShape.d.ts +32 -0
  25. package/dist/components/Drawing/CircleShape.d.ts +29 -0
  26. package/dist/components/Drawing/CustomSymbolShape.d.ts +31 -0
  27. package/dist/components/Drawing/IDrawingShape.d.ts +32 -0
  28. package/dist/components/Drawing/LineShape.d.ts +29 -0
  29. package/dist/components/Drawing/Polyline.d.ts +29 -0
  30. package/dist/components/Drawing/RectangleShape.d.ts +29 -0
  31. package/dist/components/Drawing/TriangleShape.d.ts +34 -0
  32. package/dist/components/Drawing/drawHelper.d.ts +35 -0
  33. package/dist/components/Drawing/drawingQuery.d.ts +44 -0
  34. package/dist/components/Drawing/types.d.ts +21 -0
  35. package/dist/components/SettingsModal/SettingsModal.d.ts +73 -0
  36. package/dist/components/SettingsModal/SettingsModal.styles.d.ts +62 -0
  37. package/dist/components/ShapePropertiesModal/ShapePropertiesModal.d.ts +13 -0
  38. package/dist/components/ShapePropertiesModal/applyShapeProperties.d.ts +16 -0
  39. package/dist/components/TickUpHost.d.ts +162 -0
  40. package/dist/components/TickUpProducts.d.ts +23 -0
  41. package/dist/components/Toolbar/Buttons.d.ts +4 -0
  42. package/dist/components/Toolbar/ChartTypeSelectDropdown.d.ts +9 -0
  43. package/dist/components/Toolbar/IntervalSelect.d.ts +15 -0
  44. package/dist/components/Toolbar/RangeSelector.d.ts +9 -0
  45. package/dist/components/Toolbar/SettingsToolbar.d.ts +50 -0
  46. package/dist/components/Toolbar/Toolbar.d.ts +10 -0
  47. package/dist/components/Toolbar/icons.d.ts +79 -0
  48. package/dist/components/Tooltip.d.ts +17 -0
  49. package/dist/contexts/ModeContext.d.ts +24 -0
  50. package/dist/engines/TickUpEngine.d.ts +12 -0
  51. package/dist/engines/prime/PrimeRenderer.d.ts +4 -0
  52. package/dist/engines/prime/TickUpPrime.d.ts +15 -0
  53. package/dist/full.d.ts +71 -0
  54. package/dist/hooks/useChartData.d.ts +15 -0
  55. package/dist/hooks/useElementSize.d.ts +13 -0
  56. package/dist/hooks/usePanAndZoom.d.ts +12 -0
  57. package/dist/index.d.ts +47 -0
  58. package/dist/main.d.ts +1 -0
  59. package/dist/services/FormattingService.d.ts +36 -0
  60. package/dist/styles/App.styles.d.ts +11 -0
  61. package/dist/styles/ChartCanvas.styles.d.ts +26 -0
  62. package/dist/styles/ChartTypeSelectDropdown.styles.d.ts +13 -0
  63. package/dist/styles/IntervalSelect.styles.d.ts +25 -0
  64. package/dist/styles/RangeSelector.styles.d.ts +10 -0
  65. package/dist/styles/SettingsToolbar.styles.d.ts +19 -0
  66. package/dist/styles/TickUpStage.styles.d.ts +31 -0
  67. package/dist/styles/Toolbar.styles.d.ts +12 -0
  68. package/dist/styles/Tooltip.styles.d.ts +22 -0
  69. package/dist/styles/XAxis.styles.d.ts +5 -0
  70. package/dist/styles/YAxis.styles.d.ts +6 -0
  71. package/dist/test-utils/assetUrlStub.d.ts +3 -0
  72. package/dist/test-utils/svgRawStub.d.ts +3 -0
  73. package/dist/tickup-full.cjs.js +1417 -0
  74. package/dist/tickup-full.es.js +6699 -0
  75. package/dist/tickup-icon.svg +5 -0
  76. package/dist/tickup.cjs.js +1417 -0
  77. package/dist/tickup.es.js +6427 -0
  78. package/dist/types/Drawings.d.ts +54 -0
  79. package/dist/types/Graph.d.ts +45 -0
  80. package/dist/types/Interval.d.ts +11 -0
  81. package/dist/types/buttons.d.ts +30 -0
  82. package/dist/types/chartContext.d.ts +52 -0
  83. package/dist/types/chartOptions.d.ts +161 -0
  84. package/dist/types/liveData.d.ts +14 -0
  85. package/dist/types/overlay.d.ts +64 -0
  86. package/dist/types/tickupProducts.d.ts +18 -0
  87. package/dist/types/types.d.ts +36 -0
  88. package/dist/utils/LocaleResolver.d.ts +15 -0
  89. package/dist/utils/captureChartRegion.d.ts +34 -0
  90. package/dist/utils/deepEqual.d.ts +1 -0
  91. package/dist/utils/deepMerge.d.ts +2 -0
  92. package/dist/utils/i18n.d.ts +26 -0
  93. package/dist/utils/liveDataMerge.d.ts +21 -0
  94. package/dist/utils/marketData.d.ts +8 -0
  95. package/dist/utils/timeUtils.d.ts +9 -0
  96. package/dist/vite.svg +1 -0
  97. package/documentation/01-glossary.md +61 -0
  98. package/documentation/01-introduction.md +7 -0
  99. package/documentation/02-installation.md +48 -0
  100. package/documentation/03-quick-start.md +86 -0
  101. package/documentation/04-products-and-layout.md +51 -0
  102. package/documentation/05-props-and-chart-options.md +109 -0
  103. package/documentation/06-imperative-api.md +117 -0
  104. package/documentation/07-data-and-live-updates.md +62 -0
  105. package/documentation/08-drawings-and-shapes.md +132 -0
  106. package/documentation/09-settings-modal.md +37 -0
  107. package/documentation/10-toolbar-and-interactions.md +85 -0
  108. package/documentation/11-exports-and-advanced.md +142 -0
  109. package/documentation/12-overlays-and-indicators.md +65 -0
  110. package/documentation/13-internationalization-and-axes.md +56 -0
  111. package/documentation/14-legal-and-policies.md +32 -0
  112. package/documentation/README.md +33 -0
  113. package/legal/ACCEPTABLE_USE_POLICY.md +79 -0
  114. package/legal/PRIVACY_POLICY.md +131 -0
  115. package/legal/README.md +21 -0
  116. package/legal/TERMS_OF_SERVICE.md +153 -0
  117. package/package.json +98 -0
@@ -0,0 +1,61 @@
1
+ # Glossary
2
+
3
+ ## Data
4
+
5
+ - **Interval** — One bar or tick row: open, high, low, close, time (`t` in **Unix seconds**), optional volume (`v`). See `Interval` type.
6
+ - **Series** — Ordered array of intervals, usually sorted by `t`.
7
+ - **Time range** — Visible window on the X axis: `start` and `end` (Unix seconds). Indices `startIndex` / `endIndex` refer to positions in the loaded series.
8
+ - **Price range** — Visible Y window: min/max prices and derived `range` span.
9
+
10
+ ## Chart presentation
11
+
12
+ - **Chart type** — `ChartType`: Candlestick, Line, Area, Bar (OHLCV rendering mode).
13
+ - **Theme** — `base.theme` on the chart (`light`, `dark`, `grey`) plus **`TickUpHost`** shell theme: **`themeVariant`** (controlled), **`defaultThemeVariant`**, **`onThemeVariantChange`** (**`GlobalStyle`** / modal chrome). Align chart and shell for readable grid and watermarks.
14
+ - **Axes** — Time (X) and price (Y) scales, tick formatting, locale, timezone options under `chartOptions.base.style.axes` and `chartOptions.axes`.
15
+ - **Histogram** — Volume bars below (or proportionally to) the main plot when `showHistogram` is true.
16
+ - **Overlay** — Additional computed or static series drawn on top of price (see overlay types in code).
17
+
18
+ ## Products (tiers)
19
+
20
+ TickUp ships **named product components** that fix toolbar layout:
21
+
22
+ | Product | Typical use |
23
+ |-----------|-------------|
24
+ | **Pulse** | Minimal embed: plot + axes only; optional **compact symbol strip** if `symbol` / `defaultSymbol` is non-empty |
25
+ | **Flow** | Top bar (symbol, settings, chart type); no drawing sidebar |
26
+ | **Command** | Full UI: side drawing bar + top bar |
27
+ | **Desk** | Same as Command; in-chart branding watermark required |
28
+
29
+ Use **`TickUpHost`** **without** `productId` to control `showSidebar` / `showTopBar` / `showSettingsBar` yourself.
30
+
31
+ **Prime** may refer to **`productId: 'prime'`** (**`TickUpPrimeTier`**) or the **`prime`** render engine (**`chartOptions.base.engine`** / **`TickUpPrime`**). See [Prime engine & Pro roadmap](https://github.com/BARDAMRI/tickup-prime/blob/main/documentation/15-prime-engine-and-pro-roadmap.md).
32
+
33
+ ## Live data
34
+
35
+ - **Placement** — How new bars are merged: `replace`, `append`, `prepend`, `mergeByTime` (`LiveDataPlacement`).
36
+ - **Apply result** — `LiveDataApplyResult`: success flag, resulting intervals, `errors`, `warnings`.
37
+
38
+ ## Drawings
39
+
40
+ - **Shape** — User or API-created overlay: line, rectangle, circle, triangle, angle, arrow, polyline, custom symbol (`ShapeType`).
41
+ - **Drawing spec** — Plain object `{ type, points, style?, id?, symbol?, size? }` for creation (`DrawingSpec`).
42
+ - **Patch** — Partial update `{ style?, points?, symbol?, size? }` (`DrawingPatch`).
43
+ - **Z-index** — Stack order: later shapes draw above earlier ones; hit-testing uses top-most first.
44
+
45
+ ## Interaction modes
46
+
47
+ Internal drawing **mode** (toolbar) toggles between none, draw tools, select, and edit. Pan/zoom applies when mode is default navigation.
48
+
49
+ ## Snapshot / export
50
+
51
+ - **Main canvas** — OHLC layer only (no histogram/drawings) via `getMainCanvasElement`.
52
+ - **Chart region snapshot** — PNG of the composed view (plot + axes) via `captureChartRegionToPngDataUrl` and toolbar integration.
53
+
54
+ ## Indicators
55
+
56
+ - **Overlay** — A computed line series (e.g. SMA) drawn over price; configured via `base.showOverlayLine` and `base.overlays` or `base.overlayKinds`. See [Overlays & indicators](./12-overlays-and-indicators.md).
57
+
58
+ ## Market calendar (axes)
59
+
60
+ - **Trading session** — Recurring weekday window (`dayOfWeek` + `HH:mm` start/end) used to dim time outside regular hours.
61
+ - **Holiday** — ISO date string list for calendar-aware behavior where applied.
@@ -0,0 +1,7 @@
1
+ # Introduction
2
+
3
+ TickUp is a high-performance React charting library for financial OHLCV workflows, built on Canvas 2D with product-grade UI tiers and an imperative API for real-time updates.
4
+
5
+ You can start with the open-source core package for charting, drawing tools, overlays, and streaming data, then move to the **Prime Engine** as the professional upgrade path when you need premium visual rendering profiles and advanced Pro capabilities.
6
+
7
+ For onboarding, continue to [Installation](./02-installation.md) and [Quick start](./03-quick-start.md).
@@ -0,0 +1,48 @@
1
+ # Installation
2
+
3
+ ## Requirements
4
+
5
+ - **React** 18 or 19
6
+ - **react-dom** 18 or 19
7
+ - **styled-components** 6.x
8
+
9
+ These are **peer dependencies**; your app must install them.
10
+
11
+ ## npm
12
+
13
+ ```bash
14
+ npm install tickup
15
+ ```
16
+
17
+ With peer dependencies in a single command:
18
+
19
+ ```bash
20
+ npm install tickup react react-dom styled-components
21
+ ```
22
+
23
+ ## TypeScript
24
+
25
+ Types ship with the package (`dist/index.d.ts`). Enable `strict` as usual; import types from `tickup`.
26
+
27
+ ## Bundler notes
28
+
29
+ - **ESM** entry: `tickup` → `dist/index.es.js`
30
+ - **CJS** entry: `dist/index.cjs.js`
31
+
32
+ Vite, Webpack, and Next.js typically resolve the correct format automatically.
33
+
34
+ ## Styled-components
35
+
36
+ TickUp uses styled-components for layout and themed UI. Ensure your app wraps the tree appropriately (e.g. single `ThemeProvider` if you use one globally; TickUp does not require a specific theme object for its internal styled components).
37
+
38
+ ## Verify
39
+
40
+ ```tsx
41
+ import { TickUpCommand } from 'tickup/full';
42
+
43
+ export function SmokeTest() {
44
+ return <TickUpCommand style={{ height: 400 }} />;
45
+ }
46
+ ```
47
+
48
+ You still need to pass `intervalsArray` (can be `[]` for an empty chart). See [Quick start](./03-quick-start.md).
@@ -0,0 +1,86 @@
1
+ # Quick start
2
+
3
+ ### Prime Preview
4
+ ![The "Hero" Prime Neon](../assets/showcase/hero-prime-neon.png)
5
+ *Luxury rendering and neon effects enabled via `@tickup/prime`.*
6
+
7
+ TickUp Charts is **React-first**: embed **`TickUpHost`**, **`TickUpStage`**, or product components (`TickUpCommand`, …). There is **no** imperative `TickUpCore(container)` class — use props + refs (e.g. **`ref.setEngine(TickUpPrime)`** for **dark** Prime, or **`createTickUpPrimeEngine('light')`** when the shell is light). See [Prime engine & Pro roadmap](https://github.com/BARDAMRI/tickup-prime/blob/main/documentation/15-prime-engine-and-pro-roadmap.md).
8
+
9
+ ## 1. Render a product component
10
+
11
+ ```tsx
12
+ import { useRef } from 'react';
13
+ import { TickUpCommand, type TickUpHostHandle } from 'tickup/full';
14
+
15
+ const sample = [
16
+ { t: 1700000000, o: 100, h: 102, l: 99, c: 101, v: 1200 },
17
+ { t: 1700000060, o: 101, h: 103, l: 100, c: 102, v: 900 },
18
+ ];
19
+
20
+ export function App() {
21
+ const chartRef = useRef<TickUpHostHandle>(null);
22
+
23
+ return (
24
+ <div style={{ height: 480, width: '100%' }}>
25
+ <TickUpCommand
26
+ ref={chartRef}
27
+ intervalsArray={sample}
28
+ defaultSymbol="DEMO"
29
+ />
30
+ </div>
31
+ );
32
+ }
33
+ ```
34
+
35
+ `TickUpCommand` is the full-trader layout. For a minimal plot only, use **`TickUpPulse`** (same props, different chrome). Pass **`symbol`** or **`defaultSymbol`** so the ticker appears in a **compact strip** above the chart (Pulse has no top-bar symbol field). See [Products & layout](./04-products-and-layout.md) and [Toolbar & interactions](./10-toolbar-and-interactions.md).
36
+
37
+ ## 2. Give the chart a sized parent
38
+
39
+ The chart fills its container. Use explicit `height` (and usually `width` or flex) on a wrapper `div`.
40
+
41
+ ## 3. Updating data from React state
42
+
43
+ Control the series with props:
44
+
45
+ ```tsx
46
+ const [bars, setBars] = useState<Interval[]>(initial);
47
+
48
+ <TickUpCommand ref={chartRef} intervalsArray={bars} />;
49
+ ```
50
+
51
+ When `intervalsArray` changes reference or content, the stage syncs. For streaming updates without replacing the whole array, prefer the **imperative** API below.
52
+
53
+ ## 4. Imperative live updates
54
+
55
+ ```tsx
56
+ const r = chartRef.current?.applyLiveData(
57
+ { t: 1700000120, o: 102, h: 104, l: 101, c: 103, v: 1100 },
58
+ 'append'
59
+ );
60
+ if (r && !r.ok) console.warn(r.errors);
61
+ ```
62
+
63
+ See [Data & live updates](./07-data-and-live-updates.md).
64
+
65
+ ## 5. Optional: `chartOptions`
66
+
67
+ Pass a **stable** object (e.g. `useMemo`) so you do not reset internal UI state on every render:
68
+
69
+ ```tsx
70
+ const options = useMemo(
71
+ () => ({
72
+ base: { showHistogram: true },
73
+ axes: { yAxisPosition: AxesPosition.left, numberOfYTicks: 5 },
74
+ }),
75
+ []
76
+ );
77
+
78
+ <TickUpCommand chartOptions={options} intervalsArray={bars} />;
79
+ ```
80
+
81
+ See [Props & chart options](./05-props-and-chart-options.md).
82
+
83
+ ## Next
84
+
85
+ - [Products & layout](./04-products-and-layout.md) — choose the right tier
86
+ - [Imperative API](./06-imperative-api.md) — full ref surface
@@ -0,0 +1,51 @@
1
+ # Products & layout
2
+
3
+ ## Product components
4
+
5
+ Import from **`tickup/full`**:
6
+
7
+ | Export | `productId` | Side drawing bar | Top bar | Settings entry |
8
+ |--------|-------------|------------------|---------|----------------|
9
+ | `TickUpPulse` | `pulse` | No | No | No |
10
+ | `TickUpFlow` | `flow` | No | Yes | Yes |
11
+ | `TickUpCommand` | `command` | Yes | Yes | Yes |
12
+ | `TickUpDesk` | `desk` | Yes | Yes | Yes (branding on) |
13
+ | `TickUpPrimeTier` | `prime` | Yes | Yes | Yes |
14
+
15
+ Props types: `TickUpPulseProps`, `TickUpFlowProps`, etc. Product components **omit** `showSidebar`, `showTopBar`, and `showSettingsBar` from their public props; those are fixed per tier.
16
+
17
+ ### Prime tier vs Prime engine
18
+
19
+ - **`TickUpPrimeTier`** — Same chrome as **Command**; shows an **evaluation strip** when **`licenseKey`** is unset.
20
+ - **`TickUpPrime`** (engine) — Visual profile: **`chartOptions.base.engine: 'prime'`** or **`ref.setEngine(TickUpPrime)`** (dark plot). For a **light** Prime plot, use **`getTickUpPrimeThemePatch('light')`** / **`createTickUpPrimeEngine('light')`**. Usable on **any** tier. See [Prime engine & Pro roadmap](https://github.com/BARDAMRI/tickup-prime/blob/main/documentation/15-prime-engine-and-pro-roadmap.md).
21
+
22
+ ### Symbol on Pulse (no top bar)
23
+
24
+ **Pulse** has no symbol field in the toolbar. If you pass a non-empty **`symbol`** (controlled) or **`defaultSymbol`** (fallback when `symbol` is omitted), the stage shows a **compact read-only symbol strip** above the plot (same typography/colors as axis styling). If both resolve to empty after trim, the strip is hidden. See [Toolbar & interactions](./10-toolbar-and-interactions.md).
25
+
26
+ The same strip appears for **`TickUpHost`** / **`TickUpStage`** whenever **`showTopBar`** is `false` and a symbol string is available — not only for Pulse.
27
+
28
+ ## Custom layout: `TickUpHost`
29
+
30
+ Use **`TickUpHost`** **without** `productId`:
31
+
32
+ ```tsx
33
+ import { TickUpHost } from 'tickup/full';
34
+
35
+ <TickUpHost
36
+ showSidebar
37
+ showTopBar
38
+ showSettingsBar
39
+ intervalsArray={data}
40
+ />;
41
+ ```
42
+
43
+ Then you control which chrome appears. Settings saved in the modal still respect **locked** layout when `productId` is set on other variants.
44
+
45
+ ## Desk specifics
46
+
47
+ - **Desk** — `showAttribution` (in-chart watermark) is forced **on**.
48
+
49
+ ## Mode provider
50
+
51
+ The shell wraps children in **`ModeProvider`** internally. If you use **`TickUpStage`** alone (advanced), wrap with `ModeProvider` yourself. See [Exports & advanced](./11-exports-and-advanced.md).
@@ -0,0 +1,109 @@
1
+ # Props & chart options
2
+
3
+ ## `TickUpHostProps` / `TickUpHostHandle`
4
+
5
+ ### Data & view
6
+
7
+ | Prop | Purpose |
8
+ |------|---------|
9
+ | `intervalsArray` | OHLCV series (`Interval[]`). Default `[]`. |
10
+ | `initialVisibleTimeRange` | Optional `TimeRange` (`start`/`end` unix seconds). |
11
+ | `initialNumberOfYTicks` | Default Y tick count (default 5). |
12
+ | `initialXAxisHeight` | X axis height hint (pixels). |
13
+ | `initialYAxisWidth` | Y axis width hint (pixels). |
14
+ | `initialTimeDetailLevel` | `TimeDetailLevel` for axis time density. |
15
+ | `initialTimeFormat12h` | 12h vs 24h time formatting. |
16
+
17
+ ### `chartOptions` (deep partial merge)
18
+
19
+ Type: `DeepPartial<ChartOptions>`. Merged with library defaults (`DEFAULT_GRAPH_OPTIONS`). **Important:** pass a **stable reference** (`useMemo`) when the object does not meaningfully change, so internal state (e.g. chart type from the toolbar) is not overwritten by a new empty `{}` every render.
20
+
21
+ When you **do** change options intentionally, any deep change triggers a merge into current state.
22
+
23
+ ### Layout (only without `productId`)
24
+
25
+ | Prop | Purpose |
26
+ |------|---------|
27
+ | `showSidebar` | Drawing tools column. |
28
+ | `showTopBar` | Symbol + chart controls row. |
29
+ | `showSettingsBar` | Gear and related controls in the top cluster. |
30
+
31
+ ### Toolbar / host hooks
32
+
33
+ | Prop | Purpose |
34
+ |------|---------|
35
+ | `symbol` | Controlled symbol string (toolbar input when the top bar is shown). |
36
+ | `defaultSymbol` | Initial symbol when `symbol` is **omitted** (uncontrolled). Ignored for display once `symbol` is passed. |
37
+ | `onSymbolChange` | Fired when the user edits the symbol in the **top bar** (Flow, Command, Desk). |
38
+ | `onSymbolSearch` | Search submit (button or Enter) when the top bar is present. Return **`false`** or **reject** the returned `Promise` if loading the symbol failed — the input reverts to the last successfully displayed ticker and **`onSymbolChange`** is invoked with that previous value so controlled state stays consistent. Return **`true`** or **`undefined`** on success. |
39
+ | `onRefreshRequest` | User hit Refresh in toolbar. |
40
+
41
+ **When the top bar is hidden** (e.g. **Pulse**, or `showTopBar: false` on `TickUpHost`):
42
+
43
+ - There is no editable symbol control; use React state and pass **`symbol`** (or **`defaultSymbol`** only) from the host.
44
+ - If the resolved text is non-empty (trimmed controlled value, else trimmed `defaultSymbol`), a **read-only symbol strip** is rendered above the chart. Empty string hides it.
45
+
46
+ `getChartContext()` still reports the same symbol metadata for introspection.
47
+
48
+ ### Other
49
+
50
+ | Prop | Purpose |
51
+ |------|---------|
52
+ | `productId` | Lock layout to a tier (`pulse` \| `flow` \| `command` \| `desk` \| `prime`). |
53
+ | `showAttribution` | In-chart TickUp watermark (default true; forced on for Desk). Uses transparent bundled marks. |
54
+ | `licenseKey` | For **`productId: 'prime'`**: non-empty value hides the eval strip. |
55
+ | `themeVariant` | Shell **light** \| **dark** — when set, the host is **controlled**; keep it in sync with your app state and update from **`onThemeVariantChange`** when the user toggles theme in the toolbar. |
56
+ | `defaultThemeVariant` | Initial shell theme when **`themeVariant`** is omitted (uncontrolled). Default **`light`**. |
57
+ | `onThemeVariantChange` | Called when the user toggles light/dark from the settings toolbar; use with **`themeVariant`** for controlled mode or alone to observe toggles in uncontrolled mode. |
58
+
59
+ ### Shell vs chart theme
60
+
61
+ - **`themeVariant` / `defaultThemeVariant` / `onThemeVariantChange`** drive **`GlobalStyle`** (page background), settings-modal chrome, and related shell UI — not the plot alone.
62
+ - Plot colors still come from **`chartOptions`** (`base.theme`, `base.style`, …). Keep them **consistent** with the shell (e.g. light shell + `base.theme: 'light'`) so axes, grid, and watermarks stay readable.
63
+ - For the **Prime** renderer (`base.engine: 'prime'`), use **`getTickUpPrimeThemePatch('light' | 'dark')`** or **`createTickUpPrimeEngine(theme)`** with **`ref.setEngine`** so the merged patch matches your host theme. **`TickUpPrime`** alone applies the **dark** Prime plot; see [Prime engine & Pro roadmap](https://github.com/BARDAMRI/tickup-prime/blob/main/documentation/15-prime-engine-and-pro-roadmap.md).
64
+
65
+ ## `ChartOptions` structure (high level)
66
+
67
+ ```ts
68
+ ChartOptions = {
69
+ base: {
70
+ engine?, // 'standard' | 'prime' — canvas profile; prime + base.theme 'light' uses light Prime palette & toolbars (see doc 15)
71
+ chartType, // Candlestick | Line | Area | Bar
72
+ theme,
73
+ showOverlayLine,
74
+ showHistogram,
75
+ showCrosshair, // hover cross lines
76
+ showCrosshairValues, // time/price labels on crosshair
77
+ showCandleTooltip, // OHLC hover panel
78
+ style: { candles, line, area, bar, histogram, grid, overlay, axes, drawings, showGrid, backgroundColor },
79
+ overlays?, overlayKinds?,
80
+ },
81
+ axes: { yAxisPosition, currency, numberOfYTicks },
82
+ };
83
+ ```
84
+
85
+ ### Interaction flags (`base`)
86
+
87
+ - **`showCrosshair`** — Vertical + horizontal guide lines in default navigation mode.
88
+ - **`showCrosshairValues`** — Labels for cursor time (along bottom) and price (along Y-axis side). Requires crosshair enabled.
89
+ - **`showCandleTooltip`** — Corner panel with date, O/H/L/C, change, volume.
90
+
91
+ These can be toggled from the **Settings** modal (Chart Style → Hover) when using the full shell.
92
+
93
+ ### Axes & formatting
94
+
95
+ Under `base.style.axes`: locale, language, decimals, currency, date format, timezone, **trading sessions**, **holidays**, exchange, notation, tick size, conversion/display currency fields, etc. See [i18n & axes](./13-internationalization-and-axes.md).
96
+
97
+ ### Overlays / indicators
98
+
99
+ - **`base.showOverlayLine`** — Master switch for drawing indicator lines on the plot.
100
+ - **`base.overlays`** — `OverlayWithCalc[]` (recommended for explicit periods).
101
+ - **`base.overlayKinds`** — Shorthand list of kinds with library default parameters.
102
+
103
+ See [Overlays & indicators](./12-overlays-and-indicators.md).
104
+
105
+ ### Drawings default style
106
+
107
+ Under `base.style.drawings`: line color, width, line style, fill, and **selected** state styling.
108
+
109
+ See also existing reference: [`docs/Documentation/ChartStyleOptions.md`](../docs/Documentation/ChartStyleOptions.md) if present for extra detail; defaults live in `src/components/DefaultData.ts`.
@@ -0,0 +1,117 @@
1
+ # Imperative API (ref handle)
2
+
3
+ Obtain a handle with `useRef<TickUpHostHandle>()` (or `TickUpHostHandle`) and attach `ref` to `TickUpCommand`, `TickUpHost`, etc.
4
+
5
+ ## Drawings
6
+
7
+ | Method | Description |
8
+ |--------|-------------|
9
+ | `addShape(shape)` | Add from `DrawingSpec` or a shape instance (`DrawingInput`). |
10
+ | `updateShape(shapeId, newShape)` | Replace with full spec/instance or apply a `DrawingPatch` (see `isDrawingPatch`). |
11
+ | `patchShape(shapeId, patch)` | `DrawingPatch` only: style, points, symbol/size for custom symbols. |
12
+ | `deleteShape(shapeId)` | Remove by id. |
13
+ | `deleteSelectedDrawing()` | Removes the currently selected shape from the stage. |
14
+ | `updateSelectedShape(patch)` | Update properties (color, points, etc.) of the currently selected shape. |
15
+ | `setDrawingsFromSpecs(specs)` | Replace stack from `DrawingSpec[]`. |
16
+
17
+ Helpers exported from the package: `drawingFromSpec`, `applyDrawingPatch`, `isDrawingPatch`.
18
+
19
+ ## Intervals (series)
20
+
21
+ | Method | Description |
22
+ |--------|-------------|
23
+ | `addInterval(interval)` | Append a bar; series is kept sorted by `t`. |
24
+ | `updateInterval(index, interval)` | Replace bar at **0-based index** in the current sorted series. |
25
+ | `deleteInterval(index)` | Remove bar at **0-based index**. |
26
+ | `applyLiveData(updates, placement)` | Preferred for streaming and time-keyed upserts; see [Data & live updates](./07-data-and-live-updates.md). |
27
+
28
+ Resolve an index with `getViewInfo()?.intervals.findIndex(...)`. For time-based edits, prefer **`mergeByTime`** in `applyLiveData`.
29
+
30
+ ## View & canvas
31
+
32
+ | Method | Description |
33
+ |--------|-------------|
34
+ | `fitVisibleRangeToData()` | Fit visible time range to loaded data. |
35
+ | `nudgeVisibleTimeRangeToLatest(options?)` | If the last bar is past the right edge, pans the window by the minimum amount so it stays visible (keeps the same time span when possible). Optional `trailingPaddingSec`. No-op if the latest bar is already in view — useful for live streams without calling `fitVisibleRangeToData` every tick. |
36
+ | `getMainCanvasElement()` | Main OHLC `HTMLCanvasElement` (snapshots). |
37
+ | `getCanvasSize()` | `{ width, height, dpr }` (backing store pixels + DPR). |
38
+ | `getVisibleRanges()` | **`VisibleViewRanges`**: current **time** window (`time.start` / `time.end` in **unix seconds**, `time.startIndex` / `time.endIndex` into the sorted series) and **price** band (`price.min`, `price.max`, `price.range`) used for Y-axis scaling. Same values as `getViewInfo().visibleRange` / `.visiblePriceRange`. On **`TickUpHost`** / product refs, returns **`null`** until the inner stage is mounted — use `?.`. Type **`VisibleViewRanges`** is exported from **`tickup`** / **`tickup/full`**. |
39
+ | `clearCanvas()` | Clear off-screen buffers **and** clear the drawings list (shapes removed). |
40
+ | `redrawCanvas()` | Re-run the draw pipeline with current state (no data reload). |
41
+ | `reloadCanvas()` | Stage **reload** hook (rebinds view to current intervals / internal reload path). |
42
+ | `setEngine(engine)` | Merge a **`TickUpChartEngine`** patch into live **`chartOptions`**. Use **`TickUpPrime`** (dark Prime plot), **`createTickUpPrimeEngine('light' \| 'dark')`** (Prime plot aligned to host theme), **`TickUpStandardEngine`**, or a custom **`{ id, getChartOptionsPatch }`**. Imports: **`tickup`** or **`tickup/full`**. Prefer **`getTickUpPrimeThemePatch`** in **`chartOptions`** when applying Prime so props and **`setEngine`** stay in sync — see [Prime engine & Pro roadmap](https://github.com/BARDAMRI/tickup-prime/blob/main/documentation/15-prime-engine-and-pro-roadmap.md). |
43
+ | `setInteractionMode(mode)` | Forwarded to the stage: same drawing modes as the package toolbar (`Mode` enum from **`tickup/full`**). |
44
+ | `deleteSelectedDrawing()` | Removes the currently selected shape on the stage (no-op if nothing selected). |
45
+ | `selectShape(id)` | Programmatically select a drawing by its ID. |
46
+ | `unselectShape()` | Clear the current selection. |
47
+ | `updateSelectedShape(patch)` | Modify the active selection properties. |
48
+
49
+ ## Introspection
50
+
51
+ | Method | Description |
52
+ |--------|-------------|
53
+ | `getViewInfo()` | Intervals, drawings instances, visible time/price ranges, canvas size. On **`TickUpHost` / product refs**, this may be **`null`** until the inner stage is mounted — use optional chaining (`?.`) in `useEffect` or after layout. Prefer **`getVisibleRanges()`** when you only need the visible time/price snapshot (no intervals or drawings). |
54
+ | `getDrawings(query?)` | `DrawingSnapshot[]` with optional `DrawingQuery` filter. |
55
+ | `getDrawingById(id)` | Single snapshot or null. |
56
+ | `getSelectedDrawing()` | Get the snapshot of the currently selected drawing. |
57
+ | `getSelectedDrawingId()` | Get the unique ID of the selected drawing. |
58
+ | `getDrawingInstances(query?)` | Live `IDrawingShape[]` for advanced use. |
59
+ | `getChartContext()` | `ChartContextInfo`: symbol, chart type, theme, layout metrics, data window (`data.visibleTimeStart` / `visibleTimeEnd` / indices / price fields mirror **`getVisibleRanges()`**), drawing count, selection index, tick settings. May be `null` from the shell until the stage is ready. |
60
+
61
+ ## Example: read visible ranges after zoom/pan
62
+
63
+ `time.start` / `time.end` track the plotted X domain (unix seconds). `price.min` / `price.max` include padding around the highs/lows of the bars in view.
64
+
65
+ ```tsx
66
+ import { useEffect, useRef } from 'react';
67
+ import { TickUpCommand, type TickUpHostHandle } from 'tickup/full';
68
+
69
+ const ref = useRef<TickUpHostHandle>(null);
70
+
71
+ useEffect(() => {
72
+ const t = window.setInterval(() => {
73
+ const v = ref.current?.getVisibleRanges();
74
+ if (v) {
75
+ console.log('visible unix sec', v.time.start, v.time.end, 'bars', v.time.startIndex, v.time.endIndex);
76
+ console.log('visible price', v.price.min, v.price.max);
77
+ }
78
+ }, 1000);
79
+ return () => clearInterval(t);
80
+ }, []);
81
+ ```
82
+
83
+ ## Example: add and patch a line
84
+
85
+ ```tsx
86
+ import { ShapeType, type TickUpHostHandle } from 'tickup/full';
87
+
88
+ ref.current?.addShape({
89
+ type: ShapeType.Line,
90
+ points: [
91
+ { time: t0, price: p0 },
92
+ { time: t1, price: p1 },
93
+ ],
94
+ style: { lineColor: '#ff00aa', lineWidth: 2 },
95
+ });
96
+
97
+ ref.current?.patchShape('some-id', {
98
+ style: { lineWidth: 3 },
99
+ });
100
+ ```
101
+
102
+ After `addShape`, read the new id via `getDrawings()` (last / highest `zIndex`) or pass an explicit `id` in `DrawingSpec`.
103
+
104
+ ## Example: programmatic selection and update
105
+
106
+ ```tsx
107
+ // 1. Select a specific shape
108
+ chartRef.current?.selectShape("trend-line-1");
109
+
110
+ // 2. Modify whichever shape is currently selected (convenience)
111
+ chartRef.current?.updateSelectedShape({
112
+ style: { lineColor: "#00ff00" }
113
+ });
114
+
115
+ // 3. Clear focus
116
+ chartRef.current?.unselectShape();
117
+ ```
@@ -0,0 +1,62 @@
1
+ # Data & live updates
2
+
3
+ ## `Interval` shape
4
+
5
+ ```ts
6
+ interface Interval {
7
+ t: number; // unix seconds
8
+ o: number;
9
+ c: number;
10
+ l: number;
11
+ h: number;
12
+ v?: number;
13
+ }
14
+ ```
15
+
16
+ Times are **seconds**, not milliseconds.
17
+
18
+ ## React prop: `intervalsArray`
19
+
20
+ Supply the full series from parent state. When the array reference or backing data changes, the chart updates.
21
+
22
+ For high-frequency streaming, prefer **`applyLiveData`** on the ref to avoid reallocating huge arrays on every tick.
23
+
24
+ ## `applyLiveData(updates, placement)`
25
+
26
+ - **updates** — Single `Interval` or `Interval[]`.
27
+ - **placement** — `LiveDataPlacement`:
28
+
29
+ | Value | Behavior (conceptual) |
30
+ |-------|------------------------|
31
+ | `replace` | Replace series with normalized incoming set. Fails `ok` if incoming is empty after validation. |
32
+ | `append` | Append only bars with `t` ≥ last bar’s `t`; same `t` replaces the last bar; earlier times produce **warnings** and are skipped. |
33
+ | `prepend` | Prepend only bars with `t` ≤ first bar’s `t`; same `t` replaces the first bar; later times produce **warnings** and are skipped. |
34
+ | `mergeByTime` | Concatenate, sort by `t`, then **dedupe by time** (last row wins per timestamp). |
35
+
36
+ **Existing** series is normalized on merge; invalid base rows add to `errors`. Incoming rows go through **`normalizeIntervals`** (OHLC clamping, bad volume dropped, low/high swap notes in `warnings`).
37
+
38
+ Returns **`LiveDataApplyResult`**: `{ ok, intervals, errors, warnings }`. Always check `ok` and surface `errors` in production; inspect `warnings` for skipped bars or clamping.
39
+
40
+ ## Normalization utilities (exported)
41
+
42
+ From `tickup`:
43
+
44
+ - **`normalizeInterval`** — Validate/clamp one partial row; returns `{ value, notes }`.
45
+ - **`normalizeIntervals`** — Batch version; `errors` / `warnings` arrays.
46
+ - **`dedupeByTimePreferLast`** — Collapse duplicate `t`.
47
+ - **`applyLiveDataMerge`** — Lower-level merge helper used by the stage.
48
+
49
+ Use these server-side or before calling `applyLiveData` if you need consistent cleaning.
50
+
51
+ `onRefreshRequest` fires when the user chooses Refresh. Reload your feed, set new `intervalsArray`, or call `reloadCanvas` / `fitVisibleRangeToData` as needed.
52
+
53
+ ## Timeframe / Interval changes
54
+
55
+ While `intervalsArray` provides the chart with data, the user often initiates a change in the required data set by picking a new interval (e.g. from 1m to 1h).
56
+
57
+ Use **`onIntervalSearch(tf)`** on the `TickUpHost` to intercept these changes. This is the ideal place to swap your data source or fetch a new historical block for the new timeframe. See [Toolbar & Interactions](./10-toolbar-and-interactions.md) for details on the search and revert flow.
58
+
59
+ ## Pitfalls
60
+
61
+ - Do not pass a **new literal** `chartOptions={{}}` every render without `useMemo`; see [Props & chart options](./05-props-and-chart-options.md).
62
+ - Ensure `t` is monotonic where your feed requires it; merge modes handle ordering differently.