@websy/websy-designs 1.7.8 → 1.7.10

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.
@@ -131,6 +131,30 @@ class AuthHelper {
131
131
  res.redirect('/login')
132
132
  }
133
133
  }
134
+ checkPermissions (req, res, next) {
135
+ console.log('hello')
136
+ const permissions = {
137
+ entities: {
138
+ POST: false,
139
+ PUT: true,
140
+ GET: true,
141
+ DELETE: true
142
+ },
143
+ item: {
144
+ POST: true,
145
+ PUT: true,
146
+ GET: true,
147
+ DELETE: true
148
+ }
149
+ }
150
+ if (permissions[req.params.entity] && permissions[req.params.entity][req.method] === true) {
151
+ next()
152
+ }
153
+ else {
154
+ res.status(403)
155
+ res.json('User does not have permissions to ....')
156
+ }
157
+ }
134
158
  }
135
159
 
136
160
  module.exports = AuthHelper
@@ -2,9 +2,8 @@ const express = require('express')
2
2
  const router = express.Router()
3
3
  // const PG = require('../helpers/dbHelper')
4
4
  // const dbHelper = new PG()
5
- // const AuthHelper = require('../helpers/auth')
6
5
 
7
- function APIRoutes (dbHelper) {
6
+ function APIRoutes (dbHelper, authHelper) {
8
7
  router.delete('/:entity/:id', (req, res) => {
9
8
  const sql = `DELETE FROM ${req.params.entity} WHERE ${dbHelper.buildWhereWithId(req.params.entity, req.params.id)}`
10
9
  dbHelper.execute(sql).then(response => res.json(response), err => res.json(err))
@@ -44,7 +43,7 @@ function APIRoutes (dbHelper) {
44
43
  }
45
44
  }, err => res.json(err))
46
45
  })
47
- router.post('/:entity', (req, res) => {
46
+ router.post('/:entity', authHelper.checkPermissions, (req, res) => {
48
47
  // const sql = dbHelper.buildInsert(req.params.entity, req.body, req.session.passport.user.id)
49
48
  console.log(req.body)
50
49
  const sql = dbHelper.buildInsert(req.params.entity, req.body)
@@ -26,6 +26,7 @@ module.exports = function (options) {
26
26
  app.set('trust proxy', 1)
27
27
  process.env.wdRoot = __dirname
28
28
  let version = options.version || 'v1'
29
+ process.env.WD_VERSION = version
29
30
  app.use(bodyParser.json({limit: '5mb'}))
30
31
  app.use(bodyParser.urlencoded({limit: '5mb', extended: true}))
31
32
  app.use(bodyParser.raw({limit: '5mb'}))
@@ -172,7 +173,7 @@ module.exports = function (options) {
172
173
  }
173
174
  app.use(protectedRoutes)
174
175
  if (options.useAPI === true) {
175
- app.use('/api', protectedRoutes, require(`./routes/${version}/api`)(dbHelper))
176
+ app.use('/api', protectedRoutes, require(`./routes/${version}/api`)(dbHelper, app.authHelper))
176
177
  }
177
178
  if (options.useShop === true) {
178
179
  app.use('/shop', protectedRoutes, require(`./routes/${version}/shop`)(dbHelper, options.dbEngine, app))
@@ -6055,7 +6055,13 @@ class WebsyTable3 {
6055
6055
  <div id="${this.elementId}_hScrollContainer" class="websy-h-scroll-container">
6056
6056
  <div id="${this.elementId}_hScrollHandle" class="websy-scroll-handle websy-scroll-handle-x"></div>
6057
6057
  </div>
6058
- <div id="${this.elementId}_touchScroller" class="websy-table-touch-scroller hidden"></div>
6058
+ `
6059
+ if (this.isTouchDevice === true) {
6060
+ html += `
6061
+ <div id="${this.elementId}_touchScroller" class="websy-table-touch-scroller"></div>
6062
+ `
6063
+ }
6064
+ html += `
6059
6065
  </div>
6060
6066
  <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
6061
6067
  <div>
@@ -6079,7 +6085,7 @@ class WebsyTable3 {
6079
6085
  el.addEventListener('click', this.handleClick.bind(this))
6080
6086
  el.addEventListener('mousedown', this.handleMouseDown.bind(this))
6081
6087
  el.addEventListener('touchstart', this.handleTouchStart.bind(this))
6082
- window.addEventListener('touchmove', this.handleTouchMove.bind(this))
6088
+ el.addEventListener('touchmove', this.handleTouchMove.bind(this))
6083
6089
  window.addEventListener('touchend', this.handleTouchEnd.bind(this))
6084
6090
  window.addEventListener('mousemove', this.handleMouseMove.bind(this))
6085
6091
  window.addEventListener('mouseup', this.handleMouseUp.bind(this))
@@ -6212,12 +6218,12 @@ class WebsyTable3 {
6212
6218
  }
6213
6219
  if (sizingColumns[sizeIndex].showAsLink === true && cell.value.trim() !== '') {
6214
6220
  cell.value = `
6215
- <a href='${cell.value}' target='${sizingColumns[sizeIndex].openInNewTab === true ? '_blank' : '_self'}'>${cell.displayText || sizingColumns[sizeIndex].linkText || cell.value}</a>
6221
+ <a href="${cell.value}" target='${sizingColumns[sizeIndex].openInNewTab === true ? '_blank' : '_self'}'>${cell.displayText || sizingColumns[sizeIndex].linkText || cell.value}</a>
6216
6222
  `
6217
6223
  }
6218
6224
  if (sizingColumns[sizeIndex].showAsRouterLink === true && cell.value.trim() !== '') {
6219
6225
  cell.value = `
6220
- <a data-view='${(cell.link || cell.value).replace(/'/g, '\'')}' class='websy-trigger'>${cell.value}</a>
6226
+ <a data-view="${(cell.link || cell.value).replace(/'/g, '\'')}" class='websy-trigger'>${cell.value}</a>
6221
6227
  `
6222
6228
  }
6223
6229
  if (sizingColumns[sizeIndex].showAsImage === true) {
@@ -6623,8 +6629,8 @@ class WebsyTable3 {
6623
6629
  this.isPerpetual = true
6624
6630
  // this.perpetualScroll()
6625
6631
  this.touchStartTime = null
6626
- const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
6627
- touchScrollEl.classList.add('hidden')
6632
+ // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
6633
+ // touchScrollEl.classList.add('hidden')
6628
6634
  }
6629
6635
  }
6630
6636
  handleTouchMove (event) {
@@ -6635,6 +6641,12 @@ class WebsyTable3 {
6635
6641
  if (typeof event.targetTouches !== 'undefined' && event.targetTouches.length > 0) {
6636
6642
  let deltaX = (this.mouseXStart - event.targetTouches[0].pageX)
6637
6643
  let deltaY = (this.mouseYStart - event.targetTouches[0].pageY)
6644
+ const hScrollContainerEl = document.getElementById(`${this.elementId}_hScrollContainer`)
6645
+ const vScrollContainerEl = document.getElementById(`${this.elementId}_vScrollContainer`)
6646
+ const hScrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6647
+ const vScrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
6648
+ let translatedDeltaX = deltaX * (hScrollHandleEl.getBoundingClientRect().width / vScrollContainerEl.getBoundingClientRect().width)
6649
+ let translatedDeltaY = deltaY * (vScrollHandleEl.getBoundingClientRect().height / vScrollContainerEl.getBoundingClientRect().height)
6638
6650
  // need to adjust the delta so that it scrolls at a reasonable speed/distance
6639
6651
  const scrollHandleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6640
6652
  const scrollHandleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
@@ -6644,7 +6656,7 @@ class WebsyTable3 {
6644
6656
  // else {
6645
6657
  // this.isTouchScrolling = false
6646
6658
  // }
6647
- console.log('delta init', deltaY)
6659
+ console.log('delta', this.mouseYStart, event.targetTouches[0].pageY, deltaY)
6648
6660
  // deltaX = deltaX * (scrollHandleXEl.offsetWidth / this.sizes.scrollableWidth)
6649
6661
  // deltaY = deltaY * (scrollHandleYEl.offsetHeight / this.sizes.bodyHeight)
6650
6662
  // console.log('delta', deltaY)
@@ -6659,11 +6671,13 @@ class WebsyTable3 {
6659
6671
  // delta = Math.max(-10, delta)
6660
6672
  if (this.isTouchScrolling === true) {
6661
6673
  // this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
6662
- if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 10) {
6663
- this.scrollX(Math.max(-5, Math.min(5, deltaX)))
6674
+ if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 20) {
6675
+ // this.scrollX(Math.max(-5, Math.min(5, translatedDeltaX)))
6676
+ this.scrollX(translatedDeltaX)
6664
6677
  }
6665
- else {
6666
- this.scrollY(Math.max(-5, Math.min(5, deltaY)))
6678
+ else if (deltaY > 20) {
6679
+ // this.scrollY(Math.max(-5, Math.min(5, translatedDeltaY)))
6680
+ this.scrollY(translatedDeltaY)
6667
6681
  }
6668
6682
  }
6669
6683
  }
@@ -6683,8 +6697,8 @@ class WebsyTable3 {
6683
6697
  this.isPerpetual = false
6684
6698
  this.mouseYStart = event.targetTouches[0].pageY
6685
6699
  this.mouseXStart = event.targetTouches[0].pageX
6686
- const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
6687
- touchScrollEl.classList.remove('hidden')
6700
+ // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
6701
+ // touchScrollEl.classList.remove('hidden')
6688
6702
  const handleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
6689
6703
  this.handleYStart = handleYEl.offsetTop
6690
6704
  const handleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
@@ -6987,7 +7001,8 @@ class WebsyChart {
6987
7001
  brushHeight: 50,
6988
7002
  minBandWidth: 30,
6989
7003
  maxBandWidth: 100,
6990
- allowUnevenBands: true
7004
+ allowUnevenBands: true,
7005
+ balancedMinMax: false
6991
7006
  }
6992
7007
  this.elementId = elementId
6993
7008
  this.options = Object.assign({}, DEFAULTS, options)
@@ -7527,14 +7542,14 @@ else {
7527
7542
  this.options.data.bottom = { data: [] }
7528
7543
  }
7529
7544
  if (this.options.orientation === 'vertical') {
7530
- this.leftAxisLayer.attr('class', 'y-axis')
7531
- this.rightAxisLayer.attr('class', 'y-axis')
7532
- this.bottomAxisLayer.attr('class', 'x-axis')
7545
+ this.leftAxisLayer && this.leftAxisLayer.attr('class', 'y-axis')
7546
+ this.rightAxisLayer && this.rightAxisLayer.attr('class', 'y-axis')
7547
+ this.bottomAxisLayer && this.bottomAxisLayer.attr('class', 'x-axis')
7533
7548
  }
7534
7549
  else {
7535
- this.leftAxisLayer.attr('class', 'x-axis')
7536
- this.rightAxisLayer.attr('class', 'x-axis')
7537
- this.bottomAxisLayer.attr('class', 'y-axis')
7550
+ this.leftAxisLayer && this.leftAxisLayer.attr('class', 'x-axis')
7551
+ this.rightAxisLayer && this.rightAxisLayer.attr('class', 'x-axis')
7552
+ this.bottomAxisLayer && this.bottomAxisLayer.attr('class', 'y-axis')
7538
7553
  }
7539
7554
  const el = document.getElementById(this.elementId)
7540
7555
  if (el) {
@@ -7650,6 +7665,22 @@ else {
7650
7665
  if (this.options.data.right.formatter) {
7651
7666
  this.longestRight = this.options.data.right.formatter(this.options.data.right.max).toString()
7652
7667
  }
7668
+ }
7669
+ // Check to see if we need to balance the min and max values
7670
+ if (this.options.balancedMinMax) {
7671
+ if (this.options.orientation === 'horizontal') {
7672
+ let biggestBottom = Math.max(Math.abs(this.options.data.bottom.min, this.options.data.bottom.max))
7673
+ this.options.data.bottom.min = 1 - biggestBottom
7674
+ this.options.data.bottom.max = biggestBottom
7675
+ }
7676
+ else {
7677
+ let biggestLeft = Math.max(Math.abs(this.options.data.left.min, this.options.data.left.max))
7678
+ this.options.data.left.min = 1 - biggestLeft
7679
+ this.options.data.left.max = biggestLeft
7680
+ let biggestRight = Math.max(Math.abs(this.options.data.right.min, this.options.data.right.max))
7681
+ this.options.data.right.min = 1 - biggestRight
7682
+ this.options.data.right.max = biggestRight
7683
+ }
7653
7684
  }
7654
7685
  // establish the space needed for the various axes
7655
7686
  // this.options.margin.axisLeft = this.longestLeft * ((this.options.data.left && this.options.data.left.fontSize) || this.options.fontSize) * 0.7
@@ -7831,7 +7862,7 @@ else {
7831
7862
  // }
7832
7863
  // }
7833
7864
  // Translate the layers
7834
- const leftBrushAdjustment = this.brushNeeded === true ? this.options.brushHeight + 5 : 0
7865
+ const leftBrushAdjustment = this.brushNeeded === true ? this.options.brushHeight : 0
7835
7866
  this.leftAxisLayer
7836
7867
  .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7837
7868
  .style('font-size', (this.options.data.left && this.options.data.left.fontSize) || this.options.fontSize)
@@ -7848,23 +7879,23 @@ else {
7848
7879
  this.bottomAxisLabel
7849
7880
  .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
7850
7881
  this.plotArea
7851
- .attr('transform', `translate(${leftBrushAdjustment - 5 + 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})`)
7852
7883
  this.areaLayer
7853
- .attr('transform', `translate(${leftBrushAdjustment - 5 + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7884
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7854
7885
  this.lineLayer
7855
- .attr('transform', `translate(${leftBrushAdjustment - 5 + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7886
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7856
7887
  this.barLayer
7857
- .attr('transform', `translate(${leftBrushAdjustment - 5 + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7888
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7858
7889
  this.labelLayer
7859
- .attr('transform', `translate(${leftBrushAdjustment - 5 + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7890
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7860
7891
  this.symbolLayer
7861
- .attr('transform', `translate(${leftBrushAdjustment - 5 + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7892
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7862
7893
  this.refLineLayer
7863
- .attr('transform', `translate(${leftBrushAdjustment - 5 + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7894
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7864
7895
  this.trackingLineLayer
7865
- .attr('transform', `translate(${leftBrushAdjustment - 5 + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7896
+ .attr('transform', `translate(${leftBrushAdjustment + this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
7866
7897
  this.clip
7867
- .attr('transform', `translate(${(leftBrushAdjustment - 5) + this.options.margin.left + this.options.margin.axisLeft}, 0)`)
7898
+ .attr('transform', `translate(${(leftBrushAdjustment) + this.options.margin.left + this.options.margin.axisLeft}, 0)`)
7868
7899
  .attr('width', this.plotWidth)
7869
7900
  .attr('height', this.plotHeight + this.options.margin.top + this.options.margin.axisTop)
7870
7901
  if (this.options.orientation === 'horizontal') {
@@ -8421,9 +8452,9 @@ function getBarWidth (d, i, yAxis, xAxis) {
8421
8452
  let output
8422
8453
  if (this.options.orientation === 'horizontal') {
8423
8454
  // output = this[`${yAxis}Axis`](Math.abs(d.y.value))
8424
- output = this[`${yAxis}Axis`](Math.abs(d.y.value))
8455
+ // output = this[`${yAxis}Axis`](Math.abs(d.y.value))
8425
8456
  // output = (this[`${yAxis}Axis`](0)) + this[`${yAxis}Axis`](Math.abs(d.y.value))
8426
- // output = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
8457
+ output = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
8427
8458
  }
8428
8459
  else {
8429
8460
  let x = getBarX.call(this, d, i, yAxis, xAxis)
@@ -8459,11 +8490,21 @@ function getBarX (d, i, yAxis, xAxis) {
8459
8490
  let accH = getBarWidth.call(this, {x: d.x, y: { value: d.y.accumulative }}, i, yAxis, xAxis)
8460
8491
  let h = getBarWidth.call(this, d, i, yAxis, xAxis)
8461
8492
  // output = (this[`${yAxis}Axis`](0)) + ((accH + h) * (d.y.accumulative > 0 ? 0 : 1))
8462
- output = (this[`${yAxis}Axis`](0)) + ((accH) * (d.y.accumulative > 0 ? 1 : 0))
8493
+ if (d.y.value >= 0) {
8494
+ output = (this[`${yAxis}Axis`](0)) + ((Math.abs(accH)) * (d.y.accumulative > 0 ? 1 : 0))
8495
+ }
8496
+ else {
8497
+ output = (this[`${yAxis}Axis`](0)) - ((Math.abs(accH) + Math.abs(h)) * (d.y.accumulative > 0 ? 1 : 0))
8498
+ }
8463
8499
  }
8464
8500
  else {
8465
8501
  let h = getBarWidth.call(this, d, i, yAxis, xAxis)
8466
- output = (this[`${yAxis}Axis`](0)) + (h * (d.y.value > 0 ? 0 : 1))
8502
+ if (d.y.value >= 0) {
8503
+ output = (this[`${yAxis}Axis`](0))
8504
+ }
8505
+ else {
8506
+ output = (this[`${yAxis}Axis`](0)) + h
8507
+ }
8467
8508
  }
8468
8509
  }
8469
8510
  else {
@@ -8648,27 +8689,28 @@ if (this.options.showLabels === true || series.showLabels === true) {
8648
8689
  if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
8649
8690
  this.setAttribute('text-anchor', 'middle')
8650
8691
  }
8651
- else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
8692
+ else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
8652
8693
  this.setAttribute('text-anchor', 'end')
8653
8694
  this.setAttribute('x', +(this.getAttribute('x')) - 8)
8654
8695
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
8655
8696
  }
8656
- else if (d.y.value < 0 && d.y.value !== that.options.data[yAxis].min) {
8657
- this.setAttribute('text-anchor', 'end')
8658
- this.setAttribute('x', +(this.getAttribute('x')) - 8)
8659
- this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8660
- }
8661
- else if (d.y.value < 0 && d.y.value === that.options.data[yAxis].min) {
8697
+ else if (d.y.value < 0 && this.getAttribute('x') < 0) {
8662
8698
  this.setAttribute('text-anchor', 'start')
8663
- this.setAttribute('x', +(this.getAttribute('x')) + 8)
8699
+ this.setAttribute('x', Math.max(+(this.getAttribute('x')) + 8, 8))
8664
8700
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
8665
8701
  }
8702
+ else if (d.y.value < 0 && this.getAttribute('x') > 0) {
8703
+ this.setAttribute('text-anchor', 'end')
8704
+ this.setAttribute('x', +(this.getAttribute('x')) - 8)
8705
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8706
+ }
8666
8707
  else if (series.labelPosition === 'outside') {
8667
8708
  this.setAttribute('text-anchor', 'start')
8668
8709
  this.setAttribute('x', +(this.getAttribute('x')) + 8)
8669
8710
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8670
8711
  }
8671
- else {
8712
+ else {
8713
+ this.setAttribute('text-anchor', 'start')
8672
8714
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8673
8715
  }
8674
8716
  }
@@ -8705,16 +8747,16 @@ if (this.options.showLabels === true || series.showLabels === true) {
8705
8747
  this.setAttribute('x', +(this.getAttribute('x')) - 8)
8706
8748
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
8707
8749
  }
8708
- else if (d.y.value < 0 && d.y.value !== that.options.data[yAxis].min) {
8709
- this.setAttribute('text-anchor', 'end')
8710
- this.setAttribute('x', +(this.getAttribute('x')) - 8)
8711
- this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8712
- }
8713
- else if (d.y.value < 0 && d.y.value === that.options.data[yAxis].min) {
8750
+ else if (d.y.value < 0 && this.getAttribute('x') < 0) {
8714
8751
  this.setAttribute('text-anchor', 'start')
8715
- this.setAttribute('x', +(this.getAttribute('x')) + 8)
8752
+ this.setAttribute('x', Math.max(+(this.getAttribute('x')) + 8, 8))
8716
8753
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
8717
8754
  }
8755
+ else if (d.y.value < 0 && this.getAttribute('x') > 0) {
8756
+ this.setAttribute('text-anchor', 'end')
8757
+ this.setAttribute('x', +(this.getAttribute('x')) - 8)
8758
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
8759
+ }
8718
8760
  else if (series.labelPosition === 'outside') {
8719
8761
  this.setAttribute('text-anchor', 'start')
8720
8762
  this.setAttribute('x', +(this.getAttribute('x')) + 8)