@dschz/solid-uplot 0.1.0 → 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.
@@ -5,27 +5,59 @@ import uPlot from 'uplot';
5
5
  import { S as SeriesDatum } from '../getSeriesData-D1zBqQ9Y.js';
6
6
  import 'solid-js/store';
7
7
 
8
+ /** Placement options for children components relative to the chart */
8
9
  type ChildrenPlacement = "top" | "bottom";
10
+ /**
11
+ * A SolidJS-compatible uPlot plugin that can be either a standard uPlot plugin
12
+ * or a factory function that creates a plugin with access to the plugin bus
13
+ *
14
+ * @template T - The type of the plugin bus data structure
15
+ */
9
16
  type SolidUplotPlugin<T extends VoidStruct = VoidStruct> = uPlot.Plugin | PluginFactory<T>;
17
+ /**
18
+ * Configuration options for the SolidUplot component, extending uPlot.Options
19
+ * with SolidJS-specific enhancements
20
+ *
21
+ * @template T - The type of the plugin bus data structure
22
+ */
10
23
  type SolidUplotOptions<T extends VoidStruct = VoidStruct> = Omit<uPlot.Options, "plugins" | "width" | "height"> & {
24
+ /** Chart width in pixels */
11
25
  readonly width?: number;
26
+ /** Chart height in pixels */
12
27
  readonly height?: number;
28
+ /** Plugin communication bus for coordinating between plugins */
13
29
  readonly pluginBus?: SolidUplotPluginBus<T>;
30
+ /** Array of plugins to apply to the chart */
14
31
  readonly plugins?: SolidUplotPlugin<T>[];
15
32
  };
33
+ /**
34
+ * Metadata provided to the onCreate callback when the chart is initialized
35
+ */
16
36
  type OnCreateMeta = {
37
+ /** Array of series data extracted from the chart configuration */
17
38
  readonly seriesData: SeriesDatum[];
18
39
  };
40
+ /**
41
+ * Props for the SolidUplot component
42
+ *
43
+ * @template T - The type of the plugin bus data structure
44
+ */
19
45
  type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> & {
20
- /** The ref of the uPlot instance */
46
+ /** Ref callback to access the chart container element */
21
47
  readonly ref?: (el: HTMLDivElement) => void;
22
- /** Callback when uPlot instance is created */
48
+ /** Callback fired when the uPlot instance is created */
23
49
  readonly onCreate?: (u: uPlot, meta: OnCreateMeta) => void;
24
- /** Apply scale reset on redraw triggered by updated plot data (default: `true`) */
50
+ /**
51
+ * Whether to reset scales when chart data is updated
52
+ * @default true
53
+ */
25
54
  readonly resetScales?: boolean;
26
- /** The style of the uPlot instance container */
55
+ /** CSS styles for the chart container (position is managed internally) */
27
56
  readonly style?: Omit<JSX.CSSProperties, "position">;
28
- /** The placement of the children container. Defaults to "top" */
57
+ /**
58
+ * Where to place children components relative to the chart
59
+ * @default "top"
60
+ */
29
61
  readonly childrenPlacement?: ChildrenPlacement;
30
62
  /**
31
63
  * Enable automatic resizing to fit container.
@@ -39,6 +71,35 @@ type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> &
39
71
  */
40
72
  readonly autoResize?: boolean;
41
73
  };
74
+ /**
75
+ * A SolidJS wrapper component for uPlot charts with enhanced features
76
+ *
77
+ * This component provides:
78
+ * - Reactive data updates
79
+ * - Plugin system with communication bus
80
+ * - Automatic resizing capabilities
81
+ * - Flexible children placement
82
+ * - TypeScript support with generics
83
+ *
84
+ * @template T - The type of the plugin bus data structure for type-safe plugin communication
85
+ *
86
+ * @param props - Component props extending uPlot options with SolidJS enhancements
87
+ * @returns JSX element containing the chart and any children components
88
+ *
89
+ * @example
90
+ * ```tsx
91
+ * <SolidUplot
92
+ * data={chartData}
93
+ * height={400}
94
+ * autoResize
95
+ * series={[
96
+ * {},
97
+ * { label: "Series 1", stroke: "red" }
98
+ * ]}
99
+ * onCreate={(chart) => console.log("Chart created:", chart)}
100
+ * />
101
+ * ```
102
+ */
42
103
  declare const SolidUplot: <T extends VoidStruct = VoidStruct>(props: ParentProps<SolidUplotProps<T>>) => JSX.Element;
43
104
 
44
- export { SolidUplot, SolidUplotPluginBus, VoidStruct };
105
+ export { SolidUplot };
@@ -226,6 +226,13 @@ declare const focusSeries: (options?: FocusSeriesPluginOptions) => PluginFactory
226
226
  * Simple legend placement options - only top corners to avoid axis conflicts
227
227
  */
228
228
  type LegendPlacement = "top-left" | "top-right";
229
+ /**
230
+ * Props passed to the custom legend SolidJS component.
231
+ *
232
+ * The legend plugin automatically provides these props to your custom component, ensuring it always
233
+ * receives the latest series data from the chart via the plugin bus system. This creates a reactive
234
+ * data flow where series data changes immediately trigger legend updates with fresh data information.
235
+ */
229
236
  type LegendProps = {
230
237
  readonly u: uPlot;
231
238
  readonly seriesData: SeriesDatum[];
package/package.json CHANGED
@@ -1,10 +1,44 @@
1
1
  {
2
2
  "name": "@dschz/solid-uplot",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "SolidJS wrapper for uPlot — ultra-fast, tiny time-series & charting library",
5
5
  "type": "module",
6
6
  "author": "Daniel Sanchez <dsanc89@pm.me>",
7
7
  "license": "MIT",
8
+ "keywords": [
9
+ "analytics",
10
+ "canvas",
11
+ "chart",
12
+ "charts",
13
+ "dashboard",
14
+ "data-dashboard",
15
+ "data-visualization",
16
+ "data-viz",
17
+ "fast",
18
+ "financial-charts",
19
+ "interactive-charts",
20
+ "lightweight",
21
+ "lightweight-charts",
22
+ "metrics",
23
+ "plugin",
24
+ "plugins",
25
+ "plotting",
26
+ "real-time",
27
+ "solid",
28
+ "solid-chart",
29
+ "solid-component",
30
+ "solid-plugin",
31
+ "solid-uplot",
32
+ "solidjs",
33
+ "solidjs-wrapper",
34
+ "streaming-data",
35
+ "time-series",
36
+ "timeseries",
37
+ "typescript",
38
+ "uplot",
39
+ "uplot-solid",
40
+ "visualization"
41
+ ],
8
42
  "homepage": "https://github.com/dsnchz/solid-uplot#readme",
9
43
  "repository": {
10
44
  "type": "git",