Skip to content

Commit 816e0ee

Browse files
committed
add onload callback
1 parent 5465113 commit 816e0ee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/components/ChartUPlot.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ export interface UPlotProps {
189189
margin?: { title?: number; legend?: number };
190190
/** Callback for messages from the WebView */
191191
onMessage?: (event: any) => void;
192+
/** Callback when the WebView has loaded */
193+
onLoad?: (() => void) | null;
192194
/** JavaScript to be injected into the WebView */
193195
injectedJavaScript?: string;
194196
/** Additional props for the WebView */
@@ -204,6 +206,7 @@ const ChartUPlot = forwardRef<any, UPlotProps>(
204206
functions,
205207
margin = { title: MARGIN_TITLE, legend: MARGIN_LEGEND },
206208
onMessage,
209+
onLoad = null,
207210
injectedJavaScript = '',
208211
...webviewProps
209212
},
@@ -573,6 +576,10 @@ const ChartUPlot = forwardRef<any, UPlotProps>(
573576
scrollEnabled={false}
574577
onLoadEnd={(): void => {
575578
createChart(optionsFinal, data, bgColor);
579+
580+
if (onLoad) {
581+
onLoad();
582+
}
576583
}}
577584
ref={(r) => {
578585
if (r) {

0 commit comments

Comments
 (0)