@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.
- package/dist/websy-designs-es6.debug.js +215 -87
- package/dist/websy-designs-es6.js +233 -86
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +215 -87
- package/dist/websy-designs.js +233 -86
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -5892,7 +5892,7 @@ class WebsyTable3 {
|
|
|
5892
5892
|
}
|
|
5893
5893
|
// console.log('rowspan', cell.rowspan)
|
|
5894
5894
|
bodyHtml += `<td
|
|
5895
|
-
class='websy-table-cell ${sizeIndex < this.pinnedColumns ? 'pinned' : 'unpinned'} ${(cell.classes || []).join(' ')}'
|
|
5895
|
+
class='websy-table-cell ${sizeIndex < this.pinnedColumns ? 'pinned' : 'unpinned'} ${(cell.classes || []).join(' ')} ${(sizingColumns[sizeIndex].classes || []).join(' ')}'
|
|
5896
5896
|
style='${style}'
|
|
5897
5897
|
data-info='${cell.value}'
|
|
5898
5898
|
colspan='${cell.colspan || 1}'
|
|
@@ -5989,7 +5989,7 @@ class WebsyTable3 {
|
|
|
5989
5989
|
style += col.style
|
|
5990
5990
|
}
|
|
5991
5991
|
headerHtml += `<td
|
|
5992
|
-
class='websy-table-cell ${colIndex < this.pinnedColumns ? 'pinned' : 'unpinned'}'
|
|
5992
|
+
class='websy-table-cell ${colIndex < this.pinnedColumns ? 'pinned' : 'unpinned'} ${(col.classes || []).join(' ')}'
|
|
5993
5993
|
style='${style}'
|
|
5994
5994
|
colspan='${col.colspan || 1}'
|
|
5995
5995
|
rowspan='${col.rowspan || 1}'
|
|
@@ -6045,7 +6045,7 @@ class WebsyTable3 {
|
|
|
6045
6045
|
let totalHtml = `<tr class="websy-table-row websy-table-total-row">`
|
|
6046
6046
|
this.options.totals.forEach((col, colIndex) => {
|
|
6047
6047
|
totalHtml += `<td
|
|
6048
|
-
class='websy-table-cell'
|
|
6048
|
+
class='websy-table-cell ${(col.classes || []).join(' ')}'
|
|
6049
6049
|
colspan='${col.colspan || 1}'
|
|
6050
6050
|
rowspan='${col.rowspan || 1}'
|
|
6051
6051
|
`
|
|
@@ -6070,6 +6070,10 @@ class WebsyTable3 {
|
|
|
6070
6070
|
let outerEl = document.getElementById(this.elementId)
|
|
6071
6071
|
let tableEl = document.getElementById(`${this.elementId}_tableContainer`)
|
|
6072
6072
|
let headEl = document.getElementById(`${this.elementId}_tableHeader`)
|
|
6073
|
+
if (!headEl) {
|
|
6074
|
+
// something isn't right so exit the function
|
|
6075
|
+
return
|
|
6076
|
+
}
|
|
6073
6077
|
headEl.style.width = 'auto'
|
|
6074
6078
|
headEl.innerHTML = this.buildHeaderHtml()
|
|
6075
6079
|
this.sizes.outer = outerEl.getBoundingClientRect()
|
|
@@ -6316,7 +6320,9 @@ class WebsyTable3 {
|
|
|
6316
6320
|
el.classList.remove('has-error')
|
|
6317
6321
|
}
|
|
6318
6322
|
const tableEl = document.getElementById(`${this.elementId}_tableInner`)
|
|
6319
|
-
tableEl
|
|
6323
|
+
if (tableEl) {
|
|
6324
|
+
tableEl.classList.remove('hidden')
|
|
6325
|
+
}
|
|
6320
6326
|
const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
|
|
6321
6327
|
if (containerEl) {
|
|
6322
6328
|
containerEl.classList.remove('active')
|
|
@@ -6351,6 +6357,10 @@ class WebsyTable3 {
|
|
|
6351
6357
|
this.appendRows(data)
|
|
6352
6358
|
}
|
|
6353
6359
|
let bodyEl = document.getElementById(`${this.elementId}_tableBody`)
|
|
6360
|
+
if (!bodyEl) {
|
|
6361
|
+
// something isn't right so exit the function
|
|
6362
|
+
return
|
|
6363
|
+
}
|
|
6354
6364
|
// bodyEl.innerHTML = this.buildBodyHtml(data, true)
|
|
6355
6365
|
// if (this.options.maxHeight) {
|
|
6356
6366
|
// bodyEl.style.height = `${this.options.maxHeight - this.sizes.header.height - this.sizes.total.height}px`
|
|
@@ -6550,6 +6560,7 @@ class WebsyChart {
|
|
|
6550
6560
|
lineWidth: 2,
|
|
6551
6561
|
forceZero: true,
|
|
6552
6562
|
grouping: 'grouped',
|
|
6563
|
+
groupPadding: 3,
|
|
6553
6564
|
fontSize: 14,
|
|
6554
6565
|
symbolSize: 20,
|
|
6555
6566
|
showTrackingLine: true,
|
|
@@ -6558,7 +6569,8 @@ class WebsyChart {
|
|
|
6558
6569
|
legendPosition: 'bottom',
|
|
6559
6570
|
tooltipWidth: 200,
|
|
6560
6571
|
brushHeight: 50,
|
|
6561
|
-
minBandWidth: 30
|
|
6572
|
+
minBandWidth: 30,
|
|
6573
|
+
allowUnevenBands: true
|
|
6562
6574
|
}
|
|
6563
6575
|
this.elementId = elementId
|
|
6564
6576
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
@@ -6583,25 +6595,43 @@ class WebsyChart {
|
|
|
6583
6595
|
xAxis += 'Brush'
|
|
6584
6596
|
}
|
|
6585
6597
|
xAxis += 'Axis'
|
|
6586
|
-
let width = this[xAxis].step()
|
|
6587
6598
|
let output
|
|
6588
|
-
let
|
|
6589
|
-
if (this.
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6599
|
+
let width = this.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth
|
|
6600
|
+
if (this.customBottomRange) {
|
|
6601
|
+
for (let index = 0; index < this.customBottomRange.length; index++) {
|
|
6602
|
+
if (input > this.customBottomRange[index]) {
|
|
6603
|
+
if (this.customBottomRange[index + 1]) {
|
|
6604
|
+
if (input < this.customBottomRange[index + 1]) {
|
|
6605
|
+
output = index
|
|
6606
|
+
break
|
|
6607
|
+
}
|
|
6608
|
+
}
|
|
6609
|
+
else {
|
|
6610
|
+
output = index
|
|
6611
|
+
break
|
|
6612
|
+
}
|
|
6613
|
+
}
|
|
6598
6614
|
}
|
|
6599
|
-
}
|
|
6615
|
+
}
|
|
6616
|
+
else {
|
|
6617
|
+
let domain = [...this[xAxis].domain()]
|
|
6618
|
+
if (this.options.orientation === 'horizontal') {
|
|
6619
|
+
domain = domain.reverse()
|
|
6620
|
+
}
|
|
6621
|
+
for (let j = 0; j < domain.length; j++) {
|
|
6622
|
+
let breakA = this[xAxis](domain[j]) - (width / 2)
|
|
6623
|
+
let breakB = breakA + width
|
|
6624
|
+
if (input > breakA && input <= breakB) {
|
|
6625
|
+
output = j
|
|
6626
|
+
break
|
|
6627
|
+
}
|
|
6628
|
+
}
|
|
6629
|
+
}
|
|
6600
6630
|
return output
|
|
6601
6631
|
}
|
|
6602
6632
|
let that = this
|
|
6603
6633
|
this.brushed = function (event) {
|
|
6604
|
-
console.log('brushing', event)
|
|
6634
|
+
console.log('brushing', event)
|
|
6605
6635
|
that.brushedDomain = []
|
|
6606
6636
|
let xAxis = 'bottom'
|
|
6607
6637
|
let xAxisCaps = 'Bottom'
|
|
@@ -6609,6 +6639,9 @@ class WebsyChart {
|
|
|
6609
6639
|
xAxis = 'left'
|
|
6610
6640
|
xAxisCaps = 'Left'
|
|
6611
6641
|
}
|
|
6642
|
+
if (!that[`${xAxis}Axis`]) {
|
|
6643
|
+
return
|
|
6644
|
+
}
|
|
6612
6645
|
if (!that[`${xAxis}Axis`].invert) {
|
|
6613
6646
|
that[`${xAxis}Axis`].invert = that.invertOverride
|
|
6614
6647
|
}
|
|
@@ -6798,7 +6831,12 @@ else {
|
|
|
6798
6831
|
}
|
|
6799
6832
|
this.options.data.series.forEach(s => {
|
|
6800
6833
|
if (this.options.data[xData].scale !== 'Time') {
|
|
6801
|
-
|
|
6834
|
+
if (this.customBottomRange && this.customBottomRange.length > 0) {
|
|
6835
|
+
xPoint = this.customBottomRange[x0] + ((this.customBottomRange[x0 + 1] - this.customBottomRange[x0]) / 2)
|
|
6836
|
+
}
|
|
6837
|
+
else {
|
|
6838
|
+
xPoint = this[xAxis](this.parseX(xLabel))
|
|
6839
|
+
}
|
|
6802
6840
|
s.data.forEach(d => {
|
|
6803
6841
|
if (d.x.value === xLabel) {
|
|
6804
6842
|
if (!tooltipTitle) {
|
|
@@ -6887,7 +6925,7 @@ else {
|
|
|
6887
6925
|
onLeft: xPoint > this.plotWidth / 2
|
|
6888
6926
|
}
|
|
6889
6927
|
if (xPoint > this.plotWidth / 2) {
|
|
6890
|
-
posOptions.left = xPoint - this.options.tooltipWidth + this.options.margin.left + this.options.margin.axisLeft + 15
|
|
6928
|
+
posOptions.left = xPoint - this.options.tooltipWidth - 15 // + this.options.margin.left + this.options.margin.axisLeft + 15)
|
|
6891
6929
|
if (this.options.data[xData].scale !== 'Time') {
|
|
6892
6930
|
// posOptions.left -= (this[xAxis].bandwidth())
|
|
6893
6931
|
posOptions.left += 10
|
|
@@ -6896,7 +6934,7 @@ else {
|
|
|
6896
6934
|
else {
|
|
6897
6935
|
posOptions.left = xPoint + this.options.margin.left + this.options.margin.axisLeft + 15
|
|
6898
6936
|
if (this.options.data[xData].scale !== 'Time') {
|
|
6899
|
-
posOptions.left += (this[xAxis
|
|
6937
|
+
posOptions.left += (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
6900
6938
|
}
|
|
6901
6939
|
}
|
|
6902
6940
|
posOptions.top = this.options.margin.top + this.options.margin.axisTop
|
|
@@ -6904,7 +6942,7 @@ else {
|
|
|
6904
6942
|
delete posOptions.onLeft
|
|
6905
6943
|
let adjuster = 0
|
|
6906
6944
|
if (this.options.data[xData].scale !== 'Time') {
|
|
6907
|
-
adjuster = (this[xAxis
|
|
6945
|
+
adjuster = (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2) // - this.options.margin.top
|
|
6908
6946
|
}
|
|
6909
6947
|
posOptions = {
|
|
6910
6948
|
width: this.options.tooltipWidth,
|
|
@@ -6925,8 +6963,8 @@ else {
|
|
|
6925
6963
|
// else {
|
|
6926
6964
|
// xPoint = x0
|
|
6927
6965
|
// }
|
|
6928
|
-
if (this.options.data[xData].scale !== 'Time') {
|
|
6929
|
-
xPoint += (this[xAxis
|
|
6966
|
+
if (this.options.data[xData].scale !== 'Time' && this.customBottomRange.length === 0) {
|
|
6967
|
+
xPoint += (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2) // - this.options.margin.top
|
|
6930
6968
|
}
|
|
6931
6969
|
let trackingXStart = xPoint
|
|
6932
6970
|
let trackingXEnd = xPoint
|
|
@@ -6995,6 +7033,7 @@ if (!this.options.data) {
|
|
|
6995
7033
|
// tell the user no data has been provided
|
|
6996
7034
|
}
|
|
6997
7035
|
else {
|
|
7036
|
+
this.processedX = {}
|
|
6998
7037
|
this.transition = d3.transition().duration(this.options.transitionDuration)
|
|
6999
7038
|
if (this.options.data.bottom.scale && this.options.data.bottom.scale === 'Time') {
|
|
7000
7039
|
this.parseX = function (input) {
|
|
@@ -7041,7 +7080,13 @@ else {
|
|
|
7041
7080
|
// establish the space and size for the legend
|
|
7042
7081
|
// the legend gets rendered so that we can get its actual size
|
|
7043
7082
|
if (this.options.showLegend === true) {
|
|
7044
|
-
let legendData =
|
|
7083
|
+
let legendData = []
|
|
7084
|
+
if (this.options.legendData && this.options.legendData.length > 0) {
|
|
7085
|
+
legendData = this.options.legendData
|
|
7086
|
+
}
|
|
7087
|
+
else {
|
|
7088
|
+
this.options.data.series.map((s, i) => ({value: s.label || s.key, color: s.color || this.options.colors[i % this.options.colors.length]}))
|
|
7089
|
+
}
|
|
7045
7090
|
if (this.options.legendPosition === 'top' || this.options.legendPosition === 'bottom') {
|
|
7046
7091
|
this.legendArea.style('width', '100%')
|
|
7047
7092
|
this.legend.options.align = 'center'
|
|
@@ -7213,18 +7258,30 @@ else {
|
|
|
7213
7258
|
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
|
|
7214
7259
|
this.brushNeeded = false
|
|
7215
7260
|
if (this.options.orientation === 'vertical') {
|
|
7216
|
-
|
|
7217
|
-
|
|
7261
|
+
this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
|
|
7262
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7263
|
+
return a + 1
|
|
7264
|
+
}
|
|
7265
|
+
return a + b.valueCount
|
|
7266
|
+
}, 0)
|
|
7267
|
+
if (this.options.maxBandWidth) {
|
|
7268
|
+
this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.totalValueCount) * this.options.maxBandWidth)
|
|
7218
7269
|
}
|
|
7219
7270
|
// some if to check if brushing is needed
|
|
7220
|
-
if (this.plotWidth / this.options.data.bottom.
|
|
7271
|
+
if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
|
|
7221
7272
|
this.brushNeeded = true
|
|
7222
7273
|
this.plotHeight -= this.options.brushHeight
|
|
7223
7274
|
}
|
|
7224
7275
|
}
|
|
7225
7276
|
else {
|
|
7226
7277
|
// some if to check if brushing is needed
|
|
7227
|
-
|
|
7278
|
+
this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
|
|
7279
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7280
|
+
return a + 1
|
|
7281
|
+
}
|
|
7282
|
+
return a + b.valueCount
|
|
7283
|
+
}, 0)
|
|
7284
|
+
if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
|
|
7228
7285
|
this.brushNeeded = true
|
|
7229
7286
|
this.plotWidth -= this.options.brushHeight
|
|
7230
7287
|
}
|
|
@@ -7279,14 +7336,39 @@ else {
|
|
|
7279
7336
|
// this.tooltip.transform(this.options.margin.left + this.options.margin.axisLeft, this.options.margin.top + this.options.margin.axisTop)
|
|
7280
7337
|
// Configure the bottom axis
|
|
7281
7338
|
let bottomDomain = this.createDomain('bottom')
|
|
7282
|
-
let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7339
|
+
let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7340
|
+
let bottomRange = [0, this.plotWidth]
|
|
7341
|
+
this.customBottomRange = []
|
|
7342
|
+
if (this.options.allowUnevenBands === true) {
|
|
7343
|
+
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') {
|
|
7344
|
+
let acc = 0
|
|
7345
|
+
this.customBottomRange = [0, ...this.options.data.bottom.data.map(d => {
|
|
7346
|
+
acc += d.valueCount
|
|
7347
|
+
return (this.plotWidth / this.options.data.bottom.totalValueCount) * acc
|
|
7348
|
+
})]
|
|
7349
|
+
}
|
|
7350
|
+
}
|
|
7351
|
+
this.options.data.bottom.step = this.plotWidth / this.options.data.bottom.totalValueCount
|
|
7352
|
+
this.options.data.bottom.bandWidth = this.options.data.bottom.step
|
|
7353
|
+
if (this.options.data.bottom.padding) {
|
|
7354
|
+
this.totalPadding = this.plotWidth * this.options.data.bottom.padding
|
|
7355
|
+
let rangeLength = bottomDomain.length
|
|
7356
|
+
if (this.customBottomRange.length > 0) {
|
|
7357
|
+
rangeLength = this.customBottomRange.length
|
|
7358
|
+
}
|
|
7359
|
+
this.bandPadding = (this.totalPadding / (rangeLength)) / 2
|
|
7360
|
+
this.options.data.bottom.bandWidth = (this.plotWidth - this.totalPadding) / this.options.data.bottom.totalValueCount
|
|
7361
|
+
}
|
|
7362
|
+
if (this.options.grouping === 'grouped' && this.options.data.series.length > 1) {
|
|
7363
|
+
this.options.data.bottom.bandWidth = this.options.data.bottom.bandWidth - (this.options.groupPadding * 2)
|
|
7364
|
+
}
|
|
7283
7365
|
this.bottomAxis = d3[`scale${this.options.data.bottom.scale || 'Band'}`]()
|
|
7284
7366
|
.domain(bottomDomain)
|
|
7285
|
-
.range(
|
|
7367
|
+
.range(bottomRange)
|
|
7286
7368
|
if (!this.brushInitialized) {
|
|
7287
7369
|
this.bottomBrushAxis = d3[`scale${this.options.data.bottom.scale || 'Band'}`]()
|
|
7288
7370
|
.domain(bottomBrushDomain)
|
|
7289
|
-
.range(
|
|
7371
|
+
.range(bottomRange)
|
|
7290
7372
|
}
|
|
7291
7373
|
if (this.bottomAxis.nice) {
|
|
7292
7374
|
// this.bottomAxis.nice()
|
|
@@ -7458,6 +7540,10 @@ else {
|
|
|
7458
7540
|
.style('text-anchor', `${((this.options.data.bottom && this.options.data.bottom.rotate) || 0) === 0 ? 'middle' : 'end'}`)
|
|
7459
7541
|
.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`)
|
|
7460
7542
|
}
|
|
7543
|
+
if (this.customBottomRange.length > 0) {
|
|
7544
|
+
this.bottomAxisLayer.selectAll('g')
|
|
7545
|
+
.attr('transform', (d, i) => `translate(${this.customBottomRange[i] + ((this.customBottomRange[i + 1] - this.customBottomRange[i]) / 2)}, 0)`)
|
|
7546
|
+
}
|
|
7461
7547
|
}
|
|
7462
7548
|
// Configure the left axis
|
|
7463
7549
|
let leftDomain = this.createDomain('left')
|
|
@@ -7603,6 +7689,8 @@ this.options.data.series.forEach((series, index) => {
|
|
|
7603
7689
|
this.renderLabels(series, index)
|
|
7604
7690
|
this.renderedKeys[series.key] = series.type
|
|
7605
7691
|
})
|
|
7692
|
+
this.refLineLayer.selectAll('.reference-line').remove()
|
|
7693
|
+
this.refLineLayer.selectAll('.reference-line-label').remove()
|
|
7606
7694
|
if (this.options.refLines && this.options.refLines.length > 0) {
|
|
7607
7695
|
this.options.refLines.forEach(l => this.renderRefLine(l))
|
|
7608
7696
|
}
|
|
@@ -7614,21 +7702,21 @@ const drawArea = (xAxis, yAxis, curveStyle) => {
|
|
|
7614
7702
|
return d3
|
|
7615
7703
|
.area()
|
|
7616
7704
|
.x(d => {
|
|
7617
|
-
return this[xAxis](this.parseX(d.x.value))
|
|
7705
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
7618
7706
|
})
|
|
7619
7707
|
.y0(d => {
|
|
7620
|
-
return this[yAxis](0)
|
|
7708
|
+
return this[`${yAxis}Axis`](0)
|
|
7621
7709
|
})
|
|
7622
7710
|
.y1(d => {
|
|
7623
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value)
|
|
7711
|
+
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
7624
7712
|
})
|
|
7625
7713
|
.curve(d3[curveStyle || this.options.curveStyle])
|
|
7626
7714
|
}
|
|
7627
|
-
let xAxis = '
|
|
7628
|
-
let yAxis = series.axis === 'secondary' ? '
|
|
7629
|
-
if (this.options.
|
|
7630
|
-
xAxis = series.axis === 'secondary' ? '
|
|
7631
|
-
yAxis = '
|
|
7715
|
+
let xAxis = 'bottom'
|
|
7716
|
+
let yAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
7717
|
+
if (this.options.orientation === 'horizontal') {
|
|
7718
|
+
xAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
7719
|
+
yAxis = 'bottom'
|
|
7632
7720
|
}
|
|
7633
7721
|
let areas = this.areaLayer.selectAll(`.area_${series.key}`)
|
|
7634
7722
|
.data([series.data])
|
|
@@ -7651,7 +7739,7 @@ areas.enter().append('path')
|
|
|
7651
7739
|
.attr('d', d => drawArea(xAxis, yAxis, series.curveStyle)(d))
|
|
7652
7740
|
.attr('class', `area_${series.key}`)
|
|
7653
7741
|
.attr('id', `area_${series.key}`)
|
|
7654
|
-
|
|
7742
|
+
.attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2) + ',0)')
|
|
7655
7743
|
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
7656
7744
|
.attr('fill', series.color)
|
|
7657
7745
|
// .style('fill-opacity', 0)
|
|
@@ -7674,15 +7762,14 @@ if (this.options.orientation === 'horizontal') {
|
|
|
7674
7762
|
// if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
7675
7763
|
// barWidth = barWidth / this.options.data.series.length - 4
|
|
7676
7764
|
// }
|
|
7677
|
-
function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
7678
|
-
let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
7679
|
-
let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
7765
|
+
function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
7680
7766
|
let output
|
|
7681
7767
|
if (this.options.orientation === 'horizontal') {
|
|
7682
|
-
output =
|
|
7768
|
+
output = this.options.data[xAxis.replace('Brush', '')].bandWidth
|
|
7683
7769
|
}
|
|
7684
7770
|
else {
|
|
7685
|
-
|
|
7771
|
+
let x = getBarX.call(this, d, i, xAxis)
|
|
7772
|
+
if (typeof x === 'undefined' || x === null) {
|
|
7686
7773
|
return null
|
|
7687
7774
|
}
|
|
7688
7775
|
output = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
|
|
@@ -7692,26 +7779,19 @@ function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
|
7692
7779
|
}
|
|
7693
7780
|
return output
|
|
7694
7781
|
}
|
|
7695
|
-
function getBarWidth (d, i, xAxis) {
|
|
7696
|
-
let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
7697
|
-
let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length
|
|
7782
|
+
function getBarWidth (d, i, xAxis) {
|
|
7698
7783
|
let output
|
|
7699
|
-
if (this.options.orientation === 'horizontal') {
|
|
7700
|
-
// let width = this[`${yAxis}Axis`](d.y.value)
|
|
7784
|
+
if (this.options.orientation === 'horizontal') {
|
|
7701
7785
|
let width = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
|
|
7702
7786
|
acummulativeY[d.y.index] += width
|
|
7703
7787
|
output = width
|
|
7704
7788
|
}
|
|
7705
7789
|
else {
|
|
7706
|
-
|
|
7790
|
+
let x = getBarX.call(this, d, i, xAxis)
|
|
7791
|
+
if (typeof x === 'undefined' || x === null) {
|
|
7707
7792
|
return null
|
|
7708
|
-
}
|
|
7709
|
-
|
|
7710
|
-
output = Math.max(1, groupedBarWidth)
|
|
7711
|
-
}
|
|
7712
|
-
else {
|
|
7713
|
-
output = Math.max(1, barWidth)
|
|
7714
|
-
}
|
|
7793
|
+
}
|
|
7794
|
+
output = Math.max(1, this.options.data[xAxis.replace('Brush', '')].bandWidth)
|
|
7715
7795
|
}
|
|
7716
7796
|
if (isNaN(output)) {
|
|
7717
7797
|
return 0
|
|
@@ -7719,8 +7799,11 @@ function getBarWidth (d, i, xAxis) {
|
|
|
7719
7799
|
return output
|
|
7720
7800
|
}
|
|
7721
7801
|
function getBarX (d, i, xAxis) {
|
|
7722
|
-
let barWidth = this[
|
|
7723
|
-
|
|
7802
|
+
// let barWidth = this.plotWidth / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
7803
|
+
// if (this.options.data[xAxis.replace('Brush', '')].padding) {
|
|
7804
|
+
// barWidth = barWidth - (barWidth * this.options.data[xAxis.replace('Brush', '')].padding)
|
|
7805
|
+
// }
|
|
7806
|
+
// let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
7724
7807
|
let output
|
|
7725
7808
|
if (this.options.orientation === 'horizontal') {
|
|
7726
7809
|
if (this.options.grouping === 'stacked') {
|
|
@@ -7737,10 +7820,34 @@ function getBarX (d, i, xAxis) {
|
|
|
7737
7820
|
}
|
|
7738
7821
|
}
|
|
7739
7822
|
else {
|
|
7740
|
-
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7823
|
+
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
|
|
7824
|
+
let adjustment = this.customBottomRange[i] + (i * this.options.data[xAxis.replace('Brush', '')].bandWidth)
|
|
7825
|
+
if (this.options.grouping === 'grouped') {
|
|
7826
|
+
let xIndex = 0
|
|
7827
|
+
if (this.processedX[d.x.value]) {
|
|
7828
|
+
xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel))
|
|
7829
|
+
}
|
|
7830
|
+
let barAdjustment =
|
|
7831
|
+
(this.options.data[xAxis.replace('Brush', '')].bandWidth * xIndex) +
|
|
7832
|
+
(xIndex * this.options.groupPadding * 2) + this.options.groupPadding +
|
|
7833
|
+
(xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
7834
|
+
// let barAdjustment =
|
|
7835
|
+
// (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
|
|
7836
|
+
// this.options.groupPadding
|
|
7837
|
+
// // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
7838
|
+
if (this.customBottomRange.length > 0) {
|
|
7839
|
+
output = this.customBottomRange[this[xAxis.replace('Brush', '') + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
|
|
7840
|
+
}
|
|
7841
|
+
else {
|
|
7842
|
+
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + barAdjustment
|
|
7843
|
+
}
|
|
7844
|
+
if (!this.processedX[d.x.value]) {
|
|
7845
|
+
this.processedX[d.x.value] = []
|
|
7846
|
+
}
|
|
7847
|
+
if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
|
|
7848
|
+
this.processedX[d.x.value].push(d.y.tooltipLabel)
|
|
7849
|
+
}
|
|
7850
|
+
console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
|
|
7744
7851
|
}
|
|
7745
7852
|
else {
|
|
7746
7853
|
// output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
|
|
@@ -7753,15 +7860,15 @@ function getBarX (d, i, xAxis) {
|
|
|
7753
7860
|
return output
|
|
7754
7861
|
}
|
|
7755
7862
|
function getBarY (d, i, heightBounds, yAxis, xAxis) {
|
|
7756
|
-
let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
7757
|
-
let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
7863
|
+
// let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
7864
|
+
// let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
7758
7865
|
let output
|
|
7759
7866
|
if (this.options.orientation === 'horizontal') {
|
|
7760
7867
|
if (this.options.grouping !== 'grouped') {
|
|
7761
7868
|
output = this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
7762
7869
|
}
|
|
7763
7870
|
else {
|
|
7764
|
-
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + ((d.y.index || i) * barWidth)
|
|
7871
|
+
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + ((d.y.index || i) * this.options.data[xAxis.replace('Brush', '')].barWidth)
|
|
7765
7872
|
}
|
|
7766
7873
|
}
|
|
7767
7874
|
else {
|
|
@@ -7955,12 +8062,12 @@ function getLabelX (d, labelPosition = 'inside') {
|
|
|
7955
8062
|
}
|
|
7956
8063
|
}
|
|
7957
8064
|
else {
|
|
7958
|
-
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis
|
|
8065
|
+
return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
7959
8066
|
}
|
|
7960
8067
|
}
|
|
7961
8068
|
function getLabelY (d, labelPosition = 'inside') {
|
|
7962
8069
|
if (this.options.orientation === 'horizontal') {
|
|
7963
|
-
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis
|
|
8070
|
+
return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
7964
8071
|
}
|
|
7965
8072
|
else {
|
|
7966
8073
|
if (this.options.grouping === 'stacked') {
|
|
@@ -7979,23 +8086,34 @@ const drawLine = (xAxis, yAxis, curveStyle) => {
|
|
|
7979
8086
|
return d3
|
|
7980
8087
|
.line()
|
|
7981
8088
|
.x(d => {
|
|
7982
|
-
|
|
7983
|
-
|
|
8089
|
+
if (this.options.orientation === 'horizontal') {
|
|
8090
|
+
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
8091
|
+
}
|
|
8092
|
+
else {
|
|
8093
|
+
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8094
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8095
|
+
}
|
|
7984
8096
|
})
|
|
7985
8097
|
.y(d => {
|
|
7986
|
-
|
|
8098
|
+
if (this.options.orientation === 'horizontal') {
|
|
8099
|
+
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8100
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8101
|
+
}
|
|
8102
|
+
else {
|
|
8103
|
+
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
8104
|
+
}
|
|
7987
8105
|
})
|
|
7988
8106
|
.curve(d3[curveStyle || this.options.curveStyle])
|
|
7989
8107
|
}
|
|
7990
8108
|
let xAxis = 'bottom'
|
|
7991
8109
|
let yAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
7992
|
-
if (this.options.
|
|
8110
|
+
if (this.options.orientation === 'horizontal') {
|
|
7993
8111
|
xAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
7994
8112
|
yAxis = 'bottom'
|
|
7995
8113
|
}
|
|
7996
8114
|
let xBrushAxis = 'bottomBrush'
|
|
7997
8115
|
let yBrushAxis = 'leftBrush'
|
|
7998
|
-
if (this.options.
|
|
8116
|
+
if (this.options.orientation === 'horizontal') {
|
|
7999
8117
|
xBrushAxis = 'leftBrush'
|
|
8000
8118
|
yBrushAxis = 'bottomBrush'
|
|
8001
8119
|
}
|
|
@@ -8081,8 +8199,6 @@ if (this.options.orientation === 'horizontal') {
|
|
|
8081
8199
|
xAttr = 'y'
|
|
8082
8200
|
length = this.plotHeight
|
|
8083
8201
|
}
|
|
8084
|
-
this.refLineLayer.selectAll('.reference-line').remove()
|
|
8085
|
-
this.refLineLayer.selectAll('.reference-line-label').remove()
|
|
8086
8202
|
this.refLineLayer
|
|
8087
8203
|
.append('line')
|
|
8088
8204
|
.attr(`${yAttr}1`, this[`${yAxis}Axis`](data.value))
|
|
@@ -8131,7 +8247,7 @@ const drawSymbol = (size) => {
|
|
|
8131
8247
|
}
|
|
8132
8248
|
let xAxis = 'bottom'
|
|
8133
8249
|
let yAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
8134
|
-
if (this.options.
|
|
8250
|
+
if (this.options.orientation === 'horizontal') {
|
|
8135
8251
|
xAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
8136
8252
|
yAxis = 'bottom'
|
|
8137
8253
|
}
|
|
@@ -8149,8 +8265,13 @@ symbols
|
|
|
8149
8265
|
.attr('fill', series.fillSymbols ? series.color : 'white')
|
|
8150
8266
|
.attr('stroke', series.color)
|
|
8151
8267
|
.attr('transform', d => {
|
|
8152
|
-
let adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8153
|
-
|
|
8268
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8269
|
+
if (this.options.orientation === 'horizontal') {
|
|
8270
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
|
|
8271
|
+
}
|
|
8272
|
+
else {
|
|
8273
|
+
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8274
|
+
}
|
|
8154
8275
|
})
|
|
8155
8276
|
// Enter
|
|
8156
8277
|
symbols.enter()
|
|
@@ -8161,8 +8282,13 @@ symbols.enter()
|
|
|
8161
8282
|
.attr('stroke', series.color)
|
|
8162
8283
|
.attr('class', d => { return `symbol symbol_${series.key}` })
|
|
8163
8284
|
.attr('transform', d => {
|
|
8164
|
-
let adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8165
|
-
|
|
8285
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8286
|
+
if (this.options.orientation === 'horizontal') {
|
|
8287
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
|
|
8288
|
+
}
|
|
8289
|
+
else {
|
|
8290
|
+
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8291
|
+
}
|
|
8166
8292
|
})
|
|
8167
8293
|
|
|
8168
8294
|
}
|
|
@@ -8266,9 +8392,9 @@ if (el) {
|
|
|
8266
8392
|
if (el) {
|
|
8267
8393
|
el.classList.remove('has-error')
|
|
8268
8394
|
}
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8395
|
+
if (this.svg) {
|
|
8396
|
+
this.svg.classed('hidden', false)
|
|
8397
|
+
}
|
|
8272
8398
|
const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
|
|
8273
8399
|
if (containerEl) {
|
|
8274
8400
|
containerEl.classList.remove('active')
|
|
@@ -8283,8 +8409,10 @@ if (el) {
|
|
|
8283
8409
|
el.classList.add('has-error')
|
|
8284
8410
|
}
|
|
8285
8411
|
// const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
|
|
8286
|
-
// chartEl.classList.add('hidden')
|
|
8287
|
-
this.svg
|
|
8412
|
+
// chartEl.classList.add('hidden')
|
|
8413
|
+
if (this.svg) {
|
|
8414
|
+
this.svg.classed('hidden', true)
|
|
8415
|
+
}
|
|
8288
8416
|
const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
|
|
8289
8417
|
if (containerEl) {
|
|
8290
8418
|
containerEl.classList.add('active')
|