@@ -53,10 +53,21 @@ actual fun PlotPanelRaw(
5353 val processedPlotSpec = remember(rawSpec.hashCode()) {
5454 processRawSpecs(rawSpec, frontendOnly = false )
5555 }
56- var errorMessage: String? by remember { mutableStateOf(null ) }
5756
58- if (PlotConfig .isFailure(processedPlotSpec)) {
59- errorMessage = PlotConfig .getErrorMessage(processedPlotSpec)
57+ var errorMessage: String? by remember(processedPlotSpec) { mutableStateOf(null ) } // Reset error on spec change
58+
59+ LaunchedEffect (processedPlotSpec, sizingPolicy, computationMessagesHandler) {
60+ runCatching {
61+ if (PlotConfig .isFailure(processedPlotSpec)) {
62+ errorMessage = PlotConfig .getErrorMessage(processedPlotSpec)
63+ } else {
64+ plotCanvasFigure?.update(processedPlotSpec, sizingPolicy, computationMessagesHandler)
65+ ? : LOG .info { " Error updating plot figure - plotCanvasFigure is null" }
66+ }
67+ }.onFailure { e ->
68+ errorMessage = e.message ? : " Unknown error: ${e::class .simpleName} "
69+ LOG .error(e) { " Error updating plot figure" }
70+ }
6071 }
6172
6273 // Background
@@ -74,17 +85,6 @@ actual fun PlotPanelRaw(
7485 }
7586 }
7687
77- LaunchedEffect (processedPlotSpec, sizingPolicy, computationMessagesHandler) {
78- runCatching {
79- plotCanvasFigure?.update(processedPlotSpec, sizingPolicy, computationMessagesHandler)
80- ? : LOG .info { " Error updating plot figure - plotCanvasFigure is null" }
81- }.onFailure { e ->
82- errorMessage = e.message ? : " Unknown error: ${e::class .simpleName} "
83- LOG .error(e) { " Error updating plot figure" }
84- }
85-
86- }
87-
8888 errorMessage?.let { errMsg ->
8989 // Reset the figure to resolve the 'Registration already removed' error.
9090 // On error, the CanvasView is removed and the plotCanvasFigure changes state to 'detached',
@@ -105,7 +105,6 @@ actual fun PlotPanelRaw(
105105 modifier = finalModifier,
106106 factory = { ctx ->
107107 plotCanvasFigure = plotCanvasFigure ? : PlotCanvasFigure ()
108-
109108 CanvasView (ctx).apply {
110109 figure = plotCanvasFigure
111110 onError = { e ->
0 commit comments