From fdf180d340f08aa4f83b33a2460718bd496cd217 Mon Sep 17 00:00:00 2001 From: lana-k Date: Sun, 23 Mar 2025 21:09:12 +0100 Subject: [PATCH] fix plot resize --- src/lib/ReactPlotlyEditorWithPlotRef.jsx | 65 +++++++++++++++++++ .../Tabs/Tab/DataView/Chart/index.vue | 29 +++++---- 2 files changed, 81 insertions(+), 13 deletions(-) create mode 100644 src/lib/ReactPlotlyEditorWithPlotRef.jsx diff --git a/src/lib/ReactPlotlyEditorWithPlotRef.jsx b/src/lib/ReactPlotlyEditorWithPlotRef.jsx new file mode 100644 index 0000000..bf78bf0 --- /dev/null +++ b/src/lib/ReactPlotlyEditorWithPlotRef.jsx @@ -0,0 +1,65 @@ +import ReactPlotlyEditor from 'react-chart-editor' +import React, { createRef } from 'react' +import EditorControls from 'react-chart-editor/lib/EditorControls' + +/** + * This extended ReactPlotlyEditor has a reference to PlotComponent. + * The reference makes it possible to call updatePlotly method of PlotComponent. + * updatePlotly method allows smoothly resize the plot + * when resize chart editor container. + */ +export default class ReactPlotlyEditorWithPlotRef extends ReactPlotlyEditor { + constructor(props) { + super(props) + this.plotComponentRef = createRef() + } + render() { + return ( +
+ {!this.props.hideControls && ( + + {this.props.children} + + )} +
+ +
+
+ ) + } +} diff --git a/src/views/Main/Workspace/Tabs/Tab/DataView/Chart/index.vue b/src/views/Main/Workspace/Tabs/Tab/DataView/Chart/index.vue index ab677b0..d473f3a 100644 --- a/src/views/Main/Workspace/Tabs/Tab/DataView/Chart/index.vue +++ b/src/views/Main/Workspace/Tabs/Tab/DataView/Chart/index.vue @@ -1,5 +1,5 @@