@websy/websy-designs 1.4.37 → 1.4.38

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.
@@ -7083,6 +7083,18 @@ class WebsyChart {
7083
7083
  .attr('id', `${this.elementId}_legend`)
7084
7084
  .attr('class', 'websy-chart-legend')
7085
7085
  this.legend = new WebsyDesigns.Legend(`${this.elementId}_legend`, {})
7086
+ this.errorContainer = d3.select(el).append('div')
7087
+ .attr('id', `${this.elementId}_errorContainer`)
7088
+ .attr('class', 'websy-vis-error-container')
7089
+ .html(`
7090
+ <div>
7091
+ <div id="${this.elementId}_errorTitle"></div>
7092
+ <div id="${this.elementId}_errorMessage"></div>
7093
+ </div>
7094
+ `)
7095
+ this.loadingContainer = d3.select(el).append('div')
7096
+ .attr('id', `${this.elementId}_loadingContainer`)
7097
+ this.loadingDialog = new WebsyDesigns.LoadingDialog(`${this.elementId}_loadingContainer`)
7086
7098
  this.prep()
7087
7099
  // el.innerHTML += `
7088
7100
  // <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
@@ -8097,9 +8109,10 @@ function getBarWidth (d, i, xAxis) {
8097
8109
  let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length
8098
8110
  let output
8099
8111
  if (this.options.orientation === 'horizontal') {
8100
- let width = this[`${yAxis}Axis`](d.y.value)
8112
+ // let width = this[`${yAxis}Axis`](d.y.value)
8113
+ let width = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
8101
8114
  acummulativeY[d.y.index] += width
8102
- output = Math.max(1, width)
8115
+ output = width
8103
8116
  }
8104
8117
  else {
8105
8118
  if (!getBarX.call(this, d, i, xAxis)) {
@@ -8123,10 +8136,16 @@ function getBarX (d, i, xAxis) {
8123
8136
  let output
8124
8137
  if (this.options.orientation === 'horizontal') {
8125
8138
  if (this.options.grouping === 'stacked') {
8126
- output = this[`${yAxis}Axis`](d.y.accumulative)
8139
+ let h = getBarWidth.call(this, d, i, xAxis)
8140
+ let adjustment = 0
8141
+ if (d.y.accumulative && d.y.accumulative !== 0) {
8142
+ adjustment = this[`${yAxis}Axis`](d.y.accumulative || 0)
8143
+ }
8144
+ output = this[`${yAxis}Axis`](0) + (adjustment * (d.y.value < 0 ? 1 : 0)) + (h * (d.y.value < 0 ? 1 : 0))
8127
8145
  }
8128
8146
  else {
8129
- output = 0
8147
+ let h = getBarWidth.call(this, d, i, xAxis)
8148
+ output = (this[`${yAxis}Axis`](0)) + (h * (d.y.value < 0 ? 1 : 0))
8130
8149
  }
8131
8150
  }
8132
8151
  else {
@@ -8178,7 +8197,7 @@ bars
8178
8197
  .remove()
8179
8198
 
8180
8199
  bars
8181
- .attr('width', (d, i) => getBarWidth.call(this, d, i, xAxis))
8200
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
8182
8201
  .attr('height', (d, i) => getBarHeight.call(this, d, i, this.plotHeight, yAxis, xAxis))
8183
8202
  .attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
8184
8203
  .attr('y', (d, i) => getBarY.call(this, d, i, this.plotHeight, yAxis, xAxis))
@@ -8188,7 +8207,7 @@ bars
8188
8207
  bars
8189
8208
  .enter()
8190
8209
  .append('rect')
8191
- .attr('width', (d, i) => getBarWidth.call(this, d, i, xAxis))
8210
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
8192
8211
  .attr('height', (d, i) => getBarHeight.call(this, d, i, this.plotHeight, yAxis, xAxis))
8193
8212
  .attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
8194
8213
  .attr('y', (d, i) => getBarY.call(this, d, i, this.plotHeight, yAxis, xAxis))
@@ -8207,7 +8226,7 @@ if (!this.brushBarsInitialized[series.key]) {
8207
8226
  .remove()
8208
8227
 
8209
8228
  brushBars
8210
- .attr('width', (d, i) => getBarWidth.call(this, d, i, `${xAxis}Brush`))
8229
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
8211
8230
  .attr('height', (d, i) => getBarHeight.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
8212
8231
  .attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
8213
8232
  .attr('y', (d, i) => getBarY.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
@@ -8217,7 +8236,7 @@ if (!this.brushBarsInitialized[series.key]) {
8217
8236
  brushBars
8218
8237
  .enter()
8219
8238
  .append('rect')
8220
- .attr('width', (d, i) => getBarWidth.call(this, d, i, `${xAxis}Brush`))
8239
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
8221
8240
  .attr('height', (d, i) => getBarHeight.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
8222
8241
  .attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
8223
8242
  .attr('y', (d, i) => getBarY.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
@@ -8667,6 +8686,9 @@ if (el) {
8667
8686
  containerEl.classList.remove('active')
8668
8687
  }
8669
8688
  }
8689
+ hideLoading () {
8690
+ this.loadingDialog.hide()
8691
+ }
8670
8692
  showError (options) {
8671
8693
  const el = document.getElementById(`${this.elementId}`)
8672
8694
  if (el) {
@@ -8692,6 +8714,9 @@ if (el) {
8692
8714
  }
8693
8715
  }
8694
8716
  }
8717
+ showLoading (options) {
8718
+ this.loadingDialog.show(options)
8719
+ }
8695
8720
  }
8696
8721
 
8697
8722
  class WebsyLegend {
@@ -7794,6 +7794,9 @@ var WebsyChart = /*#__PURE__*/function () {
7794
7794
 
7795
7795
  this.legendArea = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_legend")).attr('class', 'websy-chart-legend');
7796
7796
  this.legend = new WebsyDesigns.Legend("".concat(this.elementId, "_legend"), {});
7797
+ 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 "));
7798
+ this.loadingContainer = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_loadingContainer"));
7799
+ this.loadingDialog = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loadingContainer"));
7797
7800
  this.prep(); // el.innerHTML += `
7798
7801
  // <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
7799
7802
  // <div>
@@ -8792,9 +8795,10 @@ var WebsyChart = /*#__PURE__*/function () {
8792
8795
  var output;
8793
8796
 
8794
8797
  if (this.options.orientation === 'horizontal') {
8795
- var width = this["".concat(yAxis, "Axis")](d.y.value);
8798
+ // let width = this[`${yAxis}Axis`](d.y.value)
8799
+ var width = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
8796
8800
  acummulativeY[d.y.index] += width;
8797
- output = Math.max(1, width);
8801
+ output = width;
8798
8802
  } else {
8799
8803
  if (!getBarX.call(this, d, i, xAxis)) {
8800
8804
  return null;
@@ -8821,12 +8825,21 @@ var WebsyChart = /*#__PURE__*/function () {
8821
8825
 
8822
8826
  if (this.options.orientation === 'horizontal') {
8823
8827
  if (this.options.grouping === 'stacked') {
8824
- output = this["".concat(yAxis, "Axis")](d.y.accumulative);
8828
+ var h = getBarWidth.call(this, d, i, xAxis);
8829
+ var adjustment = 0;
8830
+
8831
+ if (d.y.accumulative && d.y.accumulative !== 0) {
8832
+ adjustment = this["".concat(yAxis, "Axis")](d.y.accumulative || 0);
8833
+ }
8834
+
8835
+ output = this["".concat(yAxis, "Axis")](0) + adjustment * (d.y.value < 0 ? 1 : 0) + h * (d.y.value < 0 ? 1 : 0);
8825
8836
  } else {
8826
- output = 0;
8837
+ var _h = getBarWidth.call(this, d, i, xAxis);
8838
+
8839
+ output = this["".concat(yAxis, "Axis")](0) + _h * (d.y.value < 0 ? 1 : 0);
8827
8840
  }
8828
8841
  } else {
8829
- var adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
8842
+ var _adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
8830
8843
 
8831
8844
  if (this.options.grouping === 'grouped') {
8832
8845
  var barAdjustment = groupedBarWidth * index + (xAxis.indexOf('Brush') === -1 ? 5 : 1); // + (index > 0 ? 4 : 0)
@@ -8874,7 +8887,7 @@ var WebsyChart = /*#__PURE__*/function () {
8874
8887
 
8875
8888
  bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8876
8889
  bars.attr('width', function (d, i) {
8877
- return getBarWidth.call(_this50, d, i, xAxis);
8890
+ return Math.abs(getBarWidth.call(_this50, d, i, xAxis));
8878
8891
  }).attr('height', function (d, i) {
8879
8892
  return getBarHeight.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
8880
8893
  }).attr('x', function (d, i) {
@@ -8886,7 +8899,7 @@ var WebsyChart = /*#__PURE__*/function () {
8886
8899
  return d.y.color || d.color || series.color;
8887
8900
  });
8888
8901
  bars.enter().append('rect').attr('width', function (d, i) {
8889
- return getBarWidth.call(_this50, d, i, xAxis);
8902
+ return Math.abs(getBarWidth.call(_this50, d, i, xAxis));
8890
8903
  }).attr('height', function (d, i) {
8891
8904
  return getBarHeight.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
8892
8905
  }).attr('x', function (d, i) {
@@ -8904,7 +8917,7 @@ var WebsyChart = /*#__PURE__*/function () {
8904
8917
  this.brushBarsInitialized[series.key] = true;
8905
8918
  brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8906
8919
  brushBars.attr('width', function (d, i) {
8907
- return getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush"));
8920
+ return Math.abs(getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush")));
8908
8921
  }).attr('height', function (d, i) {
8909
8922
  return getBarHeight.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8910
8923
  }).attr('x', function (d, i) {
@@ -8916,7 +8929,7 @@ var WebsyChart = /*#__PURE__*/function () {
8916
8929
  return d.y.color || d.color || series.color;
8917
8930
  });
8918
8931
  brushBars.enter().append('rect').attr('width', function (d, i) {
8919
- return getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush"));
8932
+ return Math.abs(getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush")));
8920
8933
  }).attr('height', function (d, i) {
8921
8934
  return getBarHeight.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8922
8935
  }).attr('x', function (d, i) {
@@ -9307,6 +9320,11 @@ var WebsyChart = /*#__PURE__*/function () {
9307
9320
  containerEl.classList.remove('active');
9308
9321
  }
9309
9322
  }
9323
+ }, {
9324
+ key: "hideLoading",
9325
+ value: function hideLoading() {
9326
+ this.loadingDialog.hide();
9327
+ }
9310
9328
  }, {
9311
9329
  key: "showError",
9312
9330
  value: function showError(options) {
@@ -9341,6 +9359,11 @@ var WebsyChart = /*#__PURE__*/function () {
9341
9359
  }
9342
9360
  }
9343
9361
  }
9362
+ }, {
9363
+ key: "showLoading",
9364
+ value: function showLoading(options) {
9365
+ this.loadingDialog.show(options);
9366
+ }
9344
9367
  }, {
9345
9368
  key: "data",
9346
9369
  set: function set(d) {