@websy/websy-designs 1.4.25 → 1.4.27

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.
@@ -2580,7 +2580,8 @@ class WebsyNavigationMenu {
2580
2580
  }
2581
2581
  handleSearch (searchText) {
2582
2582
  const el = document.getElementById(this.elementId)
2583
- let lowestItems = this.flatItems.filter(d => d.level === this.maxLevel)
2583
+ // let lowestItems = this.flatItems.filter(d => d.level === this.maxLevel)
2584
+ let lowestItems = this.flatItems.filter(d => !d.hasChildren)
2584
2585
  let visibleItems = lowestItems
2585
2586
  let defaultMethod = 'remove'
2586
2587
  if (searchText && searchText.length > 1) {
@@ -6967,7 +6968,7 @@ else {
6967
6968
  firstBottom = Math.max(0, firstBottomWidth)
6968
6969
  }
6969
6970
  }
6970
- this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth)
6971
+ this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth) + 5 // + 5 to accommodate for space between text and axis line
6971
6972
  this.options.margin.axisRight = longestRightBounds.width
6972
6973
  this.options.margin.axisBottom = longestBottomBounds.height + 10
6973
6974
  this.options.margin.axisTop = 0
@@ -7223,7 +7224,6 @@ else {
7223
7224
  if (this.rightAxis.nice) {
7224
7225
  this.rightAxis.nice()
7225
7226
  }
7226
- console.log('axis right', this.options.margin.axisRight)
7227
7227
  if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
7228
7228
  this.rightAxisLayer.call(
7229
7229
  d3.axisRight(this.rightAxis)
@@ -7479,7 +7479,12 @@ if (this.options.showLabels === true || series.showLabels === true) {
7479
7479
  .attr('x', d => getLabelX.call(this, d, series.labelPosition))
7480
7480
  .attr('y', d => getLabelY.call(this, d, series.labelPosition))
7481
7481
  .attr('class', `label_${series.key}`)
7482
- .attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
7482
+ .attr('fill', d => {
7483
+ if (this.options.grouping === 'stacked' && d.y.value === 0) {
7484
+ return 'transparent'
7485
+ }
7486
+ return this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color)
7487
+ })
7483
7488
  .style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
7484
7489
  .transition(this.transition)
7485
7490
  .text(d => d.y.label || d.y.value)
@@ -7517,7 +7522,12 @@ if (this.options.showLabels === true || series.showLabels === true) {
7517
7522
  .attr('y', d => getLabelY.call(this, d, series.labelPosition))
7518
7523
  .attr('alignment-baseline', 'central')
7519
7524
  .attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle')
7520
- .attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
7525
+ .attr('fill', d => {
7526
+ if (this.options.grouping === 'stacked' && d.y.value === 0) {
7527
+ return 'transparent'
7528
+ }
7529
+ return this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color)
7530
+ })
7521
7531
  .style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
7522
7532
  .text(d => d.y.label || d.y.value)
7523
7533
  .each(function (d, i) {
@@ -7635,18 +7645,24 @@ if (series.showSymbols === true) {
7635
7645
  /* global d3 data */
7636
7646
  let xAxis = 'bottom'
7637
7647
  let yAxis = 'left'
7648
+ let yAttr = 'y'
7649
+ let xAttr = 'x'
7638
7650
  let that = this
7651
+ let length = this.plotWidth
7639
7652
  if (this.options.orientation === 'horizontal') {
7640
7653
  xAxis = 'left'
7641
7654
  yAxis = 'bottom'
7655
+ yAttr = 'x'
7656
+ xAttr = 'y'
7657
+ length = this.plotHeight
7642
7658
  }
7643
7659
  this.refLineLayer.selectAll('.reference-line').remove()
7644
7660
  this.refLineLayer.selectAll('.reference-line-label').remove()
7645
7661
  this.refLineLayer
7646
7662
  .append('line')
7647
- .attr('y1', this[`${yAxis}Axis`](data.value))
7648
- .attr('y2', this[`${yAxis}Axis`](data.value))
7649
- .attr('x2', this.plotWidth)
7663
+ .attr(`${yAttr}1`, this[`${yAxis}Axis`](data.value))
7664
+ .attr(`${yAttr}2`, this[`${yAxis}Axis`](data.value))
7665
+ .attr(`${xAttr}2`, length)
7650
7666
  .attr('class', `reference-line`)
7651
7667
  .style('stroke', data.color)
7652
7668
  .style('stroke-width', `${data.lineWidth}px`)
@@ -7656,7 +7672,7 @@ if (data.label && data.label !== '') {
7656
7672
  this.refLineLayer
7657
7673
  .append('text')
7658
7674
  .attr('class', `reference-line-label`)
7659
- .attr('x', this.plotWidth)
7675
+ .attr('x', length)
7660
7676
  .attr('y', this[`${yAxis}Axis`](data.value))
7661
7677
  .attr('font-size', this.options.fontSize)
7662
7678
  .attr('fill', data.color)
@@ -8217,8 +8233,7 @@ class WebsyChartTooltip {
8217
8233
  }
8218
8234
  if (position.onTop === true) {
8219
8235
  classes.push('top')
8220
- }
8221
- console.log(classes.join(' '))
8236
+ }
8222
8237
  let fO = this.tooltipLayer
8223
8238
  .selectAll('foreignObject')
8224
8239
  .attr('width', `${position.width}px`)
@@ -2734,9 +2734,10 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2734
2734
  value: function handleSearch(searchText) {
2735
2735
  var _this17 = this;
2736
2736
 
2737
- var el = document.getElementById(this.elementId);
2737
+ var el = document.getElementById(this.elementId); // let lowestItems = this.flatItems.filter(d => d.level === this.maxLevel)
2738
+
2738
2739
  var lowestItems = this.flatItems.filter(function (d) {
2739
- return d.level === _this17.maxLevel;
2740
+ return !d.hasChildren;
2740
2741
  });
2741
2742
  var visibleItems = lowestItems;
2742
2743
  var defaultMethod = 'remove';
@@ -7704,7 +7705,8 @@ var WebsyChart = /*#__PURE__*/function () {
7704
7705
  }
7705
7706
  }
7706
7707
 
7707
- this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth);
7708
+ this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth) + 5; // + 5 to accommodate for space between text and axis line
7709
+
7708
7710
  this.options.margin.axisRight = longestRightBounds.width;
7709
7711
  this.options.margin.axisBottom = longestBottomBounds.height + 10;
7710
7712
  this.options.margin.axisTop = 0; // adjust axis margins based on title options
@@ -7909,8 +7911,6 @@ var WebsyChart = /*#__PURE__*/function () {
7909
7911
  this.rightAxis.nice();
7910
7912
  }
7911
7913
 
7912
- console.log('axis right', this.options.margin.axisRight);
7913
-
7914
7914
  if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
7915
7915
  this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
7916
7916
  if (_this44.options.data.right.formatter) {
@@ -8140,6 +8140,10 @@ var WebsyChart = /*#__PURE__*/function () {
8140
8140
  }).attr('y', function (d) {
8141
8141
  return getLabelY.call(_this46, d, series.labelPosition);
8142
8142
  }).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
8143
+ if (_this46.options.grouping === 'stacked' && d.y.value === 0) {
8144
+ return 'transparent';
8145
+ }
8146
+
8143
8147
  return _this46.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8144
8148
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
8145
8149
  return d.y.label || d.y.value;
@@ -8169,6 +8173,10 @@ var WebsyChart = /*#__PURE__*/function () {
8169
8173
  }).attr('y', function (d) {
8170
8174
  return getLabelY.call(_this46, d, series.labelPosition);
8171
8175
  }).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
8176
+ if (_this46.options.grouping === 'stacked' && d.y.value === 0) {
8177
+ return 'transparent';
8178
+ }
8179
+
8172
8180
  return _this46.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8173
8181
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
8174
8182
  return d.y.label || d.y.value;
@@ -8276,20 +8284,26 @@ var WebsyChart = /*#__PURE__*/function () {
8276
8284
  /* global d3 data */
8277
8285
  var xAxis = 'bottom';
8278
8286
  var yAxis = 'left';
8287
+ var yAttr = 'y';
8288
+ var xAttr = 'x';
8279
8289
  var that = this;
8290
+ var length = this.plotWidth;
8280
8291
 
8281
8292
  if (this.options.orientation === 'horizontal') {
8282
8293
  xAxis = 'left';
8283
8294
  yAxis = 'bottom';
8295
+ yAttr = 'x';
8296
+ xAttr = 'y';
8297
+ length = this.plotHeight;
8284
8298
  }
8285
8299
 
8286
8300
  this.refLineLayer.selectAll('.reference-line').remove();
8287
8301
  this.refLineLayer.selectAll('.reference-line-label').remove();
8288
- 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);
8302
+ 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);
8289
8303
 
8290
8304
  if (data.label && data.label !== '') {
8291
8305
  // show the text on the line
8292
- 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');
8306
+ 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');
8293
8307
  }
8294
8308
  }
8295
8309
  }, {
@@ -8895,7 +8909,6 @@ var WebsyChartTooltip = /*#__PURE__*/function () {
8895
8909
  classes.push('top');
8896
8910
  }
8897
8911
 
8898
- console.log(classes.join(' '));
8899
8912
  var fO = this.tooltipLayer.selectAll('foreignObject').attr('width', "".concat(position.width, "px")) // .attr('height', `${position.height}px`)
8900
8913
  // .attr('y', `0px`)
8901
8914
  .attr('class', "websy-chart-tooltip ".concat(classes.join(' ')));