dash-core-components 2.6.1 → 2.7.0
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.
- package/LICENSE +1 -1
- package/dash_core_components/async-datepicker.js +1 -1
- package/dash_core_components/async-datepicker.js.map +1 -1
- package/dash_core_components/async-dropdown.js +1 -1
- package/dash_core_components/async-dropdown.js.map +1 -1
- package/dash_core_components/async-graph.js +1 -1
- package/dash_core_components/async-graph.js.map +1 -1
- package/dash_core_components/async-highlight.js +1 -1
- package/dash_core_components/async-highlight.js.map +1 -1
- package/dash_core_components/async-markdown.js +1 -1
- package/dash_core_components/async-markdown.js.map +1 -1
- package/dash_core_components/async-mathjax.js +1 -1
- package/dash_core_components/async-plotlyjs.js +1 -1
- package/dash_core_components/async-slider.js +2 -1
- package/dash_core_components/async-slider.js.map +1 -1
- package/dash_core_components/async-upload.js +1 -1
- package/dash_core_components/async-upload.js.map +1 -1
- package/dash_core_components/dash_core_components-shared.js +1 -1
- package/dash_core_components/dash_core_components-shared.js.map +1 -1
- package/dash_core_components/dash_core_components.js +1 -1
- package/dash_core_components/dash_core_components.js.map +1 -1
- package/dash_core_components/plotly.min.js +7 -7
- package/lib/components/Checklist.react.js +14 -61
- package/lib/components/Clipboard.react.js +12 -82
- package/lib/components/ConfirmDialog.react.js +5 -35
- package/lib/components/ConfirmDialogProvider.react.js +7 -45
- package/lib/components/DatePickerRange.react.js +3 -64
- package/lib/components/DatePickerSingle.react.js +3 -58
- package/lib/components/Download.react.js +8 -41
- package/lib/components/Dropdown.react.js +3 -51
- package/lib/components/Graph.react.js +17 -121
- package/lib/components/Input.react.js +9 -80
- package/lib/components/Interval.react.js +10 -42
- package/lib/components/Link.react.js +18 -62
- package/lib/components/Loading.react.js +12 -59
- package/lib/components/Location.react.js +18 -56
- package/lib/components/LogoutButton.react.js +8 -42
- package/lib/components/Markdown.react.js +4 -53
- package/lib/components/RadioItems.react.js +15 -63
- package/lib/components/RangeSlider.react.js +3 -53
- package/lib/components/Slider.react.js +3 -50
- package/lib/components/Store.react.js +17 -69
- package/lib/components/Tab.react.js +1 -23
- package/lib/components/Tabs.react.js +26 -92
- package/lib/components/Textarea.react.js +9 -70
- package/lib/components/Tooltip.react.js +4 -25
- package/lib/components/Upload.react.js +3 -50
- package/lib/fragments/DatePickerRange.react.js +36 -83
- package/lib/fragments/DatePickerSingle.react.js +27 -67
- package/lib/fragments/Dropdown.react.js +50 -86
- package/lib/fragments/Graph.privateprops.js +0 -3
- package/lib/fragments/Graph.react.js +135 -235
- package/lib/fragments/Loading/spinners/CircleSpinner.js +5 -14
- package/lib/fragments/Loading/spinners/CubeSpinner.js +5 -16
- package/lib/fragments/Loading/spinners/DefaultSpinner.js +5 -14
- package/lib/fragments/Loading/spinners/DotSpinner.js +5 -14
- package/lib/fragments/Loading/spinners/GraphSpinner.js +4 -13
- package/lib/fragments/Markdown.react.js +13 -60
- package/lib/fragments/Math.react.js +2 -28
- package/lib/fragments/RangeSlider.react.js +20 -60
- package/lib/fragments/Slider.react.js +20 -60
- package/lib/fragments/Upload.react.js +23 -52
- package/lib/index.js +0 -28
- package/lib/third-party/highlight.js +0 -40
- package/lib/utils/DatePickerPersistence.js +0 -5
- package/lib/utils/LazyLoader/datePickerRange.js +1 -5
- package/lib/utils/LazyLoader/datePickerSingle.js +1 -5
- package/lib/utils/LazyLoader/dropdown.js +1 -5
- package/lib/utils/LazyLoader/graph.js +1 -5
- package/lib/utils/LazyLoader/hljs.js +1 -5
- package/lib/utils/LazyLoader/markdown.js +1 -5
- package/lib/utils/LazyLoader/mathjax.js +1 -5
- package/lib/utils/LazyLoader/plotly.js +1 -5
- package/lib/utils/LazyLoader/rangeSlider.js +1 -5
- package/lib/utils/LazyLoader/slider.js +1 -5
- package/lib/utils/LazyLoader/upload.js +1 -5
- package/lib/utils/MarkdownHighlighter.js +0 -6
- package/lib/utils/computeSliderMarkers.js +17 -68
- package/lib/utils/computeSliderStyle.js +0 -6
- package/lib/utils/convertToMoment.js +0 -8
- package/lib/utils/mathjax.js +0 -1
- package/lib/utils/optionTypes.js +3 -18
- package/package.json +18 -18
- package/lib/components/css/react-virtualized-select@3.1.0.css +0 -22
|
@@ -4,65 +4,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/mathjax"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _withPolyfill = _interopRequireDefault(require("react-resize-detector/build/withPolyfill"));
|
|
13
|
-
|
|
14
10
|
var _ramda = require("ramda");
|
|
15
|
-
|
|
16
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
12
|
var _Graph = require("../components/Graph.react");
|
|
19
|
-
|
|
20
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
|
-
|
|
30
18
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
-
|
|
32
19
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
|
-
|
|
34
20
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
35
|
-
|
|
36
21
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
-
|
|
38
22
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
39
|
-
|
|
40
23
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
41
|
-
|
|
42
24
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
43
|
-
|
|
44
25
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
45
|
-
|
|
46
26
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
47
|
-
|
|
48
27
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
49
|
-
|
|
50
28
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
51
|
-
|
|
52
29
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
53
|
-
|
|
54
30
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
55
|
-
|
|
56
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
57
|
-
|
|
31
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
58
32
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
59
|
-
|
|
60
33
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
61
|
-
|
|
62
34
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
63
|
-
|
|
64
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
65
|
-
|
|
66
35
|
/* global Plotly:true */
|
|
67
36
|
|
|
68
37
|
/**
|
|
@@ -81,6 +50,7 @@ var AUTO_LAYOUT = {};
|
|
|
81
50
|
var UNRESPONSIVE_LAYOUT = {
|
|
82
51
|
autosize: false
|
|
83
52
|
};
|
|
53
|
+
|
|
84
54
|
/**
|
|
85
55
|
* `responsive: true` causes Plotly.js to resize the graph on `window.resize`.
|
|
86
56
|
* This is necessary for `dcc.Graph` call to `Plotly.Plots.resize(target)` to do something.
|
|
@@ -88,7 +58,6 @@ var UNRESPONSIVE_LAYOUT = {
|
|
|
88
58
|
* Users can override this value for specific use-cases by explicitly passing `responsive: false`
|
|
89
59
|
* if `responsive` is not set to True.
|
|
90
60
|
*/
|
|
91
|
-
|
|
92
61
|
var RESPONSIVE_CONFIG = {
|
|
93
62
|
responsive: true
|
|
94
63
|
};
|
|
@@ -96,19 +65,17 @@ var AUTO_CONFIG = {};
|
|
|
96
65
|
var UNRESPONSIVE_CONFIG = {
|
|
97
66
|
responsive: false
|
|
98
67
|
};
|
|
99
|
-
|
|
100
68
|
var filterEventData = function filterEventData(gd, eventData, event) {
|
|
101
69
|
var filteredEventData;
|
|
102
|
-
|
|
103
70
|
if ((0, _ramda.includes)(event, ['click', 'hover', 'selected'])) {
|
|
104
71
|
var _ret = function () {
|
|
105
72
|
var points = [];
|
|
106
|
-
|
|
107
73
|
if ((0, _ramda.isNil)(eventData)) {
|
|
108
74
|
return {
|
|
109
75
|
v: null
|
|
110
76
|
};
|
|
111
77
|
}
|
|
78
|
+
|
|
112
79
|
/*
|
|
113
80
|
* remove `data`, `layout`, `xaxis`, etc
|
|
114
81
|
* objects from the event data since they're so big
|
|
@@ -117,20 +84,17 @@ var filterEventData = function filterEventData(gd, eventData, event) {
|
|
|
117
84
|
* also, pull down the `customdata` point from the data array
|
|
118
85
|
* into the event object
|
|
119
86
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
87
|
var data = gd.data;
|
|
123
|
-
|
|
124
88
|
var _loop = function _loop(i) {
|
|
125
89
|
var fullPoint = eventData.points[i];
|
|
126
90
|
var pointData = (0, _ramda.filter)(function (o) {
|
|
127
91
|
return !(0, _ramda.includes)((0, _ramda.type)(o), ['Object', 'Array']);
|
|
128
|
-
}, fullPoint);
|
|
92
|
+
}, fullPoint);
|
|
129
93
|
|
|
94
|
+
// permit a bounding box to pass through, if present
|
|
130
95
|
if ((0, _ramda.has)('bbox', fullPoint)) {
|
|
131
96
|
pointData.bbox = fullPoint.bbox;
|
|
132
97
|
}
|
|
133
|
-
|
|
134
98
|
if ((0, _ramda.has)('curveNumber', fullPoint) && (0, _ramda.has)('customdata', data[pointData.curveNumber])) {
|
|
135
99
|
if ((0, _ramda.has)('pointNumber', fullPoint)) {
|
|
136
100
|
pointData.customdata = data[pointData.curveNumber].customdata[fullPoint.pointNumber];
|
|
@@ -139,26 +103,22 @@ var filterEventData = function filterEventData(gd, eventData, event) {
|
|
|
139
103
|
return data[pointData.curveNumber].customdata[point];
|
|
140
104
|
});
|
|
141
105
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
106
|
+
}
|
|
144
107
|
|
|
108
|
+
// specific to histogram. see https://github.com/plotly/plotly.js/pull/2113/
|
|
145
109
|
if ((0, _ramda.has)('pointNumbers', fullPoint)) {
|
|
146
110
|
pointData.pointNumbers = fullPoint.pointNumbers;
|
|
147
111
|
}
|
|
148
|
-
|
|
149
112
|
points[i] = pointData;
|
|
150
113
|
};
|
|
151
|
-
|
|
152
114
|
for (var i = 0; i < eventData.points.length; i++) {
|
|
153
115
|
_loop(i);
|
|
154
116
|
}
|
|
155
|
-
|
|
156
117
|
filteredEventData = {
|
|
157
|
-
points
|
|
118
|
+
points
|
|
158
119
|
};
|
|
159
120
|
}();
|
|
160
|
-
|
|
161
|
-
if (_typeof(_ret) === "object") return _ret.v;
|
|
121
|
+
if (typeof _ret === "object") return _ret.v;
|
|
162
122
|
} else if (event === 'relayout' || event === 'restyle') {
|
|
163
123
|
/*
|
|
164
124
|
* relayout shouldn't include any big objects
|
|
@@ -168,69 +128,61 @@ var filterEventData = function filterEventData(gd, eventData, event) {
|
|
|
168
128
|
*/
|
|
169
129
|
filteredEventData = eventData;
|
|
170
130
|
}
|
|
171
|
-
|
|
172
131
|
if ((0, _ramda.has)('range', eventData)) {
|
|
173
132
|
filteredEventData.range = eventData.range;
|
|
174
133
|
}
|
|
175
|
-
|
|
176
134
|
if ((0, _ramda.has)('lassoPoints', eventData)) {
|
|
177
135
|
filteredEventData.lassoPoints = eventData.lassoPoints;
|
|
178
136
|
}
|
|
179
|
-
|
|
180
137
|
return filteredEventData;
|
|
181
138
|
};
|
|
139
|
+
|
|
182
140
|
/**
|
|
183
141
|
* Graph can be used to render any plotly.js-powered data visualization.
|
|
184
142
|
*
|
|
185
143
|
* You can define callbacks based on user interaction with Graphs such as
|
|
186
144
|
* hovering, clicking or selecting
|
|
187
145
|
*/
|
|
188
|
-
|
|
189
|
-
|
|
190
146
|
var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
191
147
|
_inherits(PlotlyGraph, _Component);
|
|
192
|
-
|
|
193
148
|
var _super = _createSuper(PlotlyGraph);
|
|
194
|
-
|
|
195
149
|
function PlotlyGraph(props) {
|
|
196
|
-
var
|
|
197
|
-
|
|
150
|
+
var _this2;
|
|
198
151
|
_classCallCheck(this, PlotlyGraph);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
152
|
+
_this2 = _super.call(this, props);
|
|
153
|
+
_this2.gd = /*#__PURE__*/_react.default.createRef();
|
|
154
|
+
_this2._hasPlotted = false;
|
|
155
|
+
_this2._prevGd = null;
|
|
156
|
+
_this2._queue = Promise.resolve();
|
|
157
|
+
_this2.bindEvents = _this2.bindEvents.bind(_assertThisInitialized(_this2));
|
|
158
|
+
_this2.getConfig = _this2.getConfig.bind(_assertThisInitialized(_this2));
|
|
159
|
+
_this2.getConfigOverride = _this2.getConfigOverride.bind(_assertThisInitialized(_this2));
|
|
160
|
+
_this2.getLayout = _this2.getLayout.bind(_assertThisInitialized(_this2));
|
|
161
|
+
_this2.getLayoutOverride = _this2.getLayoutOverride.bind(_assertThisInitialized(_this2));
|
|
162
|
+
_this2.graphResize = _this2.graphResize.bind(_assertThisInitialized(_this2));
|
|
163
|
+
_this2.isResponsive = _this2.isResponsive.bind(_assertThisInitialized(_this2));
|
|
164
|
+
_this2.amendTraces = _this2.amendTraces.bind(_assertThisInitialized(_this2));
|
|
165
|
+
_this2.state = {
|
|
212
166
|
override: {},
|
|
213
167
|
originals: {}
|
|
214
168
|
};
|
|
215
|
-
return
|
|
169
|
+
return _this2;
|
|
216
170
|
}
|
|
217
|
-
|
|
218
171
|
_createClass(PlotlyGraph, [{
|
|
219
172
|
key: "plot",
|
|
220
173
|
value: function plot(props) {
|
|
221
|
-
var
|
|
222
|
-
|
|
174
|
+
var _this3 = this;
|
|
223
175
|
var figure = props.figure,
|
|
224
|
-
|
|
176
|
+
config = props.config;
|
|
225
177
|
var animate = props.animate,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
178
|
+
animation_options = props.animation_options,
|
|
179
|
+
responsive = props.responsive,
|
|
180
|
+
mathjax = props.mathjax;
|
|
229
181
|
var gd = this.gd.current;
|
|
230
182
|
figure = props._dashprivate_transformFigure(figure, gd);
|
|
231
183
|
config = props._dashprivate_transformConfig(config, gd);
|
|
232
|
-
var configClone = this.getConfig(config, responsive);
|
|
233
|
-
|
|
184
|
+
var configClone = this.getConfig(config, responsive);
|
|
185
|
+
// add typesetMath | not exposed to the dash API
|
|
234
186
|
configClone.typesetMath = mathjax;
|
|
235
187
|
var figureClone = {
|
|
236
188
|
data: figure.data,
|
|
@@ -238,7 +190,6 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
238
190
|
frames: figure.frames,
|
|
239
191
|
config: configClone
|
|
240
192
|
};
|
|
241
|
-
|
|
242
193
|
if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
|
|
243
194
|
// in case we've have figure frames,
|
|
244
195
|
// we need to recreate frames before animation
|
|
@@ -249,84 +200,96 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
249
200
|
return Plotly.animate(gd, figureClone, animation_options);
|
|
250
201
|
});
|
|
251
202
|
}
|
|
252
|
-
|
|
253
203
|
return Plotly.animate(gd, figureClone, animation_options);
|
|
254
204
|
}
|
|
255
|
-
|
|
256
205
|
gd.classList.add('dash-graph--pending');
|
|
257
206
|
return (0, _mathjax.default)(mathjax).then(function () {
|
|
258
|
-
var gd =
|
|
207
|
+
var gd = _this3.gd.current;
|
|
259
208
|
return gd && Plotly.react(gd, figureClone);
|
|
260
209
|
}).then(function () {
|
|
261
|
-
var gd =
|
|
210
|
+
var gd = _this3.gd.current;
|
|
262
211
|
|
|
212
|
+
// double-check gd hasn't been unmounted
|
|
263
213
|
if (!gd) {
|
|
264
214
|
return;
|
|
265
215
|
}
|
|
216
|
+
gd.classList.remove('dash-graph--pending');
|
|
266
217
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
Plotly.purge(_this2._prevGd);
|
|
218
|
+
// in case we've made a new DOM element, transfer events
|
|
219
|
+
if (_this3._hasPlotted && gd !== _this3._prevGd) {
|
|
220
|
+
if (_this3._prevGd && _this3._prevGd.removeAllListeners) {
|
|
221
|
+
_this3._prevGd.removeAllListeners();
|
|
222
|
+
Plotly.purge(_this3._prevGd);
|
|
274
223
|
}
|
|
275
|
-
|
|
276
|
-
_this2._hasPlotted = false;
|
|
224
|
+
_this3._hasPlotted = false;
|
|
277
225
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
_this2._hasPlotted = true;
|
|
285
|
-
_this2._prevGd = gd;
|
|
226
|
+
if (!_this3._hasPlotted) {
|
|
227
|
+
_this3.bindEvents();
|
|
228
|
+
_this3.graphResize(true);
|
|
229
|
+
_this3._hasPlotted = true;
|
|
230
|
+
_this3._prevGd = gd;
|
|
286
231
|
}
|
|
287
232
|
});
|
|
288
233
|
}
|
|
289
234
|
}, {
|
|
290
|
-
key: "
|
|
291
|
-
value: function
|
|
292
|
-
var
|
|
293
|
-
|
|
294
|
-
var
|
|
295
|
-
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
var
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (!traceIndices) {
|
|
311
|
-
function getFirstProp(data) {
|
|
312
|
-
return data[Object.keys(data)[0]];
|
|
235
|
+
key: "amendTraces",
|
|
236
|
+
value: function amendTraces(p, oldProps, newProps) {
|
|
237
|
+
var oldPrepend = oldProps.prependData,
|
|
238
|
+
oldExtend = oldProps.extendData;
|
|
239
|
+
var newPrepend = newProps.prependData,
|
|
240
|
+
newExtend = newProps.extendData;
|
|
241
|
+
var _this = this;
|
|
242
|
+
function mergeTraces(props, dataKey, plotlyFnKey) {
|
|
243
|
+
var clearState = props.clearState;
|
|
244
|
+
var dataArray = props[dataKey];
|
|
245
|
+
var _p = Promise.resolve();
|
|
246
|
+
dataArray.forEach(function (data) {
|
|
247
|
+
var updateData, traceIndices, maxPoints;
|
|
248
|
+
if (Array.isArray(data) && typeof data[0] === 'object') {
|
|
249
|
+
var _data = _slicedToArray(data, 3);
|
|
250
|
+
updateData = _data[0];
|
|
251
|
+
traceIndices = _data[1];
|
|
252
|
+
maxPoints = _data[2];
|
|
253
|
+
} else {
|
|
254
|
+
updateData = data;
|
|
313
255
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
256
|
+
if (!traceIndices) {
|
|
257
|
+
var getFirstProp = function getFirstProp(data) {
|
|
258
|
+
return data[Object.keys(data)[0]];
|
|
259
|
+
};
|
|
260
|
+
var generateIndices = function generateIndices(data) {
|
|
261
|
+
return Array.from(Array(getFirstProp(data).length).keys());
|
|
262
|
+
};
|
|
263
|
+
traceIndices = generateIndices(updateData);
|
|
317
264
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
265
|
+
_p = _p.then(function () {
|
|
266
|
+
var gd = _this.gd.current;
|
|
267
|
+
return gd && Plotly[plotlyFnKey](gd, updateData, traceIndices, maxPoints);
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
return _p.then(function () {
|
|
271
|
+
return clearState(dataKey);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
var modified = false;
|
|
275
|
+
if (newPrepend !== null && newPrepend !== void 0 && newPrepend.length && oldPrepend !== newPrepend) {
|
|
276
|
+
modified = true;
|
|
322
277
|
p = p.then(function () {
|
|
323
|
-
|
|
324
|
-
return gd && Plotly[plotlyFnKey](gd, updateData, traceIndices, maxPoints);
|
|
278
|
+
return mergeTraces(newProps, 'prependData', 'prependTraces');
|
|
325
279
|
});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
280
|
+
}
|
|
281
|
+
if (newExtend !== null && newExtend !== void 0 && newExtend.length && oldExtend !== newExtend) {
|
|
282
|
+
modified = true;
|
|
283
|
+
p = p.then(function () {
|
|
284
|
+
return mergeTraces(newProps, 'extendData', 'extendTraces');
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
if (modified) {
|
|
288
|
+
p = p.then(function () {
|
|
289
|
+
return newProps._dashprivate_onFigureModified(newProps.figure);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return p;
|
|
330
293
|
}
|
|
331
294
|
}, {
|
|
332
295
|
key: "getConfig",
|
|
@@ -339,14 +302,12 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
339
302
|
if (!layout) {
|
|
340
303
|
return layout;
|
|
341
304
|
}
|
|
342
|
-
|
|
343
305
|
var override = this.getLayoutOverride(responsive);
|
|
344
306
|
var _this$state = this.state,
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
307
|
+
prev_override = _this$state.override,
|
|
308
|
+
prev_originals = _this$state.originals;
|
|
309
|
+
// Store the original data that we're about to override
|
|
348
310
|
var originals = {};
|
|
349
|
-
|
|
350
311
|
for (var key in override) {
|
|
351
312
|
if (layout[key] !== prev_override[key]) {
|
|
352
313
|
originals[key] = layout[key];
|
|
@@ -354,23 +315,20 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
354
315
|
originals[key] = prev_originals[key];
|
|
355
316
|
}
|
|
356
317
|
}
|
|
357
|
-
|
|
358
318
|
this.setState({
|
|
359
|
-
override
|
|
360
|
-
originals
|
|
361
|
-
});
|
|
362
|
-
|
|
319
|
+
override,
|
|
320
|
+
originals
|
|
321
|
+
});
|
|
322
|
+
// Undo the previous override, but only for keys that the user did not change
|
|
363
323
|
for (var _key in prev_originals) {
|
|
364
324
|
if (layout[_key] === prev_override[_key]) {
|
|
365
325
|
layout[_key] = prev_originals[_key];
|
|
366
326
|
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
|
|
327
|
+
}
|
|
328
|
+
// Apply the current override
|
|
370
329
|
for (var _key2 in override) {
|
|
371
330
|
layout[_key2] = override[_key2];
|
|
372
331
|
}
|
|
373
|
-
|
|
374
332
|
return layout; // not really a clone
|
|
375
333
|
}
|
|
376
334
|
}, {
|
|
@@ -379,10 +337,8 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
379
337
|
switch (responsive) {
|
|
380
338
|
case false:
|
|
381
339
|
return UNRESPONSIVE_CONFIG;
|
|
382
|
-
|
|
383
340
|
case true:
|
|
384
341
|
return RESPONSIVE_CONFIG;
|
|
385
|
-
|
|
386
342
|
default:
|
|
387
343
|
return AUTO_CONFIG;
|
|
388
344
|
}
|
|
@@ -393,10 +349,8 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
393
349
|
switch (responsive) {
|
|
394
350
|
case false:
|
|
395
351
|
return UNRESPONSIVE_LAYOUT;
|
|
396
|
-
|
|
397
352
|
case true:
|
|
398
353
|
return RESPONSIVE_LAYOUT;
|
|
399
|
-
|
|
400
354
|
default:
|
|
401
355
|
return AUTO_LAYOUT;
|
|
402
356
|
}
|
|
@@ -405,30 +359,24 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
405
359
|
key: "isResponsive",
|
|
406
360
|
value: function isResponsive(props) {
|
|
407
361
|
var config = props.config,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
362
|
+
figure = props.figure,
|
|
363
|
+
responsive = props.responsive;
|
|
411
364
|
if ((0, _ramda.type)(responsive) === 'Boolean') {
|
|
412
365
|
return responsive;
|
|
413
366
|
}
|
|
414
|
-
|
|
415
367
|
return Boolean(config.responsive && (!figure.layout || (figure.layout.autosize || (0, _ramda.isNil)(figure.layout.autosize)) && ((0, _ramda.isNil)(figure.layout.height) || (0, _ramda.isNil)(figure.layout.width))));
|
|
416
368
|
}
|
|
417
369
|
}, {
|
|
418
370
|
key: "graphResize",
|
|
419
371
|
value: function graphResize() {
|
|
420
372
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
421
|
-
|
|
422
373
|
if (!force && !this.isResponsive(this.props)) {
|
|
423
374
|
return;
|
|
424
375
|
}
|
|
425
|
-
|
|
426
376
|
var gd = this.gd.current;
|
|
427
|
-
|
|
428
377
|
if (!gd) {
|
|
429
378
|
return;
|
|
430
379
|
}
|
|
431
|
-
|
|
432
380
|
gd.classList.add('dash-graph--pending');
|
|
433
381
|
Plotly.Plots.resize(gd).catch(function () {}).finally(function () {
|
|
434
382
|
return gd.classList.remove('dash-graph--pending');
|
|
@@ -438,31 +386,29 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
438
386
|
key: "bindEvents",
|
|
439
387
|
value: function bindEvents() {
|
|
440
388
|
var _this$props = this.props,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
389
|
+
setProps = _this$props.setProps,
|
|
390
|
+
clear_on_unhover = _this$props.clear_on_unhover,
|
|
391
|
+
relayoutData = _this$props.relayoutData,
|
|
392
|
+
restyleData = _this$props.restyleData,
|
|
393
|
+
hoverData = _this$props.hoverData,
|
|
394
|
+
selectedData = _this$props.selectedData;
|
|
447
395
|
var gd = this.gd.current;
|
|
448
396
|
gd.on('plotly_click', function (eventData) {
|
|
449
397
|
var clickData = filterEventData(gd, eventData, 'click');
|
|
450
|
-
|
|
451
398
|
if (!(0, _ramda.isNil)(clickData)) {
|
|
452
399
|
setProps({
|
|
453
|
-
clickData
|
|
400
|
+
clickData
|
|
454
401
|
});
|
|
455
402
|
}
|
|
456
403
|
});
|
|
457
404
|
gd.on('plotly_clickannotation', function (eventData) {
|
|
458
405
|
var clickAnnotationData = (0, _ramda.omit)(['event', 'fullAnnotation'], eventData);
|
|
459
406
|
setProps({
|
|
460
|
-
clickAnnotationData
|
|
407
|
+
clickAnnotationData
|
|
461
408
|
});
|
|
462
409
|
});
|
|
463
410
|
gd.on('plotly_hover', function (eventData) {
|
|
464
411
|
var hover = filterEventData(gd, eventData, 'hover');
|
|
465
|
-
|
|
466
412
|
if (!(0, _ramda.isNil)(hover) && !(0, _ramda.equals)(hover, hoverData)) {
|
|
467
413
|
setProps({
|
|
468
414
|
hoverData: hover
|
|
@@ -471,7 +417,6 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
471
417
|
});
|
|
472
418
|
gd.on('plotly_selected', function (eventData) {
|
|
473
419
|
var selected = filterEventData(gd, eventData, 'selected');
|
|
474
|
-
|
|
475
420
|
if (!(0, _ramda.isNil)(selected) && !(0, _ramda.equals)(selected, selectedData)) {
|
|
476
421
|
setProps({
|
|
477
422
|
selectedData: selected
|
|
@@ -485,7 +430,6 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
485
430
|
});
|
|
486
431
|
gd.on('plotly_relayout', function (eventData) {
|
|
487
432
|
var relayout = filterEventData(gd, eventData, 'relayout');
|
|
488
|
-
|
|
489
433
|
if (!(0, _ramda.isNil)(relayout) && !(0, _ramda.equals)(relayout, relayoutData)) {
|
|
490
434
|
setProps({
|
|
491
435
|
relayoutData: relayout
|
|
@@ -494,7 +438,6 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
494
438
|
});
|
|
495
439
|
gd.on('plotly_restyle', function (eventData) {
|
|
496
440
|
var restyle = filterEventData(gd, eventData, 'restyle');
|
|
497
|
-
|
|
498
441
|
if (!(0, _ramda.isNil)(restyle) && !(0, _ramda.equals)(restyle, restyleData)) {
|
|
499
442
|
setProps({
|
|
500
443
|
restyleData: restyle
|
|
@@ -512,38 +455,15 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
512
455
|
}, {
|
|
513
456
|
key: "componentDidMount",
|
|
514
457
|
value: function componentDidMount() {
|
|
515
|
-
var _this4 = this,
|
|
516
|
-
_this$props$prependDa,
|
|
517
|
-
_this$props$extendDat;
|
|
518
|
-
|
|
519
458
|
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
|
-
}
|
|
459
|
+
this._queue = this.amendTraces(p, {}, this.props);
|
|
538
460
|
}
|
|
539
461
|
}, {
|
|
540
462
|
key: "componentWillUnmount",
|
|
541
463
|
value: function componentWillUnmount() {
|
|
542
464
|
var gd = this.gd.current;
|
|
543
|
-
|
|
544
465
|
if (gd && gd.removeAllListeners) {
|
|
545
466
|
gd.removeAllListeners();
|
|
546
|
-
|
|
547
467
|
if (this._hasPlotted) {
|
|
548
468
|
Plotly.purge(gd);
|
|
549
469
|
}
|
|
@@ -557,12 +477,8 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
557
477
|
}, {
|
|
558
478
|
key: "UNSAFE_componentWillReceiveProps",
|
|
559
479
|
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
560
|
-
var
|
|
561
|
-
_this$props$prependDa2,
|
|
562
|
-
_this$props$extendDat2;
|
|
563
|
-
|
|
480
|
+
var _this4 = this;
|
|
564
481
|
var idChanged = this.props.id !== nextProps.id;
|
|
565
|
-
|
|
566
482
|
if (idChanged) {
|
|
567
483
|
/*
|
|
568
484
|
* then the dom needs to get re-rendered with a new ID.
|
|
@@ -570,46 +486,32 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
570
486
|
*/
|
|
571
487
|
return;
|
|
572
488
|
}
|
|
573
|
-
|
|
574
|
-
var p = Promise.resolve();
|
|
575
|
-
|
|
489
|
+
var p = this._queue;
|
|
576
490
|
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
|
-
p = p.then(function () {
|
|
582
|
-
return _this5.mergeTraces(nextProps, 'prependData', 'prependTraces');
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
if (this.props.extendData !== nextProps.extendData) {
|
|
587
491
|
p = p.then(function () {
|
|
588
|
-
return
|
|
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);
|
|
492
|
+
return _this4.plot(nextProps);
|
|
595
493
|
});
|
|
596
494
|
}
|
|
495
|
+
this._queue = this.amendTraces(p, this.props, nextProps);
|
|
597
496
|
}
|
|
598
497
|
}, {
|
|
599
498
|
key: "componentDidUpdate",
|
|
600
499
|
value: function componentDidUpdate(prevProps) {
|
|
500
|
+
var _this5 = this;
|
|
601
501
|
if (prevProps.id !== this.props.id || prevProps.mathjax !== this.props.mathjax) {
|
|
602
|
-
this.
|
|
502
|
+
this._queue = this._queue.then(function () {
|
|
503
|
+
return _this5.plot(_this5.props);
|
|
504
|
+
});
|
|
603
505
|
}
|
|
604
506
|
}
|
|
605
507
|
}, {
|
|
606
508
|
key: "render",
|
|
607
509
|
value: function render() {
|
|
608
510
|
var _this$props2 = this.props,
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
511
|
+
className = _this$props2.className,
|
|
512
|
+
id = _this$props2.id,
|
|
513
|
+
style = _this$props2.style,
|
|
514
|
+
loading_state = _this$props2.loading_state;
|
|
613
515
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
614
516
|
id: id,
|
|
615
517
|
key: id,
|
|
@@ -634,10 +536,8 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
|
|
|
634
536
|
}));
|
|
635
537
|
}
|
|
636
538
|
}]);
|
|
637
|
-
|
|
638
539
|
return PlotlyGraph;
|
|
639
540
|
}(_react.Component);
|
|
640
|
-
|
|
641
541
|
PlotlyGraph.propTypes = _objectSpread(_objectSpread({}, _Graph.graphPropTypes), {}, {
|
|
642
542
|
prependData: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object])),
|
|
643
543
|
extendData: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object])),
|