@websy/websy-designs 1.4.33 → 1.4.35

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.
@@ -6686,6 +6686,12 @@ var WebsyTable3 = /*#__PURE__*/function () {
6686
6686
  headEl.style.width = 'initial';
6687
6687
  bodyEl.style.width = 'initial';
6688
6688
  this.sizes.bodyHeight = this.sizes.table.height - (this.sizes.header.height + this.sizes.total.height);
6689
+
6690
+ if (this.options.maxHeight) {
6691
+ var requiredHeight = ((this.totalRowCount || 9) + 1) * this.sizes.cellHeight;
6692
+ this.sizes.bodyHeight = Math.min(requiredHeight, this.options.maxHeight - (this.sizes.header.height + this.sizes.total.height));
6693
+ }
6694
+
6689
6695
  this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight);
6690
6696
  this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight;
6691
6697
  this.startRow = 0;
@@ -6906,8 +6912,14 @@ var WebsyTable3 = /*#__PURE__*/function () {
6906
6912
  }
6907
6913
 
6908
6914
  var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody")); // bodyEl.innerHTML = this.buildBodyHtml(data, true)
6915
+ // if (this.options.maxHeight) {
6916
+ // bodyEl.style.height = `${this.options.maxHeight - this.sizes.header.height - this.sizes.total.height}px`
6917
+ // }
6918
+ // else {
6919
+ // bodyEl.style.height = `calc(100% - ${this.sizes.header.height}px - ${this.sizes.total.height}px)`
6920
+ // }
6909
6921
 
6910
- bodyEl.style.height = "calc(100% - ".concat(this.sizes.header.height, "px - ").concat(this.sizes.total.height, "px)");
6922
+ bodyEl.style.height = "".concat(this.sizes.bodyHeight, "px");
6911
6923
 
6912
6924
  if (this.options.virtualScroll === true) {
6913
6925
  // set the scroll element positions
@@ -7171,7 +7183,9 @@ var WebsyChart = /*#__PURE__*/function () {
7171
7183
  showTooltip: true,
7172
7184
  showLegend: false,
7173
7185
  legendPosition: 'bottom',
7174
- tooltipWidth: 200
7186
+ tooltipWidth: 200,
7187
+ brushHeight: 50,
7188
+ minBandWidth: 30
7175
7189
  };
7176
7190
  this.elementId = elementId;
7177
7191
  this.options = _extends({}, DEFAULTS, options);
@@ -7180,6 +7194,9 @@ var WebsyChart = /*#__PURE__*/function () {
7180
7194
  this.topAxis = null;
7181
7195
  this.bottomAxis = null;
7182
7196
  this.renderedKeys = {};
7197
+ this.brushedDomain = [];
7198
+ this.brushBarsInitialized = {};
7199
+ this.brushLinesInitialized = {};
7183
7200
 
7184
7201
  if (!elementId) {
7185
7202
  console.log('No element Id provided for Websy Chart');
@@ -7187,12 +7204,19 @@ var WebsyChart = /*#__PURE__*/function () {
7187
7204
  }
7188
7205
 
7189
7206
  this.invertOverride = function (input, input2) {
7190
- var xAxis = 'bottomAxis';
7207
+ var forBrush = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
7208
+ var xAxis = 'bottom';
7191
7209
 
7192
7210
  if (_this42.options.orientation === 'horizontal') {
7193
- xAxis = 'leftAxis';
7211
+ xAxis = 'left';
7194
7212
  }
7195
7213
 
7214
+ if (forBrush === true) {
7215
+ xAxis += 'Brush';
7216
+ }
7217
+
7218
+ xAxis += 'Axis';
7219
+
7196
7220
  var width = _this42[xAxis].step();
7197
7221
 
7198
7222
  var output;
@@ -7216,6 +7240,66 @@ var WebsyChart = /*#__PURE__*/function () {
7216
7240
  return output;
7217
7241
  };
7218
7242
 
7243
+ var that = this;
7244
+
7245
+ this.brushed = function (event) {
7246
+ console.log('brushing', event);
7247
+ that.brushedDomain = [];
7248
+ var xAxis = 'bottom';
7249
+ var xAxisCaps = 'Bottom';
7250
+
7251
+ if (that.options.orientation === 'horizontal') {
7252
+ xAxis = 'left';
7253
+ xAxisCaps = 'Left';
7254
+ }
7255
+
7256
+ if (!that["".concat(xAxis, "Axis")].invert) {
7257
+ that["".concat(xAxis, "Axis")].invert = that.invertOverride;
7258
+ }
7259
+
7260
+ var s = event.selection || that["".concat(xAxis, "Axis")].range();
7261
+
7262
+ if (!event.selection || event.selection.length === 0) {
7263
+ that.brushLayer.select('.brush').call(that.brush).call(that.brush.move, s);
7264
+ return;
7265
+ }
7266
+
7267
+ if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
7268
+ that.brushedDomain = s.map(that["".concat(xAxis, "BrushAxis")].invert, that[["".concat(xAxis, "Axis")]]);
7269
+ } else {
7270
+ var startEndOrdinal = s.map(function (a, b) {
7271
+ return that.bottomAxis.invert(a, b, true);
7272
+ }, that.bottomBrushAxis);
7273
+
7274
+ if (startEndOrdinal && startEndOrdinal.length === 2 && typeof startEndOrdinal[0] !== 'undefined' && typeof startEndOrdinal[1] !== 'undefined') {
7275
+ var domain = [];
7276
+
7277
+ var domainValues = _toConsumableArray(that["".concat(xAxis, "BrushAxis")].domain());
7278
+
7279
+ for (var i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
7280
+ // domain.push(that.xRange[i])
7281
+ that.brushedDomain.push(domainValues[i]);
7282
+ }
7283
+ }
7284
+ }
7285
+
7286
+ if (that.brushedDomain.length > 0) {
7287
+ that["".concat(xAxis, "Axis")].domain(that.brushedDomain);
7288
+ that["".concat(xAxis, "AxisLayer")].call(d3["axis".concat(xAxisCaps)](that["".concat(xAxis, "Axis")]));
7289
+ }
7290
+
7291
+ if (that.leftAxis && that.bottomAxis) {
7292
+ that.renderComponents();
7293
+
7294
+ if (that.options.orientation === 'vertical') {
7295
+ // that.bottomAxisLayer.call(that.bAxisFunc)
7296
+ if (that.options.data.bottom.rotate) {
7297
+ that.bottomAxisLayer.selectAll('text').attr('transform', "rotate(".concat(that.options.data.bottom && that.options.data.bottom.rotate || 0, ")")).style('text-anchor', "".concat((that.options.data.bottom && that.options.data.bottom.rotate || 0) === 0 ? 'middle' : 'end')).style('transform-origin', (that.options.data.bottom && that.options.data.bottom.rotate || 0) === 0 ? '0 0' : "0 ".concat(that.options.data.bottom && that.options.data.bottom.fontSize || that.options.fontSize, "px"));
7298
+ }
7299
+ }
7300
+ }
7301
+ };
7302
+
7219
7303
  var el = document.getElementById(this.elementId);
7220
7304
 
7221
7305
  if (el) {
@@ -7225,10 +7309,18 @@ var WebsyChart = /*#__PURE__*/function () {
7225
7309
  console.error('d3 library has not been loaded');
7226
7310
  } else {
7227
7311
  el.innerHTML = '';
7228
- this.svg = d3.select(el).append('svg');
7312
+ this.svg = d3.select(el).append('svg'); // .attr('id', `${this.elementId}_chartContainer`)
7313
+
7229
7314
  this.legendArea = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_legend")).attr('class', 'websy-chart-legend');
7230
7315
  this.legend = new WebsyDesigns.Legend("".concat(this.elementId, "_legend"), {});
7231
- this.prep();
7316
+ this.prep(); // el.innerHTML += `
7317
+ // <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
7318
+ // <div>
7319
+ // <div id="${this.elementId}_errorTitle"></div>
7320
+ // <div id="${this.elementId}_errorMessage"></div>
7321
+ // </div>
7322
+ // </div>
7323
+ // `
7232
7324
  }
7233
7325
  } else {
7234
7326
  console.error("No element found with ID ".concat(this.elementId));
@@ -7254,30 +7346,43 @@ var WebsyChart = /*#__PURE__*/function () {
7254
7346
  }, {
7255
7347
  key: "createDomain",
7256
7348
  value: function createDomain(side) {
7349
+ var forBrush = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
7257
7350
  var domain = [];
7258
- /* global d3 side domain:writable */
7351
+ /* global d3 side domain:writable forBrush */
7352
+ // if we have a brushed domain we use that
7259
7353
 
7260
- if (typeof this.options.data[side].min !== 'undefined' && typeof this.options.data[side].max !== 'undefined') {
7261
- // domain = [this.options.data[side].min - (this.options.data[side].min * 0.1), this.options.data[side].max * 1.1]
7262
- domain = [this.options.data[side].min, this.options.data[side].max];
7354
+ var xAxis = 'bottom';
7263
7355
 
7264
- if (this.options.forceZero === true) {
7265
- domain = [Math.min(0, this.options.data[side].min), this.options.data[side].max];
7266
- }
7356
+ if (this.options.orientation === 'horizontal') {
7357
+ xAxis = 'left';
7267
7358
  }
7268
7359
 
7269
- if (this.options.data[side].data) {
7270
- domain = this.options.data[side].data.map(function (d) {
7271
- return d.value;
7272
- });
7273
- }
7360
+ if (this.brushedDomain.length > 0 && side === xAxis && forBrush === false) {
7361
+ domain = _toConsumableArray(this.brushedDomain);
7362
+ } else {
7363
+ // otherwise we create the domain
7364
+ if (typeof this.options.data[side].min !== 'undefined' && typeof this.options.data[side].max !== 'undefined') {
7365
+ // domain = [this.options.data[side].min - (this.options.data[side].min * 0.1), this.options.data[side].max * 1.1]
7366
+ domain = [this.options.data[side].min, this.options.data[side].max];
7274
7367
 
7275
- if (this.options.data[side].scale === 'Time') {
7276
- var min = this.options.data[side].data[0].value;
7277
- var max = this.options.data[side].data[this.options.data[side].data.length - 1].value;
7278
- min = this.parseX(min);
7279
- max = this.parseX(max);
7280
- domain = [min, max];
7368
+ if (this.options.forceZero === true) {
7369
+ domain = [Math.min(0, this.options.data[side].min), this.options.data[side].max];
7370
+ }
7371
+ }
7372
+
7373
+ if (this.options.data[side].data) {
7374
+ domain = this.options.data[side].data.map(function (d) {
7375
+ return d.value;
7376
+ });
7377
+ }
7378
+
7379
+ if (this.options.data[side].scale === 'Time') {
7380
+ var min = this.options.data[side].data[0].value;
7381
+ var max = this.options.data[side].data[this.options.data[side].data.length - 1].value;
7382
+ min = this.parseX(min);
7383
+ max = this.parseX(max);
7384
+ domain = [min, max];
7385
+ }
7281
7386
  }
7282
7387
 
7283
7388
  return domain;
@@ -7440,7 +7545,7 @@ var WebsyChart = /*#__PURE__*/function () {
7440
7545
  });
7441
7546
  tooltipHTML = " \n <ul>\n ";
7442
7547
  tooltipHTML += tooltipData.map(function (d) {
7443
- return "\n <li>\n <i style='background-color: ".concat(d.color, ";'></i>\n ").concat(d.tooltipLabel || '', "<span> - ").concat(d.tooltipValue || d.value, "</span>\n </li>\n ");
7548
+ return "\n <li>\n <i style='background-color: ".concat(d.color, ";'></i>\n ").concat(d.tooltipLabel || '', "<span>: ").concat(d.tooltipValue || d.value, "</span>\n </li>\n ");
7444
7549
  }).join('');
7445
7550
  tooltipHTML += "</ul>";
7446
7551
  var posOptions = {
@@ -7518,6 +7623,9 @@ var WebsyChart = /*#__PURE__*/function () {
7518
7623
  key: "prep",
7519
7624
  value: function prep() {
7520
7625
  /* global d3 WebsyDesigns */
7626
+ this.defs = this.svg.append('defs');
7627
+ this.clip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_clip")).append('rect');
7628
+ this.brushClip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_brushclip")).append('rect');
7521
7629
  this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer');
7522
7630
  this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer');
7523
7631
  this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer');
@@ -7534,6 +7642,13 @@ var WebsyChart = /*#__PURE__*/function () {
7534
7642
  this.trackingLineLayer = this.svg.append('g').attr('class', 'tracking-line-layer');
7535
7643
  this.trackingLineLayer.append('line').attr('class', 'tracking-line');
7536
7644
  this.tooltip = new WebsyDesigns.WebsyChartTooltip(this.svg);
7645
+ this.brushLayer = this.svg.append('g'); // .attr(
7646
+ // 'clip-path',
7647
+ // `url(#${this.elementId.replace(/\s/g, '_')}_brushclip)`
7648
+ // )
7649
+
7650
+ this.brushArea = this.brushLayer.append('g').attr('class', 'brush-area');
7651
+ this.brushLayer.append('g').attr('class', 'brush');
7537
7652
  this.eventLayer = this.svg.append('g').attr('class', 'event-line').append('rect');
7538
7653
  this.eventLayer.on('mouseout', this.handleEventMouseOut.bind(this)).on('mousemove', this.handleEventMouseMove.bind(this));
7539
7654
  this.render();
@@ -7673,7 +7788,7 @@ var WebsyChart = /*#__PURE__*/function () {
7673
7788
 
7674
7789
  if (this.options.data.bottom.formatter) {
7675
7790
  this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString();
7676
- firstBottom = this.longestBottom;
7791
+ firstBottom = this.options.data.bottom.formatter(this.options.data.bottom.data[0].value).toString();
7677
7792
  } else {
7678
7793
  if (this.options.data.bottom.scale === 'Time') {
7679
7794
  this.longestBottom = '01/01/2000';
@@ -7681,7 +7796,8 @@ var WebsyChart = /*#__PURE__*/function () {
7681
7796
  } else {
7682
7797
  this.longestBottom = this.options.data.bottom.data.reduce(function (a, b) {
7683
7798
  return a.length > b.value.length ? a : b.value;
7684
- }, '');
7799
+ }, ''); // firstBottom = (this.options.data.bottom.data[0] || [{value: ''}]).value
7800
+
7685
7801
  firstBottom = this.options.data.bottom.data[0].value;
7686
7802
  }
7687
7803
  }
@@ -7773,7 +7889,7 @@ var WebsyChart = /*#__PURE__*/function () {
7773
7889
  if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 && this.options.axis.hideBottom !== true) {
7774
7890
  this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, longestBottomBounds.width / 2);
7775
7891
  } else if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) < 0 && this.options.axis.hideBottom !== true) {
7776
- this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, longestBottomBounds.width);
7892
+ this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, firstBottomWidth / 2);
7777
7893
  } else if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) > 0 && this.options.axis.hideBottom !== true) {
7778
7894
  this.options.margin.axisRight = Math.max(this.options.margin.axisRight, longestBottomBounds.width);
7779
7895
  } // if (this.options.data.bottom.rotate) {
@@ -7806,7 +7922,27 @@ var WebsyChart = /*#__PURE__*/function () {
7806
7922
 
7807
7923
 
7808
7924
  this.plotWidth = this.width - this.options.margin.legendLeft - this.options.margin.legendRight - this.options.margin.left - this.options.margin.right - this.options.margin.axisLeft - this.options.margin.axisRight;
7809
- this.plotHeight = this.height - this.options.margin.legendTop - this.options.margin.legendBottom - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom - this.options.margin.axisTop; // Translate the layers
7925
+ this.plotHeight = this.height - this.options.margin.legendTop - this.options.margin.legendBottom - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom - this.options.margin.axisTop;
7926
+ this.brushNeeded = false;
7927
+
7928
+ if (this.options.orientation === 'vertical') {
7929
+ if (this.options.maxBandWidth) {
7930
+ this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.data || []).length * this.options.maxBandWidth);
7931
+ } // some if to check if brushing is needed
7932
+
7933
+
7934
+ if (this.plotWidth / this.options.data.bottom.data.length < this.options.minBandWidth) {
7935
+ this.brushNeeded = true;
7936
+ this.plotHeight -= this.options.brushHeight;
7937
+ }
7938
+ } else {
7939
+ // some if to check if brushing is needed
7940
+ if (this.plotHeight / this.options.data.left.data.length < this.options.minBandWidth) {
7941
+ this.brushNeeded = true;
7942
+ this.plotWidth -= this.options.brushHeight;
7943
+ }
7944
+ } // Translate the layers
7945
+
7810
7946
 
7811
7947
  this.leftAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")")).style('font-size', this.options.data.left && this.options.data.left.fontSize || this.options.fontSize);
7812
7948
  this.rightAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.plotWidth + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")")).style('font-size', this.options.data.right && this.options.data.right.fontSize || this.options.fontSize);
@@ -7822,19 +7958,71 @@ var WebsyChart = /*#__PURE__*/function () {
7822
7958
  this.symbolLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
7823
7959
  this.refLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
7824
7960
  this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
7961
+ this.brushLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height, ")"));
7962
+ this.brushClip.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height, ")")).attr('width', this.plotWidth).attr('height', this.options.brushHeight);
7825
7963
  this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
7826
7964
  var that = this;
7827
7965
  this.eventLayer.attr('x', 0).attr('y', 0).attr('width', this.plotWidth).attr('height', this.plotHeight).attr('fill-opacity', '0'); // this.tooltip.transform(this.options.margin.left + this.options.margin.axisLeft, this.options.margin.top + this.options.margin.axisTop)
7828
7966
  // Configure the bottom axis
7829
7967
 
7830
7968
  var bottomDomain = this.createDomain('bottom');
7969
+ var bottomBrushDomain = this.createDomain('bottom', true);
7831
7970
  this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomDomain).range([0, this.plotWidth]);
7832
7971
 
7972
+ if (!this.brushInitialized) {
7973
+ this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomBrushDomain).range([0, this.plotWidth]);
7974
+ }
7975
+
7833
7976
  if (this.bottomAxis.nice) {// this.bottomAxis.nice()
7834
7977
  }
7835
7978
 
7836
7979
  if (this.bottomAxis.padding && this.options.data.bottom.padding) {
7837
7980
  this.bottomAxis.padding(this.options.data.bottom.padding || 0);
7981
+ } // BRUSH
7982
+
7983
+
7984
+ var brushMethod = "brushX";
7985
+ var brushLength = this.plotWidth;
7986
+ var brushEnd = this.plotWidth;
7987
+ var brushThickness = this.options.brushHeight;
7988
+
7989
+ if (this.options.orientation === 'horizontal') {
7990
+ brushMethod = 'brushY';
7991
+ brushLength = this.options.brushHeight;
7992
+ brushThickness = this.plotHeight;
7993
+ } else {
7994
+ if (brushLength / bottomDomain.length < this.options.minBandWidth) {
7995
+ brushEnd = this.plotWidth * (this.plotWidth / this.options.minBandWidth / bottomDomain.length);
7996
+ }
7997
+ }
7998
+
7999
+ this.brush = d3[brushMethod]().extent([[0, 0], [brushLength, brushThickness]]).on('brush end', this.brushed);
8000
+
8001
+ var brushResizePath = function brushResizePath(d) {
8002
+ var e = +(d.type === 'e');
8003
+ var x = e ? 1 : -1;
8004
+ var y = _this44.options.brushHeight;
8005
+ return 'M' + 0.5 * x + ',' + y + 'A6,6 0 0 ' + e + ' ' + 6.5 * x + ',' + (y + 6) + 'V' + (2 * y - 6) + 'A6,6 0 0 ' + e + ' ' + 0.5 * x + ',' + 2 * y + 'Z' + 'M' + 2.5 * x + ',' + (y + 8) + 'V' + (2 * y - 8) + 'M' + 4.5 * x + ',' + (y + 8) + 'V' + (2 * y - 8);
8006
+ };
8007
+
8008
+ this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').remove();
8009
+ this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').data([{
8010
+ type: 'w'
8011
+ }, {
8012
+ type: 'e'
8013
+ }]).enter().append('path').attr('class', 'handle--custom').attr('stroke', 'transparent').attr('fill', 'transparent').attr('cursor', 'ew-resize').attr('d', brushResizePath); // BRUSH END
8014
+ // this.brushArea.selectAll('*').remove()
8015
+
8016
+ if (this.brushNeeded) {
8017
+ if (!this.brushInitialized) {
8018
+ this.brushLayer.style('visibility', 'visible');
8019
+ this.brushInitialized = true;
8020
+ this.brushLayer.select('.brush').call(this.brush).call(this.brush.move, [0, brushEnd]);
8021
+ }
8022
+ } else {
8023
+ this.brushLayer.style('visibility', 'hidden'); // this.brushLayer.selectAll().remove()
8024
+
8025
+ this.brushArea.selectAll('*').remove();
7838
8026
  }
7839
8027
 
7840
8028
  if (this.options.margin.axisBottom > 0) {
@@ -7888,17 +8076,15 @@ var WebsyChart = /*#__PURE__*/function () {
7888
8076
  }
7889
8077
 
7890
8078
  this.options.calculatedTimeFormatPattern = timeFormatPattern;
7891
- var bAxisFunc = d3.axisBottom(this.bottomAxis) // .ticks(this.options.data.bottom.ticks || Math.min(this.options.data.bottom.data.length, 5))
7892
- .ticks(tickDefinition); // console.log('tickDefinition', tickDefinition)
7893
- // console.log(bAxisFunc)
8079
+ this.bAxisFunc = d3.axisBottom(this.bottomAxis).ticks(tickDefinition);
7894
8080
 
7895
8081
  if (this.options.data.bottom.formatter) {
7896
- bAxisFunc.tickFormat(function (d) {
8082
+ this.bAxisFunc.tickFormat(function (d) {
7897
8083
  return _this44.options.data.bottom.formatter(d);
7898
8084
  });
7899
8085
  }
7900
8086
 
7901
- this.bottomAxisLayer.call(bAxisFunc); // console.log(this.bottomAxisLayer.ticks)
8087
+ this.bottomAxisLayer.call(this.bAxisFunc); // console.log(this.bottomAxisLayer.ticks)
7902
8088
 
7903
8089
  if (this.options.data.bottom.rotate) {
7904
8090
  this.bottomAxisLayer.selectAll('text').attr('transform', "rotate(".concat(this.options.data.bottom && this.options.data.bottom.rotate || 0, ")")).style('text-anchor', "".concat((this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 ? 'middle' : 'end')).style('transform-origin', (this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 ? '0 0' : "0 ".concat(this.options.data.bottom && this.options.data.bottom.fontSize || this.options.fontSize, "px"));
@@ -7907,8 +8093,10 @@ var WebsyChart = /*#__PURE__*/function () {
7907
8093
 
7908
8094
 
7909
8095
  var leftDomain = this.createDomain('left');
8096
+ var leftBrushDomain = this.createDomain('left', true);
7910
8097
  var rightDomain = this.createDomain('right');
7911
8098
  this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range([this.plotHeight, 0]);
8099
+ this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range([this.options.brushHeight, 0]);
7912
8100
 
7913
8101
  if (this.leftAxis.padding && this.options.data.left.padding) {
7914
8102
  this.leftAxis.padding(this.options.data.left.padding || 0);
@@ -7955,7 +8143,7 @@ var WebsyChart = /*#__PURE__*/function () {
7955
8143
  }
7956
8144
 
7957
8145
  if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
7958
- this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
8146
+ this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.right.ticks || 5).tickFormat(function (d) {
7959
8147
  if (_this44.options.data.right.formatter) {
7960
8148
  d = _this44.options.data.right.formatter(d);
7961
8149
  }
@@ -7990,48 +8178,55 @@ var WebsyChart = /*#__PURE__*/function () {
7990
8178
  // remove the components
7991
8179
  this["remove".concat(this.renderedKeys[key])](key);
7992
8180
  }
7993
- } // Draw the series data
8181
+ }
7994
8182
 
8183
+ this.renderComponents();
8184
+ }
8185
+ }
8186
+ }
8187
+ }, {
8188
+ key: "renderComponents",
8189
+ value: function renderComponents() {
8190
+ var _this45 = this;
7995
8191
 
7996
- this.renderedKeys = {};
7997
- this.options.data.series.forEach(function (series, index) {
7998
- if (!series.key) {
7999
- series.key = _this44.createIdentity();
8000
- }
8192
+ // Draw the series data
8193
+ this.renderedKeys = {};
8194
+ this.options.data.series.forEach(function (series, index) {
8195
+ if (!series.key) {
8196
+ series.key = _this45.createIdentity();
8197
+ }
8001
8198
 
8002
- if (!series.color) {
8003
- series.color = _this44.options.colors[index % _this44.options.colors.length];
8004
- }
8199
+ if (!series.color) {
8200
+ series.color = _this45.options.colors[index % _this45.options.colors.length];
8201
+ }
8005
8202
 
8006
- _this44["render".concat(series.type || 'bar')](series, index);
8203
+ _this45["render".concat(series.type || 'bar')](series, index);
8007
8204
 
8008
- _this44.renderLabels(series, index);
8205
+ _this45.renderLabels(series, index);
8009
8206
 
8010
- _this44.renderedKeys[series.key] = series.type;
8011
- });
8207
+ _this45.renderedKeys[series.key] = series.type;
8208
+ });
8012
8209
 
8013
- if (this.options.refLines && this.options.refLines.length > 0) {
8014
- this.options.refLines.forEach(function (l) {
8015
- return _this44.renderRefLine(l);
8016
- });
8017
- }
8018
- }
8210
+ if (this.options.refLines && this.options.refLines.length > 0) {
8211
+ this.options.refLines.forEach(function (l) {
8212
+ return _this45.renderRefLine(l);
8213
+ });
8019
8214
  }
8020
8215
  }
8021
8216
  }, {
8022
8217
  key: "renderarea",
8023
8218
  value: function renderarea(series, index) {
8024
- var _this45 = this;
8219
+ var _this46 = this;
8025
8220
 
8026
8221
  /* global d3 series index */
8027
8222
  var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
8028
8223
  return d3.area().x(function (d) {
8029
- return _this45[xAxis](_this45.parseX(d.x.value));
8224
+ return _this46[xAxis](_this46.parseX(d.x.value));
8030
8225
  }).y0(function (d) {
8031
- return _this45[yAxis](0);
8226
+ return _this46[yAxis](0);
8032
8227
  }).y1(function (d) {
8033
- return _this45[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
8034
- }).curve(d3[curveStyle || _this45.options.curveStyle]);
8228
+ return _this46[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
8229
+ }).curve(d3[curveStyle || _this46.options.curveStyle]);
8035
8230
  };
8036
8231
 
8037
8232
  var xAxis = 'bottomAxis';
@@ -8066,90 +8261,189 @@ var WebsyChart = /*#__PURE__*/function () {
8066
8261
  }, {
8067
8262
  key: "renderbar",
8068
8263
  value: function renderbar(series, index) {
8264
+ var _this47 = this;
8265
+
8069
8266
  /* global series index d3 */
8070
8267
  var xAxis = 'bottom';
8071
8268
  var yAxis = 'left';
8072
8269
  var bars = this.barLayer.selectAll(".bar_".concat(series.key)).data(series.data);
8270
+ var brushBars = this.brushArea.selectAll(".bar_".concat(series.key)).data(series.data);
8073
8271
  var acummulativeY = new Array(this.options.data.series.length).fill(0);
8074
8272
 
8075
8273
  if (this.options.orientation === 'horizontal') {
8076
8274
  xAxis = 'left';
8077
8275
  yAxis = 'bottom';
8078
- }
8079
-
8080
- var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8081
- var groupedBarWidth = (barWidth - 10) / this.options.data.series.length; // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
8276
+ } // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
8082
8277
  // barWidth = barWidth / this.options.data.series.length - 4
8083
8278
  // }
8084
8279
 
8085
- function getBarHeight(d, i) {
8280
+
8281
+ function getBarHeight(d, i, heightBounds, yAxis, xAxis) {
8282
+ var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8283
+ var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
8284
+ var output;
8285
+
8086
8286
  if (this.options.orientation === 'horizontal') {
8087
- return barWidth;
8287
+ output = barWidth;
8088
8288
  } else {
8089
- return this["".concat(yAxis, "Axis")](d.y.value);
8289
+ if (!getBarX.call(this, d, i, xAxis)) {
8290
+ return null;
8291
+ }
8292
+
8293
+ output = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
8294
+ }
8295
+
8296
+ if (isNaN(output)) {
8297
+ return null;
8090
8298
  }
8299
+
8300
+ return output;
8091
8301
  }
8092
8302
 
8093
- function getBarWidth(d, i) {
8303
+ function getBarWidth(d, i, xAxis) {
8304
+ var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8305
+ var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
8306
+ var output;
8307
+
8094
8308
  if (this.options.orientation === 'horizontal') {
8095
8309
  var width = this["".concat(yAxis, "Axis")](d.y.value);
8096
8310
  acummulativeY[d.y.index] += width;
8097
- return width;
8311
+ output = Math.max(1, width);
8098
8312
  } else {
8313
+ if (!getBarX.call(this, d, i, xAxis)) {
8314
+ return null;
8315
+ }
8316
+
8099
8317
  if (this.options.grouping === 'grouped') {
8100
- return groupedBarWidth;
8318
+ output = Math.max(1, groupedBarWidth);
8319
+ } else {
8320
+ output = Math.max(1, barWidth);
8101
8321
  }
8322
+ }
8102
8323
 
8103
- return barWidth;
8324
+ if (isNaN(output)) {
8325
+ return 0;
8104
8326
  }
8327
+
8328
+ return output;
8105
8329
  }
8106
8330
 
8107
- function getBarX(d, i) {
8331
+ function getBarX(d, i, xAxis) {
8332
+ var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8333
+ var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
8334
+ var output;
8335
+
8108
8336
  if (this.options.orientation === 'horizontal') {
8109
8337
  if (this.options.grouping === 'stacked') {
8110
- return this["".concat(yAxis, "Axis")](d.y.accumulative);
8338
+ output = this["".concat(yAxis, "Axis")](d.y.accumulative);
8111
8339
  } else {
8112
- return 0;
8340
+ output = 0;
8113
8341
  }
8114
8342
  } else {
8115
- var adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
8343
+ var adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
8116
8344
 
8117
8345
  if (this.options.grouping === 'grouped') {
8118
- var barAdjustment = groupedBarWidth * index + 5; // + (index > 0 ? 4 : 0)
8346
+ var barAdjustment = groupedBarWidth * index + (xAxis.indexOf('Brush') === -1 ? 5 : 1); // + (index > 0 ? 4 : 0)
8119
8347
 
8120
- return this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
8348
+ output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
8121
8349
  } else {
8122
- return this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + i * barWidth + adjustment;
8350
+ // output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
8351
+ output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)); // + (i * barWidth)
8123
8352
  }
8124
8353
  }
8354
+
8355
+ if (isNaN(output)) {
8356
+ return null;
8357
+ }
8358
+
8359
+ return output;
8125
8360
  }
8126
8361
 
8127
- function getBarY(d, i) {
8362
+ function getBarY(d, i, heightBounds, yAxis, xAxis) {
8363
+ var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8364
+ var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
8365
+ var output;
8366
+
8128
8367
  if (this.options.orientation === 'horizontal') {
8129
8368
  if (this.options.grouping !== 'grouped') {
8130
- return this["".concat(xAxis, "Axis")](this.parseX(d.x.value));
8369
+ output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value));
8131
8370
  } else {
8132
- return this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
8371
+ output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
8133
8372
  }
8134
8373
  } else {
8135
8374
  if (this.options.grouping === 'stacked') {
8136
- return this["".concat(yAxis, "Axis")](d.y.accumulative);
8375
+ output = heightBounds - this["".concat(yAxis, "Axis")](d.y.accumulative);
8137
8376
  } else {
8138
- return this.plotHeight - getBarHeight.call(this, d, i);
8377
+ var h = getBarHeight.call(this, d, i, heightBounds, yAxis, xAxis);
8378
+ output = this["".concat(yAxis, "Axis")](0) - h * (d.y.value < 0 ? 0 : 1);
8139
8379
  }
8140
8380
  }
8381
+
8382
+ if (isNaN(output)) {
8383
+ return null;
8384
+ }
8385
+
8386
+ return output;
8141
8387
  }
8142
8388
 
8143
8389
  bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8144
- bars.attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)).transition(this.transition).attr('fill', function (d) {
8390
+ bars.attr('width', function (d, i) {
8391
+ return getBarWidth.call(_this47, d, i, xAxis);
8392
+ }).attr('height', function (d, i) {
8393
+ return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8394
+ }).attr('x', function (d, i) {
8395
+ return getBarX.call(_this47, d, i, xAxis);
8396
+ }).attr('y', function (d, i) {
8397
+ return getBarY.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8398
+ }) // .transition(this.transition)
8399
+ .attr('fill', function (d) {
8145
8400
  return d.y.color || d.color || series.color;
8146
8401
  });
8147
- bars.enter().append('rect').attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)) // .transition(this.transition)
8402
+ bars.enter().append('rect').attr('width', function (d, i) {
8403
+ return getBarWidth.call(_this47, d, i, xAxis);
8404
+ }).attr('height', function (d, i) {
8405
+ return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8406
+ }).attr('x', function (d, i) {
8407
+ return getBarX.call(_this47, d, i, xAxis);
8408
+ }).attr('y', function (d, i) {
8409
+ return getBarY.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8410
+ }) // .transition(this.transition)
8148
8411
  .attr('fill', function (d) {
8149
8412
  return d.y.color || d.color || series.color;
8150
8413
  }).attr('class', function (d) {
8151
8414
  return "bar bar_".concat(series.key);
8152
8415
  });
8416
+
8417
+ if (!this.brushBarsInitialized[series.key]) {
8418
+ this.brushBarsInitialized[series.key] = true;
8419
+ brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8420
+ brushBars.attr('width', function (d, i) {
8421
+ return getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush"));
8422
+ }).attr('height', function (d, i) {
8423
+ return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8424
+ }).attr('x', function (d, i) {
8425
+ return getBarX.call(_this47, d, i, "".concat(xAxis, "Brush"));
8426
+ }).attr('y', function (d, i) {
8427
+ return getBarY.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8428
+ }) // .transition(this.transition)
8429
+ .attr('fill', function (d) {
8430
+ return d.y.color || d.color || series.color;
8431
+ });
8432
+ brushBars.enter().append('rect').attr('width', function (d, i) {
8433
+ return getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush"));
8434
+ }).attr('height', function (d, i) {
8435
+ return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8436
+ }).attr('x', function (d, i) {
8437
+ return getBarX.call(_this47, d, i, "".concat(xAxis, "Brush"));
8438
+ }).attr('y', function (d, i) {
8439
+ return getBarY.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8440
+ }) // .transition(this.transition)
8441
+ .attr('fill', function (d) {
8442
+ return d.y.color || d.color || series.color;
8443
+ }).attr('class', function (d) {
8444
+ return "bar bar_".concat(series.key);
8445
+ });
8446
+ }
8153
8447
  }
8154
8448
  }, {
8155
8449
  key: "removebar",
@@ -8160,7 +8454,7 @@ var WebsyChart = /*#__PURE__*/function () {
8160
8454
  }, {
8161
8455
  key: "renderLabels",
8162
8456
  value: function renderLabels(series, index) {
8163
- var _this46 = this;
8457
+ var _this48 = this;
8164
8458
 
8165
8459
  /* global series index d3 WebsyDesigns */
8166
8460
  var xAxis = 'bottomAxis';
@@ -8179,15 +8473,15 @@ var WebsyChart = /*#__PURE__*/function () {
8179
8473
  var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
8180
8474
  labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
8181
8475
  labels.attr('x', function (d) {
8182
- return getLabelX.call(_this46, d, series.labelPosition);
8476
+ return getLabelX.call(_this48, d, series.labelPosition);
8183
8477
  }).attr('y', function (d) {
8184
- return getLabelY.call(_this46, d, series.labelPosition);
8478
+ return getLabelY.call(_this48, d, series.labelPosition);
8185
8479
  }).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
8186
- if (_this46.options.grouping === 'stacked' && d.y.value === 0) {
8480
+ if (_this48.options.grouping === 'stacked' && d.y.value === 0) {
8187
8481
  return 'transparent';
8188
8482
  }
8189
8483
 
8190
- return _this46.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8484
+ return _this48.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8191
8485
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
8192
8486
  return d.y.label || d.y.value;
8193
8487
  }).each(function (d, i) {
@@ -8212,15 +8506,15 @@ var WebsyChart = /*#__PURE__*/function () {
8212
8506
  }
8213
8507
  });
8214
8508
  labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', function (d) {
8215
- return getLabelX.call(_this46, d, series.labelPosition);
8509
+ return getLabelX.call(_this48, d, series.labelPosition);
8216
8510
  }).attr('y', function (d) {
8217
- return getLabelY.call(_this46, d, series.labelPosition);
8511
+ return getLabelY.call(_this48, d, series.labelPosition);
8218
8512
  }).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
8219
- if (_this46.options.grouping === 'stacked' && d.y.value === 0) {
8513
+ if (_this48.options.grouping === 'stacked' && d.y.value === 0) {
8220
8514
  return 'transparent';
8221
8515
  }
8222
8516
 
8223
- return _this46.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8517
+ return _this48.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8224
8518
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
8225
8519
  return d.y.label || d.y.value;
8226
8520
  }).each(function (d, i) {
@@ -8277,16 +8571,16 @@ var WebsyChart = /*#__PURE__*/function () {
8277
8571
  }, {
8278
8572
  key: "renderline",
8279
8573
  value: function renderline(series, index) {
8280
- var _this47 = this;
8574
+ var _this49 = this;
8281
8575
 
8282
8576
  /* global series index d3 */
8283
8577
  var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
8284
8578
  return d3.line().x(function (d) {
8285
- var adjustment = _this47.options.data[xAxis].scale === 'Time' ? 0 : _this47["".concat(xAxis, "Axis")].bandwidth() / 2;
8286
- return _this47["".concat(xAxis, "Axis")](_this47.parseX(d.x.value)) + adjustment;
8579
+ var adjustment = _this49.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this49["".concat(xAxis, "Axis")].bandwidth() / 2;
8580
+ return _this49["".concat(xAxis, "Axis")](_this49.parseX(d.x.value)) + adjustment;
8287
8581
  }).y(function (d) {
8288
- return _this47["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8289
- }).curve(d3[curveStyle || _this47.options.curveStyle]);
8582
+ return _this49["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8583
+ }).curve(d3[curveStyle || _this49.options.curveStyle]);
8290
8584
  };
8291
8585
 
8292
8586
  var xAxis = 'bottom';
@@ -8297,7 +8591,16 @@ var WebsyChart = /*#__PURE__*/function () {
8297
8591
  yAxis = 'bottom';
8298
8592
  }
8299
8593
 
8300
- var lines = this.lineLayer.selectAll(".line_".concat(series.key)).data([series.data]); // Exit
8594
+ var xBrushAxis = 'bottomBrush';
8595
+ var yBrushAxis = 'leftBrush';
8596
+
8597
+ if (this.options.orienation === 'horizontal') {
8598
+ xBrushAxis = 'leftBrush';
8599
+ yBrushAxis = 'bottomBrush';
8600
+ }
8601
+
8602
+ var lines = this.lineLayer.selectAll(".line_".concat(series.key)).data([series.data]);
8603
+ var brushLines = this.brushArea.selectAll(".line_".concat(series.key)).data([series.data]); // Exit
8301
8604
 
8302
8605
  lines.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove(); // Update
8303
8606
 
@@ -8313,6 +8616,24 @@ var WebsyChart = /*#__PURE__*/function () {
8313
8616
  .style('stroke-width', series.lineWidth || this.options.lineWidth).attr('stroke', series.color).attr('fill', 'transparent') // .transition(this.transition)
8314
8617
  .style('stroke-opacity', 1);
8315
8618
 
8619
+ if (!this.brushLinesInitialized[series.key]) {
8620
+ this.brushLinesInitialized[series.key] = true; // Exit
8621
+
8622
+ brushLines.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove(); // Update
8623
+
8624
+ brushLines.style('stroke-width', 1) // .attr('id', `line_${series.key}`)
8625
+ // .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
8626
+ .attr('stroke', series.color).attr('fill', 'transparent').transition(this.transition).attr('d', function (d) {
8627
+ return drawLine(xBrushAxis, yBrushAxis, series.curveStyle)(d);
8628
+ }); // Enter
8629
+
8630
+ brushLines.enter().append('path').attr('d', function (d) {
8631
+ return drawLine(xBrushAxis, yBrushAxis, series.curveStyle)(d);
8632
+ }).attr('class', "line_".concat(series.key)).attr('id', "line_".concat(series.key)) // .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
8633
+ .style('stroke-width', 1).attr('stroke', series.color).attr('fill', 'transparent') // .transition(this.transition)
8634
+ .style('stroke-opacity', 1);
8635
+ }
8636
+
8316
8637
  if (series.showArea === true) {
8317
8638
  this.renderarea(series, index);
8318
8639
  }
@@ -8358,14 +8679,14 @@ var WebsyChart = /*#__PURE__*/function () {
8358
8679
  }, {
8359
8680
  key: "rendersymbol",
8360
8681
  value: function rendersymbol(series, index) {
8361
- var _this48 = this;
8682
+ var _this50 = this;
8362
8683
 
8363
8684
  /* global d3 series index series.key */
8364
8685
  var drawSymbol = function drawSymbol(size) {
8365
8686
  return d3.symbol() // .type(d => {
8366
8687
  // return d3.symbols[0]
8367
8688
  // })
8368
- .size(size || _this48.options.symbolSize);
8689
+ .size(size || _this50.options.symbolSize);
8369
8690
  };
8370
8691
 
8371
8692
  var xAxis = 'bottom';
@@ -8383,8 +8704,8 @@ var WebsyChart = /*#__PURE__*/function () {
8383
8704
  symbols.attr('d', function (d) {
8384
8705
  return drawSymbol(d.y.size || series.symbolSize)(d);
8385
8706
  }).transition(this.transition).attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('transform', function (d) {
8386
- var adjustment = _this48.options.data[xAxis].scale === 'Time' ? 0 : _this48["".concat(xAxis, "Axis")].bandwidth() / 2;
8387
- return "translate(".concat(_this48["".concat(xAxis, "Axis")](_this48.parseX(d.x.value)) + adjustment, ", ").concat(_this48["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
8707
+ var adjustment = _this50.options.data[xAxis].scale === 'Time' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
8708
+ return "translate(".concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ", ").concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
8388
8709
  }); // Enter
8389
8710
 
8390
8711
  symbols.enter().append('path').attr('d', function (d) {
@@ -8393,8 +8714,8 @@ var WebsyChart = /*#__PURE__*/function () {
8393
8714
  .attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('class', function (d) {
8394
8715
  return "symbol symbol_".concat(series.key);
8395
8716
  }).attr('transform', function (d) {
8396
- var adjustment = _this48.options.data[xAxis].scale === 'Time' ? 0 : _this48["".concat(xAxis, "Axis")].bandwidth() / 2;
8397
- return "translate(".concat(_this48["".concat(xAxis, "Axis")](_this48.parseX(d.x.value)) + adjustment, ", ").concat(_this48["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
8717
+ var adjustment = _this50.options.data[xAxis].scale === 'Time' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
8718
+ return "translate(".concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ", ").concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
8398
8719
  });
8399
8720
  }
8400
8721
  }, {
@@ -8482,6 +8803,58 @@ var WebsyChart = /*#__PURE__*/function () {
8482
8803
  this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
8483
8804
  }
8484
8805
  }
8806
+ }, {
8807
+ key: "hideError",
8808
+ value: function hideError() {
8809
+ var el = document.getElementById("".concat(this.elementId));
8810
+
8811
+ if (el) {
8812
+ el.classList.remove('has-error');
8813
+ } // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
8814
+ // chartEl.classList.remove('hidden')
8815
+
8816
+
8817
+ this.svg.classed('hidden', false);
8818
+ var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
8819
+
8820
+ if (containerEl) {
8821
+ containerEl.classList.remove('active');
8822
+ }
8823
+ }
8824
+ }, {
8825
+ key: "showError",
8826
+ value: function showError(options) {
8827
+ var el = document.getElementById("".concat(this.elementId));
8828
+
8829
+ if (el) {
8830
+ el.classList.add('has-error');
8831
+ } // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
8832
+ // chartEl.classList.add('hidden')
8833
+
8834
+
8835
+ this.svg.classed('hidden', true);
8836
+ var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
8837
+
8838
+ if (containerEl) {
8839
+ containerEl.classList.add('active');
8840
+ }
8841
+
8842
+ if (options.title) {
8843
+ var titleEl = document.getElementById("".concat(this.elementId, "_errorTitle"));
8844
+
8845
+ if (titleEl) {
8846
+ titleEl.innerHTML = options.title;
8847
+ }
8848
+ }
8849
+
8850
+ if (options.message) {
8851
+ var messageEl = document.getElementById("".concat(this.elementId, "_errorMessage"));
8852
+
8853
+ if (messageEl) {
8854
+ messageEl.innerHTML = options.message;
8855
+ }
8856
+ }
8857
+ }
8485
8858
  }, {
8486
8859
  key: "data",
8487
8860
  set: function set(d) {
@@ -8549,7 +8922,7 @@ var WebsyLegend = /*#__PURE__*/function () {
8549
8922
  }, {
8550
8923
  key: "resize",
8551
8924
  value: function resize() {
8552
- var _this49 = this;
8925
+ var _this51 = this;
8553
8926
 
8554
8927
  var el = document.getElementById(this.elementId);
8555
8928
 
@@ -8562,7 +8935,7 @@ var WebsyLegend = /*#__PURE__*/function () {
8562
8935
  // }
8563
8936
  var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
8564
8937
  html += this._data.map(function (d, i) {
8565
- return _this49.getLegendItemHTML(d);
8938
+ return _this51.getLegendItemHTML(d);
8566
8939
  }).join('');
8567
8940
  html += "\n <div>\n ";
8568
8941
  el.innerHTML = html;
@@ -8734,7 +9107,7 @@ var WebsyMap = /*#__PURE__*/function () {
8734
9107
  }, {
8735
9108
  key: "render",
8736
9109
  value: function render() {
8737
- var _this50 = this;
9110
+ var _this52 = this;
8738
9111
 
8739
9112
  var mapEl = document.getElementById("".concat(this.elementId, "_map"));
8740
9113
  var legendEl = document.getElementById("".concat(this.elementId, "_map"));
@@ -8743,7 +9116,7 @@ var WebsyMap = /*#__PURE__*/function () {
8743
9116
  var legendData = this.options.data.polygons.map(function (s, i) {
8744
9117
  return {
8745
9118
  value: s.label || s.key,
8746
- color: s.color || _this50.options.colors[i % _this50.options.colors.length]
9119
+ color: s.color || _this52.options.colors[i % _this52.options.colors.length]
8747
9120
  };
8748
9121
  });
8749
9122
  var longestValue = legendData.map(function (s) {
@@ -8807,7 +9180,7 @@ var WebsyMap = /*#__PURE__*/function () {
8807
9180
 
8808
9181
  if (this.polygons) {
8809
9182
  this.polygons.forEach(function (p) {
8810
- return _this50.map.removeLayer(p);
9183
+ return _this52.map.removeLayer(p);
8811
9184
  });
8812
9185
  }
8813
9186
 
@@ -8865,18 +9238,18 @@ var WebsyMap = /*#__PURE__*/function () {
8865
9238
  }
8866
9239
 
8867
9240
  if (!p.options.color) {
8868
- p.options.color = _this50.options.colors[i % _this50.options.colors.length];
9241
+ p.options.color = _this52.options.colors[i % _this52.options.colors.length];
8869
9242
  }
8870
9243
 
8871
9244
  var pol = L.polygon(p.data.map(function (c) {
8872
9245
  return c.map(function (d) {
8873
9246
  return [d.Latitude, d.Longitude];
8874
9247
  });
8875
- }), p.options).addTo(_this50.map);
9248
+ }), p.options).addTo(_this52.map);
8876
9249
 
8877
- _this50.polygons.push(pol);
9250
+ _this52.polygons.push(pol);
8878
9251
 
8879
- _this50.map.fitBounds(pol.getBounds());
9252
+ _this52.map.fitBounds(pol.getBounds());
8880
9253
  });
8881
9254
  } // if (this.data.markers.length > 0) {
8882
9255
  // el.classList.remove('hidden')