plotly.js 2.6.4 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotly.js",
3
- "version": "2.6.4",
3
+ "version": "2.7.0",
4
4
  "description": "The open source javascript graphing library that powers plotly",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",
@@ -103,7 +103,7 @@
103
103
  "native-promise-only": "^0.8.1",
104
104
  "parse-svg-path": "^0.1.2",
105
105
  "polybooljs": "^1.2.0",
106
- "probe-image-size": "^7.2.1",
106
+ "probe-image-size": "^7.2.2",
107
107
  "regl": "^2.1.0",
108
108
  "regl-error2d": "^2.0.12",
109
109
  "regl-line2d": "^3.1.2",
@@ -2396,7 +2396,8 @@ function findUIPattern(key, patternSpecs) {
2396
2396
  var spec = patternSpecs[i];
2397
2397
  var match = key.match(spec.pattern);
2398
2398
  if(match) {
2399
- return {head: match[1], attr: spec.attr};
2399
+ var head = match[1] || '';
2400
+ return {head: head, tail: key.substr(head.length + 1), attr: spec.attr};
2400
2401
  }
2401
2402
  }
2402
2403
  }
@@ -2448,26 +2449,54 @@ function valsMatch(v1, v2) {
2448
2449
 
2449
2450
  function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
2450
2451
  var layoutPreGUI = oldFullLayout._preGUI;
2451
- var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal;
2452
+ var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal, head, tail;
2452
2453
  var bothInheritAutorange = [];
2454
+ var newAutorangeIn = {};
2453
2455
  var newRangeAccepted = {};
2454
2456
  for(key in layoutPreGUI) {
2455
2457
  match = findUIPattern(key, layoutUIControlPatterns);
2456
2458
  if(match) {
2457
- revAttr = match.attr || (match.head + '.uirevision');
2459
+ head = match.head;
2460
+ tail = match.tail;
2461
+ revAttr = match.attr || (head + '.uirevision');
2458
2462
  oldRev = nestedProperty(oldFullLayout, revAttr).get();
2459
2463
  newRev = oldRev && getNewRev(revAttr, layout);
2464
+
2460
2465
  if(newRev && (newRev === oldRev)) {
2461
2466
  preGUIVal = layoutPreGUI[key];
2462
2467
  if(preGUIVal === null) preGUIVal = undefined;
2463
2468
  newNP = nestedProperty(layout, key);
2464
2469
  newVal = newNP.get();
2470
+
2465
2471
  if(valsMatch(newVal, preGUIVal)) {
2466
- if(newVal === undefined && key.substr(key.length - 9) === 'autorange') {
2467
- bothInheritAutorange.push(key.substr(0, key.length - 10));
2472
+ if(newVal === undefined && tail === 'autorange') {
2473
+ bothInheritAutorange.push(head);
2468
2474
  }
2469
2475
  newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get()));
2470
2476
  continue;
2477
+ } else if(tail === 'autorange' || tail.substr(0, 6) === 'range[') {
2478
+ // Special case for (auto)range since we push it back into the layout
2479
+ // so all null should be treated equivalently to autorange: true with any range
2480
+ var pre0 = layoutPreGUI[head + '.range[0]'];
2481
+ var pre1 = layoutPreGUI[head + '.range[1]'];
2482
+ var preAuto = layoutPreGUI[head + '.autorange'];
2483
+ if(preAuto || (preAuto === null && pre0 === null && pre1 === null)) {
2484
+ // Only read the input layout once and stash the result,
2485
+ // so we get it before we start modifying it
2486
+ if(!(head in newAutorangeIn)) {
2487
+ var newContainer = nestedProperty(layout, head).get();
2488
+ newAutorangeIn[head] = newContainer && (
2489
+ newContainer.autorange ||
2490
+ (newContainer.autorange !== false && (
2491
+ !newContainer.range || newContainer.range.length !== 2)
2492
+ )
2493
+ );
2494
+ }
2495
+ if(newAutorangeIn[head]) {
2496
+ newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get()));
2497
+ continue;
2498
+ }
2499
+ }
2471
2500
  }
2472
2501
  }
2473
2502
  } else {
@@ -2478,12 +2507,12 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
2478
2507
  // so remove it from _preGUI for next time.
2479
2508
  delete layoutPreGUI[key];
2480
2509
 
2481
- if(key.substr(key.length - 8, 6) === 'range[') {
2482
- newRangeAccepted[key.substr(0, key.length - 9)] = 1;
2510
+ if(match && match.tail.substr(0, 6) === 'range[') {
2511
+ newRangeAccepted[match.head] = 1;
2483
2512
  }
2484
2513
  }
2485
2514
 
2486
- // Special logic for `autorange`, since it interacts with `range`:
2515
+ // More special logic for `autorange`, since it interacts with `range`:
2487
2516
  // If the new figure's matching `range` was kept, and `autorange`
2488
2517
  // wasn't supplied explicitly in either the original or the new figure,
2489
2518
  // we shouldn't alter that - but we may just have done that, so fix it.
@@ -722,11 +722,14 @@ proto.project = function(v) {
722
722
  proto.getView = function() {
723
723
  var map = this.map;
724
724
  var mapCenter = map.getCenter();
725
- var center = { lon: mapCenter.lng, lat: mapCenter.lat };
725
+ var lon = mapCenter.lng;
726
+ var lat = mapCenter.lat;
727
+ var center = { lon: lon, lat: lat };
726
728
 
727
729
  var canvas = map.getCanvas();
728
- var w = canvas.width;
729
- var h = canvas.height;
730
+ var w = parseInt(canvas.style.width);
731
+ var h = parseInt(canvas.style.height);
732
+
730
733
  return {
731
734
  center: center,
732
735
  zoom: map.getZoom(),
@@ -428,7 +428,7 @@ function appendBarText(gd, plotinfo, bar, cd, i, x0, x1, y0, y1, opts, makeOnCom
428
428
  }
429
429
 
430
430
  transform.fontSize = font.size;
431
- recordMinTextSize(trace.type, transform, fullLayout);
431
+ recordMinTextSize(trace.type === 'histogram' ? 'bar' : trace.type, transform, fullLayout);
432
432
  calcBar.transform = transform;
433
433
 
434
434
  transition(textSelection, fullLayout, opts, makeOnCompleteCallback)
@@ -3,6 +3,8 @@
3
3
  var barAttrs = require('../bar/attributes');
4
4
  var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
5
5
  var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
6
+ var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
7
+ var fontAttrs = require('../../plots/font_attributes');
6
8
  var makeBinAttrs = require('./bin_attributes');
7
9
  var constants = require('./constants');
8
10
  var extendFlat = require('../../lib/extend').extendFlat;
@@ -198,6 +200,44 @@ module.exports = {
198
200
  keys: constants.eventDataKeys
199
201
  }),
200
202
 
203
+ texttemplate: texttemplateAttrs({
204
+ arrayOk: false,
205
+ editType: 'plot'
206
+ }, {
207
+ keys: ['label', 'value']
208
+ }),
209
+
210
+ textposition: extendFlat({}, barAttrs.textposition, {
211
+ arrayOk: false
212
+ }),
213
+
214
+ textfont: fontAttrs({
215
+ arrayOk: false,
216
+ editType: 'plot',
217
+ colorEditType: 'style',
218
+ description: 'Sets the text font.'
219
+ }),
220
+
221
+ outsidetextfont: fontAttrs({
222
+ arrayOk: false,
223
+ editType: 'plot',
224
+ colorEditType: 'style',
225
+ description: 'Sets the font used for `text` lying outside the bar.'
226
+ }),
227
+
228
+ insidetextfont: fontAttrs({
229
+ arrayOk: false,
230
+ editType: 'plot',
231
+ colorEditType: 'style',
232
+ description: 'Sets the font used for `text` lying inside the bar.'
233
+ }),
234
+
235
+ insidetextanchor: barAttrs.insidetextanchor,
236
+
237
+ textangle: barAttrs.textangle,
238
+ cliponaxis: barAttrs.cliponaxis,
239
+ constraintext: barAttrs.constraintext,
240
+
201
241
  marker: barAttrs.marker,
202
242
 
203
243
  offsetgroup: barAttrs.offsetgroup,
@@ -4,6 +4,7 @@ var Registry = require('../../registry');
4
4
  var Lib = require('../../lib');
5
5
  var Color = require('../../components/color');
6
6
 
7
+ var handleText = require('../bar/defaults').handleText;
7
8
  var handleStyleDefaults = require('../bar/style_defaults');
8
9
  var attributes = require('./attributes');
9
10
 
@@ -22,6 +23,16 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
22
23
  }
23
24
 
24
25
  coerce('text');
26
+ var textposition = coerce('textposition');
27
+ handleText(traceIn, traceOut, layout, coerce, textposition, {
28
+ moduleHasSelected: true,
29
+ moduleHasUnselected: true,
30
+ moduleHasConstrain: true,
31
+ moduleHasCliponaxis: true,
32
+ moduleHasTextangle: true,
33
+ moduleHasInsideanchor: true
34
+ });
35
+
25
36
  coerce('hovertext');
26
37
  coerce('hovertemplate');
27
38
  coerce('xhoverformat');
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use strict';
2
2
 
3
3
  // package version injected by `npm run preprocess`
4
- exports.version = '2.6.4';
4
+ exports.version = '2.7.0';