@websy/websy-designs 1.4.37 → 1.5.0
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 +233 -90
- package/dist/websy-designs-es6.js +242 -88
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +233 -90
- package/dist/websy-designs.js +242 -88
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -6962,6 +6962,7 @@ class WebsyChart {
|
|
|
6962
6962
|
lineWidth: 2,
|
|
6963
6963
|
forceZero: true,
|
|
6964
6964
|
grouping: 'grouped',
|
|
6965
|
+
groupPadding: 3,
|
|
6965
6966
|
fontSize: 14,
|
|
6966
6967
|
symbolSize: 20,
|
|
6967
6968
|
showTrackingLine: true,
|
|
@@ -6970,7 +6971,8 @@ class WebsyChart {
|
|
|
6970
6971
|
legendPosition: 'bottom',
|
|
6971
6972
|
tooltipWidth: 200,
|
|
6972
6973
|
brushHeight: 50,
|
|
6973
|
-
minBandWidth: 30
|
|
6974
|
+
minBandWidth: 30,
|
|
6975
|
+
allowUnevenBands: true
|
|
6974
6976
|
}
|
|
6975
6977
|
this.elementId = elementId
|
|
6976
6978
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
@@ -6995,25 +6997,43 @@ class WebsyChart {
|
|
|
6995
6997
|
xAxis += 'Brush'
|
|
6996
6998
|
}
|
|
6997
6999
|
xAxis += 'Axis'
|
|
6998
|
-
let width = this[xAxis].step()
|
|
6999
7000
|
let output
|
|
7000
|
-
let
|
|
7001
|
-
if (this.
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7001
|
+
let width = this.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth
|
|
7002
|
+
if (this.customBottomRange) {
|
|
7003
|
+
for (let index = 0; index < this.customBottomRange.length; index++) {
|
|
7004
|
+
if (input > this.customBottomRange[index]) {
|
|
7005
|
+
if (this.customBottomRange[index + 1]) {
|
|
7006
|
+
if (input < this.customBottomRange[index + 1]) {
|
|
7007
|
+
output = index
|
|
7008
|
+
break
|
|
7009
|
+
}
|
|
7010
|
+
}
|
|
7011
|
+
else {
|
|
7012
|
+
output = index
|
|
7013
|
+
break
|
|
7014
|
+
}
|
|
7015
|
+
}
|
|
7010
7016
|
}
|
|
7011
|
-
}
|
|
7017
|
+
}
|
|
7018
|
+
else {
|
|
7019
|
+
let domain = [...this[xAxis].domain()]
|
|
7020
|
+
if (this.options.orientation === 'horizontal') {
|
|
7021
|
+
domain = domain.reverse()
|
|
7022
|
+
}
|
|
7023
|
+
for (let j = 0; j < domain.length; j++) {
|
|
7024
|
+
let breakA = this[xAxis](domain[j]) - (width / 2)
|
|
7025
|
+
let breakB = breakA + width
|
|
7026
|
+
if (input > breakA && input <= breakB) {
|
|
7027
|
+
output = j
|
|
7028
|
+
break
|
|
7029
|
+
}
|
|
7030
|
+
}
|
|
7031
|
+
}
|
|
7012
7032
|
return output
|
|
7013
7033
|
}
|
|
7014
7034
|
let that = this
|
|
7015
7035
|
this.brushed = function (event) {
|
|
7016
|
-
console.log('brushing', event)
|
|
7036
|
+
console.log('brushing', event)
|
|
7017
7037
|
that.brushedDomain = []
|
|
7018
7038
|
let xAxis = 'bottom'
|
|
7019
7039
|
let xAxisCaps = 'Bottom'
|
|
@@ -7021,6 +7041,9 @@ class WebsyChart {
|
|
|
7021
7041
|
xAxis = 'left'
|
|
7022
7042
|
xAxisCaps = 'Left'
|
|
7023
7043
|
}
|
|
7044
|
+
if (!that[`${xAxis}Axis`]) {
|
|
7045
|
+
return
|
|
7046
|
+
}
|
|
7024
7047
|
if (!that[`${xAxis}Axis`].invert) {
|
|
7025
7048
|
that[`${xAxis}Axis`].invert = that.invertOverride
|
|
7026
7049
|
}
|
|
@@ -7083,6 +7106,18 @@ class WebsyChart {
|
|
|
7083
7106
|
.attr('id', `${this.elementId}_legend`)
|
|
7084
7107
|
.attr('class', 'websy-chart-legend')
|
|
7085
7108
|
this.legend = new WebsyDesigns.Legend(`${this.elementId}_legend`, {})
|
|
7109
|
+
this.errorContainer = d3.select(el).append('div')
|
|
7110
|
+
.attr('id', `${this.elementId}_errorContainer`)
|
|
7111
|
+
.attr('class', 'websy-vis-error-container')
|
|
7112
|
+
.html(`
|
|
7113
|
+
<div>
|
|
7114
|
+
<div id="${this.elementId}_errorTitle"></div>
|
|
7115
|
+
<div id="${this.elementId}_errorMessage"></div>
|
|
7116
|
+
</div>
|
|
7117
|
+
`)
|
|
7118
|
+
this.loadingContainer = d3.select(el).append('div')
|
|
7119
|
+
.attr('id', `${this.elementId}_loadingContainer`)
|
|
7120
|
+
this.loadingDialog = new WebsyDesigns.LoadingDialog(`${this.elementId}_loadingContainer`)
|
|
7086
7121
|
this.prep()
|
|
7087
7122
|
// el.innerHTML += `
|
|
7088
7123
|
// <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
|
|
@@ -7198,7 +7233,12 @@ else {
|
|
|
7198
7233
|
}
|
|
7199
7234
|
this.options.data.series.forEach(s => {
|
|
7200
7235
|
if (this.options.data[xData].scale !== 'Time') {
|
|
7201
|
-
|
|
7236
|
+
if (this.customBottomRange && this.customBottomRange.length > 0) {
|
|
7237
|
+
xPoint = this.customBottomRange[x0] + ((this.customBottomRange[x0 + 1] - this.customBottomRange[x0]) / 2)
|
|
7238
|
+
}
|
|
7239
|
+
else {
|
|
7240
|
+
xPoint = this[xAxis](this.parseX(xLabel))
|
|
7241
|
+
}
|
|
7202
7242
|
s.data.forEach(d => {
|
|
7203
7243
|
if (d.x.value === xLabel) {
|
|
7204
7244
|
if (!tooltipTitle) {
|
|
@@ -7287,7 +7327,7 @@ else {
|
|
|
7287
7327
|
onLeft: xPoint > this.plotWidth / 2
|
|
7288
7328
|
}
|
|
7289
7329
|
if (xPoint > this.plotWidth / 2) {
|
|
7290
|
-
posOptions.left = xPoint - this.options.tooltipWidth + this.options.margin.left + this.options.margin.axisLeft + 15
|
|
7330
|
+
posOptions.left = xPoint - this.options.tooltipWidth - 15 // + this.options.margin.left + this.options.margin.axisLeft + 15)
|
|
7291
7331
|
if (this.options.data[xData].scale !== 'Time') {
|
|
7292
7332
|
// posOptions.left -= (this[xAxis].bandwidth())
|
|
7293
7333
|
posOptions.left += 10
|
|
@@ -7296,7 +7336,7 @@ else {
|
|
|
7296
7336
|
else {
|
|
7297
7337
|
posOptions.left = xPoint + this.options.margin.left + this.options.margin.axisLeft + 15
|
|
7298
7338
|
if (this.options.data[xData].scale !== 'Time') {
|
|
7299
|
-
posOptions.left += (this[xAxis
|
|
7339
|
+
posOptions.left += (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
7300
7340
|
}
|
|
7301
7341
|
}
|
|
7302
7342
|
posOptions.top = this.options.margin.top + this.options.margin.axisTop
|
|
@@ -7304,7 +7344,7 @@ else {
|
|
|
7304
7344
|
delete posOptions.onLeft
|
|
7305
7345
|
let adjuster = 0
|
|
7306
7346
|
if (this.options.data[xData].scale !== 'Time') {
|
|
7307
|
-
adjuster = (this[xAxis
|
|
7347
|
+
adjuster = (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2) // - this.options.margin.top
|
|
7308
7348
|
}
|
|
7309
7349
|
posOptions = {
|
|
7310
7350
|
width: this.options.tooltipWidth,
|
|
@@ -7325,8 +7365,8 @@ else {
|
|
|
7325
7365
|
// else {
|
|
7326
7366
|
// xPoint = x0
|
|
7327
7367
|
// }
|
|
7328
|
-
if (this.options.data[xData].scale !== 'Time') {
|
|
7329
|
-
xPoint += (this[xAxis
|
|
7368
|
+
if (this.options.data[xData].scale !== 'Time' && this.customBottomRange.length === 0) {
|
|
7369
|
+
xPoint += (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2) // - this.options.margin.top
|
|
7330
7370
|
}
|
|
7331
7371
|
let trackingXStart = xPoint
|
|
7332
7372
|
let trackingXEnd = xPoint
|
|
@@ -7395,6 +7435,7 @@ if (!this.options.data) {
|
|
|
7395
7435
|
// tell the user no data has been provided
|
|
7396
7436
|
}
|
|
7397
7437
|
else {
|
|
7438
|
+
this.processedX = {}
|
|
7398
7439
|
this.transition = d3.transition().duration(this.options.transitionDuration)
|
|
7399
7440
|
if (this.options.data.bottom.scale && this.options.data.bottom.scale === 'Time') {
|
|
7400
7441
|
this.parseX = function (input) {
|
|
@@ -7441,7 +7482,13 @@ else {
|
|
|
7441
7482
|
// establish the space and size for the legend
|
|
7442
7483
|
// the legend gets rendered so that we can get its actual size
|
|
7443
7484
|
if (this.options.showLegend === true) {
|
|
7444
|
-
let legendData =
|
|
7485
|
+
let legendData = []
|
|
7486
|
+
if (this.options.legendData && this.options.legendData.length > 0) {
|
|
7487
|
+
legendData = this.options.legendData
|
|
7488
|
+
}
|
|
7489
|
+
else {
|
|
7490
|
+
this.options.data.series.map((s, i) => ({value: s.label || s.key, color: s.color || this.options.colors[i % this.options.colors.length]}))
|
|
7491
|
+
}
|
|
7445
7492
|
if (this.options.legendPosition === 'top' || this.options.legendPosition === 'bottom') {
|
|
7446
7493
|
this.legendArea.style('width', '100%')
|
|
7447
7494
|
this.legend.options.align = 'center'
|
|
@@ -7613,18 +7660,30 @@ else {
|
|
|
7613
7660
|
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
|
|
7614
7661
|
this.brushNeeded = false
|
|
7615
7662
|
if (this.options.orientation === 'vertical') {
|
|
7616
|
-
|
|
7617
|
-
|
|
7663
|
+
this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
|
|
7664
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7665
|
+
return a + 1
|
|
7666
|
+
}
|
|
7667
|
+
return a + b.valueCount
|
|
7668
|
+
}, 0)
|
|
7669
|
+
if (this.options.maxBandWidth) {
|
|
7670
|
+
this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.totalValueCount) * this.options.maxBandWidth)
|
|
7618
7671
|
}
|
|
7619
7672
|
// some if to check if brushing is needed
|
|
7620
|
-
if (this.plotWidth / this.options.data.bottom.
|
|
7673
|
+
if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
|
|
7621
7674
|
this.brushNeeded = true
|
|
7622
7675
|
this.plotHeight -= this.options.brushHeight
|
|
7623
7676
|
}
|
|
7624
7677
|
}
|
|
7625
7678
|
else {
|
|
7626
7679
|
// some if to check if brushing is needed
|
|
7627
|
-
|
|
7680
|
+
this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
|
|
7681
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7682
|
+
return a + 1
|
|
7683
|
+
}
|
|
7684
|
+
return a + b.valueCount
|
|
7685
|
+
}, 0)
|
|
7686
|
+
if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
|
|
7628
7687
|
this.brushNeeded = true
|
|
7629
7688
|
this.plotWidth -= this.options.brushHeight
|
|
7630
7689
|
}
|
|
@@ -7679,14 +7738,39 @@ else {
|
|
|
7679
7738
|
// this.tooltip.transform(this.options.margin.left + this.options.margin.axisLeft, this.options.margin.top + this.options.margin.axisTop)
|
|
7680
7739
|
// Configure the bottom axis
|
|
7681
7740
|
let bottomDomain = this.createDomain('bottom')
|
|
7682
|
-
let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7741
|
+
let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7742
|
+
let bottomRange = [0, this.plotWidth]
|
|
7743
|
+
this.customBottomRange = []
|
|
7744
|
+
if (this.options.allowUnevenBands === true) {
|
|
7745
|
+
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') {
|
|
7746
|
+
let acc = 0
|
|
7747
|
+
this.customBottomRange = [0, ...this.options.data.bottom.data.map(d => {
|
|
7748
|
+
acc += d.valueCount
|
|
7749
|
+
return (this.plotWidth / this.options.data.bottom.totalValueCount) * acc
|
|
7750
|
+
})]
|
|
7751
|
+
}
|
|
7752
|
+
}
|
|
7753
|
+
this.options.data.bottom.step = this.plotWidth / this.options.data.bottom.totalValueCount
|
|
7754
|
+
this.options.data.bottom.bandWidth = this.options.data.bottom.step
|
|
7755
|
+
if (this.options.data.bottom.padding) {
|
|
7756
|
+
this.totalPadding = this.plotWidth * this.options.data.bottom.padding
|
|
7757
|
+
let rangeLength = bottomDomain.length
|
|
7758
|
+
if (this.customBottomRange.length > 0) {
|
|
7759
|
+
rangeLength = this.customBottomRange.length
|
|
7760
|
+
}
|
|
7761
|
+
this.bandPadding = (this.totalPadding / (rangeLength)) / 2
|
|
7762
|
+
this.options.data.bottom.bandWidth = (this.plotWidth - this.totalPadding) / this.options.data.bottom.totalValueCount
|
|
7763
|
+
}
|
|
7764
|
+
if (this.options.grouping === 'grouped' && this.options.data.series.length > 1) {
|
|
7765
|
+
this.options.data.bottom.bandWidth = this.options.data.bottom.bandWidth - (this.options.groupPadding * 2)
|
|
7766
|
+
}
|
|
7683
7767
|
this.bottomAxis = d3[`scale${this.options.data.bottom.scale || 'Band'}`]()
|
|
7684
7768
|
.domain(bottomDomain)
|
|
7685
|
-
.range(
|
|
7769
|
+
.range(bottomRange)
|
|
7686
7770
|
if (!this.brushInitialized) {
|
|
7687
7771
|
this.bottomBrushAxis = d3[`scale${this.options.data.bottom.scale || 'Band'}`]()
|
|
7688
7772
|
.domain(bottomBrushDomain)
|
|
7689
|
-
.range(
|
|
7773
|
+
.range(bottomRange)
|
|
7690
7774
|
}
|
|
7691
7775
|
if (this.bottomAxis.nice) {
|
|
7692
7776
|
// this.bottomAxis.nice()
|
|
@@ -7858,6 +7942,10 @@ else {
|
|
|
7858
7942
|
.style('text-anchor', `${((this.options.data.bottom && this.options.data.bottom.rotate) || 0) === 0 ? 'middle' : 'end'}`)
|
|
7859
7943
|
.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`)
|
|
7860
7944
|
}
|
|
7945
|
+
if (this.customBottomRange.length > 0) {
|
|
7946
|
+
this.bottomAxisLayer.selectAll('g')
|
|
7947
|
+
.attr('transform', (d, i) => `translate(${this.customBottomRange[i] + ((this.customBottomRange[i + 1] - this.customBottomRange[i]) / 2)}, 0)`)
|
|
7948
|
+
}
|
|
7861
7949
|
}
|
|
7862
7950
|
// Configure the left axis
|
|
7863
7951
|
let leftDomain = this.createDomain('left')
|
|
@@ -8003,6 +8091,8 @@ this.options.data.series.forEach((series, index) => {
|
|
|
8003
8091
|
this.renderLabels(series, index)
|
|
8004
8092
|
this.renderedKeys[series.key] = series.type
|
|
8005
8093
|
})
|
|
8094
|
+
this.refLineLayer.selectAll('.reference-line').remove()
|
|
8095
|
+
this.refLineLayer.selectAll('.reference-line-label').remove()
|
|
8006
8096
|
if (this.options.refLines && this.options.refLines.length > 0) {
|
|
8007
8097
|
this.options.refLines.forEach(l => this.renderRefLine(l))
|
|
8008
8098
|
}
|
|
@@ -8014,21 +8104,21 @@ const drawArea = (xAxis, yAxis, curveStyle) => {
|
|
|
8014
8104
|
return d3
|
|
8015
8105
|
.area()
|
|
8016
8106
|
.x(d => {
|
|
8017
|
-
return this[xAxis](this.parseX(d.x.value))
|
|
8107
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
8018
8108
|
})
|
|
8019
8109
|
.y0(d => {
|
|
8020
|
-
return this[yAxis](0)
|
|
8110
|
+
return this[`${yAxis}Axis`](0)
|
|
8021
8111
|
})
|
|
8022
8112
|
.y1(d => {
|
|
8023
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value)
|
|
8113
|
+
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
8024
8114
|
})
|
|
8025
8115
|
.curve(d3[curveStyle || this.options.curveStyle])
|
|
8026
8116
|
}
|
|
8027
|
-
let xAxis = '
|
|
8028
|
-
let yAxis = series.axis === 'secondary' ? '
|
|
8029
|
-
if (this.options.
|
|
8030
|
-
xAxis = series.axis === 'secondary' ? '
|
|
8031
|
-
yAxis = '
|
|
8117
|
+
let xAxis = 'bottom'
|
|
8118
|
+
let yAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
8119
|
+
if (this.options.orientation === 'horizontal') {
|
|
8120
|
+
xAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
8121
|
+
yAxis = 'bottom'
|
|
8032
8122
|
}
|
|
8033
8123
|
let areas = this.areaLayer.selectAll(`.area_${series.key}`)
|
|
8034
8124
|
.data([series.data])
|
|
@@ -8051,7 +8141,7 @@ areas.enter().append('path')
|
|
|
8051
8141
|
.attr('d', d => drawArea(xAxis, yAxis, series.curveStyle)(d))
|
|
8052
8142
|
.attr('class', `area_${series.key}`)
|
|
8053
8143
|
.attr('id', `area_${series.key}`)
|
|
8054
|
-
|
|
8144
|
+
.attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[`${xAxis}Axis`].bandWidth / 2) + ',0)')
|
|
8055
8145
|
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8056
8146
|
.attr('fill', series.color)
|
|
8057
8147
|
// .style('fill-opacity', 0)
|
|
@@ -8074,15 +8164,14 @@ if (this.options.orientation === 'horizontal') {
|
|
|
8074
8164
|
// if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
8075
8165
|
// barWidth = barWidth / this.options.data.series.length - 4
|
|
8076
8166
|
// }
|
|
8077
|
-
function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
8078
|
-
let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
8079
|
-
let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
8167
|
+
function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
8080
8168
|
let output
|
|
8081
8169
|
if (this.options.orientation === 'horizontal') {
|
|
8082
|
-
output =
|
|
8170
|
+
output = this.options.data[xAxis.replace('Brush', '')].bandWidth
|
|
8083
8171
|
}
|
|
8084
8172
|
else {
|
|
8085
|
-
|
|
8173
|
+
let x = getBarX.call(this, d, i, xAxis)
|
|
8174
|
+
if (typeof x === 'undefined' || x === null) {
|
|
8086
8175
|
return null
|
|
8087
8176
|
}
|
|
8088
8177
|
output = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
|
|
@@ -8092,25 +8181,19 @@ function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
|
8092
8181
|
}
|
|
8093
8182
|
return output
|
|
8094
8183
|
}
|
|
8095
|
-
function getBarWidth (d, i, xAxis) {
|
|
8096
|
-
let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
8097
|
-
let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length
|
|
8184
|
+
function getBarWidth (d, i, xAxis) {
|
|
8098
8185
|
let output
|
|
8099
|
-
if (this.options.orientation === 'horizontal') {
|
|
8100
|
-
let width = this[`${yAxis}Axis`](d.y.value)
|
|
8186
|
+
if (this.options.orientation === 'horizontal') {
|
|
8187
|
+
let width = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
|
|
8101
8188
|
acummulativeY[d.y.index] += width
|
|
8102
|
-
output =
|
|
8189
|
+
output = width
|
|
8103
8190
|
}
|
|
8104
8191
|
else {
|
|
8105
|
-
|
|
8192
|
+
let x = getBarX.call(this, d, i, xAxis)
|
|
8193
|
+
if (typeof x === 'undefined' || x === null) {
|
|
8106
8194
|
return null
|
|
8107
|
-
}
|
|
8108
|
-
|
|
8109
|
-
output = Math.max(1, groupedBarWidth)
|
|
8110
|
-
}
|
|
8111
|
-
else {
|
|
8112
|
-
output = Math.max(1, barWidth)
|
|
8113
|
-
}
|
|
8195
|
+
}
|
|
8196
|
+
output = Math.max(1, this.options.data[xAxis.replace('Brush', '')].bandWidth)
|
|
8114
8197
|
}
|
|
8115
8198
|
if (isNaN(output)) {
|
|
8116
8199
|
return 0
|
|
@@ -8118,22 +8201,55 @@ function getBarWidth (d, i, xAxis) {
|
|
|
8118
8201
|
return output
|
|
8119
8202
|
}
|
|
8120
8203
|
function getBarX (d, i, xAxis) {
|
|
8121
|
-
let barWidth = this[
|
|
8122
|
-
|
|
8204
|
+
// let barWidth = this.plotWidth / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
8205
|
+
// if (this.options.data[xAxis.replace('Brush', '')].padding) {
|
|
8206
|
+
// barWidth = barWidth - (barWidth * this.options.data[xAxis.replace('Brush', '')].padding)
|
|
8207
|
+
// }
|
|
8208
|
+
// let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
8123
8209
|
let output
|
|
8124
8210
|
if (this.options.orientation === 'horizontal') {
|
|
8125
8211
|
if (this.options.grouping === 'stacked') {
|
|
8126
|
-
|
|
8212
|
+
let h = getBarWidth.call(this, d, i, xAxis)
|
|
8213
|
+
let adjustment = 0
|
|
8214
|
+
if (d.y.accumulative && d.y.accumulative !== 0) {
|
|
8215
|
+
adjustment = this[`${yAxis}Axis`](d.y.accumulative || 0)
|
|
8216
|
+
}
|
|
8217
|
+
output = this[`${yAxis}Axis`](0) + (adjustment * (d.y.value < 0 ? 1 : 0)) + (h * (d.y.value < 0 ? 1 : 0))
|
|
8127
8218
|
}
|
|
8128
8219
|
else {
|
|
8129
|
-
|
|
8220
|
+
let h = getBarWidth.call(this, d, i, xAxis)
|
|
8221
|
+
output = (this[`${yAxis}Axis`](0)) + (h * (d.y.value < 0 ? 1 : 0))
|
|
8130
8222
|
}
|
|
8131
8223
|
}
|
|
8132
8224
|
else {
|
|
8133
|
-
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8225
|
+
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
|
|
8226
|
+
let adjustment = this.customBottomRange[i] + (i * this.options.data[xAxis.replace('Brush', '')].bandWidth)
|
|
8227
|
+
if (this.options.grouping === 'grouped') {
|
|
8228
|
+
let xIndex = 0
|
|
8229
|
+
if (this.processedX[d.x.value]) {
|
|
8230
|
+
xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel))
|
|
8231
|
+
}
|
|
8232
|
+
let barAdjustment =
|
|
8233
|
+
(this.options.data[xAxis.replace('Brush', '')].bandWidth * xIndex) +
|
|
8234
|
+
(xIndex * this.options.groupPadding * 2) + this.options.groupPadding +
|
|
8235
|
+
(xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
8236
|
+
// let barAdjustment =
|
|
8237
|
+
// (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
|
|
8238
|
+
// this.options.groupPadding
|
|
8239
|
+
// // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
8240
|
+
if (this.customBottomRange.length > 0) {
|
|
8241
|
+
output = this.customBottomRange[this[xAxis.replace('Brush', '') + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
|
|
8242
|
+
}
|
|
8243
|
+
else {
|
|
8244
|
+
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + barAdjustment
|
|
8245
|
+
}
|
|
8246
|
+
if (!this.processedX[d.x.value]) {
|
|
8247
|
+
this.processedX[d.x.value] = []
|
|
8248
|
+
}
|
|
8249
|
+
if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
|
|
8250
|
+
this.processedX[d.x.value].push(d.y.tooltipLabel)
|
|
8251
|
+
}
|
|
8252
|
+
console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
|
|
8137
8253
|
}
|
|
8138
8254
|
else {
|
|
8139
8255
|
// output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
|
|
@@ -8146,15 +8262,15 @@ function getBarX (d, i, xAxis) {
|
|
|
8146
8262
|
return output
|
|
8147
8263
|
}
|
|
8148
8264
|
function getBarY (d, i, heightBounds, yAxis, xAxis) {
|
|
8149
|
-
let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
8150
|
-
let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
8265
|
+
// let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
8266
|
+
// let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
8151
8267
|
let output
|
|
8152
8268
|
if (this.options.orientation === 'horizontal') {
|
|
8153
8269
|
if (this.options.grouping !== 'grouped') {
|
|
8154
8270
|
output = this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
8155
8271
|
}
|
|
8156
8272
|
else {
|
|
8157
|
-
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + ((d.y.index || i) * barWidth)
|
|
8273
|
+
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + ((d.y.index || i) * this.options.data[xAxis.replace('Brush', '')].barWidth)
|
|
8158
8274
|
}
|
|
8159
8275
|
}
|
|
8160
8276
|
else {
|
|
@@ -8178,7 +8294,7 @@ bars
|
|
|
8178
8294
|
.remove()
|
|
8179
8295
|
|
|
8180
8296
|
bars
|
|
8181
|
-
.attr('width', (d, i) => getBarWidth.call(this, d, i, xAxis))
|
|
8297
|
+
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
|
|
8182
8298
|
.attr('height', (d, i) => getBarHeight.call(this, d, i, this.plotHeight, yAxis, xAxis))
|
|
8183
8299
|
.attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
|
|
8184
8300
|
.attr('y', (d, i) => getBarY.call(this, d, i, this.plotHeight, yAxis, xAxis))
|
|
@@ -8188,7 +8304,7 @@ bars
|
|
|
8188
8304
|
bars
|
|
8189
8305
|
.enter()
|
|
8190
8306
|
.append('rect')
|
|
8191
|
-
.attr('width', (d, i) => getBarWidth.call(this, d, i, xAxis))
|
|
8307
|
+
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
|
|
8192
8308
|
.attr('height', (d, i) => getBarHeight.call(this, d, i, this.plotHeight, yAxis, xAxis))
|
|
8193
8309
|
.attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
|
|
8194
8310
|
.attr('y', (d, i) => getBarY.call(this, d, i, this.plotHeight, yAxis, xAxis))
|
|
@@ -8207,7 +8323,7 @@ if (!this.brushBarsInitialized[series.key]) {
|
|
|
8207
8323
|
.remove()
|
|
8208
8324
|
|
|
8209
8325
|
brushBars
|
|
8210
|
-
.attr('width', (d, i) => getBarWidth.call(this, d, i, `${xAxis}Brush`))
|
|
8326
|
+
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
|
|
8211
8327
|
.attr('height', (d, i) => getBarHeight.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
8212
8328
|
.attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
|
|
8213
8329
|
.attr('y', (d, i) => getBarY.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
@@ -8217,7 +8333,7 @@ if (!this.brushBarsInitialized[series.key]) {
|
|
|
8217
8333
|
brushBars
|
|
8218
8334
|
.enter()
|
|
8219
8335
|
.append('rect')
|
|
8220
|
-
.attr('width', (d, i) => getBarWidth.call(this, d, i, `${xAxis}Brush`))
|
|
8336
|
+
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
|
|
8221
8337
|
.attr('height', (d, i) => getBarHeight.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
8222
8338
|
.attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
|
|
8223
8339
|
.attr('y', (d, i) => getBarY.call(this, d, i, this.options.brushHeight, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
@@ -8348,12 +8464,12 @@ function getLabelX (d, labelPosition = 'inside') {
|
|
|
8348
8464
|
}
|
|
8349
8465
|
}
|
|
8350
8466
|
else {
|
|
8351
|
-
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis
|
|
8467
|
+
return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
8352
8468
|
}
|
|
8353
8469
|
}
|
|
8354
8470
|
function getLabelY (d, labelPosition = 'inside') {
|
|
8355
8471
|
if (this.options.orientation === 'horizontal') {
|
|
8356
|
-
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis
|
|
8472
|
+
return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
8357
8473
|
}
|
|
8358
8474
|
else {
|
|
8359
8475
|
if (this.options.grouping === 'stacked') {
|
|
@@ -8372,23 +8488,34 @@ const drawLine = (xAxis, yAxis, curveStyle) => {
|
|
|
8372
8488
|
return d3
|
|
8373
8489
|
.line()
|
|
8374
8490
|
.x(d => {
|
|
8375
|
-
|
|
8376
|
-
|
|
8491
|
+
if (this.options.orientation === 'horizontal') {
|
|
8492
|
+
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
8493
|
+
}
|
|
8494
|
+
else {
|
|
8495
|
+
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8496
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8497
|
+
}
|
|
8377
8498
|
})
|
|
8378
8499
|
.y(d => {
|
|
8379
|
-
|
|
8500
|
+
if (this.options.orientation === 'horizontal') {
|
|
8501
|
+
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8502
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8503
|
+
}
|
|
8504
|
+
else {
|
|
8505
|
+
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
8506
|
+
}
|
|
8380
8507
|
})
|
|
8381
8508
|
.curve(d3[curveStyle || this.options.curveStyle])
|
|
8382
8509
|
}
|
|
8383
8510
|
let xAxis = 'bottom'
|
|
8384
8511
|
let yAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
8385
|
-
if (this.options.
|
|
8512
|
+
if (this.options.orientation === 'horizontal') {
|
|
8386
8513
|
xAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
8387
8514
|
yAxis = 'bottom'
|
|
8388
8515
|
}
|
|
8389
8516
|
let xBrushAxis = 'bottomBrush'
|
|
8390
8517
|
let yBrushAxis = 'leftBrush'
|
|
8391
|
-
if (this.options.
|
|
8518
|
+
if (this.options.orientation === 'horizontal') {
|
|
8392
8519
|
xBrushAxis = 'leftBrush'
|
|
8393
8520
|
yBrushAxis = 'bottomBrush'
|
|
8394
8521
|
}
|
|
@@ -8474,8 +8601,6 @@ if (this.options.orientation === 'horizontal') {
|
|
|
8474
8601
|
xAttr = 'y'
|
|
8475
8602
|
length = this.plotHeight
|
|
8476
8603
|
}
|
|
8477
|
-
this.refLineLayer.selectAll('.reference-line').remove()
|
|
8478
|
-
this.refLineLayer.selectAll('.reference-line-label').remove()
|
|
8479
8604
|
this.refLineLayer
|
|
8480
8605
|
.append('line')
|
|
8481
8606
|
.attr(`${yAttr}1`, this[`${yAxis}Axis`](data.value))
|
|
@@ -8524,7 +8649,7 @@ const drawSymbol = (size) => {
|
|
|
8524
8649
|
}
|
|
8525
8650
|
let xAxis = 'bottom'
|
|
8526
8651
|
let yAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
8527
|
-
if (this.options.
|
|
8652
|
+
if (this.options.orientation === 'horizontal') {
|
|
8528
8653
|
xAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
8529
8654
|
yAxis = 'bottom'
|
|
8530
8655
|
}
|
|
@@ -8542,8 +8667,13 @@ symbols
|
|
|
8542
8667
|
.attr('fill', series.fillSymbols ? series.color : 'white')
|
|
8543
8668
|
.attr('stroke', series.color)
|
|
8544
8669
|
.attr('transform', d => {
|
|
8545
|
-
let adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8546
|
-
|
|
8670
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8671
|
+
if (this.options.orientation === 'horizontal') {
|
|
8672
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
|
|
8673
|
+
}
|
|
8674
|
+
else {
|
|
8675
|
+
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8676
|
+
}
|
|
8547
8677
|
})
|
|
8548
8678
|
// Enter
|
|
8549
8679
|
symbols.enter()
|
|
@@ -8554,8 +8684,13 @@ symbols.enter()
|
|
|
8554
8684
|
.attr('stroke', series.color)
|
|
8555
8685
|
.attr('class', d => { return `symbol symbol_${series.key}` })
|
|
8556
8686
|
.attr('transform', d => {
|
|
8557
|
-
let adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8558
|
-
|
|
8687
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
8688
|
+
if (this.options.orientation === 'horizontal') {
|
|
8689
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
|
|
8690
|
+
}
|
|
8691
|
+
else {
|
|
8692
|
+
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8693
|
+
}
|
|
8559
8694
|
})
|
|
8560
8695
|
|
|
8561
8696
|
}
|
|
@@ -8659,22 +8794,27 @@ if (el) {
|
|
|
8659
8794
|
if (el) {
|
|
8660
8795
|
el.classList.remove('has-error')
|
|
8661
8796
|
}
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8797
|
+
if (this.svg) {
|
|
8798
|
+
this.svg.classed('hidden', false)
|
|
8799
|
+
}
|
|
8665
8800
|
const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
|
|
8666
8801
|
if (containerEl) {
|
|
8667
8802
|
containerEl.classList.remove('active')
|
|
8668
8803
|
}
|
|
8669
8804
|
}
|
|
8805
|
+
hideLoading () {
|
|
8806
|
+
this.loadingDialog.hide()
|
|
8807
|
+
}
|
|
8670
8808
|
showError (options) {
|
|
8671
8809
|
const el = document.getElementById(`${this.elementId}`)
|
|
8672
8810
|
if (el) {
|
|
8673
8811
|
el.classList.add('has-error')
|
|
8674
8812
|
}
|
|
8675
8813
|
// const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
|
|
8676
|
-
// chartEl.classList.add('hidden')
|
|
8677
|
-
this.svg
|
|
8814
|
+
// chartEl.classList.add('hidden')
|
|
8815
|
+
if (this.svg) {
|
|
8816
|
+
this.svg.classed('hidden', true)
|
|
8817
|
+
}
|
|
8678
8818
|
const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
|
|
8679
8819
|
if (containerEl) {
|
|
8680
8820
|
containerEl.classList.add('active')
|
|
@@ -8692,6 +8832,9 @@ if (el) {
|
|
|
8692
8832
|
}
|
|
8693
8833
|
}
|
|
8694
8834
|
}
|
|
8835
|
+
showLoading (options) {
|
|
8836
|
+
this.loadingDialog.show(options)
|
|
8837
|
+
}
|
|
8695
8838
|
}
|
|
8696
8839
|
|
|
8697
8840
|
class WebsyLegend {
|