@@ -164,6 +164,11 @@ const ChartUPlot = forwardRef<any, UPlotProps>(
164164 height : containerHeight ,
165165 } ) ;
166166 } else {
167+ if ( ! webref ) {
168+ console . error ( 'WebView reference is not set' ) ;
169+ return ;
170+ }
171+
167172 webref ?. injectJavaScript ( `
168173 if (window._chart) {
169174 window._chart.setSize(${ JSON . stringify ( containerWidth ) } , ${ JSON . stringify ( containerHeight ) } );
@@ -198,8 +203,14 @@ const ChartUPlot = forwardRef<any, UPlotProps>(
198203 if ( isWeb ) {
199204 uplotInstance . current ?. setData ( newData ) ;
200205 } else {
206+ if ( ! webref ) {
207+ console . error ( 'WebView reference is not set' ) ;
208+ return ;
209+ }
210+
201211 webref ?. injectJavaScript ( `
202212 if (window._chart) {
213+ console.debug('Setting new data for uPlot chart');
203214 window._data = ${ JSON . stringify ( newData ) } ;
204215 window._chart.setData(window._data);
205216 } else {
@@ -221,6 +232,11 @@ const ChartUPlot = forwardRef<any, UPlotProps>(
221232
222233 uplotInstance . current ?. setData ( dataRef . current ) ;
223234 } else {
235+ if ( ! webref ) {
236+ console . error ( 'WebView reference is not set' ) ;
237+ return ;
238+ }
239+
224240 webref ?. injectJavaScript ( `
225241 var item = ${ JSON . stringify ( item ) } ;
226242
@@ -235,6 +251,7 @@ const ChartUPlot = forwardRef<any, UPlotProps>(
235251 window._data[i].push(item[i]);
236252 }
237253 if (window._chart) {
254+ console.debug('Pushing new data to uPlot chart');
238255 window._chart.setData(window._data);
239256 } else {
240257 console.error('Chart not initialized');
@@ -249,6 +266,11 @@ const ChartUPlot = forwardRef<any, UPlotProps>(
249266 if ( isWeb ) {
250267 uplotInstance . current ?. setScale ( axis , options ) ;
251268 } else {
269+ if ( ! webref ) {
270+ console . error ( 'WebView reference is not set' ) ;
271+ return ;
272+ }
273+
252274 webref ?. injectJavaScript ( `
253275 if (window._chart) {
254276 window._chart.setScale(${ JSON . stringify ( axis ) } , ${ JSON . stringify ( options ) } );true;
0 commit comments