@websy/websy-designs 1.4.37 → 1.5.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.
@@ -7658,6 +7658,7 @@ var WebsyChart = /*#__PURE__*/function () {
7658
7658
  lineWidth: 2,
7659
7659
  forceZero: true,
7660
7660
  grouping: 'grouped',
7661
+ groupPadding: 3,
7661
7662
  fontSize: 14,
7662
7663
  symbolSize: 20,
7663
7664
  showTrackingLine: true,
@@ -7666,7 +7667,8 @@ var WebsyChart = /*#__PURE__*/function () {
7666
7667
  legendPosition: 'bottom',
7667
7668
  tooltipWidth: 200,
7668
7669
  brushHeight: 50,
7669
- minBandWidth: 30
7670
+ minBandWidth: 30,
7671
+ allowUnevenBands: true
7670
7672
  };
7671
7673
  this.elementId = elementId;
7672
7674
  this.options = _extends({}, DEFAULTS, options);
@@ -7697,24 +7699,39 @@ var WebsyChart = /*#__PURE__*/function () {
7697
7699
  }
7698
7700
 
7699
7701
  xAxis += 'Axis';
7700
-
7701
- var width = _this45[xAxis].step();
7702
-
7703
7702
  var output;
7704
7703
 
7705
- var domain = _toConsumableArray(_this45[xAxis].domain());
7704
+ var width = _this45.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth;
7706
7705
 
7707
- if (_this45.options.orientation === 'horizontal') {
7708
- domain = domain.reverse();
7709
- }
7706
+ if (_this45.customBottomRange) {
7707
+ for (var index = 0; index < _this45.customBottomRange.length; index++) {
7708
+ if (input > _this45.customBottomRange[index]) {
7709
+ if (_this45.customBottomRange[index + 1]) {
7710
+ if (input < _this45.customBottomRange[index + 1]) {
7711
+ output = index;
7712
+ break;
7713
+ }
7714
+ } else {
7715
+ output = index;
7716
+ break;
7717
+ }
7718
+ }
7719
+ }
7720
+ } else {
7721
+ var domain = _toConsumableArray(_this45[xAxis].domain());
7710
7722
 
7711
- for (var j = 0; j < domain.length; j++) {
7712
- var breakA = _this45[xAxis](domain[j]) - width / 2;
7713
- var breakB = breakA + width;
7723
+ if (_this45.options.orientation === 'horizontal') {
7724
+ domain = domain.reverse();
7725
+ }
7714
7726
 
7715
- if (input > breakA && input <= breakB) {
7716
- output = j;
7717
- break;
7727
+ for (var j = 0; j < domain.length; j++) {
7728
+ var breakA = _this45[xAxis](domain[j]) - width / 2;
7729
+ var breakB = breakA + width;
7730
+
7731
+ if (input > breakA && input <= breakB) {
7732
+ output = j;
7733
+ break;
7734
+ }
7718
7735
  }
7719
7736
  }
7720
7737
 
@@ -7734,6 +7751,10 @@ var WebsyChart = /*#__PURE__*/function () {
7734
7751
  xAxisCaps = 'Left';
7735
7752
  }
7736
7753
 
7754
+ if (!that["".concat(xAxis, "Axis")]) {
7755
+ return;
7756
+ }
7757
+
7737
7758
  if (!that["".concat(xAxis, "Axis")].invert) {
7738
7759
  that["".concat(xAxis, "Axis")].invert = that.invertOverride;
7739
7760
  }
@@ -7794,6 +7815,9 @@ var WebsyChart = /*#__PURE__*/function () {
7794
7815
 
7795
7816
  this.legendArea = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_legend")).attr('class', 'websy-chart-legend');
7796
7817
  this.legend = new WebsyDesigns.Legend("".concat(this.elementId, "_legend"), {});
7818
+ this.errorContainer = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_errorContainer")).attr('class', 'websy-vis-error-container').html(" \n <div>\n <div id=\"".concat(this.elementId, "_errorTitle\"></div>\n <div id=\"").concat(this.elementId, "_errorMessage\"></div>\n </div>\n "));
7819
+ this.loadingContainer = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_loadingContainer"));
7820
+ this.loadingDialog = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loadingContainer"));
7797
7821
  this.prep(); // el.innerHTML += `
7798
7822
  // <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
7799
7823
  // <div>
@@ -7933,7 +7957,12 @@ var WebsyChart = /*#__PURE__*/function () {
7933
7957
 
7934
7958
  this.options.data.series.forEach(function (s) {
7935
7959
  if (_this46.options.data[xData].scale !== 'Time') {
7936
- xPoint = _this46[xAxis](_this46.parseX(xLabel));
7960
+ if (_this46.customBottomRange && _this46.customBottomRange.length > 0) {
7961
+ xPoint = _this46.customBottomRange[x0] + (_this46.customBottomRange[x0 + 1] - _this46.customBottomRange[x0]) / 2;
7962
+ } else {
7963
+ xPoint = _this46[xAxis](_this46.parseX(xLabel));
7964
+ }
7965
+
7937
7966
  s.data.forEach(function (d) {
7938
7967
  if (d.x.value === xLabel) {
7939
7968
  if (!tooltipTitle) {
@@ -8037,7 +8066,7 @@ var WebsyChart = /*#__PURE__*/function () {
8037
8066
  };
8038
8067
 
8039
8068
  if (xPoint > this.plotWidth / 2) {
8040
- posOptions.left = xPoint - this.options.tooltipWidth + this.options.margin.left + this.options.margin.axisLeft + 15;
8069
+ posOptions.left = xPoint - this.options.tooltipWidth - 15; // + this.options.margin.left + this.options.margin.axisLeft + 15)
8041
8070
 
8042
8071
  if (this.options.data[xData].scale !== 'Time') {
8043
8072
  // posOptions.left -= (this[xAxis].bandwidth())
@@ -8047,7 +8076,7 @@ var WebsyChart = /*#__PURE__*/function () {
8047
8076
  posOptions.left = xPoint + this.options.margin.left + this.options.margin.axisLeft + 15;
8048
8077
 
8049
8078
  if (this.options.data[xData].scale !== 'Time') {
8050
- posOptions.left += this[xAxis].bandwidth() / 2;
8079
+ posOptions.left += this.options.data[xAxis.replace('Axis', '')].bandWidth / 2;
8051
8080
  }
8052
8081
  }
8053
8082
 
@@ -8058,7 +8087,7 @@ var WebsyChart = /*#__PURE__*/function () {
8058
8087
  var adjuster = 0;
8059
8088
 
8060
8089
  if (this.options.data[xData].scale !== 'Time') {
8061
- adjuster = this[xAxis].bandwidth() / 2; // - this.options.margin.top
8090
+ adjuster = this.options.data[xAxis.replace('Axis', '')].bandWidth / 2; // - this.options.margin.top
8062
8091
  }
8063
8092
 
8064
8093
  posOptions = {
@@ -8081,8 +8110,8 @@ var WebsyChart = /*#__PURE__*/function () {
8081
8110
  // xPoint = x0
8082
8111
  // }
8083
8112
 
8084
- if (this.options.data[xData].scale !== 'Time') {
8085
- xPoint += this[xAxis].bandwidth() / 2; // - this.options.margin.top
8113
+ if (this.options.data[xData].scale !== 'Time' && this.customBottomRange.length === 0) {
8114
+ xPoint += this.options.data[xAxis.replace('Axis', '')].bandWidth / 2; // - this.options.margin.top
8086
8115
  }
8087
8116
 
8088
8117
  var trackingXStart = xPoint;
@@ -8146,6 +8175,7 @@ var WebsyChart = /*#__PURE__*/function () {
8146
8175
 
8147
8176
  if (!this.options.data) {// tell the user no data has been provided
8148
8177
  } else {
8178
+ this.processedX = {};
8149
8179
  this.transition = d3.transition().duration(this.options.transitionDuration);
8150
8180
 
8151
8181
  if (this.options.data.bottom.scale && this.options.data.bottom.scale === 'Time') {
@@ -8203,12 +8233,18 @@ var WebsyChart = /*#__PURE__*/function () {
8203
8233
  // the legend gets rendered so that we can get its actual size
8204
8234
 
8205
8235
  if (this.options.showLegend === true) {
8206
- var legendData = this.options.data.series.map(function (s, i) {
8207
- return {
8208
- value: s.label || s.key,
8209
- color: s.color || _this47.options.colors[i % _this47.options.colors.length]
8210
- };
8211
- });
8236
+ var legendData = [];
8237
+
8238
+ if (this.options.legendData && this.options.legendData.length > 0) {
8239
+ legendData = this.options.legendData;
8240
+ } else {
8241
+ this.options.data.series.map(function (s, i) {
8242
+ return {
8243
+ value: s.label || s.key,
8244
+ color: s.color || _this47.options.colors[i % _this47.options.colors.length]
8245
+ };
8246
+ });
8247
+ }
8212
8248
 
8213
8249
  if (this.options.legendPosition === 'top' || this.options.legendPosition === 'bottom') {
8214
8250
  this.legendArea.style('width', '100%');
@@ -8412,18 +8448,34 @@ var WebsyChart = /*#__PURE__*/function () {
8412
8448
  this.brushNeeded = false;
8413
8449
 
8414
8450
  if (this.options.orientation === 'vertical') {
8451
+ this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce(function (a, b) {
8452
+ if (typeof b.valueCount === 'undefined') {
8453
+ return a + 1;
8454
+ }
8455
+
8456
+ return a + b.valueCount;
8457
+ }, 0);
8458
+
8415
8459
  if (this.options.maxBandWidth) {
8416
- this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.data || []).length * this.options.maxBandWidth);
8460
+ this.plotWidth = Math.min(this.plotWidth, this.options.data.bottom.totalValueCount * this.options.maxBandWidth);
8417
8461
  } // some if to check if brushing is needed
8418
8462
 
8419
8463
 
8420
- if (this.plotWidth / this.options.data.bottom.data.length < this.options.minBandWidth) {
8464
+ if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
8421
8465
  this.brushNeeded = true;
8422
8466
  this.plotHeight -= this.options.brushHeight;
8423
8467
  }
8424
8468
  } else {
8425
8469
  // some if to check if brushing is needed
8426
- if (this.plotHeight / this.options.data.left.data.length < this.options.minBandWidth) {
8470
+ this.options.data.left.totalValueCount = this.options.data.left.data.reduce(function (a, b) {
8471
+ if (typeof b.valueCount === 'undefined') {
8472
+ return a + 1;
8473
+ }
8474
+
8475
+ return a + b.valueCount;
8476
+ }, 0);
8477
+
8478
+ if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
8427
8479
  this.brushNeeded = true;
8428
8480
  this.plotWidth -= this.options.brushHeight;
8429
8481
  }
@@ -8453,10 +8505,42 @@ var WebsyChart = /*#__PURE__*/function () {
8453
8505
 
8454
8506
  var bottomDomain = this.createDomain('bottom');
8455
8507
  var bottomBrushDomain = this.createDomain('bottom', true);
8456
- this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomDomain).range([0, this.plotWidth]);
8508
+ var bottomRange = [0, this.plotWidth];
8509
+ this.customBottomRange = [];
8510
+
8511
+ if (this.options.allowUnevenBands === true) {
8512
+ if (this.options.data.bottom.data && this.options.data.bottom.data[0] && this.options.data.bottom.data[0].valueCount && this.options.data.bottom.scale === 'Ordinal') {
8513
+ var acc = 0;
8514
+ this.customBottomRange = [0].concat(_toConsumableArray(this.options.data.bottom.data.map(function (d) {
8515
+ acc += d.valueCount;
8516
+ return _this47.plotWidth / _this47.options.data.bottom.totalValueCount * acc;
8517
+ })));
8518
+ }
8519
+ }
8520
+
8521
+ this.options.data.bottom.step = this.plotWidth / this.options.data.bottom.totalValueCount;
8522
+ this.options.data.bottom.bandWidth = this.options.data.bottom.step;
8523
+
8524
+ if (this.options.data.bottom.padding) {
8525
+ this.totalPadding = this.plotWidth * this.options.data.bottom.padding;
8526
+ var rangeLength = bottomDomain.length;
8527
+
8528
+ if (this.customBottomRange.length > 0) {
8529
+ rangeLength = this.customBottomRange.length;
8530
+ }
8531
+
8532
+ this.bandPadding = this.totalPadding / rangeLength / 2;
8533
+ this.options.data.bottom.bandWidth = (this.plotWidth - this.totalPadding) / this.options.data.bottom.totalValueCount;
8534
+ }
8535
+
8536
+ if (this.options.grouping === 'grouped' && this.options.data.series.length > 1) {
8537
+ this.options.data.bottom.bandWidth = this.options.data.bottom.bandWidth - this.options.groupPadding * 2;
8538
+ }
8539
+
8540
+ this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomDomain).range(bottomRange);
8457
8541
 
8458
8542
  if (!this.brushInitialized) {
8459
- this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomBrushDomain).range([0, this.plotWidth]);
8543
+ this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomBrushDomain).range(bottomRange);
8460
8544
  }
8461
8545
 
8462
8546
  if (this.bottomAxis.nice) {// this.bottomAxis.nice()
@@ -8575,6 +8659,12 @@ var WebsyChart = /*#__PURE__*/function () {
8575
8659
  if (this.options.data.bottom.rotate) {
8576
8660
  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"));
8577
8661
  }
8662
+
8663
+ if (this.customBottomRange.length > 0) {
8664
+ this.bottomAxisLayer.selectAll('g').attr('transform', function (d, i) {
8665
+ return "translate(".concat(_this47.customBottomRange[i] + (_this47.customBottomRange[i + 1] - _this47.customBottomRange[i]) / 2, ", 0)");
8666
+ });
8667
+ }
8578
8668
  } // Configure the left axis
8579
8669
 
8580
8670
 
@@ -8692,6 +8782,8 @@ var WebsyChart = /*#__PURE__*/function () {
8692
8782
 
8693
8783
  _this48.renderedKeys[series.key] = series.type;
8694
8784
  });
8785
+ this.refLineLayer.selectAll('.reference-line').remove();
8786
+ this.refLineLayer.selectAll('.reference-line-label').remove();
8695
8787
 
8696
8788
  if (this.options.refLines && this.options.refLines.length > 0) {
8697
8789
  this.options.refLines.forEach(function (l) {
@@ -8707,20 +8799,20 @@ var WebsyChart = /*#__PURE__*/function () {
8707
8799
  /* global d3 series index */
8708
8800
  var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
8709
8801
  return d3.area().x(function (d) {
8710
- return _this49[xAxis](_this49.parseX(d.x.value));
8802
+ return _this49["".concat(xAxis, "Axis")](_this49.parseX(d.x.value));
8711
8803
  }).y0(function (d) {
8712
- return _this49[yAxis](0);
8804
+ return _this49["".concat(yAxis, "Axis")](0);
8713
8805
  }).y1(function (d) {
8714
- return _this49[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
8806
+ return _this49["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8715
8807
  }).curve(d3[curveStyle || _this49.options.curveStyle]);
8716
8808
  };
8717
8809
 
8718
- var xAxis = 'bottomAxis';
8719
- var yAxis = series.axis === 'secondary' ? 'rightAxis' : 'leftAxis';
8810
+ var xAxis = 'bottom';
8811
+ var yAxis = series.axis === 'secondary' ? 'right' : 'left';
8720
8812
 
8721
- if (this.options.orienation === 'horizontal') {
8722
- xAxis = series.axis === 'secondary' ? 'rightAxis' : 'leftAxis';
8723
- yAxis = 'bottomAxis';
8813
+ if (this.options.orientation === 'horizontal') {
8814
+ xAxis = series.axis === 'secondary' ? 'right' : 'left';
8815
+ yAxis = 'bottom';
8724
8816
  }
8725
8817
 
8726
8818
  var areas = this.areaLayer.selectAll(".area_".concat(series.key)).data([series.data]); // Exit
@@ -8738,8 +8830,7 @@ var WebsyChart = /*#__PURE__*/function () {
8738
8830
 
8739
8831
  areas.enter().append('path').attr('d', function (d) {
8740
8832
  return drawArea(xAxis, yAxis, series.curveStyle)(d);
8741
- }).attr('class', "area_".concat(series.key)).attr('id', "area_".concat(series.key)) // .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
8742
- // .style('stroke-width', series.lineWidth || this.options.lineWidth)
8833
+ }).attr('class', "area_".concat(series.key)).attr('id', "area_".concat(series.key)).attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data["".concat(xAxis, "Axis")].bandWidth / 2) + ',0)') // .style('stroke-width', series.lineWidth || this.options.lineWidth)
8743
8834
  .attr('fill', series.color) // .style('fill-opacity', 0)
8744
8835
  .attr('stroke', 'transparent') // .transition(this.transition)
8745
8836
  .style('fill-opacity', series.opacity || 0.5);
@@ -8765,14 +8856,14 @@ var WebsyChart = /*#__PURE__*/function () {
8765
8856
 
8766
8857
 
8767
8858
  function getBarHeight(d, i, heightBounds, yAxis, xAxis) {
8768
- var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8769
- var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
8770
8859
  var output;
8771
8860
 
8772
8861
  if (this.options.orientation === 'horizontal') {
8773
- output = barWidth;
8862
+ output = this.options.data[xAxis.replace('Brush', '')].bandWidth;
8774
8863
  } else {
8775
- if (!getBarX.call(this, d, i, xAxis)) {
8864
+ var x = getBarX.call(this, d, i, xAxis);
8865
+
8866
+ if (typeof x === 'undefined' || x === null) {
8776
8867
  return null;
8777
8868
  }
8778
8869
 
@@ -8787,24 +8878,20 @@ var WebsyChart = /*#__PURE__*/function () {
8787
8878
  }
8788
8879
 
8789
8880
  function getBarWidth(d, i, xAxis) {
8790
- var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8791
- var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
8792
8881
  var output;
8793
8882
 
8794
8883
  if (this.options.orientation === 'horizontal') {
8795
- var width = this["".concat(yAxis, "Axis")](d.y.value);
8884
+ var width = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
8796
8885
  acummulativeY[d.y.index] += width;
8797
- output = Math.max(1, width);
8886
+ output = width;
8798
8887
  } else {
8799
- if (!getBarX.call(this, d, i, xAxis)) {
8888
+ var x = getBarX.call(this, d, i, xAxis);
8889
+
8890
+ if (typeof x === 'undefined' || x === null) {
8800
8891
  return null;
8801
8892
  }
8802
8893
 
8803
- if (this.options.grouping === 'grouped') {
8804
- output = Math.max(1, groupedBarWidth);
8805
- } else {
8806
- output = Math.max(1, barWidth);
8807
- }
8894
+ output = Math.max(1, this.options.data[xAxis.replace('Brush', '')].bandWidth);
8808
8895
  }
8809
8896
 
8810
8897
  if (isNaN(output)) {
@@ -8815,23 +8902,59 @@ var WebsyChart = /*#__PURE__*/function () {
8815
8902
  }
8816
8903
 
8817
8904
  function getBarX(d, i, xAxis) {
8818
- var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8819
- var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
8905
+ // let barWidth = this.plotWidth / this.options.data[xAxis.replace('Brush', '')].totalValueCount
8906
+ // if (this.options.data[xAxis.replace('Brush', '')].padding) {
8907
+ // barWidth = barWidth - (barWidth * this.options.data[xAxis.replace('Brush', '')].padding)
8908
+ // }
8909
+ // let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data[xAxis.replace('Brush', '')].totalValueCount
8820
8910
  var output;
8821
8911
 
8822
8912
  if (this.options.orientation === 'horizontal') {
8823
8913
  if (this.options.grouping === 'stacked') {
8824
- output = this["".concat(yAxis, "Axis")](d.y.accumulative);
8914
+ var h = getBarWidth.call(this, d, i, xAxis);
8915
+ var adjustment = 0;
8916
+
8917
+ if (d.y.accumulative && d.y.accumulative !== 0) {
8918
+ adjustment = this["".concat(yAxis, "Axis")](d.y.accumulative || 0);
8919
+ }
8920
+
8921
+ output = this["".concat(yAxis, "Axis")](0) + adjustment * (d.y.value < 0 ? 1 : 0) + h * (d.y.value < 0 ? 1 : 0);
8825
8922
  } else {
8826
- output = 0;
8923
+ var _h = getBarWidth.call(this, d, i, xAxis);
8924
+
8925
+ output = this["".concat(yAxis, "Axis")](0) + _h * (d.y.value < 0 ? 1 : 0);
8827
8926
  }
8828
8927
  } else {
8829
- var adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
8928
+ // let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
8929
+ var _adjustment = this.customBottomRange[i] + i * this.options.data[xAxis.replace('Brush', '')].bandWidth;
8830
8930
 
8831
8931
  if (this.options.grouping === 'grouped') {
8832
- var barAdjustment = groupedBarWidth * index + (xAxis.indexOf('Brush') === -1 ? 5 : 1); // + (index > 0 ? 4 : 0)
8932
+ var xIndex = 0;
8933
+
8934
+ if (this.processedX[d.x.value]) {
8935
+ xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel));
8936
+ }
8937
+
8938
+ var barAdjustment = this.options.data[xAxis.replace('Brush', '')].bandWidth * xIndex + xIndex * this.options.groupPadding * 2 + this.options.groupPadding + (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1); // let barAdjustment =
8939
+ // (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
8940
+ // this.options.groupPadding
8941
+ // // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
8942
+
8943
+ if (this.customBottomRange.length > 0) {
8944
+ output = this.customBottomRange[this[xAxis.replace('Brush', '') + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment;
8945
+ } else {
8946
+ output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
8947
+ }
8948
+
8949
+ if (!this.processedX[d.x.value]) {
8950
+ this.processedX[d.x.value] = [];
8951
+ }
8833
8952
 
8834
- output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
8953
+ if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
8954
+ this.processedX[d.x.value].push(d.y.tooltipLabel);
8955
+ }
8956
+
8957
+ console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output);
8835
8958
  } else {
8836
8959
  // output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
8837
8960
  output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)); // + (i * barWidth)
@@ -8846,15 +8969,15 @@ var WebsyChart = /*#__PURE__*/function () {
8846
8969
  }
8847
8970
 
8848
8971
  function getBarY(d, i, heightBounds, yAxis, xAxis) {
8849
- var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8850
- var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
8972
+ // let barWidth = this[`${xAxis}Axis`].bandwidth()
8973
+ // let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
8851
8974
  var output;
8852
8975
 
8853
8976
  if (this.options.orientation === 'horizontal') {
8854
8977
  if (this.options.grouping !== 'grouped') {
8855
8978
  output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value));
8856
8979
  } else {
8857
- output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
8980
+ output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * this.options.data[xAxis.replace('Brush', '')].barWidth;
8858
8981
  }
8859
8982
  } else {
8860
8983
  if (this.options.grouping === 'stacked') {
@@ -8874,7 +8997,7 @@ var WebsyChart = /*#__PURE__*/function () {
8874
8997
 
8875
8998
  bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8876
8999
  bars.attr('width', function (d, i) {
8877
- return getBarWidth.call(_this50, d, i, xAxis);
9000
+ return Math.abs(getBarWidth.call(_this50, d, i, xAxis));
8878
9001
  }).attr('height', function (d, i) {
8879
9002
  return getBarHeight.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
8880
9003
  }).attr('x', function (d, i) {
@@ -8886,7 +9009,7 @@ var WebsyChart = /*#__PURE__*/function () {
8886
9009
  return d.y.color || d.color || series.color;
8887
9010
  });
8888
9011
  bars.enter().append('rect').attr('width', function (d, i) {
8889
- return getBarWidth.call(_this50, d, i, xAxis);
9012
+ return Math.abs(getBarWidth.call(_this50, d, i, xAxis));
8890
9013
  }).attr('height', function (d, i) {
8891
9014
  return getBarHeight.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
8892
9015
  }).attr('x', function (d, i) {
@@ -8904,7 +9027,7 @@ var WebsyChart = /*#__PURE__*/function () {
8904
9027
  this.brushBarsInitialized[series.key] = true;
8905
9028
  brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8906
9029
  brushBars.attr('width', function (d, i) {
8907
- return getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush"));
9030
+ return Math.abs(getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush")));
8908
9031
  }).attr('height', function (d, i) {
8909
9032
  return getBarHeight.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8910
9033
  }).attr('x', function (d, i) {
@@ -8916,7 +9039,7 @@ var WebsyChart = /*#__PURE__*/function () {
8916
9039
  return d.y.color || d.color || series.color;
8917
9040
  });
8918
9041
  brushBars.enter().append('rect').attr('width', function (d, i) {
8919
- return getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush"));
9042
+ return Math.abs(getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush")));
8920
9043
  }).attr('height', function (d, i) {
8921
9044
  return getBarHeight.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8922
9045
  }).attr('x', function (d, i) {
@@ -9036,7 +9159,7 @@ var WebsyChart = /*#__PURE__*/function () {
9036
9159
  return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4;
9037
9160
  }
9038
9161
  } else {
9039
- return this[xAxis](this.parseX(d.x.value)) + this[xAxis].bandwidth() / 2;
9162
+ return this[xAxis](this.parseX(d.x.value)) + this.options.data[xAxis.replace('Axis', '')].bandWidth / 2;
9040
9163
  }
9041
9164
  }
9042
9165
 
@@ -9044,7 +9167,7 @@ var WebsyChart = /*#__PURE__*/function () {
9044
9167
  var labelPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inside';
9045
9168
 
9046
9169
  if (this.options.orientation === 'horizontal') {
9047
- return this[xAxis](this.parseX(d.x.value)) + this[xAxis].bandwidth() / 2;
9170
+ return this[xAxis](this.parseX(d.x.value)) + this.options.data[xAxis.replace('Axis', '')].bandWidth / 2;
9048
9171
  } else {
9049
9172
  if (this.options.grouping === 'stacked') {
9050
9173
  return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1);
@@ -9062,17 +9185,26 @@ var WebsyChart = /*#__PURE__*/function () {
9062
9185
  /* global series index d3 */
9063
9186
  var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
9064
9187
  return d3.line().x(function (d) {
9065
- var adjustment = _this52.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this52["".concat(xAxis, "Axis")].bandwidth() / 2;
9066
- return _this52["".concat(xAxis, "Axis")](_this52.parseX(d.x.value)) + adjustment;
9188
+ if (_this52.options.orientation === 'horizontal') {
9189
+ return _this52["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
9190
+ } else {
9191
+ var adjustment = _this52.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this52["".concat(xAxis, "Axis")].bandwidth() / 2;
9192
+ return _this52["".concat(xAxis, "Axis")](_this52.parseX(d.x.value)) + adjustment;
9193
+ }
9067
9194
  }).y(function (d) {
9068
- return _this52["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
9195
+ if (_this52.options.orientation === 'horizontal') {
9196
+ var adjustment = _this52.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this52["".concat(xAxis, "Axis")].bandwidth() / 2;
9197
+ return _this52["".concat(xAxis, "Axis")](_this52.parseX(d.x.value)) + adjustment;
9198
+ } else {
9199
+ return _this52["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
9200
+ }
9069
9201
  }).curve(d3[curveStyle || _this52.options.curveStyle]);
9070
9202
  };
9071
9203
 
9072
9204
  var xAxis = 'bottom';
9073
9205
  var yAxis = series.axis === 'secondary' ? 'right' : 'left';
9074
9206
 
9075
- if (this.options.orienation === 'horizontal') {
9207
+ if (this.options.orientation === 'horizontal') {
9076
9208
  xAxis = series.axis === 'secondary' ? 'right' : 'left';
9077
9209
  yAxis = 'bottom';
9078
9210
  }
@@ -9080,7 +9212,7 @@ var WebsyChart = /*#__PURE__*/function () {
9080
9212
  var xBrushAxis = 'bottomBrush';
9081
9213
  var yBrushAxis = 'leftBrush';
9082
9214
 
9083
- if (this.options.orienation === 'horizontal') {
9215
+ if (this.options.orientation === 'horizontal') {
9084
9216
  xBrushAxis = 'leftBrush';
9085
9217
  yBrushAxis = 'bottomBrush';
9086
9218
  }
@@ -9147,8 +9279,6 @@ var WebsyChart = /*#__PURE__*/function () {
9147
9279
  length = this.plotHeight;
9148
9280
  }
9149
9281
 
9150
- this.refLineLayer.selectAll('.reference-line').remove();
9151
- this.refLineLayer.selectAll('.reference-line-label').remove();
9152
9282
  this.refLineLayer.append('line').attr("".concat(yAttr, "1"), this["".concat(yAxis, "Axis")](data.value)).attr("".concat(yAttr, "2"), this["".concat(yAxis, "Axis")](data.value)).attr("".concat(xAttr, "2"), length).attr('class', "reference-line").style('stroke', data.color).style('stroke-width', "".concat(data.lineWidth, "px")).style('stroke-dasharray', data.lineStyle);
9153
9283
 
9154
9284
  if (data.label && data.label !== '') {
@@ -9178,7 +9308,7 @@ var WebsyChart = /*#__PURE__*/function () {
9178
9308
  var xAxis = 'bottom';
9179
9309
  var yAxis = series.axis === 'secondary' ? 'right' : 'left';
9180
9310
 
9181
- if (this.options.orienation === 'horizontal') {
9311
+ if (this.options.orientation === 'horizontal') {
9182
9312
  xAxis = series.axis === 'secondary' ? 'right' : 'left';
9183
9313
  yAxis = 'bottom';
9184
9314
  }
@@ -9190,8 +9320,13 @@ var WebsyChart = /*#__PURE__*/function () {
9190
9320
  symbols.attr('d', function (d) {
9191
9321
  return drawSymbol(d.y.size || series.symbolSize)(d);
9192
9322
  }).transition(this.transition).attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('transform', function (d) {
9193
- var adjustment = _this53.options.data[xAxis].scale === 'Time' ? 0 : _this53["".concat(xAxis, "Axis")].bandwidth() / 2;
9194
- return "translate(".concat(_this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value)) + adjustment, ", ").concat(_this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
9323
+ var adjustment = _this53.options.data[xAxis].scale === 'Time' || _this53.options.data[xAxis].scale === 'Linear' ? 0 : _this53["".concat(xAxis, "Axis")].bandwidth() / 2;
9324
+
9325
+ if (_this53.options.orientation === 'horizontal') {
9326
+ return "translate(".concat(_this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(_this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value)) + adjustment, ")");
9327
+ } else {
9328
+ return "translate(".concat(_this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value)) + adjustment, ", ").concat(_this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
9329
+ }
9195
9330
  }); // Enter
9196
9331
 
9197
9332
  symbols.enter().append('path').attr('d', function (d) {
@@ -9200,8 +9335,13 @@ var WebsyChart = /*#__PURE__*/function () {
9200
9335
  .attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('class', function (d) {
9201
9336
  return "symbol symbol_".concat(series.key);
9202
9337
  }).attr('transform', function (d) {
9203
- var adjustment = _this53.options.data[xAxis].scale === 'Time' ? 0 : _this53["".concat(xAxis, "Axis")].bandwidth() / 2;
9204
- return "translate(".concat(_this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value)) + adjustment, ", ").concat(_this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
9338
+ var adjustment = _this53.options.data[xAxis].scale === 'Time' || _this53.options.data[xAxis].scale === 'Linear' ? 0 : _this53["".concat(xAxis, "Axis")].bandwidth() / 2;
9339
+
9340
+ if (_this53.options.orientation === 'horizontal') {
9341
+ return "translate(".concat(_this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(_this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value)) + adjustment, ")");
9342
+ } else {
9343
+ return "translate(".concat(_this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value)) + adjustment, ", ").concat(_this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
9344
+ }
9205
9345
  });
9206
9346
  }
9207
9347
  }, {
@@ -9296,17 +9436,23 @@ var WebsyChart = /*#__PURE__*/function () {
9296
9436
 
9297
9437
  if (el) {
9298
9438
  el.classList.remove('has-error');
9299
- } // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
9300
- // chartEl.classList.remove('hidden')
9439
+ }
9301
9440
 
9441
+ if (this.svg) {
9442
+ this.svg.classed('hidden', false);
9443
+ }
9302
9444
 
9303
- this.svg.classed('hidden', false);
9304
9445
  var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
9305
9446
 
9306
9447
  if (containerEl) {
9307
9448
  containerEl.classList.remove('active');
9308
9449
  }
9309
9450
  }
9451
+ }, {
9452
+ key: "hideLoading",
9453
+ value: function hideLoading() {
9454
+ this.loadingDialog.hide();
9455
+ }
9310
9456
  }, {
9311
9457
  key: "showError",
9312
9458
  value: function showError(options) {
@@ -9315,10 +9461,13 @@ var WebsyChart = /*#__PURE__*/function () {
9315
9461
  if (el) {
9316
9462
  el.classList.add('has-error');
9317
9463
  } // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
9318
- // chartEl.classList.add('hidden')
9464
+ // chartEl.classList.add('hidden')
9319
9465
 
9320
9466
 
9321
- this.svg.classed('hidden', true);
9467
+ if (this.svg) {
9468
+ this.svg.classed('hidden', true);
9469
+ }
9470
+
9322
9471
  var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
9323
9472
 
9324
9473
  if (containerEl) {
@@ -9341,6 +9490,11 @@ var WebsyChart = /*#__PURE__*/function () {
9341
9490
  }
9342
9491
  }
9343
9492
  }
9493
+ }, {
9494
+ key: "showLoading",
9495
+ value: function showLoading(options) {
9496
+ this.loadingDialog.show(options);
9497
+ }
9344
9498
  }, {
9345
9499
  key: "data",
9346
9500
  set: function set(d) {