@websy/websy-designs 1.4.38 → 1.5.1

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.
@@ -6304,7 +6304,7 @@ class WebsyTable3 {
6304
6304
  }
6305
6305
  // console.log('rowspan', cell.rowspan)
6306
6306
  bodyHtml += `<td
6307
- class='websy-table-cell ${sizeIndex < this.pinnedColumns ? 'pinned' : 'unpinned'} ${(cell.classes || []).join(' ')}'
6307
+ class='websy-table-cell ${sizeIndex < this.pinnedColumns ? 'pinned' : 'unpinned'} ${(cell.classes || []).join(' ')} ${(sizingColumns[sizeIndex].classes || []).join(' ')}'
6308
6308
  style='${style}'
6309
6309
  data-info='${cell.value}'
6310
6310
  colspan='${cell.colspan || 1}'
@@ -6401,7 +6401,7 @@ class WebsyTable3 {
6401
6401
  style += col.style
6402
6402
  }
6403
6403
  headerHtml += `<td
6404
- class='websy-table-cell ${colIndex < this.pinnedColumns ? 'pinned' : 'unpinned'}'
6404
+ class='websy-table-cell ${colIndex < this.pinnedColumns ? 'pinned' : 'unpinned'} ${(col.classes || []).join(' ')}'
6405
6405
  style='${style}'
6406
6406
  colspan='${col.colspan || 1}'
6407
6407
  rowspan='${col.rowspan || 1}'
@@ -6457,7 +6457,7 @@ class WebsyTable3 {
6457
6457
  let totalHtml = `<tr class="websy-table-row websy-table-total-row">`
6458
6458
  this.options.totals.forEach((col, colIndex) => {
6459
6459
  totalHtml += `<td
6460
- class='websy-table-cell'
6460
+ class='websy-table-cell ${(col.classes || []).join(' ')}'
6461
6461
  colspan='${col.colspan || 1}'
6462
6462
  rowspan='${col.rowspan || 1}'
6463
6463
  `
@@ -6482,6 +6482,10 @@ class WebsyTable3 {
6482
6482
  let outerEl = document.getElementById(this.elementId)
6483
6483
  let tableEl = document.getElementById(`${this.elementId}_tableContainer`)
6484
6484
  let headEl = document.getElementById(`${this.elementId}_tableHeader`)
6485
+ if (!headEl) {
6486
+ // something isn't right so exit the function
6487
+ return
6488
+ }
6485
6489
  headEl.style.width = 'auto'
6486
6490
  headEl.innerHTML = this.buildHeaderHtml()
6487
6491
  this.sizes.outer = outerEl.getBoundingClientRect()
@@ -6728,7 +6732,9 @@ class WebsyTable3 {
6728
6732
  el.classList.remove('has-error')
6729
6733
  }
6730
6734
  const tableEl = document.getElementById(`${this.elementId}_tableInner`)
6731
- tableEl.classList.remove('hidden')
6735
+ if (tableEl) {
6736
+ tableEl.classList.remove('hidden')
6737
+ }
6732
6738
  const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
6733
6739
  if (containerEl) {
6734
6740
  containerEl.classList.remove('active')
@@ -6763,6 +6769,10 @@ class WebsyTable3 {
6763
6769
  this.appendRows(data)
6764
6770
  }
6765
6771
  let bodyEl = document.getElementById(`${this.elementId}_tableBody`)
6772
+ if (!bodyEl) {
6773
+ // something isn't right so exit the function
6774
+ return
6775
+ }
6766
6776
  // bodyEl.innerHTML = this.buildBodyHtml(data, true)
6767
6777
  // if (this.options.maxHeight) {
6768
6778
  // bodyEl.style.height = `${this.options.maxHeight - this.sizes.header.height - this.sizes.total.height}px`
@@ -6962,6 +6972,7 @@ class WebsyChart {
6962
6972
  lineWidth: 2,
6963
6973
  forceZero: true,
6964
6974
  grouping: 'grouped',
6975
+ groupPadding: 3,
6965
6976
  fontSize: 14,
6966
6977
  symbolSize: 20,
6967
6978
  showTrackingLine: true,
@@ -6970,7 +6981,8 @@ class WebsyChart {
6970
6981
  legendPosition: 'bottom',
6971
6982
  tooltipWidth: 200,
6972
6983
  brushHeight: 50,
6973
- minBandWidth: 30
6984
+ minBandWidth: 30,
6985
+ allowUnevenBands: true
6974
6986
  }
6975
6987
  this.elementId = elementId
6976
6988
  this.options = Object.assign({}, DEFAULTS, options)
@@ -6995,25 +7007,43 @@ class WebsyChart {
6995
7007
  xAxis += 'Brush'
6996
7008
  }
6997
7009
  xAxis += 'Axis'
6998
- let width = this[xAxis].step()
6999
7010
  let output
7000
- let domain = [...this[xAxis].domain()]
7001
- if (this.options.orientation === 'horizontal') {
7002
- domain = domain.reverse()
7003
- }
7004
- for (let j = 0; j < domain.length; j++) {
7005
- let breakA = this[xAxis](domain[j]) - (width / 2)
7006
- let breakB = breakA + width
7007
- if (input > breakA && input <= breakB) {
7008
- output = j
7009
- break
7011
+ let width = this.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth
7012
+ if (this.customBottomRange) {
7013
+ for (let index = 0; index < this.customBottomRange.length; index++) {
7014
+ if (input > this.customBottomRange[index]) {
7015
+ if (this.customBottomRange[index + 1]) {
7016
+ if (input < this.customBottomRange[index + 1]) {
7017
+ output = index
7018
+ break
7019
+ }
7020
+ }
7021
+ else {
7022
+ output = index
7023
+ break
7024
+ }
7025
+ }
7010
7026
  }
7011
- }
7027
+ }
7028
+ else {
7029
+ let domain = [...this[xAxis].domain()]
7030
+ if (this.options.orientation === 'horizontal') {
7031
+ domain = domain.reverse()
7032
+ }
7033
+ for (let j = 0; j < domain.length; j++) {
7034
+ let breakA = this[xAxis](domain[j]) - (width / 2)
7035
+ let breakB = breakA + width
7036
+ if (input > breakA && input <= breakB) {
7037
+ output = j
7038
+ break
7039
+ }
7040
+ }
7041
+ }
7012
7042
  return output
7013
7043
  }
7014
7044
  let that = this
7015
7045
  this.brushed = function (event) {
7016
- console.log('brushing', event)
7046
+ console.log('brushing', event)
7017
7047
  that.brushedDomain = []
7018
7048
  let xAxis = 'bottom'
7019
7049
  let xAxisCaps = 'Bottom'
@@ -7021,6 +7051,9 @@ class WebsyChart {
7021
7051
  xAxis = 'left'
7022
7052
  xAxisCaps = 'Left'
7023
7053
  }
7054
+ if (!that[`${xAxis}Axis`]) {
7055
+ return
7056
+ }
7024
7057
  if (!that[`${xAxis}Axis`].invert) {
7025
7058
  that[`${xAxis}Axis`].invert = that.invertOverride
7026
7059
  }
@@ -7210,7 +7243,12 @@ else {
7210
7243
  }
7211
7244
  this.options.data.series.forEach(s => {
7212
7245
  if (this.options.data[xData].scale !== 'Time') {
7213
- xPoint = this[xAxis](this.parseX(xLabel))
7246
+ if (this.customBottomRange && this.customBottomRange.length > 0) {
7247
+ xPoint = this.customBottomRange[x0] + ((this.customBottomRange[x0 + 1] - this.customBottomRange[x0]) / 2)
7248
+ }
7249
+ else {
7250
+ xPoint = this[xAxis](this.parseX(xLabel))
7251
+ }
7214
7252
  s.data.forEach(d => {
7215
7253
  if (d.x.value === xLabel) {
7216
7254
  if (!tooltipTitle) {
@@ -7299,7 +7337,7 @@ else {
7299
7337
  onLeft: xPoint > this.plotWidth / 2
7300
7338
  }
7301
7339
  if (xPoint > this.plotWidth / 2) {
7302
- posOptions.left = xPoint - this.options.tooltipWidth + this.options.margin.left + this.options.margin.axisLeft + 15
7340
+ posOptions.left = xPoint - this.options.tooltipWidth - 15 // + this.options.margin.left + this.options.margin.axisLeft + 15)
7303
7341
  if (this.options.data[xData].scale !== 'Time') {
7304
7342
  // posOptions.left -= (this[xAxis].bandwidth())
7305
7343
  posOptions.left += 10
@@ -7308,7 +7346,7 @@ else {
7308
7346
  else {
7309
7347
  posOptions.left = xPoint + this.options.margin.left + this.options.margin.axisLeft + 15
7310
7348
  if (this.options.data[xData].scale !== 'Time') {
7311
- posOptions.left += (this[xAxis].bandwidth() / 2)
7349
+ posOptions.left += (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
7312
7350
  }
7313
7351
  }
7314
7352
  posOptions.top = this.options.margin.top + this.options.margin.axisTop
@@ -7316,7 +7354,7 @@ else {
7316
7354
  delete posOptions.onLeft
7317
7355
  let adjuster = 0
7318
7356
  if (this.options.data[xData].scale !== 'Time') {
7319
- adjuster = (this[xAxis].bandwidth() / 2) // - this.options.margin.top
7357
+ adjuster = (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2) // - this.options.margin.top
7320
7358
  }
7321
7359
  posOptions = {
7322
7360
  width: this.options.tooltipWidth,
@@ -7337,8 +7375,8 @@ else {
7337
7375
  // else {
7338
7376
  // xPoint = x0
7339
7377
  // }
7340
- if (this.options.data[xData].scale !== 'Time') {
7341
- xPoint += (this[xAxis].bandwidth() / 2) // - this.options.margin.top
7378
+ if (this.options.data[xData].scale !== 'Time' && this.customBottomRange.length === 0) {
7379
+ xPoint += (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2) // - this.options.margin.top
7342
7380
  }
7343
7381
  let trackingXStart = xPoint
7344
7382
  let trackingXEnd = xPoint
@@ -7407,6 +7445,7 @@ if (!this.options.data) {
7407
7445
  // tell the user no data has been provided
7408
7446
  }
7409
7447
  else {
7448
+ this.processedX = {}
7410
7449
  this.transition = d3.transition().duration(this.options.transitionDuration)
7411
7450
  if (this.options.data.bottom.scale && this.options.data.bottom.scale === 'Time') {
7412
7451
  this.parseX = function (input) {
@@ -7453,7 +7492,13 @@ else {
7453
7492
  // establish the space and size for the legend
7454
7493
  // the legend gets rendered so that we can get its actual size
7455
7494
  if (this.options.showLegend === true) {
7456
- let legendData = this.options.data.series.map((s, i) => ({value: s.label || s.key, color: s.color || this.options.colors[i % this.options.colors.length]}))
7495
+ let legendData = []
7496
+ if (this.options.legendData && this.options.legendData.length > 0) {
7497
+ legendData = this.options.legendData
7498
+ }
7499
+ else {
7500
+ this.options.data.series.map((s, i) => ({value: s.label || s.key, color: s.color || this.options.colors[i % this.options.colors.length]}))
7501
+ }
7457
7502
  if (this.options.legendPosition === 'top' || this.options.legendPosition === 'bottom') {
7458
7503
  this.legendArea.style('width', '100%')
7459
7504
  this.legend.options.align = 'center'
@@ -7625,18 +7670,30 @@ else {
7625
7670
  this.plotHeight = this.height - this.options.margin.legendTop - this.options.margin.legendBottom - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom - this.options.margin.axisTop
7626
7671
  this.brushNeeded = false
7627
7672
  if (this.options.orientation === 'vertical') {
7628
- if (this.options.maxBandWidth) {
7629
- this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.data || []).length * this.options.maxBandWidth)
7673
+ this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
7674
+ if (typeof b.valueCount === 'undefined') {
7675
+ return a + 1
7676
+ }
7677
+ return a + b.valueCount
7678
+ }, 0)
7679
+ if (this.options.maxBandWidth) {
7680
+ this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.totalValueCount) * this.options.maxBandWidth)
7630
7681
  }
7631
7682
  // some if to check if brushing is needed
7632
- if (this.plotWidth / this.options.data.bottom.data.length < this.options.minBandWidth) {
7683
+ if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
7633
7684
  this.brushNeeded = true
7634
7685
  this.plotHeight -= this.options.brushHeight
7635
7686
  }
7636
7687
  }
7637
7688
  else {
7638
7689
  // some if to check if brushing is needed
7639
- if (this.plotHeight / this.options.data.left.data.length < this.options.minBandWidth) {
7690
+ this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
7691
+ if (typeof b.valueCount === 'undefined') {
7692
+ return a + 1
7693
+ }
7694
+ return a + b.valueCount
7695
+ }, 0)
7696
+ if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
7640
7697
  this.brushNeeded = true
7641
7698
  this.plotWidth -= this.options.brushHeight
7642
7699
  }
@@ -7691,14 +7748,39 @@ else {
7691
7748
  // this.tooltip.transform(this.options.margin.left + this.options.margin.axisLeft, this.options.margin.top + this.options.margin.axisTop)
7692
7749
  // Configure the bottom axis
7693
7750
  let bottomDomain = this.createDomain('bottom')
7694
- let bottomBrushDomain = this.createDomain('bottom', true)
7751
+ let bottomBrushDomain = this.createDomain('bottom', true)
7752
+ let bottomRange = [0, this.plotWidth]
7753
+ this.customBottomRange = []
7754
+ if (this.options.allowUnevenBands === true) {
7755
+ if (this.options.data.bottom.data && this.options.data.bottom.data[0] && this.options.data.bottom.data[0].valueCount && this.options.data.bottom.scale === 'Ordinal') {
7756
+ let acc = 0
7757
+ this.customBottomRange = [0, ...this.options.data.bottom.data.map(d => {
7758
+ acc += d.valueCount
7759
+ return (this.plotWidth / this.options.data.bottom.totalValueCount) * acc
7760
+ })]
7761
+ }
7762
+ }
7763
+ this.options.data.bottom.step = this.plotWidth / this.options.data.bottom.totalValueCount
7764
+ this.options.data.bottom.bandWidth = this.options.data.bottom.step
7765
+ if (this.options.data.bottom.padding) {
7766
+ this.totalPadding = this.plotWidth * this.options.data.bottom.padding
7767
+ let rangeLength = bottomDomain.length
7768
+ if (this.customBottomRange.length > 0) {
7769
+ rangeLength = this.customBottomRange.length
7770
+ }
7771
+ this.bandPadding = (this.totalPadding / (rangeLength)) / 2
7772
+ this.options.data.bottom.bandWidth = (this.plotWidth - this.totalPadding) / this.options.data.bottom.totalValueCount
7773
+ }
7774
+ if (this.options.grouping === 'grouped' && this.options.data.series.length > 1) {
7775
+ this.options.data.bottom.bandWidth = this.options.data.bottom.bandWidth - (this.options.groupPadding * 2)
7776
+ }
7695
7777
  this.bottomAxis = d3[`scale${this.options.data.bottom.scale || 'Band'}`]()
7696
7778
  .domain(bottomDomain)
7697
- .range([0, this.plotWidth])
7779
+ .range(bottomRange)
7698
7780
  if (!this.brushInitialized) {
7699
7781
  this.bottomBrushAxis = d3[`scale${this.options.data.bottom.scale || 'Band'}`]()
7700
7782
  .domain(bottomBrushDomain)
7701
- .range([0, this.plotWidth])
7783
+ .range(bottomRange)
7702
7784
  }
7703
7785
  if (this.bottomAxis.nice) {
7704
7786
  // this.bottomAxis.nice()
@@ -7870,6 +7952,10 @@ else {
7870
7952
  .style('text-anchor', `${((this.options.data.bottom && this.options.data.bottom.rotate) || 0) === 0 ? 'middle' : 'end'}`)
7871
7953
  .style('transform-origin', ((this.options.data.bottom && this.options.data.bottom.rotate) || 0) === 0 ? '0 0' : `0 ${((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize)}px`)
7872
7954
  }
7955
+ if (this.customBottomRange.length > 0) {
7956
+ this.bottomAxisLayer.selectAll('g')
7957
+ .attr('transform', (d, i) => `translate(${this.customBottomRange[i] + ((this.customBottomRange[i + 1] - this.customBottomRange[i]) / 2)}, 0)`)
7958
+ }
7873
7959
  }
7874
7960
  // Configure the left axis
7875
7961
  let leftDomain = this.createDomain('left')
@@ -8015,6 +8101,8 @@ this.options.data.series.forEach((series, index) => {
8015
8101
  this.renderLabels(series, index)
8016
8102
  this.renderedKeys[series.key] = series.type
8017
8103
  })
8104
+ this.refLineLayer.selectAll('.reference-line').remove()
8105
+ this.refLineLayer.selectAll('.reference-line-label').remove()
8018
8106
  if (this.options.refLines && this.options.refLines.length > 0) {
8019
8107
  this.options.refLines.forEach(l => this.renderRefLine(l))
8020
8108
  }
@@ -8026,21 +8114,21 @@ const drawArea = (xAxis, yAxis, curveStyle) => {
8026
8114
  return d3
8027
8115
  .area()
8028
8116
  .x(d => {
8029
- return this[xAxis](this.parseX(d.x.value))
8117
+ return this[`${xAxis}Axis`](this.parseX(d.x.value))
8030
8118
  })
8031
8119
  .y0(d => {
8032
- return this[yAxis](0)
8120
+ return this[`${yAxis}Axis`](0)
8033
8121
  })
8034
8122
  .y1(d => {
8035
- return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value)
8123
+ return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
8036
8124
  })
8037
8125
  .curve(d3[curveStyle || this.options.curveStyle])
8038
8126
  }
8039
- let xAxis = 'bottomAxis'
8040
- let yAxis = series.axis === 'secondary' ? 'rightAxis' : 'leftAxis'
8041
- if (this.options.orienation === 'horizontal') {
8042
- xAxis = series.axis === 'secondary' ? 'rightAxis' : 'leftAxis'
8043
- yAxis = 'bottomAxis'
8127
+ let xAxis = 'bottom'
8128
+ let yAxis = series.axis === 'secondary' ? 'right' : 'left'
8129
+ if (this.options.orientation === 'horizontal') {
8130
+ xAxis = series.axis === 'secondary' ? 'right' : 'left'
8131
+ yAxis = 'bottom'
8044
8132
  }
8045
8133
  let areas = this.areaLayer.selectAll(`.area_${series.key}`)
8046
8134
  .data([series.data])
@@ -8063,7 +8151,7 @@ areas.enter().append('path')
8063
8151
  .attr('d', d => drawArea(xAxis, yAxis, series.curveStyle)(d))
8064
8152
  .attr('class', `area_${series.key}`)
8065
8153
  .attr('id', `area_${series.key}`)
8066
- // .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
8154
+ .attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2) + ',0)')
8067
8155
  // .style('stroke-width', series.lineWidth || this.options.lineWidth)
8068
8156
  .attr('fill', series.color)
8069
8157
  // .style('fill-opacity', 0)
@@ -8086,15 +8174,14 @@ if (this.options.orientation === 'horizontal') {
8086
8174
  // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
8087
8175
  // barWidth = barWidth / this.options.data.series.length - 4
8088
8176
  // }
8089
- function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
8090
- let barWidth = this[`${xAxis}Axis`].bandwidth()
8091
- let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
8177
+ function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
8092
8178
  let output
8093
8179
  if (this.options.orientation === 'horizontal') {
8094
- output = barWidth
8180
+ output = this.options.data[xAxis.replace('Brush', '')].bandWidth
8095
8181
  }
8096
8182
  else {
8097
- if (!getBarX.call(this, d, i, xAxis)) {
8183
+ let x = getBarX.call(this, d, i, xAxis)
8184
+ if (typeof x === 'undefined' || x === null) {
8098
8185
  return null
8099
8186
  }
8100
8187
  output = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
@@ -8104,26 +8191,19 @@ function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
8104
8191
  }
8105
8192
  return output
8106
8193
  }
8107
- function getBarWidth (d, i, xAxis) {
8108
- let barWidth = this[`${xAxis}Axis`].bandwidth()
8109
- let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length
8194
+ function getBarWidth (d, i, xAxis) {
8110
8195
  let output
8111
- if (this.options.orientation === 'horizontal') {
8112
- // let width = this[`${yAxis}Axis`](d.y.value)
8196
+ if (this.options.orientation === 'horizontal') {
8113
8197
  let width = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
8114
8198
  acummulativeY[d.y.index] += width
8115
8199
  output = width
8116
8200
  }
8117
8201
  else {
8118
- if (!getBarX.call(this, d, i, xAxis)) {
8202
+ let x = getBarX.call(this, d, i, xAxis)
8203
+ if (typeof x === 'undefined' || x === null) {
8119
8204
  return null
8120
- }
8121
- if (this.options.grouping === 'grouped') {
8122
- output = Math.max(1, groupedBarWidth)
8123
- }
8124
- else {
8125
- output = Math.max(1, barWidth)
8126
- }
8205
+ }
8206
+ output = Math.max(1, this.options.data[xAxis.replace('Brush', '')].bandWidth)
8127
8207
  }
8128
8208
  if (isNaN(output)) {
8129
8209
  return 0
@@ -8131,8 +8211,11 @@ function getBarWidth (d, i, xAxis) {
8131
8211
  return output
8132
8212
  }
8133
8213
  function getBarX (d, i, xAxis) {
8134
- let barWidth = this[`${xAxis}Axis`].bandwidth()
8135
- let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length
8214
+ // let barWidth = this.plotWidth / this.options.data[xAxis.replace('Brush', '')].totalValueCount
8215
+ // if (this.options.data[xAxis.replace('Brush', '')].padding) {
8216
+ // barWidth = barWidth - (barWidth * this.options.data[xAxis.replace('Brush', '')].padding)
8217
+ // }
8218
+ // let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data[xAxis.replace('Brush', '')].totalValueCount
8136
8219
  let output
8137
8220
  if (this.options.orientation === 'horizontal') {
8138
8221
  if (this.options.grouping === 'stacked') {
@@ -8149,10 +8232,34 @@ function getBarX (d, i, xAxis) {
8149
8232
  }
8150
8233
  }
8151
8234
  else {
8152
- let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
8153
- if (this.options.grouping === 'grouped') {
8154
- let barAdjustment = groupedBarWidth * index + (xAxis.indexOf('Brush') === -1 ? 5 : 1) // + (index > 0 ? 4 : 0)
8155
- output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + barAdjustment
8235
+ // let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
8236
+ let adjustment = this.customBottomRange[i] + (i * this.options.data[xAxis.replace('Brush', '')].bandWidth)
8237
+ if (this.options.grouping === 'grouped') {
8238
+ let xIndex = 0
8239
+ if (this.processedX[d.x.value]) {
8240
+ xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel))
8241
+ }
8242
+ let barAdjustment =
8243
+ (this.options.data[xAxis.replace('Brush', '')].bandWidth * xIndex) +
8244
+ (xIndex * this.options.groupPadding * 2) + this.options.groupPadding +
8245
+ (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
8246
+ // let barAdjustment =
8247
+ // (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
8248
+ // this.options.groupPadding
8249
+ // // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
8250
+ if (this.customBottomRange.length > 0) {
8251
+ output = this.customBottomRange[this[xAxis.replace('Brush', '') + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
8252
+ }
8253
+ else {
8254
+ output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + barAdjustment
8255
+ }
8256
+ if (!this.processedX[d.x.value]) {
8257
+ this.processedX[d.x.value] = []
8258
+ }
8259
+ if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
8260
+ this.processedX[d.x.value].push(d.y.tooltipLabel)
8261
+ }
8262
+ console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
8156
8263
  }
8157
8264
  else {
8158
8265
  // output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
@@ -8165,15 +8272,15 @@ function getBarX (d, i, xAxis) {
8165
8272
  return output
8166
8273
  }
8167
8274
  function getBarY (d, i, heightBounds, yAxis, xAxis) {
8168
- let barWidth = this[`${xAxis}Axis`].bandwidth()
8169
- let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
8275
+ // let barWidth = this[`${xAxis}Axis`].bandwidth()
8276
+ // let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
8170
8277
  let output
8171
8278
  if (this.options.orientation === 'horizontal') {
8172
8279
  if (this.options.grouping !== 'grouped') {
8173
8280
  output = this[`${xAxis}Axis`](this.parseX(d.x.value))
8174
8281
  }
8175
8282
  else {
8176
- output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + ((d.y.index || i) * barWidth)
8283
+ output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + ((d.y.index || i) * this.options.data[xAxis.replace('Brush', '')].barWidth)
8177
8284
  }
8178
8285
  }
8179
8286
  else {
@@ -8367,12 +8474,12 @@ function getLabelX (d, labelPosition = 'inside') {
8367
8474
  }
8368
8475
  }
8369
8476
  else {
8370
- return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
8477
+ return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
8371
8478
  }
8372
8479
  }
8373
8480
  function getLabelY (d, labelPosition = 'inside') {
8374
8481
  if (this.options.orientation === 'horizontal') {
8375
- return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
8482
+ return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
8376
8483
  }
8377
8484
  else {
8378
8485
  if (this.options.grouping === 'stacked') {
@@ -8391,23 +8498,34 @@ const drawLine = (xAxis, yAxis, curveStyle) => {
8391
8498
  return d3
8392
8499
  .line()
8393
8500
  .x(d => {
8394
- let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
8395
- return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
8501
+ if (this.options.orientation === 'horizontal') {
8502
+ return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
8503
+ }
8504
+ else {
8505
+ let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
8506
+ return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
8507
+ }
8396
8508
  })
8397
8509
  .y(d => {
8398
- return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
8510
+ if (this.options.orientation === 'horizontal') {
8511
+ let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
8512
+ return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
8513
+ }
8514
+ else {
8515
+ return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
8516
+ }
8399
8517
  })
8400
8518
  .curve(d3[curveStyle || this.options.curveStyle])
8401
8519
  }
8402
8520
  let xAxis = 'bottom'
8403
8521
  let yAxis = series.axis === 'secondary' ? 'right' : 'left'
8404
- if (this.options.orienation === 'horizontal') {
8522
+ if (this.options.orientation === 'horizontal') {
8405
8523
  xAxis = series.axis === 'secondary' ? 'right' : 'left'
8406
8524
  yAxis = 'bottom'
8407
8525
  }
8408
8526
  let xBrushAxis = 'bottomBrush'
8409
8527
  let yBrushAxis = 'leftBrush'
8410
- if (this.options.orienation === 'horizontal') {
8528
+ if (this.options.orientation === 'horizontal') {
8411
8529
  xBrushAxis = 'leftBrush'
8412
8530
  yBrushAxis = 'bottomBrush'
8413
8531
  }
@@ -8493,8 +8611,6 @@ if (this.options.orientation === 'horizontal') {
8493
8611
  xAttr = 'y'
8494
8612
  length = this.plotHeight
8495
8613
  }
8496
- this.refLineLayer.selectAll('.reference-line').remove()
8497
- this.refLineLayer.selectAll('.reference-line-label').remove()
8498
8614
  this.refLineLayer
8499
8615
  .append('line')
8500
8616
  .attr(`${yAttr}1`, this[`${yAxis}Axis`](data.value))
@@ -8543,7 +8659,7 @@ const drawSymbol = (size) => {
8543
8659
  }
8544
8660
  let xAxis = 'bottom'
8545
8661
  let yAxis = series.axis === 'secondary' ? 'right' : 'left'
8546
- if (this.options.orienation === 'horizontal') {
8662
+ if (this.options.orientation === 'horizontal') {
8547
8663
  xAxis = series.axis === 'secondary' ? 'right' : 'left'
8548
8664
  yAxis = 'bottom'
8549
8665
  }
@@ -8561,8 +8677,13 @@ symbols
8561
8677
  .attr('fill', series.fillSymbols ? series.color : 'white')
8562
8678
  .attr('stroke', series.color)
8563
8679
  .attr('transform', d => {
8564
- let adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
8565
- return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
8680
+ let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
8681
+ if (this.options.orientation === 'horizontal') {
8682
+ return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
8683
+ }
8684
+ else {
8685
+ return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
8686
+ }
8566
8687
  })
8567
8688
  // Enter
8568
8689
  symbols.enter()
@@ -8573,8 +8694,13 @@ symbols.enter()
8573
8694
  .attr('stroke', series.color)
8574
8695
  .attr('class', d => { return `symbol symbol_${series.key}` })
8575
8696
  .attr('transform', d => {
8576
- let adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
8577
- return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
8697
+ let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
8698
+ if (this.options.orientation === 'horizontal') {
8699
+ return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
8700
+ }
8701
+ else {
8702
+ return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
8703
+ }
8578
8704
  })
8579
8705
 
8580
8706
  }
@@ -8678,9 +8804,9 @@ if (el) {
8678
8804
  if (el) {
8679
8805
  el.classList.remove('has-error')
8680
8806
  }
8681
- // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
8682
- // chartEl.classList.remove('hidden')
8683
- this.svg.classed('hidden', false)
8807
+ if (this.svg) {
8808
+ this.svg.classed('hidden', false)
8809
+ }
8684
8810
  const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
8685
8811
  if (containerEl) {
8686
8812
  containerEl.classList.remove('active')
@@ -8695,8 +8821,10 @@ if (el) {
8695
8821
  el.classList.add('has-error')
8696
8822
  }
8697
8823
  // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
8698
- // chartEl.classList.add('hidden')
8699
- this.svg.classed('hidden', true)
8824
+ // chartEl.classList.add('hidden')
8825
+ if (this.svg) {
8826
+ this.svg.classed('hidden', true)
8827
+ }
8700
8828
  const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
8701
8829
  if (containerEl) {
8702
8830
  containerEl.classList.add('active')