Skip to content

Commit 2e9bc52

Browse files
committed
feat(chart): update data prop to accept number[][] types
1 parent dca20d3 commit 2e9bc52

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/SolidUplot.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ export type SolidUplotPlugin<T extends VoidStruct = VoidStruct> =
3939
*/
4040
export type SolidUplotOptions<T extends VoidStruct = VoidStruct> = Omit<
4141
uPlot.Options,
42-
"plugins" | "width" | "height"
42+
"plugins" | "width" | "height" | "data"
4343
> & {
4444
/** Chart width in pixels */
4545
readonly width?: number;
4646
/** Chart height in pixels */
4747
readonly height?: number;
48+
/** Chart data - accepts AlignedData or number[][] */
49+
readonly data?: uPlot.AlignedData | number[][];
4850
/** Plugin communication bus for coordinating between plugins */
4951
readonly pluginBus?: SolidUplotPluginBus<T>;
5052
/** Array of plugins to apply to the chart */
@@ -210,7 +212,7 @@ export const SolidUplot = <T extends VoidStruct = VoidStruct>(
210212
};
211213

212214
const initialSize = getInitialSize();
213-
const initialData = untrack(() => updateableOptions.data);
215+
const initialData = untrack(() => updateableOptions.data) as uPlot.AlignedData;
214216

215217
const chart = new uPlot(
216218
{
@@ -247,7 +249,7 @@ export const SolidUplot = <T extends VoidStruct = VoidStruct>(
247249
});
248250

249251
createEffect(() => {
250-
chart.setData(updateableOptions.data, updateableOptions.resetScales);
252+
chart.setData(updateableOptions.data as uPlot.AlignedData, updateableOptions.resetScales);
251253
});
252254

253255
onCleanup(() => {

0 commit comments

Comments
 (0)