dash-core-components 2.6.1 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -126,7 +126,7 @@ DashMarkdown.propTypes = {
126
126
  link_target: _propTypes.default.string,
127
127
 
128
128
  /**
129
- * A markdown string (or array of strings) that adhreres to the CommonMark spec
129
+ * A markdown string (or array of strings) that adheres to the CommonMark spec
130
130
  */
131
131
  children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
132
132
 
@@ -193,32 +193,34 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
193
193
  var _super = _createSuper(PlotlyGraph);
194
194
 
195
195
  function PlotlyGraph(props) {
196
- var _this;
196
+ var _this2;
197
197
 
198
198
  _classCallCheck(this, PlotlyGraph);
199
199
 
200
- _this = _super.call(this, props);
201
- _this.gd = /*#__PURE__*/_react.default.createRef();
202
- _this._hasPlotted = false;
203
- _this._prevGd = null;
204
- _this.bindEvents = _this.bindEvents.bind(_assertThisInitialized(_this));
205
- _this.getConfig = _this.getConfig.bind(_assertThisInitialized(_this));
206
- _this.getConfigOverride = _this.getConfigOverride.bind(_assertThisInitialized(_this));
207
- _this.getLayout = _this.getLayout.bind(_assertThisInitialized(_this));
208
- _this.getLayoutOverride = _this.getLayoutOverride.bind(_assertThisInitialized(_this));
209
- _this.graphResize = _this.graphResize.bind(_assertThisInitialized(_this));
210
- _this.isResponsive = _this.isResponsive.bind(_assertThisInitialized(_this));
211
- _this.state = {
200
+ _this2 = _super.call(this, props);
201
+ _this2.gd = /*#__PURE__*/_react.default.createRef();
202
+ _this2._hasPlotted = false;
203
+ _this2._prevGd = null;
204
+ _this2._queue = Promise.resolve();
205
+ _this2.bindEvents = _this2.bindEvents.bind(_assertThisInitialized(_this2));
206
+ _this2.getConfig = _this2.getConfig.bind(_assertThisInitialized(_this2));
207
+ _this2.getConfigOverride = _this2.getConfigOverride.bind(_assertThisInitialized(_this2));
208
+ _this2.getLayout = _this2.getLayout.bind(_assertThisInitialized(_this2));
209
+ _this2.getLayoutOverride = _this2.getLayoutOverride.bind(_assertThisInitialized(_this2));
210
+ _this2.graphResize = _this2.graphResize.bind(_assertThisInitialized(_this2));
211
+ _this2.isResponsive = _this2.isResponsive.bind(_assertThisInitialized(_this2));
212
+ _this2.amendTraces = _this2.amendTraces.bind(_assertThisInitialized(_this2));
213
+ _this2.state = {
212
214
  override: {},
213
215
  originals: {}
214
216
  };
215
- return _this;
217
+ return _this2;
216
218
  }
217
219
 
218
220
  _createClass(PlotlyGraph, [{
219
221
  key: "plot",
220
222
  value: function plot(props) {
221
- var _this2 = this;
223
+ var _this3 = this;
222
224
 
223
225
  var figure = props.figure,
224
226
  config = props.config;
@@ -255,10 +257,10 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
255
257
 
256
258
  gd.classList.add('dash-graph--pending');
257
259
  return (0, _mathjax.default)(mathjax).then(function () {
258
- var gd = _this2.gd.current;
260
+ var gd = _this3.gd.current;
259
261
  return gd && Plotly.react(gd, figureClone);
260
262
  }).then(function () {
261
- var gd = _this2.gd.current; // double-check gd hasn't been unmounted
263
+ var gd = _this3.gd.current; // double-check gd hasn't been unmounted
262
264
 
263
265
  if (!gd) {
264
266
  return;
@@ -266,67 +268,100 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
266
268
 
267
269
  gd.classList.remove('dash-graph--pending'); // in case we've made a new DOM element, transfer events
268
270
 
269
- if (_this2._hasPlotted && gd !== _this2._prevGd) {
270
- if (_this2._prevGd && _this2._prevGd.removeAllListeners) {
271
- _this2._prevGd.removeAllListeners();
271
+ if (_this3._hasPlotted && gd !== _this3._prevGd) {
272
+ if (_this3._prevGd && _this3._prevGd.removeAllListeners) {
273
+ _this3._prevGd.removeAllListeners();
272
274
 
273
- Plotly.purge(_this2._prevGd);
275
+ Plotly.purge(_this3._prevGd);
274
276
  }
275
277
 
276
- _this2._hasPlotted = false;
278
+ _this3._hasPlotted = false;
277
279
  }
278
280
 
279
- if (!_this2._hasPlotted) {
280
- _this2.bindEvents();
281
+ if (!_this3._hasPlotted) {
282
+ _this3.bindEvents();
281
283
 
282
- _this2.graphResize(true);
284
+ _this3.graphResize(true);
283
285
 
284
- _this2._hasPlotted = true;
285
- _this2._prevGd = gd;
286
+ _this3._hasPlotted = true;
287
+ _this3._prevGd = gd;
286
288
  }
287
289
  });
288
290
  }
289
291
  }, {
290
- key: "mergeTraces",
291
- value: function mergeTraces(props, dataKey, plotlyFnKey) {
292
- var _this3 = this;
292
+ key: "amendTraces",
293
+ value: function amendTraces(p, oldProps, newProps) {
294
+ var oldPrepend = oldProps.prependData,
295
+ oldExtend = oldProps.extendData;
296
+ var newPrepend = newProps.prependData,
297
+ newExtend = newProps.extendData;
293
298
 
294
- var clearState = props.clearState;
295
- var dataArray = props[dataKey];
296
- var p = Promise.resolve();
297
- dataArray.forEach(function (data) {
298
- var updateData, traceIndices, maxPoints;
299
+ var _this = this;
299
300
 
300
- if (Array.isArray(data) && _typeof(data[0]) === 'object') {
301
- var _data = _slicedToArray(data, 3);
301
+ function mergeTraces(props, dataKey, plotlyFnKey) {
302
+ var clearState = props.clearState;
303
+ var dataArray = props[dataKey];
302
304
 
303
- updateData = _data[0];
304
- traceIndices = _data[1];
305
- maxPoints = _data[2];
306
- } else {
307
- updateData = data;
308
- }
305
+ var _p = Promise.resolve();
309
306
 
310
- if (!traceIndices) {
311
- function getFirstProp(data) {
312
- return data[Object.keys(data)[0]];
307
+ dataArray.forEach(function (data) {
308
+ var updateData, traceIndices, maxPoints;
309
+
310
+ if (Array.isArray(data) && _typeof(data[0]) === 'object') {
311
+ var _data = _slicedToArray(data, 3);
312
+
313
+ updateData = _data[0];
314
+ traceIndices = _data[1];
315
+ maxPoints = _data[2];
316
+ } else {
317
+ updateData = data;
313
318
  }
314
319
 
315
- function generateIndices(data) {
316
- return Array.from(Array(getFirstProp(data).length).keys());
320
+ if (!traceIndices) {
321
+ function getFirstProp(data) {
322
+ return data[Object.keys(data)[0]];
323
+ }
324
+
325
+ function generateIndices(data) {
326
+ return Array.from(Array(getFirstProp(data).length).keys());
327
+ }
328
+
329
+ traceIndices = generateIndices(updateData);
317
330
  }
318
331
 
319
- traceIndices = generateIndices(updateData);
320
- }
332
+ _p = _p.then(function () {
333
+ var gd = _this.gd.current;
334
+ return gd && Plotly[plotlyFnKey](gd, updateData, traceIndices, maxPoints);
335
+ });
336
+ });
337
+ return _p.then(function () {
338
+ return clearState(dataKey);
339
+ });
340
+ }
321
341
 
342
+ var modified = false;
343
+
344
+ if (newPrepend !== null && newPrepend !== void 0 && newPrepend.length && oldPrepend !== newPrepend) {
345
+ modified = true;
322
346
  p = p.then(function () {
323
- var gd = _this3.gd.current;
324
- return gd && Plotly[plotlyFnKey](gd, updateData, traceIndices, maxPoints);
347
+ return mergeTraces(newProps, 'prependData', 'prependTraces');
325
348
  });
326
- });
327
- p.then(function () {
328
- return clearState(dataKey);
329
- });
349
+ }
350
+
351
+ if (newExtend !== null && newExtend !== void 0 && newExtend.length && oldExtend !== newExtend) {
352
+ modified = true;
353
+ p = p.then(function () {
354
+ return mergeTraces(newProps, 'extendData', 'extendTraces');
355
+ });
356
+ }
357
+
358
+ if (modified) {
359
+ p = p.then(function () {
360
+ return newProps._dashprivate_onFigureModified(newProps.figure);
361
+ });
362
+ }
363
+
364
+ return p;
330
365
  }
331
366
  }, {
332
367
  key: "getConfig",
@@ -512,29 +547,8 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
512
547
  }, {
513
548
  key: "componentDidMount",
514
549
  value: function componentDidMount() {
515
- var _this4 = this,
516
- _this$props$prependDa,
517
- _this$props$extendDat;
518
-
519
550
  var p = this.plot(this.props);
520
-
521
- if (this.props.prependData) {
522
- p = p.then(function () {
523
- return _this4.mergeTraces(_this4.props, 'prependData', 'prependTraces');
524
- });
525
- }
526
-
527
- if (this.props.extendData) {
528
- p = p.then(function () {
529
- return _this4.mergeTraces(_this4.props, 'extendData', 'extendTraces');
530
- });
531
- }
532
-
533
- if ((_this$props$prependDa = this.props.prependData) !== null && _this$props$prependDa !== void 0 && _this$props$prependDa.length || (_this$props$extendDat = this.props.extendData) !== null && _this$props$extendDat !== void 0 && _this$props$extendDat.length) {
534
- p.then(function () {
535
- return _this4.props._dashprivate_onFigureModified(_this4.props.figure);
536
- });
537
- }
551
+ this._queue = this.amendTraces(p, {}, this.props);
538
552
  }
539
553
  }, {
540
554
  key: "componentWillUnmount",
@@ -557,9 +571,7 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
557
571
  }, {
558
572
  key: "UNSAFE_componentWillReceiveProps",
559
573
  value: function UNSAFE_componentWillReceiveProps(nextProps) {
560
- var _this5 = this,
561
- _this$props$prependDa2,
562
- _this$props$extendDat2;
574
+ var _this4 = this;
563
575
 
564
576
  var idChanged = this.props.id !== nextProps.id;
565
577
 
@@ -571,35 +583,25 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
571
583
  return;
572
584
  }
573
585
 
574
- var p = Promise.resolve();
586
+ var p = this._queue;
575
587
 
576
588
  if (this.props.mathjax !== nextProps.mathjax || this.props.figure !== nextProps.figure || this.props._dashprivate_transformConfig !== nextProps._dashprivate_transformConfig || this.props._dashprivate_transformFigure !== nextProps._dashprivate_transformFigure) {
577
- p = this.plot(nextProps);
578
- }
579
-
580
- if (this.props.prependData !== nextProps.prependData) {
581
589
  p = p.then(function () {
582
- return _this5.mergeTraces(nextProps, 'prependData', 'prependTraces');
590
+ return _this4.plot(nextProps);
583
591
  });
584
592
  }
585
593
 
586
- if (this.props.extendData !== nextProps.extendData) {
587
- p = p.then(function () {
588
- return _this5.mergeTraces(nextProps, 'extendData', 'extendTraces');
589
- });
590
- }
591
-
592
- if ((_this$props$prependDa2 = this.props.prependData) !== null && _this$props$prependDa2 !== void 0 && _this$props$prependDa2.length || (_this$props$extendDat2 = this.props.extendData) !== null && _this$props$extendDat2 !== void 0 && _this$props$extendDat2.length) {
593
- p.then(function () {
594
- return _this5.props._dashprivate_onFigureModified(_this5.props.figure);
595
- });
596
- }
594
+ this._queue = this.amendTraces(p, this.props, nextProps);
597
595
  }
598
596
  }, {
599
597
  key: "componentDidUpdate",
600
598
  value: function componentDidUpdate(prevProps) {
599
+ var _this5 = this;
600
+
601
601
  if (prevProps.id !== this.props.id || prevProps.mathjax !== this.props.mathjax) {
602
- this.plot(this.props);
602
+ this._queue = this._queue.then(function () {
603
+ return _this5.plot(_this5.props);
604
+ });
603
605
  }
604
606
  }
605
607
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dash-core-components",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "description": "Core component suite for Dash",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "private::lint.prettier": "prettier --config .prettierrc src/**/*.js --list-different",
22
22
  "prepublishOnly": "rm -rf lib && babel src --out-dir lib --copy-files --config-file ./.lib.babelrc && rm -rf lib/jl/ lib/*.jl",
23
23
  "test": "run-s -c lint test:intg test:pyimport",
24
- "test:intg": "pytest --nopercyfinalize --headless tests/integration --reruns 3",
24
+ "test:intg": "pytest --nopercyfinalize --headless tests/integration ",
25
25
  "test:pyimport": "python -m unittest tests/test_dash_import.py",
26
26
  "prebuild:js": "cp node_modules/plotly.js-dist-min/plotly.min.js dash_core_components_base/plotly.min.js",
27
27
  "build:js": "webpack --mode production",
@@ -103,5 +103,5 @@
103
103
  "browserslist": [
104
104
  "defaults"
105
105
  ],
106
- "gitHead": "d0d774925cb35d999b767c645cca99859455f0f9"
106
+ "gitHead": "1f18e39b6c166c5ddc6356291566a3519624de38"
107
107
  }