@websy/websy-designs 1.4.2 → 1.4.3

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.
@@ -5953,9 +5953,11 @@ class WebsyTable3 {
5953
5953
  }
5954
5954
  else if (data) {
5955
5955
  let longest = ''
5956
- for (let i = 0; i < Math.min(data.length, 1000); i++) {
5957
- if (longest.length < data[i][colIndex].value.length) {
5958
- longest = data[i][colIndex].value
5956
+ for (let i = 0; i < Math.min(data.length, 1000); i++) {
5957
+ if (data[i].length === this.options.columns[this.options.columns.length - 1].length) {
5958
+ if (longest.length < data[i][colIndex].value.length) {
5959
+ longest = data[i][colIndex].value
5960
+ }
5959
5961
  }
5960
5962
  }
5961
5963
  output.push({value: longest})
@@ -6467,6 +6467,8 @@ var WebsyTable3 = /*#__PURE__*/function () {
6467
6467
  }, {
6468
6468
  key: "createSample",
6469
6469
  value: function createSample(data) {
6470
+ var _this39 = this;
6471
+
6470
6472
  var output = [];
6471
6473
  this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
6472
6474
  if (col.maxLength) {
@@ -6477,8 +6479,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6477
6479
  var longest = '';
6478
6480
 
6479
6481
  for (var i = 0; i < Math.min(data.length, 1000); i++) {
6480
- if (longest.length < data[i][colIndex].value.length) {
6481
- longest = data[i][colIndex].value;
6482
+ if (data[i].length === _this39.options.columns[_this39.options.columns.length - 1].length) {
6483
+ if (longest.length < data[i][colIndex].value.length) {
6484
+ longest = data[i][colIndex].value;
6485
+ }
6482
6486
  }
6483
6487
  }
6484
6488
 
@@ -6868,7 +6872,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6868
6872
 
6869
6873
  var WebsyChart = /*#__PURE__*/function () {
6870
6874
  function WebsyChart(elementId, options) {
6871
- var _this39 = this;
6875
+ var _this40 = this;
6872
6876
 
6873
6877
  _classCallCheck(this, WebsyChart);
6874
6878
 
@@ -6919,22 +6923,22 @@ var WebsyChart = /*#__PURE__*/function () {
6919
6923
  this.invertOverride = function (input, input2) {
6920
6924
  var xAxis = 'bottomAxis';
6921
6925
 
6922
- if (_this39.options.orientation === 'horizontal') {
6926
+ if (_this40.options.orientation === 'horizontal') {
6923
6927
  xAxis = 'leftAxis';
6924
6928
  }
6925
6929
 
6926
- var width = _this39[xAxis].step();
6930
+ var width = _this40[xAxis].step();
6927
6931
 
6928
6932
  var output;
6929
6933
 
6930
- var domain = _toConsumableArray(_this39[xAxis].domain());
6934
+ var domain = _toConsumableArray(_this40[xAxis].domain());
6931
6935
 
6932
- if (_this39.options.orientation === 'horizontal') {
6936
+ if (_this40.options.orientation === 'horizontal') {
6933
6937
  domain = domain.reverse();
6934
6938
  }
6935
6939
 
6936
6940
  for (var j = 0; j < domain.length; j++) {
6937
- var breakA = _this39[xAxis](domain[j]) - width / 2;
6941
+ var breakA = _this40[xAxis](domain[j]) - width / 2;
6938
6942
  var breakB = breakA + width;
6939
6943
 
6940
6944
  if (input > breakA && input <= breakB) {
@@ -7034,10 +7038,10 @@ var WebsyChart = /*#__PURE__*/function () {
7034
7038
  }, {
7035
7039
  key: "handleEventMouseMove",
7036
7040
  value: function handleEventMouseMove(event, d) {
7037
- var _this40 = this;
7041
+ var _this41 = this;
7038
7042
 
7039
7043
  var bisectDate = d3.bisector(function (d) {
7040
- return _this40.parseX(d.x.value);
7044
+ return _this41.parseX(d.x.value);
7041
7045
  }).left;
7042
7046
 
7043
7047
  if (this.options.showTrackingLine === true && d3.pointer(event)) {
@@ -7076,8 +7080,8 @@ var WebsyChart = /*#__PURE__*/function () {
7076
7080
  }
7077
7081
 
7078
7082
  this.options.data.series.forEach(function (s) {
7079
- if (_this40.options.data[xData].scale !== 'Time') {
7080
- xPoint = _this40[xAxis](_this40.parseX(xLabel));
7083
+ if (_this41.options.data[xData].scale !== 'Time') {
7084
+ xPoint = _this41[xAxis](_this41.parseX(xLabel));
7081
7085
  s.data.forEach(function (d) {
7082
7086
  if (d.x.value === xLabel) {
7083
7087
  if (!tooltipTitle) {
@@ -7096,13 +7100,13 @@ var WebsyChart = /*#__PURE__*/function () {
7096
7100
  var pointA = s.data[index - 1];
7097
7101
  var pointB = s.data[index];
7098
7102
 
7099
- if (_this40.options.orientation === 'horizontal') {
7103
+ if (_this41.options.orientation === 'horizontal') {
7100
7104
  pointA = _toConsumableArray(s.data).reverse()[index - 1];
7101
7105
  pointB = _toConsumableArray(s.data).reverse()[index];
7102
7106
  }
7103
7107
 
7104
7108
  if (pointA && !pointB) {
7105
- xPoint = _this40[xAxis](_this40.parseX(pointA.x.value));
7109
+ xPoint = _this41[xAxis](_this41.parseX(pointA.x.value));
7106
7110
  tooltipTitle = pointA.x.value;
7107
7111
 
7108
7112
  if (!pointA.y.color) {
@@ -7112,12 +7116,12 @@ var WebsyChart = /*#__PURE__*/function () {
7112
7116
  tooltipData.push(pointA.y);
7113
7117
 
7114
7118
  if (typeof pointA.x.value.getTime !== 'undefined') {
7115
- tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointA.x.value);
7119
+ tooltipTitle = d3.timeFormat(_this41.options.dateFormat || _this41.options.calculatedTimeFormatPattern)(pointA.x.value);
7116
7120
  }
7117
7121
  }
7118
7122
 
7119
7123
  if (pointB && !pointA) {
7120
- xPoint = _this40[xAxis](_this40.parseX(pointB.x.value));
7124
+ xPoint = _this41[xAxis](_this41.parseX(pointB.x.value));
7121
7125
  tooltipTitle = pointB.x.value;
7122
7126
 
7123
7127
  if (!pointB.y.color) {
@@ -7127,14 +7131,14 @@ var WebsyChart = /*#__PURE__*/function () {
7127
7131
  tooltipData.push(pointB.y);
7128
7132
 
7129
7133
  if (typeof pointB.x.value.getTime !== 'undefined') {
7130
- tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointB.x.value);
7134
+ tooltipTitle = d3.timeFormat(_this41.options.dateFormat || _this41.options.calculatedTimeFormatPattern)(pointB.x.value);
7131
7135
  }
7132
7136
  }
7133
7137
 
7134
7138
  if (pointA && pointB) {
7135
- var d0 = _this40[xAxis](_this40.parseX(pointA.x.value));
7139
+ var d0 = _this41[xAxis](_this41.parseX(pointA.x.value));
7136
7140
 
7137
- var d1 = _this40[xAxis](_this40.parseX(pointB.x.value));
7141
+ var d1 = _this41[xAxis](_this41.parseX(pointB.x.value));
7138
7142
 
7139
7143
  var mid = Math.abs(d0 - d1) / 2;
7140
7144
 
@@ -7143,7 +7147,7 @@ var WebsyChart = /*#__PURE__*/function () {
7143
7147
  tooltipTitle = pointB.x.value;
7144
7148
 
7145
7149
  if (typeof pointB.x.value.getTime !== 'undefined') {
7146
- tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointB.x.value);
7150
+ tooltipTitle = d3.timeFormat(_this41.options.dateFormat || _this41.options.calculatedTimeFormatPattern)(pointB.x.value);
7147
7151
  }
7148
7152
 
7149
7153
  if (!pointB.y.color) {
@@ -7156,7 +7160,7 @@ var WebsyChart = /*#__PURE__*/function () {
7156
7160
  tooltipTitle = pointA.x.value;
7157
7161
 
7158
7162
  if (typeof pointB.x.value.getTime !== 'undefined') {
7159
- tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointB.x.value);
7163
+ tooltipTitle = d3.timeFormat(_this41.options.dateFormat || _this41.options.calculatedTimeFormatPattern)(pointB.x.value);
7160
7164
  }
7161
7165
 
7162
7166
  if (!pointA.y.color) {
@@ -7270,7 +7274,7 @@ var WebsyChart = /*#__PURE__*/function () {
7270
7274
  }, {
7271
7275
  key: "render",
7272
7276
  value: function render(options) {
7273
- var _this41 = this;
7277
+ var _this42 = this;
7274
7278
 
7275
7279
  /* global d3 options WebsyUtils */
7276
7280
  if (typeof options !== 'undefined') {
@@ -7339,7 +7343,7 @@ var WebsyChart = /*#__PURE__*/function () {
7339
7343
  var legendData = this.options.data.series.map(function (s, i) {
7340
7344
  return {
7341
7345
  value: s.label || s.key,
7342
- color: s.color || _this41.options.colors[i % _this41.options.colors.length]
7346
+ color: s.color || _this42.options.colors[i % _this42.options.colors.length]
7343
7347
  };
7344
7348
  });
7345
7349
 
@@ -7621,7 +7625,7 @@ var WebsyChart = /*#__PURE__*/function () {
7621
7625
 
7622
7626
  if (this.options.data.bottom.formatter) {
7623
7627
  bAxisFunc.tickFormat(function (d) {
7624
- return _this41.options.data.bottom.formatter(d);
7628
+ return _this42.options.data.bottom.formatter(d);
7625
7629
  });
7626
7630
  }
7627
7631
 
@@ -7647,8 +7651,8 @@ var WebsyChart = /*#__PURE__*/function () {
7647
7651
 
7648
7652
  if (this.options.margin.axisLeft > 0) {
7649
7653
  this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
7650
- if (_this41.options.data.left.formatter) {
7651
- d = _this41.options.data.left.formatter(d);
7654
+ if (_this42.options.data.left.formatter) {
7655
+ d = _this42.options.data.left.formatter(d);
7652
7656
  }
7653
7657
 
7654
7658
  return d;
@@ -7685,8 +7689,8 @@ var WebsyChart = /*#__PURE__*/function () {
7685
7689
 
7686
7690
  if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
7687
7691
  this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
7688
- if (_this41.options.data.right.formatter) {
7689
- d = _this41.options.data.right.formatter(d);
7692
+ if (_this42.options.data.right.formatter) {
7693
+ d = _this42.options.data.right.formatter(d);
7690
7694
  }
7691
7695
 
7692
7696
  return d;
@@ -7725,18 +7729,18 @@ var WebsyChart = /*#__PURE__*/function () {
7725
7729
  this.renderedKeys = {};
7726
7730
  this.options.data.series.forEach(function (series, index) {
7727
7731
  if (!series.key) {
7728
- series.key = _this41.createIdentity();
7732
+ series.key = _this42.createIdentity();
7729
7733
  }
7730
7734
 
7731
7735
  if (!series.color) {
7732
- series.color = _this41.options.colors[index % _this41.options.colors.length];
7736
+ series.color = _this42.options.colors[index % _this42.options.colors.length];
7733
7737
  }
7734
7738
 
7735
- _this41["render".concat(series.type || 'bar')](series, index);
7739
+ _this42["render".concat(series.type || 'bar')](series, index);
7736
7740
 
7737
- _this41.renderLabels(series, index);
7741
+ _this42.renderLabels(series, index);
7738
7742
 
7739
- _this41.renderedKeys[series.key] = series.type;
7743
+ _this42.renderedKeys[series.key] = series.type;
7740
7744
  });
7741
7745
  }
7742
7746
  }
@@ -7744,17 +7748,17 @@ var WebsyChart = /*#__PURE__*/function () {
7744
7748
  }, {
7745
7749
  key: "renderarea",
7746
7750
  value: function renderarea(series, index) {
7747
- var _this42 = this;
7751
+ var _this43 = this;
7748
7752
 
7749
7753
  /* global d3 series index */
7750
7754
  var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
7751
7755
  return d3.area().x(function (d) {
7752
- return _this42[xAxis](_this42.parseX(d.x.value));
7756
+ return _this43[xAxis](_this43.parseX(d.x.value));
7753
7757
  }).y0(function (d) {
7754
- return _this42[yAxis](0);
7758
+ return _this43[yAxis](0);
7755
7759
  }).y1(function (d) {
7756
- return _this42[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
7757
- }).curve(d3[curveStyle || _this42.options.curveStyle]);
7760
+ return _this43[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
7761
+ }).curve(d3[curveStyle || _this43.options.curveStyle]);
7758
7762
  };
7759
7763
 
7760
7764
  var xAxis = 'bottomAxis';
@@ -7877,7 +7881,7 @@ var WebsyChart = /*#__PURE__*/function () {
7877
7881
  }, {
7878
7882
  key: "renderLabels",
7879
7883
  value: function renderLabels(series, index) {
7880
- var _this43 = this;
7884
+ var _this44 = this;
7881
7885
 
7882
7886
  /* global series index d3 WebsyDesigns */
7883
7887
  var xAxis = 'bottomAxis';
@@ -7896,11 +7900,11 @@ var WebsyChart = /*#__PURE__*/function () {
7896
7900
  var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
7897
7901
  labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
7898
7902
  labels.attr('x', function (d) {
7899
- return getLabelX.call(_this43, d, series.labelPosition);
7903
+ return getLabelX.call(_this44, d, series.labelPosition);
7900
7904
  }).attr('y', function (d) {
7901
- return getLabelY.call(_this43, d, series.labelPosition);
7905
+ return getLabelY.call(_this44, d, series.labelPosition);
7902
7906
  }).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
7903
- return _this43.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
7907
+ return _this44.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
7904
7908
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
7905
7909
  return d.y.label || d.y.value;
7906
7910
  }).each(function (d, i) {
@@ -7925,11 +7929,11 @@ var WebsyChart = /*#__PURE__*/function () {
7925
7929
  }
7926
7930
  });
7927
7931
  labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', function (d) {
7928
- return getLabelX.call(_this43, d, series.labelPosition);
7932
+ return getLabelX.call(_this44, d, series.labelPosition);
7929
7933
  }).attr('y', function (d) {
7930
- return getLabelY.call(_this43, d, series.labelPosition);
7934
+ return getLabelY.call(_this44, d, series.labelPosition);
7931
7935
  }).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
7932
- return _this43.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
7936
+ return _this44.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
7933
7937
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
7934
7938
  return d.y.label || d.y.value;
7935
7939
  }).each(function (d, i) {
@@ -7986,16 +7990,16 @@ var WebsyChart = /*#__PURE__*/function () {
7986
7990
  }, {
7987
7991
  key: "renderline",
7988
7992
  value: function renderline(series, index) {
7989
- var _this44 = this;
7993
+ var _this45 = this;
7990
7994
 
7991
7995
  /* global series index d3 */
7992
7996
  var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
7993
7997
  return d3.line().x(function (d) {
7994
- var adjustment = _this44.options.data[xAxis].scale === 'Time' ? 0 : _this44["".concat(xAxis, "Axis")].bandwidth() / 2;
7995
- return _this44["".concat(xAxis, "Axis")](_this44.parseX(d.x.value)) + adjustment;
7998
+ var adjustment = _this45.options.data[xAxis].scale === 'Time' ? 0 : _this45["".concat(xAxis, "Axis")].bandwidth() / 2;
7999
+ return _this45["".concat(xAxis, "Axis")](_this45.parseX(d.x.value)) + adjustment;
7996
8000
  }).y(function (d) {
7997
- return _this44["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
7998
- }).curve(d3[curveStyle || _this44.options.curveStyle]);
8001
+ return _this45["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8002
+ }).curve(d3[curveStyle || _this45.options.curveStyle]);
7999
8003
  };
8000
8004
 
8001
8005
  var xAxis = 'bottom';
@@ -8039,14 +8043,14 @@ var WebsyChart = /*#__PURE__*/function () {
8039
8043
  }, {
8040
8044
  key: "rendersymbol",
8041
8045
  value: function rendersymbol(series, index) {
8042
- var _this45 = this;
8046
+ var _this46 = this;
8043
8047
 
8044
8048
  /* global d3 series index series.key */
8045
8049
  var drawSymbol = function drawSymbol(size) {
8046
8050
  return d3.symbol() // .type(d => {
8047
8051
  // return d3.symbols[0]
8048
8052
  // })
8049
- .size(size || _this45.options.symbolSize);
8053
+ .size(size || _this46.options.symbolSize);
8050
8054
  };
8051
8055
 
8052
8056
  var xAxis = 'bottomAxis';
@@ -8064,7 +8068,7 @@ var WebsyChart = /*#__PURE__*/function () {
8064
8068
  symbols.attr('d', function (d) {
8065
8069
  return drawSymbol(d.y.size || series.symbolSize)(d);
8066
8070
  }).transition(this.transition).attr('fill', 'white').attr('stroke', series.color).attr('transform', function (d) {
8067
- return "translate(".concat(_this45[xAxis](_this45.parseX(d.x.value)), ", ").concat(_this45[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
8071
+ return "translate(".concat(_this46[xAxis](_this46.parseX(d.x.value)), ", ").concat(_this46[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
8068
8072
  }); // Enter
8069
8073
 
8070
8074
  symbols.enter().append('path').attr('d', function (d) {
@@ -8073,7 +8077,7 @@ var WebsyChart = /*#__PURE__*/function () {
8073
8077
  .attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
8074
8078
  return "symbol symbol_".concat(series.key);
8075
8079
  }).attr('transform', function (d) {
8076
- return "translate(".concat(_this45[xAxis](_this45.parseX(d.x.value)), ", ").concat(_this45[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
8080
+ return "translate(".concat(_this46[xAxis](_this46.parseX(d.x.value)), ", ").concat(_this46[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
8077
8081
  });
8078
8082
  }
8079
8083
  }, {
@@ -8228,7 +8232,7 @@ var WebsyLegend = /*#__PURE__*/function () {
8228
8232
  }, {
8229
8233
  key: "resize",
8230
8234
  value: function resize() {
8231
- var _this46 = this;
8235
+ var _this47 = this;
8232
8236
 
8233
8237
  var el = document.getElementById(this.elementId);
8234
8238
 
@@ -8241,7 +8245,7 @@ var WebsyLegend = /*#__PURE__*/function () {
8241
8245
  // }
8242
8246
  var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
8243
8247
  html += this._data.map(function (d, i) {
8244
- return _this46.getLegendItemHTML(d);
8248
+ return _this47.getLegendItemHTML(d);
8245
8249
  }).join('');
8246
8250
  html += "\n <div>\n ";
8247
8251
  el.innerHTML = html;
@@ -8413,7 +8417,7 @@ var WebsyMap = /*#__PURE__*/function () {
8413
8417
  }, {
8414
8418
  key: "render",
8415
8419
  value: function render() {
8416
- var _this47 = this;
8420
+ var _this48 = this;
8417
8421
 
8418
8422
  var mapEl = document.getElementById("".concat(this.elementId, "_map"));
8419
8423
  var legendEl = document.getElementById("".concat(this.elementId, "_map"));
@@ -8422,7 +8426,7 @@ var WebsyMap = /*#__PURE__*/function () {
8422
8426
  var legendData = this.options.data.polygons.map(function (s, i) {
8423
8427
  return {
8424
8428
  value: s.label || s.key,
8425
- color: s.color || _this47.options.colors[i % _this47.options.colors.length]
8429
+ color: s.color || _this48.options.colors[i % _this48.options.colors.length]
8426
8430
  };
8427
8431
  });
8428
8432
  var longestValue = legendData.map(function (s) {
@@ -8486,7 +8490,7 @@ var WebsyMap = /*#__PURE__*/function () {
8486
8490
 
8487
8491
  if (this.polygons) {
8488
8492
  this.polygons.forEach(function (p) {
8489
- return _this47.map.removeLayer(p);
8493
+ return _this48.map.removeLayer(p);
8490
8494
  });
8491
8495
  }
8492
8496
 
@@ -8544,18 +8548,18 @@ var WebsyMap = /*#__PURE__*/function () {
8544
8548
  }
8545
8549
 
8546
8550
  if (!p.options.color) {
8547
- p.options.color = _this47.options.colors[i % _this47.options.colors.length];
8551
+ p.options.color = _this48.options.colors[i % _this48.options.colors.length];
8548
8552
  }
8549
8553
 
8550
8554
  var pol = L.polygon(p.data.map(function (c) {
8551
8555
  return c.map(function (d) {
8552
8556
  return [d.Latitude, d.Longitude];
8553
8557
  });
8554
- }), p.options).addTo(_this47.map);
8558
+ }), p.options).addTo(_this48.map);
8555
8559
 
8556
- _this47.polygons.push(pol);
8560
+ _this48.polygons.push(pol);
8557
8561
 
8558
- _this47.map.fitBounds(pol.getBounds());
8562
+ _this48.map.fitBounds(pol.getBounds());
8559
8563
  });
8560
8564
  } // if (this.data.markers.length > 0) {
8561
8565
  // el.classList.remove('hidden')