@websy/websy-designs 1.4.36 → 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.
@@ -1153,12 +1153,12 @@ class WebsyDatePicker {
1153
1153
  let start = list[0]
1154
1154
  let end = ''
1155
1155
  if (this.customRangeSelected === true && this.isContinuousRange === true) {
1156
- if (list.length > 0) {
1156
+ if (list.length > 1) {
1157
1157
  end = ` - ${list[list.length - 1]}`
1158
1158
  }
1159
1159
  if (this.options.mode === 'hour') {
1160
1160
  start = this.options.hours[start].text
1161
- if (list.length > 0) {
1161
+ if (list.length > 1) {
1162
1162
  end = `${this.customRangeSelected === true ? ' - ' : ''}${this.options.hours[list[list.length - 1]].text}`
1163
1163
  }
1164
1164
  }
@@ -6671,6 +6671,18 @@ class WebsyChart {
6671
6671
  .attr('id', `${this.elementId}_legend`)
6672
6672
  .attr('class', 'websy-chart-legend')
6673
6673
  this.legend = new WebsyDesigns.Legend(`${this.elementId}_legend`, {})
6674
+ this.errorContainer = d3.select(el).append('div')
6675
+ .attr('id', `${this.elementId}_errorContainer`)
6676
+ .attr('class', 'websy-vis-error-container')
6677
+ .html(`
6678
+ <div>
6679
+ <div id="${this.elementId}_errorTitle"></div>
6680
+ <div id="${this.elementId}_errorMessage"></div>
6681
+ </div>
6682
+ `)
6683
+ this.loadingContainer = d3.select(el).append('div')
6684
+ .attr('id', `${this.elementId}_loadingContainer`)
6685
+ this.loadingDialog = new WebsyDesigns.LoadingDialog(`${this.elementId}_loadingContainer`)
6674
6686
  this.prep()
6675
6687
  // el.innerHTML += `
6676
6688
  // <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
@@ -7685,9 +7697,10 @@ function getBarWidth (d, i, xAxis) {
7685
7697
  let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length
7686
7698
  let output
7687
7699
  if (this.options.orientation === 'horizontal') {
7688
- let width = this[`${yAxis}Axis`](d.y.value)
7700
+ // let width = this[`${yAxis}Axis`](d.y.value)
7701
+ let width = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
7689
7702
  acummulativeY[d.y.index] += width
7690
- output = Math.max(1, width)
7703
+ output = width
7691
7704
  }
7692
7705
  else {
7693
7706
  if (!getBarX.call(this, d, i, xAxis)) {
@@ -7711,10 +7724,16 @@ function getBarX (d, i, xAxis) {
7711
7724
  let output
7712
7725
  if (this.options.orientation === 'horizontal') {
7713
7726
  if (this.options.grouping === 'stacked') {
7714
- output = this[`${yAxis}Axis`](d.y.accumulative)
7727
+ let h = getBarWidth.call(this, d, i, xAxis)
7728
+ let adjustment = 0
7729
+ if (d.y.accumulative && d.y.accumulative !== 0) {
7730
+ adjustment = this[`${yAxis}Axis`](d.y.accumulative || 0)
7731
+ }
7732
+ output = this[`${yAxis}Axis`](0) + (adjustment * (d.y.value < 0 ? 1 : 0)) + (h * (d.y.value < 0 ? 1 : 0))
7715
7733
  }
7716
7734
  else {
7717
- output = 0
7735
+ let h = getBarWidth.call(this, d, i, xAxis)
7736
+ output = (this[`${yAxis}Axis`](0)) + (h * (d.y.value < 0 ? 1 : 0))
7718
7737
  }
7719
7738
  }
7720
7739
  else {
@@ -7766,7 +7785,7 @@ bars
7766
7785
  .remove()
7767
7786
 
7768
7787
  bars
7769
- .attr('width', (d, i) => getBarWidth.call(this, d, i, xAxis))
7788
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
7770
7789
  .attr('height', (d, i) => getBarHeight.call(this, d, i, this.plotHeight, yAxis, xAxis))
7771
7790
  .attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
7772
7791
  .attr('y', (d, i) => getBarY.call(this, d, i, this.plotHeight, yAxis, xAxis))
@@ -7776,7 +7795,7 @@ bars
7776
7795
  bars
7777
7796
  .enter()
7778
7797
  .append('rect')
7779
- .attr('width', (d, i) => getBarWidth.call(this, d, i, xAxis))
7798
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
7780
7799
  .attr('height', (d, i) => getBarHeight.call(this, d, i, this.plotHeight, yAxis, xAxis))
7781
7800
  .attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
7782
7801
  .attr('y', (d, i) => getBarY.call(this, d, i, this.plotHeight, yAxis, xAxis))
@@ -7795,7 +7814,7 @@ if (!this.brushBarsInitialized[series.key]) {
7795
7814
  .remove()
7796
7815
 
7797
7816
  brushBars
7798
- .attr('width', (d, i) => getBarWidth.call(this, d, i, `${xAxis}Brush`))
7817
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
7799
7818
  .attr('height', (d, i) => getBarHeight.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
7800
7819
  .attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
7801
7820
  .attr('y', (d, i) => getBarY.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
@@ -7805,7 +7824,7 @@ if (!this.brushBarsInitialized[series.key]) {
7805
7824
  brushBars
7806
7825
  .enter()
7807
7826
  .append('rect')
7808
- .attr('width', (d, i) => getBarWidth.call(this, d, i, `${xAxis}Brush`))
7827
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
7809
7828
  .attr('height', (d, i) => getBarHeight.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
7810
7829
  .attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
7811
7830
  .attr('y', (d, i) => getBarY.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
@@ -8255,6 +8274,9 @@ if (el) {
8255
8274
  containerEl.classList.remove('active')
8256
8275
  }
8257
8276
  }
8277
+ hideLoading () {
8278
+ this.loadingDialog.hide()
8279
+ }
8258
8280
  showError (options) {
8259
8281
  const el = document.getElementById(`${this.elementId}`)
8260
8282
  if (el) {
@@ -8280,6 +8302,9 @@ if (el) {
8280
8302
  }
8281
8303
  }
8282
8304
  }
8305
+ showLoading (options) {
8306
+ this.loadingDialog.show(options)
8307
+ }
8283
8308
  }
8284
8309
 
8285
8310
  class WebsyLegend {
@@ -1273,14 +1273,14 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1273
1273
  var end = '';
1274
1274
 
1275
1275
  if (this.customRangeSelected === true && this.isContinuousRange === true) {
1276
- if (list.length > 0) {
1276
+ if (list.length > 1) {
1277
1277
  end = " - ".concat(list[list.length - 1]);
1278
1278
  }
1279
1279
 
1280
1280
  if (this.options.mode === 'hour') {
1281
1281
  start = this.options.hours[start].text;
1282
1282
 
1283
- if (list.length > 0) {
1283
+ if (list.length > 1) {
1284
1284
  end = "".concat(this.customRangeSelected === true ? ' - ' : '').concat(this.options.hours[list[list.length - 1]].text);
1285
1285
  }
1286
1286
  }
@@ -7318,6 +7318,9 @@ var WebsyChart = /*#__PURE__*/function () {
7318
7318
 
7319
7319
  this.legendArea = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_legend")).attr('class', 'websy-chart-legend');
7320
7320
  this.legend = new WebsyDesigns.Legend("".concat(this.elementId, "_legend"), {});
7321
+ 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 "));
7322
+ this.loadingContainer = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_loadingContainer"));
7323
+ this.loadingDialog = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loadingContainer"));
7321
7324
  this.prep(); // el.innerHTML += `
7322
7325
  // <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
7323
7326
  // <div>
@@ -8316,9 +8319,10 @@ var WebsyChart = /*#__PURE__*/function () {
8316
8319
  var output;
8317
8320
 
8318
8321
  if (this.options.orientation === 'horizontal') {
8319
- var width = this["".concat(yAxis, "Axis")](d.y.value);
8322
+ // let width = this[`${yAxis}Axis`](d.y.value)
8323
+ var width = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
8320
8324
  acummulativeY[d.y.index] += width;
8321
- output = Math.max(1, width);
8325
+ output = width;
8322
8326
  } else {
8323
8327
  if (!getBarX.call(this, d, i, xAxis)) {
8324
8328
  return null;
@@ -8345,12 +8349,21 @@ var WebsyChart = /*#__PURE__*/function () {
8345
8349
 
8346
8350
  if (this.options.orientation === 'horizontal') {
8347
8351
  if (this.options.grouping === 'stacked') {
8348
- output = this["".concat(yAxis, "Axis")](d.y.accumulative);
8352
+ var h = getBarWidth.call(this, d, i, xAxis);
8353
+ var adjustment = 0;
8354
+
8355
+ if (d.y.accumulative && d.y.accumulative !== 0) {
8356
+ adjustment = this["".concat(yAxis, "Axis")](d.y.accumulative || 0);
8357
+ }
8358
+
8359
+ output = this["".concat(yAxis, "Axis")](0) + adjustment * (d.y.value < 0 ? 1 : 0) + h * (d.y.value < 0 ? 1 : 0);
8349
8360
  } else {
8350
- output = 0;
8361
+ var _h = getBarWidth.call(this, d, i, xAxis);
8362
+
8363
+ output = this["".concat(yAxis, "Axis")](0) + _h * (d.y.value < 0 ? 1 : 0);
8351
8364
  }
8352
8365
  } else {
8353
- var adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
8366
+ var _adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
8354
8367
 
8355
8368
  if (this.options.grouping === 'grouped') {
8356
8369
  var barAdjustment = groupedBarWidth * index + (xAxis.indexOf('Brush') === -1 ? 5 : 1); // + (index > 0 ? 4 : 0)
@@ -8398,7 +8411,7 @@ var WebsyChart = /*#__PURE__*/function () {
8398
8411
 
8399
8412
  bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8400
8413
  bars.attr('width', function (d, i) {
8401
- return getBarWidth.call(_this47, d, i, xAxis);
8414
+ return Math.abs(getBarWidth.call(_this47, d, i, xAxis));
8402
8415
  }).attr('height', function (d, i) {
8403
8416
  return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8404
8417
  }).attr('x', function (d, i) {
@@ -8410,7 +8423,7 @@ var WebsyChart = /*#__PURE__*/function () {
8410
8423
  return d.y.color || d.color || series.color;
8411
8424
  });
8412
8425
  bars.enter().append('rect').attr('width', function (d, i) {
8413
- return getBarWidth.call(_this47, d, i, xAxis);
8426
+ return Math.abs(getBarWidth.call(_this47, d, i, xAxis));
8414
8427
  }).attr('height', function (d, i) {
8415
8428
  return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8416
8429
  }).attr('x', function (d, i) {
@@ -8428,7 +8441,7 @@ var WebsyChart = /*#__PURE__*/function () {
8428
8441
  this.brushBarsInitialized[series.key] = true;
8429
8442
  brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8430
8443
  brushBars.attr('width', function (d, i) {
8431
- return getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush"));
8444
+ return Math.abs(getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush")));
8432
8445
  }).attr('height', function (d, i) {
8433
8446
  return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8434
8447
  }).attr('x', function (d, i) {
@@ -8440,7 +8453,7 @@ var WebsyChart = /*#__PURE__*/function () {
8440
8453
  return d.y.color || d.color || series.color;
8441
8454
  });
8442
8455
  brushBars.enter().append('rect').attr('width', function (d, i) {
8443
- return getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush"));
8456
+ return Math.abs(getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush")));
8444
8457
  }).attr('height', function (d, i) {
8445
8458
  return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8446
8459
  }).attr('x', function (d, i) {
@@ -8831,6 +8844,11 @@ var WebsyChart = /*#__PURE__*/function () {
8831
8844
  containerEl.classList.remove('active');
8832
8845
  }
8833
8846
  }
8847
+ }, {
8848
+ key: "hideLoading",
8849
+ value: function hideLoading() {
8850
+ this.loadingDialog.hide();
8851
+ }
8834
8852
  }, {
8835
8853
  key: "showError",
8836
8854
  value: function showError(options) {
@@ -8865,6 +8883,11 @@ var WebsyChart = /*#__PURE__*/function () {
8865
8883
  }
8866
8884
  }
8867
8885
  }
8886
+ }, {
8887
+ key: "showLoading",
8888
+ value: function showLoading(options) {
8889
+ this.loadingDialog.show(options);
8890
+ }
8868
8891
  }, {
8869
8892
  key: "data",
8870
8893
  set: function set(d) {