aliencharts 0.1.1 → 0.1.2

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 CHANGED
@@ -64,6 +64,43 @@ export default function Dashboard() {
64
64
 
65
65
  For a fuller example, including live appending and theming — see [`examples/DemoPage.jsx`](./examples/DemoPage.jsx).
66
66
 
67
+ ### Drawings
68
+
69
+ Drawings are controlled by your app. Keep the drawing array and active tool in state, then pass that state into `ChartGrid`:
70
+
71
+ ```jsx
72
+ import { useCallback, useState } from "react";
73
+ import { ChartGrid } from "aliencharts";
74
+
75
+ export default function Dashboard({ charts }) {
76
+ const [drawings, setDrawings] = useState([]);
77
+ const [activeDrawingTool, setActiveDrawingTool] = useState(null);
78
+ const [selectedDrawingId, setSelectedDrawingId] = useState(null);
79
+
80
+ const createDrawingId = useCallback(
81
+ ({ chartId, type }) => `${chartId}:${type}:${crypto.randomUUID()}`,
82
+ [],
83
+ );
84
+
85
+ return (
86
+ <ChartGrid
87
+ charts={charts}
88
+ drawings={drawings}
89
+ onDrawingsChange={setDrawings}
90
+ activeDrawingTool={activeDrawingTool}
91
+ onActiveDrawingToolChange={setActiveDrawingTool}
92
+ selectedDrawingId={selectedDrawingId}
93
+ onSelectedDrawingIdChange={setSelectedDrawingId}
94
+ createDrawingId={createDrawingId}
95
+ />
96
+ );
97
+ }
98
+ ```
99
+
100
+ Supported drawing tools are `"trendline"`, `"hline"`, `"vline"`, and `"pin"`. Since drawings live outside the component, you can persist them however you want, such as local storage, a database, or app state.
101
+
102
+ Set `disableDrawings` when you want a read-only chart toolbar without drawing or moving-average tools.
103
+
67
104
  ## API
68
105
 
69
106
  ### `createSeries(options)`
@@ -97,6 +134,15 @@ Renders a responsive grid of charts. Commonly used props:
97
134
  | `xAxisLabel` | `string` | `"STEP"` | Label shown on the x-axis. |
98
135
  | `backgroundColor` | `string` | — | Chart background color. |
99
136
  | `antialiasLines` | `boolean` | `false` | Enable line antialiasing. |
137
+ | `drawings` | `Drawing[]` | `[]` | Controlled drawing objects. |
138
+ | `onDrawingsChange` | `(drawings) => void` | — | Called when drawings are created, edited, deleted, or styled. |
139
+ | `activeDrawingTool` | `"trendline" \| "hline" \| "vline" \| "pin" \| null` | `null` | Controlled active drawing tool. |
140
+ | `onActiveDrawingToolChange` | `(tool) => void` | — | Called when the toolbar or hotkeys change the active drawing tool. |
141
+ | `selectedDrawingId` | `string \| null` | `null` | Controlled selected drawing id. |
142
+ | `onSelectedDrawingIdChange` | `(id) => void` | — | Called when a drawing is selected or deselected. |
143
+ | `createDrawingId` | `({ chartId, type }) => string` | — | Optional id factory for new drawings. |
144
+ | `disableDrawings` | `boolean` | `false` | Hide and disable drawing and moving-average tools. |
145
+ | `onChartContextMenu` | `({ chart, event, point }) => void` | — | Called on chart right-click. Use it to render your own context menu. |
100
146
 
101
147
  ## License
102
148