plotly.js 2.8.2 → 2.10.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.
Files changed (88) hide show
  1. package/.circleci/config.yml +39 -1
  2. package/.circleci/env_image.sh +1 -1
  3. package/.circleci/test.sh +14 -1
  4. package/CHANGELOG.md +30 -1
  5. package/CONTRIBUTING.md +1 -1
  6. package/README.md +12 -4
  7. package/dist/README.md +26 -26
  8. package/dist/plot-schema.json +413 -0
  9. package/dist/plotly-basic.js +253 -96
  10. package/dist/plotly-basic.min.js +5 -5
  11. package/dist/plotly-cartesian.js +263 -97
  12. package/dist/plotly-cartesian.min.js +5 -5
  13. package/dist/plotly-finance.js +254 -96
  14. package/dist/plotly-finance.min.js +4 -4
  15. package/dist/plotly-geo-assets.js +3 -3
  16. package/dist/plotly-geo.js +248 -92
  17. package/dist/plotly-geo.min.js +4 -4
  18. package/dist/plotly-gl2d.js +248 -92
  19. package/dist/plotly-gl2d.min.js +7 -7
  20. package/dist/plotly-gl3d.js +249 -92
  21. package/dist/plotly-gl3d.min.js +3 -3
  22. package/dist/plotly-locale-cs.js +1 -1
  23. package/dist/plotly-locale-cy.js +1 -1
  24. package/dist/plotly-locale-de.js +1 -1
  25. package/dist/plotly-locale-es.js +1 -1
  26. package/dist/plotly-locale-fi.js +1 -1
  27. package/dist/plotly-locale-fr.js +1 -1
  28. package/dist/plotly-locale-it.js +1 -1
  29. package/dist/plotly-locale-ja.js +1 -1
  30. package/dist/plotly-locale-ko.js +1 -1
  31. package/dist/plotly-locale-pt-br.js +1 -1
  32. package/dist/plotly-locale-pt-pt.js +1 -1
  33. package/dist/plotly-locale-ru.js +1 -1
  34. package/dist/plotly-locale-sv.js +1 -1
  35. package/dist/plotly-locale-sw.js +1 -1
  36. package/dist/plotly-locale-uk.js +1 -1
  37. package/dist/plotly-locale-zh-cn.js +1 -1
  38. package/dist/plotly-mapbox.js +248 -92
  39. package/dist/plotly-mapbox.min.js +3 -3
  40. package/dist/plotly-strict.js +267 -97
  41. package/dist/plotly-strict.min.js +7 -7
  42. package/dist/plotly-with-meta.js +280 -97
  43. package/dist/plotly.js +268 -97
  44. package/dist/plotly.min.js +11 -11
  45. package/dist/translation-keys.txt +1 -1
  46. package/lib/locales/cs.js +1 -1
  47. package/lib/locales/cy.js +1 -1
  48. package/lib/locales/de.js +1 -1
  49. package/lib/locales/es.js +1 -1
  50. package/lib/locales/fi.js +1 -1
  51. package/lib/locales/fr.js +1 -1
  52. package/lib/locales/it.js +1 -1
  53. package/lib/locales/ja.js +1 -1
  54. package/lib/locales/ko.js +1 -1
  55. package/lib/locales/pt-br.js +1 -1
  56. package/lib/locales/pt-pt.js +1 -1
  57. package/lib/locales/ru.js +1 -1
  58. package/lib/locales/sv.js +1 -1
  59. package/lib/locales/sw.js +1 -1
  60. package/lib/locales/uk.js +1 -1
  61. package/lib/locales/zh-cn.js +1 -1
  62. package/package.json +15 -12
  63. package/src/components/colorbar/attributes.js +1 -0
  64. package/src/components/colorbar/draw.js +1 -0
  65. package/src/components/drawing/index.js +28 -24
  66. package/src/components/legend/draw.js +2 -1
  67. package/src/components/legend/style.js +10 -6
  68. package/src/components/modebar/modebar.js +7 -1
  69. package/src/lib/svg_text_utils.js +106 -21
  70. package/src/plot_api/plot_config.js +9 -0
  71. package/src/plots/cartesian/axes.js +47 -5
  72. package/src/plots/cartesian/layout_attributes.js +14 -0
  73. package/src/plots/cartesian/tick_label_defaults.js +8 -0
  74. package/src/plots/gl3d/layout/axis_defaults.js +1 -0
  75. package/src/plots/polar/layout_attributes.js +1 -0
  76. package/src/plots/smith/layout_defaults.js +1 -0
  77. package/src/plots/ternary/layout_attributes.js +1 -0
  78. package/src/snapshot/tosvg.js +14 -25
  79. package/src/traces/bar/plot.js +5 -4
  80. package/src/traces/carpet/ab_defaults.js +1 -0
  81. package/src/traces/indicator/attributes.js +1 -0
  82. package/src/traces/scatter/attributes.js +2 -0
  83. package/src/traces/scatter/defaults.js +2 -0
  84. package/src/traces/scatter/plot.js +4 -4
  85. package/src/traces/scatter/style.js +1 -1
  86. package/src/version.js +1 -1
  87. package/tasks/noci_test.sh +1 -1
  88. package/.vscode/launch.json +0 -0
@@ -22,6 +22,15 @@ var configAttributes = {
22
22
  ].join(' ')
23
23
  },
24
24
 
25
+ typesetMath: {
26
+ valType: 'boolean',
27
+ dflt: true,
28
+ description: [
29
+ 'Determines whether math should be typeset or not,',
30
+ 'when MathJax (either v2 or v3) is present on the page.'
31
+ ].join(' ')
32
+ },
33
+
25
34
  plotlyServerURL: {
26
35
  valType: 'string',
27
36
  dflt: '',
@@ -803,7 +803,8 @@ axes.calcTicks = function calcTicks(ax, opts) {
803
803
  var minRange = Math.min(rng[0], rng[1]);
804
804
  var maxRange = Math.max(rng[0], rng[1]);
805
805
 
806
- var isDLog = (ax.type === 'log') && !(isNumeric(ax.dtick) || ax.dtick.charAt(0) === 'L');
806
+ var numDtick = isNumeric(ax.dtick);
807
+ var isDLog = (ax.type === 'log') && !(numDtick || ax.dtick.charAt(0) === 'L');
807
808
  var isPeriod = ax.ticklabelmode === 'period';
808
809
 
809
810
  // find the first tick
@@ -834,13 +835,36 @@ axes.calcTicks = function calcTicks(ax, opts) {
834
835
  x = axes.tickIncrement(x, ax.dtick, !axrev, ax.calendar);
835
836
  }
836
837
 
838
+ var ticklabelstep = ax.ticklabelstep;
839
+
837
840
  var maxTicks = Math.max(1000, ax._length || 0);
838
841
  var tickVals = [];
839
842
  var xPrevious = null;
843
+
844
+ var dTick;
845
+ if(numDtick) {
846
+ dTick = ax.dtick;
847
+ } else {
848
+ if(ax.type === 'date') {
849
+ if(typeof ax.dtick === 'string' && ax.dtick.charAt(0) === 'M') {
850
+ dTick = ONEAVGMONTH * ax.dtick.substring(1);
851
+ }
852
+ } else {
853
+ dTick = ax._roughDTick;
854
+ }
855
+ }
856
+
857
+ var id = Math.round((
858
+ ax.r2l(x) -
859
+ ax.r2l(ax.tick0)
860
+ ) / dTick) - 1;
861
+
840
862
  for(;
841
863
  (axrev) ? (x >= endTick) : (x <= endTick);
842
864
  x = axes.tickIncrement(x, ax.dtick, axrev, ax.calendar)
843
865
  ) {
866
+ id++;
867
+
844
868
  if(ax.rangebreaks) {
845
869
  if(!axrev) {
846
870
  if(x < startTick) continue;
@@ -858,10 +882,16 @@ axes.calcTicks = function calcTicks(ax, opts) {
858
882
  minor = true;
859
883
  }
860
884
 
861
- tickVals.push({
885
+ var obj = {
862
886
  minor: minor,
863
887
  value: x
864
- });
888
+ };
889
+
890
+ if(ticklabelstep > 1 && id % ticklabelstep) {
891
+ obj.skipLabel = true;
892
+ }
893
+
894
+ tickVals.push(obj);
865
895
  }
866
896
 
867
897
  if(isPeriod) positionPeriodTicks(tickVals, ax, ax._definedDelta);
@@ -914,12 +944,20 @@ axes.calcTicks = function calcTicks(ax, opts) {
914
944
  ax._prevDateHead = '';
915
945
  ax._inCalcTicks = true;
916
946
 
947
+ var lastVisibleHead;
948
+ var hideLabel = function(tick) {
949
+ tick.text = ' '; // don't use an empty string here which can confuse automargin (issue 5132)
950
+ ax._prevDateHead = lastVisibleHead;
951
+ };
952
+
917
953
  var ticksOut = [];
918
954
  var t, p;
919
955
  for(i = 0; i < tickVals.length; i++) {
920
956
  var _minor = tickVals[i].minor;
921
957
  var _value = tickVals[i].value;
922
958
 
959
+ lastVisibleHead = ax._prevDateHead;
960
+
923
961
  t = axes.tickText(
924
962
  ax,
925
963
  _value,
@@ -934,11 +972,14 @@ axes.calcTicks = function calcTicks(ax, opts) {
934
972
  if(p > maxRange) t.periodX = maxRange;
935
973
  if(p < minRange) t.periodX = minRange;
936
974
 
937
- t.text = ' '; // don't use an empty string here which can confuse automargin (issue 5132)
938
- ax._prevDateHead = '';
975
+ hideLabel(t);
939
976
  }
940
977
  }
941
978
 
979
+ if(tickVals[i].skipLabel) {
980
+ hideLabel(t);
981
+ }
982
+
942
983
  ticksOut.push(t);
943
984
  }
944
985
 
@@ -2966,6 +3007,7 @@ axes.drawLabels = function(gd, ax, opts) {
2966
3007
  var axId = ax._id;
2967
3008
  var axLetter = axId.charAt(0);
2968
3009
  var cls = opts.cls || axId + 'tick';
3010
+
2969
3011
  var vals = opts.vals;
2970
3012
 
2971
3013
  var labelFns = opts.labelFns;
@@ -412,6 +412,20 @@ module.exports = {
412
412
  'To set ticks every 4 years, set `dtick` to *M48*'
413
413
  ].join(' ')
414
414
  },
415
+ ticklabelstep: {
416
+ valType: 'integer',
417
+ min: 1,
418
+ dflt: 1,
419
+ editType: 'ticks',
420
+ description: [
421
+ 'Sets the spacing between tick labels as compared to the spacing between ticks.',
422
+ 'A value of 1 (default) means each tick gets a label.',
423
+ 'A value of 2 means shows every 2nd label.',
424
+ 'A larger value n means only every nth tick is labeled.',
425
+ '`tick0` determines which labels are shown.',
426
+ 'Not implemented for axes with `type` *log* or *multicategory*, or when `tickmode` is *array*.'
427
+ ].join(' ')
428
+ },
415
429
  tickvals: {
416
430
  valType: 'data_array',
417
431
  editType: 'ticks',
@@ -28,6 +28,14 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
28
28
  color: dfltFontColor
29
29
  });
30
30
 
31
+ if(
32
+ !options.noTicklabelstep &&
33
+ axType !== 'multicategory' &&
34
+ axType !== 'log'
35
+ ) {
36
+ coerce('ticklabelstep');
37
+ }
38
+
31
39
  if(!options.noAng) coerce('tickangle');
32
40
 
33
41
  if(axType !== 'category') {
@@ -43,6 +43,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) {
43
43
  showGrid: true,
44
44
  noTickson: true,
45
45
  noTicklabelmode: true,
46
+ noTicklabelstep: true,
46
47
  noTicklabelposition: true,
47
48
  noTicklabeloverflow: true,
48
49
  bgColor: options.bgColor,
@@ -32,6 +32,7 @@ var axisTickAttrs = overrideAll({
32
32
  ticklen: axesAttrs.ticklen,
33
33
  tickwidth: axesAttrs.tickwidth,
34
34
  tickcolor: axesAttrs.tickcolor,
35
+ ticklabelstep: axesAttrs.ticklabelstep,
35
36
  showticklabels: axesAttrs.showticklabels,
36
37
  showtickprefix: axesAttrs.showtickprefix,
37
38
  tickprefix: axesAttrs.tickprefix,
@@ -83,6 +83,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
83
83
  }
84
84
 
85
85
  handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
86
+ noTicklabelstep: true,
86
87
  noAng: !isRealAxis,
87
88
  noExp: true,
88
89
  font: {
@@ -25,6 +25,7 @@ var ternaryAxesAttrs = {
25
25
  ticklen: axesAttrs.ticklen,
26
26
  tickwidth: axesAttrs.tickwidth,
27
27
  tickcolor: axesAttrs.tickcolor,
28
+ ticklabelstep: axesAttrs.ticklabelstep,
28
29
  showticklabels: axesAttrs.showticklabels,
29
30
  showtickprefix: axesAttrs.showtickprefix,
30
31
  tickprefix: axesAttrs.tickprefix,
@@ -33,7 +33,7 @@ module.exports = function toSVG(gd, format, scale) {
33
33
  var toppaper = fullLayout._toppaper;
34
34
  var width = fullLayout.width;
35
35
  var height = fullLayout.height;
36
- var i, k;
36
+ var i;
37
37
 
38
38
  // make background color a rect in the svg, then revert after scraping
39
39
  // all other alterations have been dealt with by properly preparing the svg
@@ -106,32 +106,21 @@ module.exports = function toSVG(gd, format, scale) {
106
106
  }
107
107
  });
108
108
 
109
- var queryParts = [];
110
- if(fullLayout._gradientUrlQueryParts) {
111
- for(k in fullLayout._gradientUrlQueryParts) queryParts.push(k);
112
- }
113
-
114
- if(fullLayout._patternUrlQueryParts) {
115
- for(k in fullLayout._patternUrlQueryParts) queryParts.push(k);
116
- }
109
+ svg.selectAll('.gradient_filled,.pattern_filled').each(function() {
110
+ var pt = d3.select(this);
117
111
 
118
- if(queryParts.length) {
119
- svg.selectAll(queryParts.join(',')).each(function() {
120
- var pt = d3.select(this);
121
-
122
- // similar to font family styles above,
123
- // we must remove " after the SVG DOM has been serialized
124
- var fill = this.style.fill;
125
- if(fill && fill.indexOf('url(') !== -1) {
126
- pt.style('fill', fill.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB));
127
- }
112
+ // similar to font family styles above,
113
+ // we must remove " after the SVG DOM has been serialized
114
+ var fill = this.style.fill;
115
+ if(fill && fill.indexOf('url(') !== -1) {
116
+ pt.style('fill', fill.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB));
117
+ }
128
118
 
129
- var stroke = this.style.stroke;
130
- if(stroke && stroke.indexOf('url(') !== -1) {
131
- pt.style('stroke', stroke.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB));
132
- }
133
- });
134
- }
119
+ var stroke = this.style.stroke;
120
+ if(stroke && stroke.indexOf('url(') !== -1) {
121
+ pt.style('stroke', stroke.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB));
122
+ }
123
+ });
135
124
 
136
125
  if(format === 'pdf' || format === 'eps') {
137
126
  // these formats make the extra line MathJax adds around symbols look super thick in some cases
@@ -629,6 +629,7 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) {
629
629
  var trace = cd[0].trace;
630
630
  var texttemplate = Lib.castOption(trace, index, 'texttemplate');
631
631
  if(!texttemplate) return '';
632
+ var isHistogram = (trace.type === 'histogram');
632
633
  var isWaterfall = (trace.type === 'waterfall');
633
634
  var isFunnel = (trace.type === 'funnel');
634
635
  var isHorizontal = trace.orientation === 'h';
@@ -670,10 +671,10 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) {
670
671
  var pt = {};
671
672
  appendArrayPointValue(pt, trace, cdi.i);
672
673
 
673
- if(pt.x === undefined) pt.x = isHorizontal ? obj.value : obj.label;
674
- if(pt.y === undefined) pt.y = isHorizontal ? obj.label : obj.value;
675
- if(pt.xLabel === undefined) pt.xLabel = isHorizontal ? obj.valueLabel : obj.labelLabel;
676
- if(pt.yLabel === undefined) pt.yLabel = isHorizontal ? obj.labelLabel : obj.valueLabel;
674
+ if(isHistogram || pt.x === undefined) pt.x = isHorizontal ? obj.value : obj.label;
675
+ if(isHistogram || pt.y === undefined) pt.y = isHorizontal ? obj.label : obj.value;
676
+ if(isHistogram || pt.xLabel === undefined) pt.xLabel = isHorizontal ? obj.valueLabel : obj.labelLabel;
677
+ if(isHistogram || pt.yLabel === undefined) pt.yLabel = isHorizontal ? obj.labelLabel : obj.valueLabel;
677
678
 
678
679
  if(isWaterfall) {
679
680
  obj.delta = +cdi.rawS || cdi.s;
@@ -30,6 +30,7 @@ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) {
30
30
  var axOut = Template.newContainer(traceOut, axName);
31
31
 
32
32
  var defaultOptions = {
33
+ noTicklabelstep: true,
33
34
  tickfont: 'x',
34
35
  id: axLetter + 'axis',
35
36
  letter: axLetter,
@@ -301,6 +301,7 @@ module.exports = {
301
301
  ticklen: axesAttrs.ticklen,
302
302
  tickwidth: axesAttrs.tickwidth,
303
303
  tickcolor: axesAttrs.tickcolor,
304
+ ticklabelstep: axesAttrs.ticklabelstep,
304
305
  showticklabels: axesAttrs.showticklabels,
305
306
  tickfont: fontAttrs({
306
307
  description: 'Sets the color bar\'s tick label font'
@@ -6,6 +6,7 @@ var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplat
6
6
  var colorScaleAttrs = require('../../components/colorscale/attributes');
7
7
  var fontAttrs = require('../../plots/font_attributes');
8
8
  var dash = require('../../components/drawing/attributes').dash;
9
+ var pattern = require('../../components/drawing/attributes').pattern;
9
10
 
10
11
  var Drawing = require('../../components/drawing');
11
12
  var constants = require('./constants');
@@ -363,6 +364,7 @@ module.exports = {
363
364
  'marker color, or marker line color, whichever is available.'
364
365
  ].join(' ')
365
366
  },
367
+ fillpattern: pattern,
366
368
  marker: extendFlat({
367
369
  symbol: {
368
370
  valType: 'enumerated',
@@ -14,6 +14,7 @@ var handleLineDefaults = require('./line_defaults');
14
14
  var handleLineShapeDefaults = require('./line_shape_defaults');
15
15
  var handleTextDefaults = require('./text_defaults');
16
16
  var handleFillColorDefaults = require('./fillcolor_defaults');
17
+ var coercePattern = require('../../lib').coercePattern;
17
18
 
18
19
  module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
19
20
  function coerce(attr, dflt) {
@@ -67,6 +68,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
67
68
  if(traceOut.fill !== 'none') {
68
69
  handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
69
70
  if(!subTypes.hasLines(traceOut)) handleLineShapeDefaults(traceIn, traceOut, coerce);
71
+ coercePattern(coerce, 'fillpattern', traceOut.fillcolor, false);
70
72
  }
71
73
 
72
74
  var lineColor = (traceOut.line || {}).color;
@@ -304,11 +304,11 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
304
304
  // the points on the axes are the first two points. Otherwise
305
305
  // animations get a little crazy if the number of points changes.
306
306
  transition(ownFillEl3).attr('d', 'M' + pt1 + 'L' + pt0 + 'L' + fullpath.substr(1))
307
- .call(Drawing.singleFillStyle);
307
+ .call(Drawing.singleFillStyle, gd);
308
308
  } else {
309
309
  // fill to self: just join the path to itself
310
310
  transition(ownFillEl3).attr('d', fullpath + 'Z')
311
- .call(Drawing.singleFillStyle);
311
+ .call(Drawing.singleFillStyle, gd);
312
312
  }
313
313
  }
314
314
  } else if(tonext) {
@@ -320,7 +320,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
320
320
  // This makes strange results if one path is *not* entirely
321
321
  // inside the other, but then that is a strange usage.
322
322
  transition(tonext).attr('d', fullpath + 'Z' + prevRevpath + 'Z')
323
- .call(Drawing.singleFillStyle);
323
+ .call(Drawing.singleFillStyle, gd);
324
324
  } else {
325
325
  // tonextx/y: for now just connect endpoints with lines. This is
326
326
  // the correct behavior if the endpoints are at the same value of
@@ -328,7 +328,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
328
328
  // things depending on whether the new endpoint projects onto the
329
329
  // existing curve or off the end of it
330
330
  transition(tonext).attr('d', fullpath + 'L' + prevRevpath.substr(1) + 'Z')
331
- .call(Drawing.singleFillStyle);
331
+ .call(Drawing.singleFillStyle, gd);
332
332
  }
333
333
  trace._polygons = trace._polygons.concat(prevPolygons);
334
334
  } else {
@@ -27,7 +27,7 @@ function style(gd) {
27
27
  .call(Drawing.lineGroupStyle);
28
28
 
29
29
  s.selectAll('g.trace path.js-fill')
30
- .call(Drawing.fillGroupStyle);
30
+ .call(Drawing.fillGroupStyle, gd);
31
31
 
32
32
  Registry.getComponentMethod('errorbars', 'style')(s);
33
33
  }
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.8.2';
4
+ exports.version = '2.10.0';
@@ -28,7 +28,7 @@ test_image () {
28
28
  $root/../orca/bin/orca.js graph \
29
29
  $root/test/image/mocks/mapbox_osm-style.json \
30
30
  $root/test/image/mocks/mapbox_density0-legend.json \
31
- --mathjax $root/node_modules/mathjax/MathJax.js \
31
+ --mathjax $root/node_modules/mathjax-v2/MathJax.js \
32
32
  --plotly $root/build/plotly.js \
33
33
  --mapbox-access-token "pk.eyJ1IjoicGxvdGx5LWpzLXRlc3RzIiwiYSI6ImNrNG9meTJmOTAxa3UzZm10dWdteDQ2eWMifQ.2REjOFyIrleMqwS8H8y1-A" \
34
34
  --output-dir $root/test/image/baselines/ \
File without changes