@websy/websy-designs 1.7.7 → 1.7.9

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.
@@ -6987,7 +6987,8 @@ class WebsyChart {
6987
6987
  brushHeight: 50,
6988
6988
  minBandWidth: 30,
6989
6989
  maxBandWidth: 100,
6990
- allowUnevenBands: true
6990
+ allowUnevenBands: true,
6991
+ balancedMinMax: false
6991
6992
  }
6992
6993
  this.elementId = elementId
6993
6994
  this.options = Object.assign({}, DEFAULTS, options)
@@ -7048,32 +7049,43 @@ class WebsyChart {
7048
7049
  }
7049
7050
  let that = this
7050
7051
  this.brushed = function (event) {
7051
- console.log('brushing', event)
7052
7052
  let newX = (that.options.margin.left + that.options.margin.axisLeft) + (1 - (event.selection[0] / ((that.plotWidth) / (that.widthForCalc + that.totalBandPadding))))
7053
+ let newY = that.options.margin.top + that.options.margin.axisTop
7054
+ if (that.options.orientation === 'horizontal') {
7055
+ newX = that.options.brushHeight + that.options.margin.left + that.options.margin.axisLeft
7056
+ newY = (that.options.margin.top + that.options.margin.axisTop) + (1 - (event.selection[0] / ((that.plotHeight) / (that.widthForCalc + that.totalBandPadding))))
7057
+ }
7053
7058
  if (that.plotArea) {
7054
- that.plotArea.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
7059
+ that.plotArea.attr('transform', `translate(${newX}, ${newY})`)
7055
7060
  }
7056
7061
  if (that.areaLayer) {
7057
- that.areaLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
7062
+ that.areaLayer.attr('transform', `translate(${newX}, ${newY})`)
7058
7063
  }
7059
7064
  if (that.lineLayer) {
7060
- that.lineLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
7065
+ that.lineLayer.attr('transform', `translate(${newX}, ${newY})`)
7061
7066
  }
7062
7067
  if (that.barLayer) {
7063
- that.barLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
7068
+ that.barLayer.attr('transform', `translate(${newX}, ${newY})`)
7064
7069
  }
7065
7070
  if (that.labelLayer) {
7066
- that.labelLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
7071
+ that.labelLayer.attr('transform', `translate(${newX}, ${newY})`)
7067
7072
  }
7068
7073
  if (that.symbolLayer) {
7069
- that.symbolLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
7074
+ that.symbolLayer.attr('transform', `translate(${newX}, ${newY})`)
7070
7075
  }
7071
7076
  if (that.refLineLayer) {
7072
- that.refLineLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
7073
- }
7074
- if (that.bottomAxisLayer) {
7075
- that.bottomAxisLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop + that.plotHeight})`)
7077
+ that.refLineLayer.attr('transform', `translate(${newX}, ${newY})`)
7078
+ }
7079
+ if (that.options.orientation === 'horizontal') {
7080
+ if (that.leftAxisLayer) {
7081
+ that.leftAxisLayer.attr('transform', `translate(${that.options.brushHeight + that.options.margin.left + that.options.margin.axisLeft}, ${newY})`)
7082
+ }
7076
7083
  }
7084
+ else {
7085
+ if (that.bottomAxisLayer) {
7086
+ that.bottomAxisLayer.attr('transform', `translate(${newX}, ${newY + that.plotHeight})`)
7087
+ }
7088
+ }
7077
7089
  // that.brushedDomain = []
7078
7090
  // let xAxis = 'bottom'
7079
7091
  // let xAxisCaps = 'Bottom'
@@ -7441,7 +7453,7 @@ this.clip = this.defs.append('clipPath').attr('id', `${this.elementId}_clip`).ap
7441
7453
  this.xAxisClip = this.defs.append('clipPath').attr('id', `${this.elementId}_xAxisClip`).append('rect')
7442
7454
  this.yAxisClip = this.defs.append('clipPath').attr('id', `${this.elementId}_yAxisClip`).append('rect')
7443
7455
  this.brushClip = this.defs.append('clipPath').attr('id', `${this.elementId}_brushclip`).append('rect')
7444
- this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer') // .attr('clip-path', `url(#${this.elementId}_yAxisClip)`).append('g')
7456
+ this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer').attr('clip-path', `url(#${this.elementId}_yAxisClip)`).append('g')
7445
7457
  this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer')
7446
7458
  this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer').attr('clip-path', `url(#${this.elementId}_xAxisClip)`).append('g')
7447
7459
  this.leftAxisLabel = this.svg.append('g').attr('class', 'left-axis-label-layer')
@@ -7639,6 +7651,22 @@ else {
7639
7651
  if (this.options.data.right.formatter) {
7640
7652
  this.longestRight = this.options.data.right.formatter(this.options.data.right.max).toString()
7641
7653
  }
7654
+ }
7655
+ // Check to see if we need to balance the min and max values
7656
+ if (this.options.balancedMinMax) {
7657
+ if (this.options.orientation === 'horizontal') {
7658
+ let biggestBottom = Math.max(Math.abs(this.options.data.bottom.min, this.options.data.bottom.max))
7659
+ this.options.data.bottom.min = 1 - biggestBottom
7660
+ this.options.data.bottom.max = biggestBottom
7661
+ }
7662
+ else {
7663
+ let biggestLeft = Math.max(Math.abs(this.options.data.left.min, this.options.data.left.max))
7664
+ this.options.data.left.min = 1 - biggestLeft
7665
+ this.options.data.left.max = biggestLeft
7666
+ let biggestRight = Math.max(Math.abs(this.options.data.right.min, this.options.data.right.max))
7667
+ this.options.data.right.min = 1 - biggestRight
7668
+ this.options.data.right.max = biggestRight
7669
+ }
7642
7670
  }
7643
7671
  // establish the space needed for the various axes
7644
7672
  // this.options.margin.axisLeft = this.longestLeft * ((this.options.data.left && this.options.data.left.fontSize) || this.options.fontSize) * 0.7
@@ -7820,48 +7848,53 @@ else {
7820
7848
  // }
7821
7849
  // }
7822
7850
  // Translate the layers
7851
+ const leftBrushAdjustment = this.brushNeeded === true ? this.options.brushHeight : 0
7823
7852
  this.leftAxisLayer
7824
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7853
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7825
7854
  .style('font-size', (this.options.data.left && this.options.data.left.fontSize) || this.options.fontSize)
7826
7855
  this.rightAxisLayer
7827
- .attr('transform', `translate(${this.options.margin.left + this.plotWidth + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7856
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.plotWidth + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7828
7857
  .style('font-size', (this.options.data.right && this.options.data.right.fontSize) || this.options.fontSize)
7829
7858
  this.bottomAxisLayer
7830
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
7859
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
7831
7860
  .style('font-size', (this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize)
7832
7861
  this.leftAxisLabel
7833
- .attr('transform', `translate(${this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop})`)
7862
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop})`)
7834
7863
  this.rightAxisLabel
7835
- .attr('transform', `translate(${this.options.margin.left + this.plotWidth + this.options.margin.axisLeft + this.options.margin.axisRight}, ${this.options.margin.top + this.options.margin.axisTop})`)
7864
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.plotWidth + this.options.margin.axisLeft + this.options.margin.axisRight}, ${this.options.margin.top + this.options.margin.axisTop})`)
7836
7865
  this.bottomAxisLabel
7837
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
7866
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
7838
7867
  this.plotArea
7839
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7868
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7840
7869
  this.areaLayer
7841
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7870
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7842
7871
  this.lineLayer
7843
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7872
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7844
7873
  this.barLayer
7845
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7874
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7846
7875
  this.labelLayer
7847
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7876
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7848
7877
  this.symbolLayer
7849
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7878
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7850
7879
  this.refLineLayer
7851
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7880
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7852
7881
  this.trackingLineLayer
7853
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7882
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7854
7883
  this.clip
7855
- .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, 0)`)
7884
+ .attr('transform', `translate(${(leftBrushAdjustment) + this.options.margin.left + this.options.margin.axisLeft}, 0)`)
7856
7885
  .attr('width', this.plotWidth)
7857
7886
  .attr('height', this.plotHeight + this.options.margin.top + this.options.margin.axisTop)
7858
7887
  if (this.options.orientation === 'horizontal') {
7859
7888
  this.brushLayer
7860
7889
  .attr('transform', `translate(${this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop})`)
7861
7890
  this.yAxisClip
7862
- .attr('transform', `translate(${this.options.brushHeight + this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop})`)
7863
- .attr('width', this.options.margin.axisLeft - this.options.brushHeight)
7864
- .attr('height', this.plotHeight)
7891
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop})`)
7892
+ .attr('width', this.options.margin.axisLeft + 10)
7893
+ .attr('height', this.plotHeight)
7894
+ this.xAxisClip
7895
+ .attr('transform', `translate(${this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
7896
+ .attr('width', this.plotWidth + this.options.margin.axisLeft + this.options.margin.axisRight)
7897
+ .attr('height', longestBottomBounds.height + 10)
7865
7898
  this.brushClip
7866
7899
  .attr('transform', `translate(${this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop})`)
7867
7900
  .attr('height', this.plotHeight)
@@ -7870,6 +7903,10 @@ else {
7870
7903
  else {
7871
7904
  this.brushLayer
7872
7905
  .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height})`)
7906
+ this.yAxisClip
7907
+ .attr('transform', `translate(${this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop - 10})`)
7908
+ .attr('width', this.options.margin.axisLeft + 10)
7909
+ .attr('height', this.plotHeight + 20)
7873
7910
  this.xAxisClip
7874
7911
  .attr('transform', `translate(${this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
7875
7912
  .attr('width', this.plotWidth + this.options.margin.axisLeft + this.options.margin.axisRight)
@@ -8386,7 +8423,7 @@ function getBarHeight (d, i, yAxis, xAxis) {
8386
8423
  output = Math.max(1, this.options.data[xAxis].bandWidth - (xAxis.indexOf('Brush') !== -1 ? 2 : this.options.groupPadding * 2))
8387
8424
  }
8388
8425
  else {
8389
- let x = getBarX.call(this, d, i, xAxis)
8426
+ let x = getBarX.call(this, d, i, yAxis, xAxis)
8390
8427
  if (typeof x === 'undefined' || x === null) {
8391
8428
  return null
8392
8429
  }
@@ -8397,15 +8434,16 @@ function getBarHeight (d, i, yAxis, xAxis) {
8397
8434
  }
8398
8435
  return output
8399
8436
  }
8400
- function getBarWidth (d, i, xAxis) {
8437
+ function getBarWidth (d, i, yAxis, xAxis) {
8401
8438
  let output
8402
8439
  if (this.options.orientation === 'horizontal') {
8403
8440
  // output = this[`${yAxis}Axis`](Math.abs(d.y.value))
8441
+ // output = this[`${yAxis}Axis`](Math.abs(d.y.value))
8442
+ // output = (this[`${yAxis}Axis`](0)) + this[`${yAxis}Axis`](Math.abs(d.y.value))
8404
8443
  output = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
8405
- // output = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
8406
8444
  }
8407
8445
  else {
8408
- let x = getBarX.call(this, d, i, xAxis)
8446
+ let x = getBarX.call(this, d, i, yAxis, xAxis)
8409
8447
  if (typeof x === 'undefined' || x === null) {
8410
8448
  return null
8411
8449
  }
@@ -8416,7 +8454,7 @@ function getBarWidth (d, i, xAxis) {
8416
8454
  }
8417
8455
  return output
8418
8456
  }
8419
- function getBarX (d, i, xAxis) {
8457
+ function getBarX (d, i, yAxis, xAxis) {
8420
8458
  let output
8421
8459
  if (this.options.orientation === 'horizontal') {
8422
8460
  // if (this.options.grouping === 'stacked') {
@@ -8435,13 +8473,24 @@ function getBarX (d, i, xAxis) {
8435
8473
  // output = (this[`${yAxis}Axis`](0)) + (h * (d.y.value < 0 ? 1 : 0))
8436
8474
  // }
8437
8475
  if (this.options.grouping === 'stacked') { // no support for stacks yet
8438
- let accH = getBarWidth.call(this, {x: d.x, y: { value: d.y.accumulative }}, i, xAxis)
8439
- let h = getBarWidth.call(this, d, i, xAxis)
8440
- output = (this[`${yAxis}Axis`](0)) + ((accH + h) * (d.y.accumulative > 0 ? 0 : 1))
8476
+ let accH = getBarWidth.call(this, {x: d.x, y: { value: d.y.accumulative }}, i, yAxis, xAxis)
8477
+ let h = getBarWidth.call(this, d, i, yAxis, xAxis)
8478
+ // output = (this[`${yAxis}Axis`](0)) + ((accH + h) * (d.y.accumulative > 0 ? 0 : 1))
8479
+ if (d.y.value >= 0) {
8480
+ output = (this[`${yAxis}Axis`](0)) + ((Math.abs(accH)) * (d.y.accumulative > 0 ? 1 : 0))
8481
+ }
8482
+ else {
8483
+ output = (this[`${yAxis}Axis`](0)) - ((Math.abs(accH) + Math.abs(h)) * (d.y.accumulative > 0 ? 1 : 0))
8484
+ }
8441
8485
  }
8442
8486
  else {
8443
- let h = getBarWidth.call(this, d, i, xAxis)
8444
- output = (this[`${yAxis}Axis`](0)) + (h * (d.y.value > 0 ? 0 : 1))
8487
+ let h = getBarWidth.call(this, d, i, yAxis, xAxis)
8488
+ if (d.y.value >= 0) {
8489
+ output = (this[`${yAxis}Axis`](0))
8490
+ }
8491
+ else {
8492
+ output = (this[`${yAxis}Axis`](0)) + h
8493
+ }
8445
8494
  }
8446
8495
  }
8447
8496
  else {
@@ -8530,9 +8579,9 @@ bars
8530
8579
  .remove()
8531
8580
 
8532
8581
  bars
8533
- .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
8582
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, yAxis, xAxis)))
8534
8583
  .attr('height', (d, i) => getBarHeight.call(this, d, i, yAxis, xAxis))
8535
- .attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
8584
+ .attr('x', (d, i) => getBarX.call(this, d, i, yAxis, xAxis))
8536
8585
  .attr('y', (d, i) => getBarY.call(this, d, i, yAxis, xAxis))
8537
8586
  // .transition(this.transition)
8538
8587
  .attr('fill', d => d.y.color || d.color || series.color)
@@ -8540,9 +8589,9 @@ bars
8540
8589
  bars
8541
8590
  .enter()
8542
8591
  .append('rect')
8543
- .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
8592
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, yAxis, xAxis)))
8544
8593
  .attr('height', (d, i) => getBarHeight.call(this, d, i, yAxis, xAxis))
8545
- .attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
8594
+ .attr('x', (d, i) => getBarX.call(this, d, i, yAxis, xAxis))
8546
8595
  .attr('y', (d, i) => getBarY.call(this, d, i, yAxis, xAxis))
8547
8596
  // .transition(this.transition)
8548
8597
  .attr('fill', d => d.y.color || d.color || series.color)
@@ -8559,9 +8608,9 @@ if (!this.brushBarsInitialized[series.key]) {
8559
8608
  .remove()
8560
8609
 
8561
8610
  brushBars
8562
- .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
8611
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`)))
8563
8612
  .attr('height', (d, i) => getBarHeight.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
8564
- .attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
8613
+ .attr('x', (d, i) => getBarX.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
8565
8614
  .attr('y', (d, i) => getBarY.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
8566
8615
  // .transition(this.transition)
8567
8616
  .attr('fill', d => d.y.color || d.color || series.color)
@@ -8569,9 +8618,9 @@ if (!this.brushBarsInitialized[series.key]) {
8569
8618
  brushBars
8570
8619
  .enter()
8571
8620
  .append('rect')
8572
- .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
8621
+ .attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`)))
8573
8622
  .attr('height', (d, i) => getBarHeight.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
8574
- .attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
8623
+ .attr('x', (d, i) => getBarX.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
8575
8624
  .attr('y', (d, i) => getBarY.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
8576
8625
  // .transition(this.transition)
8577
8626
  .attr('fill', d => d.y.color || d.color || series.color)
@@ -8627,26 +8676,30 @@ if (this.options.showLabels === true || series.showLabels === true) {
8627
8676
  this.setAttribute('text-anchor', 'middle')
8628
8677
  }
8629
8678
  else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
8679
+ console.log('anhor end for', d.y.value)
8630
8680
  this.setAttribute('text-anchor', 'end')
8631
8681
  this.setAttribute('x', +(this.getAttribute('x')) - 8)
8632
8682
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
8633
8683
  }
8634
- else if (d.y.value < 0 && d.y.value !== that.options.data[yAxis].min) {
8635
- this.setAttribute('text-anchor', 'end')
8636
- this.setAttribute('x', +(this.getAttribute('x')) - 8)
8637
- this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8638
- }
8639
- else if (d.y.value < 0 && d.y.value === that.options.data[yAxis].min) {
8684
+ else if (d.y.value < 0 && this.getAttribute('x') < 0) {
8640
8685
  this.setAttribute('text-anchor', 'start')
8641
- this.setAttribute('x', +(this.getAttribute('x')) + 8)
8686
+ this.setAttribute('x', Math.max(+(this.getAttribute('x')) + 8, 8))
8642
8687
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
8643
8688
  }
8689
+ else if (d.y.value < 0 && this.getAttribute('x') > 0) {
8690
+ console.log('anhor end for', d.y.value)
8691
+ this.setAttribute('text-anchor', 'end')
8692
+ this.setAttribute('x', +(this.getAttribute('x')) - 8)
8693
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8694
+ }
8644
8695
  else if (series.labelPosition === 'outside') {
8645
8696
  this.setAttribute('text-anchor', 'start')
8646
8697
  this.setAttribute('x', +(this.getAttribute('x')) + 8)
8647
8698
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8648
8699
  }
8649
- else {
8700
+ else {
8701
+ console.log('anhor end for', d.y.value)
8702
+ this.setAttribute('text-anchor', 'start')
8650
8703
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8651
8704
  }
8652
8705
  }