Skip to content

Commit 9fef570

Browse files
Merge pull request #749 from plotly/jlab
Fixes for jupyterlab-chart-editor
2 parents f53f127 + f12030d commit 9fef570

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/PlotlyEditor.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ class PlotlyEditor extends Component {
99
super();
1010
this.state = {graphDiv: {}};
1111
this.PlotComponent = createPlotComponent(props.plotly);
12+
this.handleDirectUpdate = this.handleDirectUpdate.bind(this);
13+
}
14+
15+
handleDirectUpdate(fig, graphDiv) {
16+
this.setState({graphDiv});
17+
if (this.props.onDirectUpdate) {
18+
this.props.onDirectUpdate(graphDiv.data, graphDiv.layout, graphDiv._transitionData._frames);
19+
}
1220
}
1321

1422
render() {
@@ -44,8 +52,8 @@ class PlotlyEditor extends Component {
4452
config={this.props.config}
4553
useResizeHandler={this.props.useResizeHandler}
4654
debug={this.props.debug}
47-
onInitialized={(fig, graphDiv) => this.setState({graphDiv})}
48-
onUpdate={(fig, graphDiv) => this.setState({graphDiv})}
55+
onInitialized={this.handleDirectUpdate}
56+
onUpdate={this.handleDirectUpdate}
4957
style={{width: '100%', height: '100%'}}
5058
divId={this.props.divId}
5159
/>
@@ -64,6 +72,7 @@ PlotlyEditor.propTypes = {
6472
dataSources: PropTypes.object,
6573
frames: PropTypes.array,
6674
onUpdate: PropTypes.func,
75+
onDirectUpdate: PropTypes.func,
6776
plotly: PropTypes.object,
6877
useResizeHandler: PropTypes.bool,
6978
debug: PropTypes.bool,

src/components/containers/ImageAccordion.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ImageAccordion extends Component {
1717
const content =
1818
images.length &&
1919
images.map((img, i) => (
20-
<ImageFold key={i} imageIndex={i} name={img.text} canDelete={canAdd}>
20+
<ImageFold key={i} imageIndex={i} name={`${_('Image')} ${i + 1}`} canDelete={canAdd}>
2121
{children}
2222
</ImageFold>
2323
));
@@ -34,7 +34,6 @@ class ImageAccordion extends Component {
3434

3535
const key = `images[${imageIndex}]`;
3636
const value = {
37-
text: `${_('Image')} ${imageIndex + 1}`,
3837
sizex: 0.1,
3938
sizey: 0.1,
4039
x: 0.5,

src/components/containers/ShapeAccordion.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ShapeAccordion extends Component {
1818
const content =
1919
shapes.length &&
2020
shapes.map((shp, i) => (
21-
<ShapeFold key={i} shapeIndex={i} name={shp.text} canDelete={canAdd}>
21+
<ShapeFold key={i} shapeIndex={i} name={`${_('Shape')} ${i + 1}`} canDelete={canAdd}>
2222
{children}
2323
</ShapeFold>
2424
));
@@ -35,7 +35,6 @@ class ShapeAccordion extends Component {
3535

3636
const key = `shapes[${shapeIndex}]`;
3737
const value = {
38-
text: `${_('Shape')} ${shapeIndex}`,
3938
line: {color: COLORS.charcoal},
4039
fillcolor: COLORS.middleGray,
4140
opacity: 0.3,

0 commit comments

Comments
 (0)