Skip to content

Commit 208784d

Browse files
committed
docs: adds more jsdoc comments to exported members
1 parent 9b0bb53 commit 208784d

File tree

3 files changed

+74
-6
lines changed

3 files changed

+74
-6
lines changed

src/SolidUplot.tsx

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,66 @@ import uPlot from "uplot";
1616
import type { PluginFactory, SolidUplotPluginBus, VoidStruct } from "./createPluginBus";
1717
import { getSeriesData, type SeriesDatum } from "./utils/getSeriesData";
1818

19+
/** Placement options for children components relative to the chart */
1920
type ChildrenPlacement = "top" | "bottom";
2021

22+
/**
23+
* A SolidJS-compatible uPlot plugin that can be either a standard uPlot plugin
24+
* or a factory function that creates a plugin with access to the plugin bus
25+
*
26+
* @template T - The type of the plugin bus data structure
27+
*/
2128
export type SolidUplotPlugin<T extends VoidStruct = VoidStruct> = uPlot.Plugin | PluginFactory<T>;
2229

30+
/**
31+
* Configuration options for the SolidUplot component, extending uPlot.Options
32+
* with SolidJS-specific enhancements
33+
*
34+
* @template T - The type of the plugin bus data structure
35+
*/
2336
export type SolidUplotOptions<T extends VoidStruct = VoidStruct> = Omit<
2437
uPlot.Options,
2538
"plugins" | "width" | "height"
2639
> & {
40+
/** Chart width in pixels */
2741
readonly width?: number;
42+
/** Chart height in pixels */
2843
readonly height?: number;
44+
/** Plugin communication bus for coordinating between plugins */
2945
readonly pluginBus?: SolidUplotPluginBus<T>;
46+
/** Array of plugins to apply to the chart */
3047
readonly plugins?: SolidUplotPlugin<T>[];
3148
};
3249

50+
/**
51+
* Metadata provided to the onCreate callback when the chart is initialized
52+
*/
3353
type OnCreateMeta = {
54+
/** Array of series data extracted from the chart configuration */
3455
readonly seriesData: SeriesDatum[];
3556
};
3657

58+
/**
59+
* Props for the SolidUplot component
60+
*
61+
* @template T - The type of the plugin bus data structure
62+
*/
3763
type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> & {
38-
/** The ref of the uPlot instance */
64+
/** Ref callback to access the chart container element */
3965
readonly ref?: (el: HTMLDivElement) => void;
40-
/** Callback when uPlot instance is created */
66+
/** Callback fired when the uPlot instance is created */
4167
readonly onCreate?: (u: uPlot, meta: OnCreateMeta) => void;
42-
/** Apply scale reset on redraw triggered by updated plot data (default: `true`) */
68+
/**
69+
* Whether to reset scales when chart data is updated
70+
* @default true
71+
*/
4372
readonly resetScales?: boolean;
44-
/** The style of the uPlot instance container */
73+
/** CSS styles for the chart container (position is managed internally) */
4574
readonly style?: Omit<JSX.CSSProperties, "position">;
46-
/** The placement of the children container. Defaults to "top" */
75+
/**
76+
* Where to place children components relative to the chart
77+
* @default "top"
78+
*/
4779
readonly childrenPlacement?: ChildrenPlacement;
4880
/**
4981
* Enable automatic resizing to fit container.
@@ -58,6 +90,35 @@ type SolidUplotProps<T extends VoidStruct = VoidStruct> = SolidUplotOptions<T> &
5890
readonly autoResize?: boolean;
5991
};
6092

93+
/**
94+
* A SolidJS wrapper component for uPlot charts with enhanced features
95+
*
96+
* This component provides:
97+
* - Reactive data updates
98+
* - Plugin system with communication bus
99+
* - Automatic resizing capabilities
100+
* - Flexible children placement
101+
* - TypeScript support with generics
102+
*
103+
* @template T - The type of the plugin bus data structure for type-safe plugin communication
104+
*
105+
* @param props - Component props extending uPlot options with SolidJS enhancements
106+
* @returns JSX element containing the chart and any children components
107+
*
108+
* @example
109+
* ```tsx
110+
* <SolidUplot
111+
* data={chartData}
112+
* height={400}
113+
* autoResize
114+
* series={[
115+
* {},
116+
* { label: "Series 1", stroke: "red" }
117+
* ]}
118+
* onCreate={(chart) => console.log("Chart created:", chart)}
119+
* />
120+
* ```
121+
*/
61122
export const SolidUplot = <T extends VoidStruct = VoidStruct>(
62123
props: ParentProps<SolidUplotProps<T>>,
63124
): JSX.Element => {

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { createPluginBus, type SolidUplotPluginBus, type VoidStruct } from "./createPluginBus";
1+
export { createPluginBus } from "./createPluginBus";
22
export { SolidUplot } from "./SolidUplot";

src/plugins/legend.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import type { FocusSeriesPluginMessageBus } from "./focusSeries";
1212
*/
1313
export type LegendPlacement = "top-left" | "top-right";
1414

15+
/**
16+
* Props passed to the custom legend SolidJS component.
17+
*
18+
* The legend plugin automatically provides these props to your custom component, ensuring it always
19+
* receives the latest series data from the chart via the plugin bus system. This creates a reactive
20+
* data flow where series data changes immediately trigger legend updates with fresh data information.
21+
*/
1522
export type LegendProps = {
1623
readonly u: uPlot;
1724
readonly seriesData: SeriesDatum[];

0 commit comments

Comments
 (0)