@websy/websy-designs 1.4.25 → 1.4.26

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.
@@ -7379,7 +7379,7 @@ else {
7379
7379
  firstBottom = Math.max(0, firstBottomWidth)
7380
7380
  }
7381
7381
  }
7382
- this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth)
7382
+ this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth) + 5 // + 5 to accommodate for space between text and axis line
7383
7383
  this.options.margin.axisRight = longestRightBounds.width
7384
7384
  this.options.margin.axisBottom = longestBottomBounds.height + 10
7385
7385
  this.options.margin.axisTop = 0
@@ -7891,7 +7891,12 @@ if (this.options.showLabels === true || series.showLabels === true) {
7891
7891
  .attr('x', d => getLabelX.call(this, d, series.labelPosition))
7892
7892
  .attr('y', d => getLabelY.call(this, d, series.labelPosition))
7893
7893
  .attr('class', `label_${series.key}`)
7894
- .attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
7894
+ .attr('fill', d => {
7895
+ if (this.options.grouping === 'stacked' && d.y.value === 0) {
7896
+ return 'transparent'
7897
+ }
7898
+ return this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color)
7899
+ })
7895
7900
  .style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
7896
7901
  .transition(this.transition)
7897
7902
  .text(d => d.y.label || d.y.value)
@@ -7929,7 +7934,12 @@ if (this.options.showLabels === true || series.showLabels === true) {
7929
7934
  .attr('y', d => getLabelY.call(this, d, series.labelPosition))
7930
7935
  .attr('alignment-baseline', 'central')
7931
7936
  .attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle')
7932
- .attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
7937
+ .attr('fill', d => {
7938
+ if (this.options.grouping === 'stacked' && d.y.value === 0) {
7939
+ return 'transparent'
7940
+ }
7941
+ return this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color)
7942
+ })
7933
7943
  .style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
7934
7944
  .text(d => d.y.label || d.y.value)
7935
7945
  .each(function (d, i) {
@@ -8047,18 +8057,24 @@ if (series.showSymbols === true) {
8047
8057
  /* global d3 data */
8048
8058
  let xAxis = 'bottom'
8049
8059
  let yAxis = 'left'
8060
+ let yAttr = 'y'
8061
+ let xAttr = 'x'
8050
8062
  let that = this
8063
+ let length = this.plotWidth
8051
8064
  if (this.options.orientation === 'horizontal') {
8052
8065
  xAxis = 'left'
8053
8066
  yAxis = 'bottom'
8067
+ yAttr = 'x'
8068
+ xAttr = 'y'
8069
+ length = this.plotHeight
8054
8070
  }
8055
8071
  this.refLineLayer.selectAll('.reference-line').remove()
8056
8072
  this.refLineLayer.selectAll('.reference-line-label').remove()
8057
8073
  this.refLineLayer
8058
8074
  .append('line')
8059
- .attr('y1', this[`${yAxis}Axis`](data.value))
8060
- .attr('y2', this[`${yAxis}Axis`](data.value))
8061
- .attr('x2', this.plotWidth)
8075
+ .attr(`${yAttr}1`, this[`${yAxis}Axis`](data.value))
8076
+ .attr(`${yAttr}2`, this[`${yAxis}Axis`](data.value))
8077
+ .attr(`${xAttr}2`, length)
8062
8078
  .attr('class', `reference-line`)
8063
8079
  .style('stroke', data.color)
8064
8080
  .style('stroke-width', `${data.lineWidth}px`)
@@ -8068,7 +8084,7 @@ if (data.label && data.label !== '') {
8068
8084
  this.refLineLayer
8069
8085
  .append('text')
8070
8086
  .attr('class', `reference-line-label`)
8071
- .attr('x', this.plotWidth)
8087
+ .attr('x', length)
8072
8088
  .attr('y', this[`${yAxis}Axis`](data.value))
8073
8089
  .attr('font-size', this.options.fontSize)
8074
8090
  .attr('fill', data.color)
@@ -8180,7 +8180,8 @@ var WebsyChart = /*#__PURE__*/function () {
8180
8180
  }
8181
8181
  }
8182
8182
 
8183
- this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth);
8183
+ this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth) + 5; // + 5 to accommodate for space between text and axis line
8184
+
8184
8185
  this.options.margin.axisRight = longestRightBounds.width;
8185
8186
  this.options.margin.axisBottom = longestBottomBounds.height + 10;
8186
8187
  this.options.margin.axisTop = 0; // adjust axis margins based on title options
@@ -8616,6 +8617,10 @@ var WebsyChart = /*#__PURE__*/function () {
8616
8617
  }).attr('y', function (d) {
8617
8618
  return getLabelY.call(_this49, d, series.labelPosition);
8618
8619
  }).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
8620
+ if (_this49.options.grouping === 'stacked' && d.y.value === 0) {
8621
+ return 'transparent';
8622
+ }
8623
+
8619
8624
  return _this49.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8620
8625
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
8621
8626
  return d.y.label || d.y.value;
@@ -8645,6 +8650,10 @@ var WebsyChart = /*#__PURE__*/function () {
8645
8650
  }).attr('y', function (d) {
8646
8651
  return getLabelY.call(_this49, d, series.labelPosition);
8647
8652
  }).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
8653
+ if (_this49.options.grouping === 'stacked' && d.y.value === 0) {
8654
+ return 'transparent';
8655
+ }
8656
+
8648
8657
  return _this49.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8649
8658
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
8650
8659
  return d.y.label || d.y.value;
@@ -8752,20 +8761,26 @@ var WebsyChart = /*#__PURE__*/function () {
8752
8761
  /* global d3 data */
8753
8762
  var xAxis = 'bottom';
8754
8763
  var yAxis = 'left';
8764
+ var yAttr = 'y';
8765
+ var xAttr = 'x';
8755
8766
  var that = this;
8767
+ var length = this.plotWidth;
8756
8768
 
8757
8769
  if (this.options.orientation === 'horizontal') {
8758
8770
  xAxis = 'left';
8759
8771
  yAxis = 'bottom';
8772
+ yAttr = 'x';
8773
+ xAttr = 'y';
8774
+ length = this.plotHeight;
8760
8775
  }
8761
8776
 
8762
8777
  this.refLineLayer.selectAll('.reference-line').remove();
8763
8778
  this.refLineLayer.selectAll('.reference-line-label').remove();
8764
- this.refLineLayer.append('line').attr('y1', this["".concat(yAxis, "Axis")](data.value)).attr('y2', this["".concat(yAxis, "Axis")](data.value)).attr('x2', this.plotWidth).attr('class', "reference-line").style('stroke', data.color).style('stroke-width', "".concat(data.lineWidth, "px")).style('stroke-dasharray', data.lineStyle);
8779
+ 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);
8765
8780
 
8766
8781
  if (data.label && data.label !== '') {
8767
8782
  // show the text on the line
8768
- this.refLineLayer.append('text').attr('class', "reference-line-label").attr('x', this.plotWidth).attr('y', this["".concat(yAxis, "Axis")](data.value)).attr('font-size', this.options.fontSize).attr('fill', data.color).text(data.label).attr('text-anchor', 'end').attr('alignment-baseline', 'text-after-edge');
8783
+ this.refLineLayer.append('text').attr('class', "reference-line-label").attr('x', length).attr('y', this["".concat(yAxis, "Axis")](data.value)).attr('font-size', this.options.fontSize).attr('fill', data.color).text(data.label).attr('text-anchor', 'end').attr('alignment-baseline', 'text-after-edge');
8769
8784
  }
8770
8785
  }
8771
8786
  }, {