plotly.js 1.52.1 → 1.52.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.
Files changed (43) hide show
  1. package/.fossa.yml +58 -0
  2. package/.ignore +3 -0
  3. package/CHANGELOG.md +21 -0
  4. package/dist/README.md +25 -25
  5. package/dist/plot-schema.json +8 -8
  6. package/dist/plotly-basic.js +187 -54
  7. package/dist/plotly-basic.min.js +2 -2
  8. package/dist/plotly-cartesian.js +187 -54
  9. package/dist/plotly-cartesian.min.js +2 -2
  10. package/dist/plotly-finance.js +187 -54
  11. package/dist/plotly-finance.min.js +2 -2
  12. package/dist/plotly-geo-assets.js +2 -2
  13. package/dist/plotly-geo.js +168 -49
  14. package/dist/plotly-geo.min.js +2 -2
  15. package/dist/plotly-gl2d.js +173 -51
  16. package/dist/plotly-gl2d.min.js +2 -2
  17. package/dist/plotly-gl3d.js +668 -449
  18. package/dist/plotly-gl3d.min.js +2 -2
  19. package/dist/plotly-mapbox.js +170 -50
  20. package/dist/plotly-mapbox.min.js +2 -2
  21. package/dist/plotly-with-meta.js +823 -533
  22. package/dist/plotly.js +814 -525
  23. package/dist/plotly.min.js +2 -2
  24. package/package.json +24 -23
  25. package/src/assets/geo_assets.js +1 -1
  26. package/src/components/annotations/attributes.js +1 -1
  27. package/src/core.js +1 -1
  28. package/src/lib/index.js +6 -3
  29. package/src/plot_api/subroutines.js +6 -0
  30. package/src/plot_api/validate.js +4 -3
  31. package/src/plots/cartesian/axes.js +6 -2
  32. package/src/plots/cartesian/constants.js +1 -2
  33. package/src/plots/cartesian/layout_defaults.js +112 -27
  34. package/src/plots/gl3d/scene.js +361 -323
  35. package/src/plots/layout_attributes.js +2 -2
  36. package/src/plots/mapbox/layers.js +2 -1
  37. package/src/plots/plots.js +30 -9
  38. package/src/traces/bar/hover.js +6 -1
  39. package/src/traces/bar/plot.js +13 -4
  40. package/src/traces/mesh3d/convert.js +9 -5
  41. package/src/traces/pie/attributes.js +7 -6
  42. package/src/traces/treemap/plot.js +2 -0
  43. package/tasks/test_syntax.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotly.js",
3
- "version": "1.52.1",
3
+ "version": "1.52.2",
4
4
  "description": "The open source javascript graphing library that powers plotly",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",
@@ -69,8 +69,8 @@
69
69
  "country-regex": "^1.1.0",
70
70
  "d3": "^3.5.12",
71
71
  "d3-force": "^1.0.6",
72
- "d3-hierarchy": "^1.1.8",
73
- "d3-interpolate": "1",
72
+ "d3-hierarchy": "^1.1.9",
73
+ "d3-interpolate": "^1.4.0",
74
74
  "delaunay-triangulate": "^1.1.6",
75
75
  "es6-promise": "^3.0.2",
76
76
  "fast-isnumeric": "^1.1.3",
@@ -80,9 +80,9 @@
80
80
  "gl-heatmap2d": "^1.0.5",
81
81
  "gl-line3d": "^1.1.11",
82
82
  "gl-mat4": "^1.2.0",
83
- "gl-mesh3d": "^2.2.0",
84
- "gl-plot2d": "^1.4.2",
85
- "gl-plot3d": "^2.3.0",
83
+ "gl-mesh3d": "^2.3.0",
84
+ "gl-plot2d": "^1.4.3",
85
+ "gl-plot3d": "^2.4.2",
86
86
  "gl-pointcloud2d": "^1.0.2",
87
87
  "gl-scatter3d": "^1.2.2",
88
88
  "gl-select-box": "^1.0.3",
@@ -93,6 +93,7 @@
93
93
  "glslify": "^7.0.0",
94
94
  "has-hover": "^1.0.1",
95
95
  "has-passive-events": "^1.0.0",
96
+ "is-mobile": "^2.1.0",
96
97
  "mapbox-gl": "1.3.2",
97
98
  "matrix-camera-controller": "^2.1.3",
98
99
  "mouse-change": "^1.4.0",
@@ -123,44 +124,44 @@
123
124
  "brfs": "^2.0.2",
124
125
  "browserify": "^16.5.0",
125
126
  "browserify-transform-tools": "^1.7.0",
126
- "check-node-version": "^3.3.0",
127
+ "check-node-version": "^4.0.2",
127
128
  "chttps": "^1.0.6",
128
- "deep-equal": "^1.0.1",
129
+ "deep-equal": "^2.0.1",
129
130
  "derequire": "^2.0.6",
130
- "ecstatic": "^3.3.2",
131
- "eslint": "^6.3.0",
131
+ "ecstatic": "^4.1.2",
132
+ "eslint": "^6.8.0",
132
133
  "falafel": "^2.1.0",
133
134
  "fs-extra": "^2.0.0",
134
- "fuse.js": "^3.4.5",
135
- "glob": "^7.1.4",
135
+ "fuse.js": "^3.4.6",
136
+ "glob": "^7.1.6",
136
137
  "gzip-size": "^5.1.1",
137
138
  "image-size": "^0.7.4",
138
- "into-stream": "^4.0.0",
139
- "jasmine-core": "^3.4.0",
139
+ "into-stream": "^5.1.1",
140
+ "jasmine-core": "^3.5.0",
140
141
  "jsdom": "^11.12.0",
141
- "karma": "^4.3.0",
142
+ "karma": "^4.4.1",
142
143
  "karma-browserify": "^6.1.0",
143
144
  "karma-chrome-launcher": "^3.1.0",
144
- "karma-firefox-launcher": "^1.2.0",
145
+ "karma-firefox-launcher": "^1.3.0",
145
146
  "karma-ie-launcher": "^1.0.0",
146
- "karma-jasmine": "^2.0.1",
147
- "karma-jasmine-spec-tags": "^1.1.0",
147
+ "karma-jasmine": "^3.0.3",
148
+ "karma-jasmine-spec-tags": "^1.2.0",
148
149
  "karma-spec-reporter": "0.0.32",
149
150
  "karma-verbose-reporter": "0.0.6",
150
151
  "karma-viewport": "^1.0.4",
151
- "madge": "^3.4.4",
152
- "minify-stream": "^1.2.0",
152
+ "madge": "^3.6.0",
153
+ "minify-stream": "^1.2.1",
153
154
  "minimist": "^1.2.0",
154
- "node-sass": "^4.12.0",
155
+ "node-sass": "^4.13.0",
155
156
  "npm-link-check": "^3.0.0",
156
- "open": "^6.4.0",
157
+ "open": "^7.0.0",
157
158
  "prepend-file": "^1.3.1",
158
159
  "prettysize": "^2.0.0",
159
160
  "read-last-lines": "^1.7.1",
160
161
  "requirejs": "^2.3.6",
161
162
  "run-series": "^1.1.8",
162
163
  "through2": "^3.0.1",
163
- "true-case-path": "^1.0.3",
164
+ "true-case-path": "^2.2.1",
164
165
  "watchify": "^3.11.1"
165
166
  }
166
167
  }
@@ -12,6 +12,6 @@ var saneTopojson = require('sane-topojson');
12
12
 
13
13
 
14
14
  // package version injected by `npm run preprocess`
15
- exports.version = '1.52.1';
15
+ exports.version = '1.52.2';
16
16
 
17
17
  exports.topojson = saneTopojson;
@@ -92,7 +92,7 @@ module.exports = templatedArray('annotation', {
92
92
  editType: 'arraydraw',
93
93
  description: [
94
94
  'Sets the horizontal alignment of the `text` within the box.',
95
- 'Has an effect only if `text` spans more two or more lines',
95
+ 'Has an effect only if `text` spans two or more lines',
96
96
  '(i.e. `text` contains one or more <br> HTML tags) or if an',
97
97
  'explicit width is set to override the text width.'
98
98
  ].join(' ')
package/src/core.js CHANGED
@@ -9,7 +9,7 @@
9
9
  'use strict';
10
10
 
11
11
  // package version injected by `npm run preprocess`
12
- exports.version = '1.52.1';
12
+ exports.version = '1.52.2';
13
13
 
14
14
  // inject promise polyfill
15
15
  require('es6-promise').polyfill();
package/src/lib/index.js CHANGED
@@ -989,11 +989,14 @@ lib.templateString = function(string, obj) {
989
989
  var getterCache = {};
990
990
 
991
991
  return string.replace(lib.TEMPLATE_STRING_REGEX, function(dummy, key) {
992
+ var v;
992
993
  if(SIMPLE_PROPERTY_REGEX.test(key)) {
993
- return obj[key] || '';
994
+ v = obj[key];
995
+ } else {
996
+ getterCache[key] = getterCache[key] || lib.nestedProperty(obj, key).get;
997
+ v = getterCache[key]();
994
998
  }
995
- getterCache[key] = getterCache[key] || lib.nestedProperty(obj, key).get;
996
- return getterCache[key]() || '';
999
+ return lib.isValidTextValue(v) ? v : '';
997
1000
  });
998
1001
  };
999
1002
 
@@ -670,6 +670,7 @@ exports.doAutoRangeAndConstraints = function(gd) {
670
670
  var fullLayout = gd._fullLayout;
671
671
  var axList = Axes.list(gd, '', true);
672
672
  var matchGroups = fullLayout._axisMatchGroups || [];
673
+ var axLookup = {};
673
674
  var ax;
674
675
  var axRng;
675
676
 
@@ -677,6 +678,7 @@ exports.doAutoRangeAndConstraints = function(gd) {
677
678
  ax = axList[i];
678
679
  cleanAxisConstraints(gd, ax);
679
680
  doAutoRange(gd, ax);
681
+ axLookup[ax._id] = 1;
680
682
  }
681
683
 
682
684
  enforceAxisConstraints(gd);
@@ -689,6 +691,10 @@ exports.doAutoRangeAndConstraints = function(gd) {
689
691
 
690
692
  for(id in group) {
691
693
  ax = Axes.getFromId(gd, id);
694
+
695
+ // skip over 'missing' axes which do not pass through doAutoRange
696
+ if(!axLookup[ax._id]) continue;
697
+ // if one axis has autorange false, we're done
692
698
  if(ax.autorange === false) continue groupLoop;
693
699
 
694
700
  axRng = Lib.simpleMap(ax.range, ax.r2l);
@@ -161,13 +161,14 @@ function crawl(objIn, objOut, schema, list, base, path) {
161
161
  var valOut = objOut[k];
162
162
 
163
163
  var nestedSchema = getNestedSchema(schema, k);
164
- var isInfoArray = (nestedSchema || {}).valType === 'info_array';
165
- var isColorscale = (nestedSchema || {}).valType === 'colorscale';
164
+ var nestedValType = (nestedSchema || {}).valType;
165
+ var isInfoArray = nestedValType === 'info_array';
166
+ var isColorscale = nestedValType === 'colorscale';
166
167
  var items = (nestedSchema || {}).items;
167
168
 
168
169
  if(!isInSchema(schema, k)) {
169
170
  list.push(format('schema', base, p));
170
- } else if(isPlainObject(valIn) && isPlainObject(valOut)) {
171
+ } else if(isPlainObject(valIn) && isPlainObject(valOut) && nestedValType !== 'any') {
171
172
  crawl(valIn, valOut, nestedSchema, list, base, p);
172
173
  } else if(isInfoArray && isArray(valIn)) {
173
174
  if(valIn.length > valOut.length) {
@@ -1669,10 +1669,14 @@ axes.drawOne = function(gd, ax, opts) {
1669
1669
  var axId = ax._id;
1670
1670
  var axLetter = axId.charAt(0);
1671
1671
  var counterLetter = axes.counterLetter(axId);
1672
- var mainLinePosition = ax._mainLinePosition;
1673
- var mainMirrorPosition = ax._mainMirrorPosition;
1674
1672
  var mainPlotinfo = fullLayout._plots[ax._mainSubplot];
1673
+
1674
+ // this happens when updating matched group with 'missing' axes
1675
+ if(!mainPlotinfo) return;
1676
+
1675
1677
  var mainAxLayer = mainPlotinfo[axLetter + 'axislayer'];
1678
+ var mainLinePosition = ax._mainLinePosition;
1679
+ var mainMirrorPosition = ax._mainMirrorPosition;
1676
1680
 
1677
1681
  var vals = ax._vals = axes.calcTicks(ax);
1678
1682
 
@@ -7,11 +7,10 @@
7
7
  */
8
8
 
9
9
  'use strict';
10
- var counterRegex = require('../../lib/regex').counter;
11
10
 
11
+ var counterRegex = require('../../lib/regex').counter;
12
12
 
13
13
  module.exports = {
14
-
15
14
  idRegex: {
16
15
  x: counterRegex('x'),
17
16
  y: counterRegex('y')
@@ -24,6 +24,8 @@ var axisIds = require('./axis_ids');
24
24
  var id2name = axisIds.id2name;
25
25
  var name2id = axisIds.name2id;
26
26
 
27
+ var AX_ID_PATTERN = require('./constants').AX_ID_PATTERN;
28
+
27
29
  var Registry = require('../../registry');
28
30
  var traceIs = Registry.traceIs;
29
31
  var getComponentMethod = Registry.getComponentMethod;
@@ -133,7 +135,28 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
133
135
 
134
136
  var bgColor = Color.combine(plotBgColor, layoutOut.paper_bgcolor);
135
137
 
136
- var axName, axLetter, axLayoutIn, axLayoutOut;
138
+ // name of single axis (e.g. 'xaxis', 'yaxis2')
139
+ var axName;
140
+ // id of single axis (e.g. 'y', 'x5')
141
+ var axId;
142
+ // 'x' or 'y'
143
+ var axLetter;
144
+ // input layout axis container
145
+ var axLayoutIn;
146
+ // full layout axis container
147
+ var axLayoutOut;
148
+
149
+ function newAxLayoutOut() {
150
+ var traces = ax2traces[axName] || [];
151
+ axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; });
152
+ axLayoutOut._annIndices = [];
153
+ axLayoutOut._shapeIndices = [];
154
+ axLayoutOut._imgIndices = [];
155
+ axLayoutOut._subplotsWith = [];
156
+ axLayoutOut._counterAxes = [];
157
+ axLayoutOut._name = axLayoutOut._attr = axName;
158
+ axLayoutOut._id = axId;
159
+ }
137
160
 
138
161
  function coerce(attr, dflt) {
139
162
  return Lib.coerce(axLayoutIn, axLayoutOut, layoutAttributes, attr, dflt);
@@ -147,9 +170,6 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
147
170
  return (axLetter === 'x') ? yIds : xIds;
148
171
  }
149
172
 
150
- var counterAxes = {x: getCounterAxes('x'), y: getCounterAxes('y')};
151
- var allAxisIds = counterAxes.x.concat(counterAxes.y);
152
-
153
173
  function getOverlayableAxes(axLetter, axName) {
154
174
  var list = (axLetter === 'x') ? xNames : yNames;
155
175
  var out = [];
@@ -165,9 +185,30 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
165
185
  return out;
166
186
  }
167
187
 
188
+ // list of available counter axis names
189
+ var counterAxes = {x: getCounterAxes('x'), y: getCounterAxes('y')};
190
+ // list of all x AND y axis ids
191
+ var allAxisIds = counterAxes.x.concat(counterAxes.y);
192
+ // lookup and list of axis ids that axes in axNames have a reference to,
193
+ // even though they are missing from allAxisIds
194
+ var missingMatchedAxisIdsLookup = {};
195
+ var missingMatchedAxisIds = [];
196
+
197
+ // fill in 'missing' axis lookup when an axis is set to match an axis
198
+ // not part of the allAxisIds list, save axis type so that we can propagate
199
+ // it to the missing axes
200
+ function addMissingMatchedAxis() {
201
+ var matchesIn = axLayoutIn.matches;
202
+ if(AX_ID_PATTERN.test(matchesIn) && allAxisIds.indexOf(matchesIn) === -1) {
203
+ missingMatchedAxisIdsLookup[matchesIn] = axLayoutIn.type;
204
+ missingMatchedAxisIds = Object.keys(missingMatchedAxisIdsLookup);
205
+ }
206
+ }
207
+
168
208
  // first pass creates the containers, determines types, and handles most of the settings
169
209
  for(i = 0; i < axNames.length; i++) {
170
210
  axName = axNames[i];
211
+ axId = name2id(axName);
171
212
  axLetter = axName.charAt(0);
172
213
 
173
214
  if(!Lib.isPlainObject(layoutIn[axName])) {
@@ -176,20 +217,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
176
217
 
177
218
  axLayoutIn = layoutIn[axName];
178
219
  axLayoutOut = Template.newContainer(layoutOut, axName, axLetter + 'axis');
179
-
180
- var traces = ax2traces[axName] || [];
181
- axLayoutOut._traceIndices = traces.map(function(t) { return t._expandedIndex; });
182
- axLayoutOut._annIndices = [];
183
- axLayoutOut._shapeIndices = [];
184
- axLayoutOut._imgIndices = [];
185
- axLayoutOut._subplotsWith = [];
186
- axLayoutOut._counterAxes = [];
187
-
188
- // set up some private properties
189
- axLayoutOut._name = axLayoutOut._attr = axName;
190
- var id = axLayoutOut._id = name2id(axName);
191
-
192
- var overlayableAxes = getOverlayableAxes(axLetter, axName);
220
+ newAxLayoutOut();
193
221
 
194
222
  var visibleDflt =
195
223
  (axLetter === 'x' && !xaMustDisplay[axName] && xaMayHide[axName]) ||
@@ -207,13 +235,13 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
207
235
  font: layoutOut.font,
208
236
  outerTicks: outerTicks[axName],
209
237
  showGrid: !noGrids[axName],
210
- data: traces,
238
+ data: ax2traces[axName] || [],
211
239
  bgColor: bgColor,
212
240
  calendar: layoutOut.calendar,
213
241
  automargin: true,
214
242
  visibleDflt: visibleDflt,
215
243
  reverseDflt: reverseDflt,
216
- splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id]
244
+ splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[axId]
217
245
  };
218
246
 
219
247
  coerce('uirevision', layoutOut.uirevision);
@@ -239,12 +267,63 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
239
267
  handlePositionDefaults(axLayoutIn, axLayoutOut, coerce, {
240
268
  letter: axLetter,
241
269
  counterAxes: counterAxes[axLetter],
242
- overlayableAxes: overlayableAxes,
270
+ overlayableAxes: getOverlayableAxes(axLetter, axName),
243
271
  grid: layoutOut.grid
244
272
  });
245
273
 
246
274
  coerce('title.standoff');
247
275
 
276
+ addMissingMatchedAxis();
277
+
278
+ axLayoutOut._input = axLayoutIn;
279
+ }
280
+
281
+ // coerce the 'missing' axes
282
+ i = 0;
283
+ while(i < missingMatchedAxisIds.length) {
284
+ axId = missingMatchedAxisIds[i++];
285
+ axName = id2name(axId);
286
+ axLetter = axName.charAt(0);
287
+
288
+ if(!Lib.isPlainObject(layoutIn[axName])) {
289
+ layoutIn[axName] = {};
290
+ }
291
+
292
+ axLayoutIn = layoutIn[axName];
293
+ axLayoutOut = Template.newContainer(layoutOut, axName, axLetter + 'axis');
294
+ newAxLayoutOut();
295
+
296
+ var defaultOptions2 = {
297
+ letter: axLetter,
298
+ font: layoutOut.font,
299
+ outerTicks: outerTicks[axName],
300
+ showGrid: !noGrids[axName],
301
+ data: [],
302
+ bgColor: bgColor,
303
+ calendar: layoutOut.calendar,
304
+ automargin: true,
305
+ visibleDflt: false,
306
+ reverseDflt: false,
307
+ splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[axId]
308
+ };
309
+
310
+ coerce('uirevision', layoutOut.uirevision);
311
+
312
+ axLayoutOut.type = missingMatchedAxisIdsLookup[axId] || 'linear';
313
+
314
+ handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions2, layoutOut);
315
+
316
+ handlePositionDefaults(axLayoutIn, axLayoutOut, coerce, {
317
+ letter: axLetter,
318
+ counterAxes: counterAxes[axLetter],
319
+ overlayableAxes: getOverlayableAxes(axLetter, axName),
320
+ grid: layoutOut.grid
321
+ });
322
+
323
+ coerce('fixedrange');
324
+
325
+ addMissingMatchedAxis();
326
+
248
327
  axLayoutOut._input = axLayoutIn;
249
328
  }
250
329
 
@@ -295,9 +374,12 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
295
374
  var constraintGroups = layoutOut._axisConstraintGroups = [];
296
375
  // similar to _axisConstraintGroups, but for matching axes
297
376
  var matchGroups = layoutOut._axisMatchGroups = [];
377
+ // make sure to include 'missing' axes here
378
+ var allAxisIdsIncludingMissing = allAxisIds.concat(missingMatchedAxisIds);
379
+ var axNamesIncludingMissing = axNames.concat(Lib.simpleMap(missingMatchedAxisIds, id2name));
298
380
 
299
- for(i = 0; i < axNames.length; i++) {
300
- axName = axNames[i];
381
+ for(i = 0; i < axNamesIncludingMissing.length; i++) {
382
+ axName = axNamesIncludingMissing[i];
301
383
  axLetter = axName.charAt(0);
302
384
  axLayoutIn = layoutIn[axName];
303
385
  axLayoutOut = layoutOut[axName];
@@ -305,15 +387,19 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
305
387
  var scaleanchorDflt;
306
388
  if(axLetter === 'y' && !axLayoutIn.hasOwnProperty('scaleanchor') && axHasImage[axName]) {
307
389
  scaleanchorDflt = axLayoutOut.anchor;
308
- } else {scaleanchorDflt = undefined;}
390
+ } else {
391
+ scaleanchorDflt = undefined;
392
+ }
309
393
 
310
394
  var constrainDflt;
311
395
  if(!axLayoutIn.hasOwnProperty('constrain') && axHasImage[axName]) {
312
396
  constrainDflt = 'domain';
313
- } else {constrainDflt = undefined;}
397
+ } else {
398
+ constrainDflt = undefined;
399
+ }
314
400
 
315
401
  handleConstraintDefaults(axLayoutIn, axLayoutOut, coerce, {
316
- allAxisIds: allAxisIds,
402
+ allAxisIds: allAxisIdsIncludingMissing,
317
403
  layoutOut: layoutOut,
318
404
  scaleanchorDflt: scaleanchorDflt,
319
405
  constrainDflt: constrainDflt
@@ -324,7 +410,6 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
324
410
  var group = matchGroups[i];
325
411
  var rng = null;
326
412
  var autorange = null;
327
- var axId;
328
413
 
329
414
  // find 'matching' range attrs
330
415
  for(axId in group) {