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 @@