@websy/websy-designs 1.5.2 → 1.6.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/server/helpers/v1/authHelper.js +1 -1
- package/dist/server/helpers/v1/pgHelper.js +49 -0
- package/dist/server/routes/v1/shop.js +1 -0
- package/dist/websy-designs-es6.debug.js +563 -282
- package/dist/websy-designs-es6.js +829 -466
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +592 -302
- package/dist/websy-designs.js +863 -489
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -1864,6 +1864,24 @@ class WebsyDropdown {
|
|
|
1864
1864
|
}
|
|
1865
1865
|
this.updateHeader(item)
|
|
1866
1866
|
}
|
|
1867
|
+
setValue (value) {
|
|
1868
|
+
this.selectedItems = []
|
|
1869
|
+
if (Array.isArray(value)) {
|
|
1870
|
+
this.options.items.forEach(d => {
|
|
1871
|
+
if (value.indexOf(d.value) !== -1) {
|
|
1872
|
+
this.selectedItems.push(d.index)
|
|
1873
|
+
}
|
|
1874
|
+
})
|
|
1875
|
+
}
|
|
1876
|
+
else {
|
|
1877
|
+
this.options.items.forEach(d => {
|
|
1878
|
+
if (d.value === value) {
|
|
1879
|
+
this.selectedItems.push(d.index)
|
|
1880
|
+
}
|
|
1881
|
+
})
|
|
1882
|
+
}
|
|
1883
|
+
this.render()
|
|
1884
|
+
}
|
|
1867
1885
|
updateHeader (item) {
|
|
1868
1886
|
const el = document.getElementById(this.elementId)
|
|
1869
1887
|
const headerEl = document.getElementById(`${this.elementId}_header`)
|
|
@@ -1986,6 +2004,7 @@ class WebsyForm {
|
|
|
1986
2004
|
return
|
|
1987
2005
|
}
|
|
1988
2006
|
this.apiService = new WebsyDesigns.APIService('')
|
|
2007
|
+
this.fieldMap = {}
|
|
1989
2008
|
this.elementId = elementId
|
|
1990
2009
|
const el = document.getElementById(elementId)
|
|
1991
2010
|
if (el) {
|
|
@@ -2034,6 +2053,15 @@ class WebsyForm {
|
|
|
2034
2053
|
}
|
|
2035
2054
|
})
|
|
2036
2055
|
}
|
|
2056
|
+
get data () {
|
|
2057
|
+
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2058
|
+
const data = {}
|
|
2059
|
+
const temp = new FormData(formEl)
|
|
2060
|
+
temp.forEach((value, key) => {
|
|
2061
|
+
data[key] = value
|
|
2062
|
+
})
|
|
2063
|
+
return data
|
|
2064
|
+
}
|
|
2037
2065
|
set data (d) {
|
|
2038
2066
|
if (!this.options.fields) {
|
|
2039
2067
|
this.options.fields = []
|
|
@@ -2113,6 +2141,7 @@ class WebsyForm {
|
|
|
2113
2141
|
<form id="${this.elementId}Form" class="websy-form ${this.options.classes || ''}">
|
|
2114
2142
|
`
|
|
2115
2143
|
this.options.fields.forEach((f, i) => {
|
|
2144
|
+
this.fieldMap[f.field] = f
|
|
2116
2145
|
if (f.component) {
|
|
2117
2146
|
componentsToProcess.push(f)
|
|
2118
2147
|
html += `
|
|
@@ -2183,6 +2212,25 @@ class WebsyForm {
|
|
|
2183
2212
|
})
|
|
2184
2213
|
}
|
|
2185
2214
|
}
|
|
2215
|
+
setValue (field, value) {
|
|
2216
|
+
if (this.fieldMap[field]) {
|
|
2217
|
+
if (this.fieldMap[field].instance) {
|
|
2218
|
+
this.fieldMap[field].instance.setValue(value)
|
|
2219
|
+
}
|
|
2220
|
+
else {
|
|
2221
|
+
const el = document.getElementById(`${this.elementId}_input_${field}`)
|
|
2222
|
+
if (el) {
|
|
2223
|
+
el.value = value
|
|
2224
|
+
}
|
|
2225
|
+
else {
|
|
2226
|
+
console.error(`Input for ${field} does not exist in form.`)
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
else {
|
|
2231
|
+
console.error(`Field ${field} does not exist in form.`)
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2186
2234
|
submitForm () {
|
|
2187
2235
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2188
2236
|
const buttonEl = formEl.querySelector('button.websy-btn.submit')
|
|
@@ -3849,15 +3897,18 @@ class WebsyRouter {
|
|
|
3849
3897
|
let inputPath = this.currentView
|
|
3850
3898
|
if (this.options.urlPrefix) {
|
|
3851
3899
|
inputPath = `/${this.options.urlPrefix}/${inputPath}`
|
|
3900
|
+
}
|
|
3901
|
+
this.currentParams = {
|
|
3902
|
+
path: '',
|
|
3903
|
+
items: {}
|
|
3852
3904
|
}
|
|
3853
3905
|
if (reloadView === true) {
|
|
3854
3906
|
this.navigate(`${inputPath}`, 'main', null, noHistory)
|
|
3855
3907
|
}
|
|
3856
3908
|
else {
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
}
|
|
3909
|
+
history.replaceState({
|
|
3910
|
+
inputPath
|
|
3911
|
+
}, 'unused', inputPath)
|
|
3861
3912
|
}
|
|
3862
3913
|
}
|
|
3863
3914
|
buildUrlPath (params) {
|
|
@@ -6570,6 +6621,7 @@ class WebsyChart {
|
|
|
6570
6621
|
tooltipWidth: 200,
|
|
6571
6622
|
brushHeight: 50,
|
|
6572
6623
|
minBandWidth: 30,
|
|
6624
|
+
maxBandWidth: 100,
|
|
6573
6625
|
allowUnevenBands: true
|
|
6574
6626
|
}
|
|
6575
6627
|
this.elementId = elementId
|
|
@@ -6597,99 +6649,124 @@ class WebsyChart {
|
|
|
6597
6649
|
xAxis += 'Axis'
|
|
6598
6650
|
let output
|
|
6599
6651
|
let width = this.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth
|
|
6600
|
-
if (this.customBottomRange) {
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
output = index
|
|
6606
|
-
break
|
|
6607
|
-
}
|
|
6608
|
-
}
|
|
6609
|
-
else {
|
|
6652
|
+
// if (this.customBottomRange) {
|
|
6653
|
+
for (let index = 0; index < this.customBottomRange.length; index++) {
|
|
6654
|
+
if (input > this.customBottomRange[index]) {
|
|
6655
|
+
if (this.customBottomRange[index + 1]) {
|
|
6656
|
+
if (input < this.customBottomRange[index + 1]) {
|
|
6610
6657
|
output = index
|
|
6611
6658
|
break
|
|
6612
6659
|
}
|
|
6613
6660
|
}
|
|
6614
|
-
|
|
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
|
|
6661
|
+
else {
|
|
6662
|
+
output = index
|
|
6626
6663
|
break
|
|
6627
6664
|
}
|
|
6628
|
-
}
|
|
6665
|
+
}
|
|
6629
6666
|
}
|
|
6667
|
+
// }
|
|
6668
|
+
// else {
|
|
6669
|
+
// let domain = [...this[xAxis].domain()]
|
|
6670
|
+
// if (this.options.orientation === 'horizontal') {
|
|
6671
|
+
// domain = domain.reverse()
|
|
6672
|
+
// }
|
|
6673
|
+
// for (let j = 0; j < domain.length; j++) {
|
|
6674
|
+
// let breakA = this[xAxis](domain[j]) - (width / 2)
|
|
6675
|
+
// let breakB = breakA + width
|
|
6676
|
+
// if (input > breakA && input <= breakB) {
|
|
6677
|
+
// output = j
|
|
6678
|
+
// break
|
|
6679
|
+
// }
|
|
6680
|
+
// }
|
|
6681
|
+
// }
|
|
6630
6682
|
return output
|
|
6631
6683
|
}
|
|
6632
6684
|
let that = this
|
|
6633
6685
|
this.brushed = function (event) {
|
|
6634
|
-
console.log('brushing', event)
|
|
6635
|
-
that.
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
if (that.options.orientation === 'horizontal') {
|
|
6639
|
-
xAxis = 'left'
|
|
6640
|
-
xAxisCaps = 'Left'
|
|
6641
|
-
}
|
|
6642
|
-
if (!that[`${xAxis}Axis`]) {
|
|
6643
|
-
return
|
|
6686
|
+
console.log('brushing', event)
|
|
6687
|
+
let newX = (that.options.margin.left + that.options.margin.axisLeft) + (1 - (event.selection[0] / ((that.plotWidth) / (that.widthForCalc + that.totalBandPadding))))
|
|
6688
|
+
if (that.plotArea) {
|
|
6689
|
+
that.plotArea.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6644
6690
|
}
|
|
6645
|
-
if (
|
|
6646
|
-
that
|
|
6691
|
+
if (that.areaLayer) {
|
|
6692
|
+
that.areaLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6647
6693
|
}
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
that.brushLayer
|
|
6651
|
-
.select('.brush')
|
|
6652
|
-
.call(that.brush)
|
|
6653
|
-
.call(that.brush.move, s)
|
|
6654
|
-
return
|
|
6694
|
+
if (that.lineLayer) {
|
|
6695
|
+
that.lineLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6655
6696
|
}
|
|
6656
|
-
if (that.
|
|
6657
|
-
that.
|
|
6697
|
+
if (that.barLayer) {
|
|
6698
|
+
that.barLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6658
6699
|
}
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
if (
|
|
6662
|
-
startEndOrdinal &&
|
|
6663
|
-
startEndOrdinal.length === 2 &&
|
|
6664
|
-
typeof startEndOrdinal[0] !== 'undefined' &&
|
|
6665
|
-
typeof startEndOrdinal[1] !== 'undefined'
|
|
6666
|
-
) {
|
|
6667
|
-
let domain = []
|
|
6668
|
-
let domainValues = [...that[`${xAxis}BrushAxis`].domain()]
|
|
6669
|
-
for (let i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
|
|
6670
|
-
// domain.push(that.xRange[i])
|
|
6671
|
-
that.brushedDomain.push(domainValues[i])
|
|
6672
|
-
}
|
|
6673
|
-
}
|
|
6700
|
+
if (that.labelLayer) {
|
|
6701
|
+
that.labelLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6674
6702
|
}
|
|
6675
|
-
if (that.
|
|
6676
|
-
that
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
)
|
|
6680
|
-
}
|
|
6681
|
-
if (that.
|
|
6682
|
-
that.
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6703
|
+
if (that.symbolLayer) {
|
|
6704
|
+
that.symbolLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6705
|
+
}
|
|
6706
|
+
if (that.refLineLayer) {
|
|
6707
|
+
that.refLineLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6708
|
+
}
|
|
6709
|
+
if (that.bottomAxisLayer) {
|
|
6710
|
+
that.bottomAxisLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop + that.plotHeight})`)
|
|
6711
|
+
}
|
|
6712
|
+
// that.brushedDomain = []
|
|
6713
|
+
// let xAxis = 'bottom'
|
|
6714
|
+
// let xAxisCaps = 'Bottom'
|
|
6715
|
+
// if (that.options.orientation === 'horizontal') {
|
|
6716
|
+
// xAxis = 'left'
|
|
6717
|
+
// xAxisCaps = 'Left'
|
|
6718
|
+
// }
|
|
6719
|
+
// if (!that[`${xAxis}Axis`]) {
|
|
6720
|
+
// return
|
|
6721
|
+
// }
|
|
6722
|
+
// if (!that[`${xAxis}Axis`].invert) {
|
|
6723
|
+
// that[`${xAxis}Axis`].invert = that.invertOverride
|
|
6724
|
+
// }
|
|
6725
|
+
// let s = event.selection || that[`${xAxis}Axis`].range()
|
|
6726
|
+
// if (!event.selection || event.selection.length === 0) {
|
|
6727
|
+
// that.brushLayer
|
|
6728
|
+
// .select('.brush')
|
|
6729
|
+
// .call(that.brush)
|
|
6730
|
+
// .call(that.brush.move, s)
|
|
6731
|
+
// return
|
|
6732
|
+
// }
|
|
6733
|
+
// if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
|
|
6734
|
+
// that.brushedDomain = s.map(that[`${xAxis}BrushAxis`].invert, that[[`${xAxis}Axis`]])
|
|
6735
|
+
// }
|
|
6736
|
+
// else {
|
|
6737
|
+
// let startEndOrdinal = s.map((a, b) => that.bottomAxis.invert(a, b, true), that.bottomBrushAxis)
|
|
6738
|
+
// if (
|
|
6739
|
+
// startEndOrdinal &&
|
|
6740
|
+
// startEndOrdinal.length === 2 &&
|
|
6741
|
+
// typeof startEndOrdinal[0] !== 'undefined' &&
|
|
6742
|
+
// typeof startEndOrdinal[1] !== 'undefined'
|
|
6743
|
+
// ) {
|
|
6744
|
+
// let domain = []
|
|
6745
|
+
// let domainValues = [...that[`${xAxis}BrushAxis`].domain()]
|
|
6746
|
+
// for (let i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
|
|
6747
|
+
// // domain.push(that.xRange[i])
|
|
6748
|
+
// that.brushedDomain.push(domainValues[i])
|
|
6749
|
+
// }
|
|
6750
|
+
// }
|
|
6751
|
+
// }
|
|
6752
|
+
// if (that.brushedDomain.length > 0) {
|
|
6753
|
+
// that[`${xAxis}Axis`].domain(that.brushedDomain)
|
|
6754
|
+
// that[`${xAxis}AxisLayer`].call(
|
|
6755
|
+
// d3[`axis${xAxisCaps}`](that[`${xAxis}Axis`])
|
|
6756
|
+
// )
|
|
6757
|
+
// }
|
|
6758
|
+
// if (that.leftAxis && that.bottomAxis) {
|
|
6759
|
+
// that.renderComponents()
|
|
6760
|
+
// if (that.options.orientation === 'vertical') {
|
|
6761
|
+
// // that.bottomAxisLayer.call(that.bAxisFunc)
|
|
6762
|
+
// if (that.options.data.bottom.rotate) {
|
|
6763
|
+
// that.bottomAxisLayer.selectAll('text')
|
|
6764
|
+
// .attr('transform', `rotate(${((that.options.data.bottom && that.options.data.bottom.rotate) || 0)})`)
|
|
6765
|
+
// .style('text-anchor', `${((that.options.data.bottom && that.options.data.bottom.rotate) || 0) === 0 ? 'middle' : 'end'}`)
|
|
6766
|
+
// .style('transform-origin', ((that.options.data.bottom && that.options.data.bottom.rotate) || 0) === 0 ? '0 0' : `0 ${((that.options.data.bottom && that.options.data.bottom.fontSize) || that.options.fontSize)}px`)
|
|
6767
|
+
// }
|
|
6768
|
+
// }
|
|
6769
|
+
// }
|
|
6693
6770
|
}
|
|
6694
6771
|
const el = document.getElementById(this.elementId)
|
|
6695
6772
|
if (el) {
|
|
@@ -6831,12 +6908,12 @@ else {
|
|
|
6831
6908
|
}
|
|
6832
6909
|
this.options.data.series.forEach(s => {
|
|
6833
6910
|
if (this.options.data[xData].scale !== 'Time') {
|
|
6834
|
-
if (this.customBottomRange && this.customBottomRange.length > 0) {
|
|
6835
|
-
|
|
6836
|
-
}
|
|
6837
|
-
else {
|
|
6838
|
-
|
|
6839
|
-
}
|
|
6911
|
+
// if (this.customBottomRange && this.customBottomRange.length > 0) {
|
|
6912
|
+
xPoint = this.customBottomRange[x0] + ((this.customBottomRange[x0 + 1] - this.customBottomRange[x0]) / 2)
|
|
6913
|
+
// }
|
|
6914
|
+
// else {
|
|
6915
|
+
// xPoint = this[xAxis](this.parseX(xLabel))
|
|
6916
|
+
// }
|
|
6840
6917
|
s.data.forEach(d => {
|
|
6841
6918
|
if (d.x.value === xLabel) {
|
|
6842
6919
|
if (!tooltipTitle) {
|
|
@@ -6958,6 +7035,10 @@ else {
|
|
|
6958
7035
|
}
|
|
6959
7036
|
}
|
|
6960
7037
|
this.tooltip.setHeight(this.plotHeight)
|
|
7038
|
+
if (isNaN(posOptions.left)) {
|
|
7039
|
+
this.tooltip.hide()
|
|
7040
|
+
return
|
|
7041
|
+
}
|
|
6961
7042
|
this.options.showTooltip && this.tooltip.show(tooltipTitle, tooltipHTML, posOptions)
|
|
6962
7043
|
// }
|
|
6963
7044
|
// else {
|
|
@@ -6992,20 +7073,22 @@ else {
|
|
|
6992
7073
|
/* global d3 WebsyDesigns */
|
|
6993
7074
|
this.defs = this.svg.append('defs')
|
|
6994
7075
|
this.clip = this.defs.append('clipPath').attr('id', `${this.elementId}_clip`).append('rect')
|
|
7076
|
+
this.xAxisClip = this.defs.append('clipPath').attr('id', `${this.elementId}_xAxisClip`).append('rect')
|
|
6995
7077
|
this.brushClip = this.defs.append('clipPath').attr('id', `${this.elementId}_brushclip`).append('rect')
|
|
6996
7078
|
this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer')
|
|
6997
7079
|
this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer')
|
|
6998
|
-
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer')
|
|
7080
|
+
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer').attr('clip-path', `url(#${this.elementId}_xAxisClip)`).append('g')
|
|
6999
7081
|
this.leftAxisLabel = this.svg.append('g').attr('class', 'left-axis-label-layer')
|
|
7000
7082
|
this.rightAxisLabel = this.svg.append('g').attr('class', 'right-axis-label-layer')
|
|
7001
7083
|
this.bottomAxisLabel = this.svg.append('g').attr('class', 'bottom-axis-label-layer')
|
|
7002
|
-
this.plotArea = this.svg.append('g').attr('class', 'plot-layer')
|
|
7003
|
-
this.areaLayer = this.svg.append('g').attr('class', 'area-layer')
|
|
7004
|
-
this.lineLayer = this.svg.append('g').attr('class', 'line-layer')
|
|
7005
|
-
this.barLayer = this.svg.append('g').attr('class', 'bar-layer')
|
|
7006
|
-
|
|
7007
|
-
this.
|
|
7008
|
-
this.
|
|
7084
|
+
this.plotArea = this.svg.append('g').attr('class', 'plot-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7085
|
+
this.areaLayer = this.svg.append('g').attr('class', 'area-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7086
|
+
this.lineLayer = this.svg.append('g').attr('class', 'line-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7087
|
+
this.barLayer = this.svg.append('g').attr('class', 'bar-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7088
|
+
// this.barLayer.attr('clip-path', `url(#${this.elementId}_clip)`)
|
|
7089
|
+
this.labelLayer = this.svg.append('g').attr('class', 'label-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7090
|
+
this.symbolLayer = this.svg.append('g').attr('class', 'symbol-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7091
|
+
this.refLineLayer = this.svg.append('g').attr('class', 'refline-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7009
7092
|
this.trackingLineLayer = this.svg.append('g').attr('class', 'tracking-line-layer')
|
|
7010
7093
|
this.trackingLineLayer.append('line').attr('class', 'tracking-line')
|
|
7011
7094
|
this.tooltip = new WebsyDesigns.WebsyChartTooltip(this.svg)
|
|
@@ -7253,39 +7336,113 @@ else {
|
|
|
7253
7336
|
this.options.margin.axisBottom = 0
|
|
7254
7337
|
}
|
|
7255
7338
|
}
|
|
7339
|
+
// At some point before this we need to add in logic to make space for any data point labels
|
|
7256
7340
|
// Define the plot size
|
|
7257
7341
|
this.plotWidth = this.width - this.options.margin.legendLeft - this.options.margin.legendRight - this.options.margin.left - this.options.margin.right - this.options.margin.axisLeft - this.options.margin.axisRight
|
|
7258
7342
|
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
|
|
7259
7343
|
this.brushNeeded = false
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
if (this.
|
|
7272
|
-
this.
|
|
7273
|
-
|
|
7344
|
+
let proposedBandWidth // distance between x axis data points.
|
|
7345
|
+
let maxBandWidthFits = false
|
|
7346
|
+
// Check to see if all bars at the max allowed width will fit
|
|
7347
|
+
this.bandPadding = 0
|
|
7348
|
+
this.totalBandPadding = 0
|
|
7349
|
+
this.brushBandPadding = 0
|
|
7350
|
+
this.totalBrushBandPadding = 0
|
|
7351
|
+
let noOfPoints = 0
|
|
7352
|
+
let noOfGroups = 0
|
|
7353
|
+
let plotable = 0
|
|
7354
|
+
if (this.options.maxBandWidth) {
|
|
7355
|
+
if (this.options.orientation === 'horizontal') {
|
|
7356
|
+
this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
|
|
7357
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7358
|
+
return a + 1
|
|
7359
|
+
}
|
|
7360
|
+
return a + b.valueCount
|
|
7361
|
+
}, 0)
|
|
7362
|
+
if (this.options.data.left.padding) {
|
|
7363
|
+
this.totalBandPadding = (this.plotHeight * this.options.data.left.padding)
|
|
7364
|
+
this.bandPadding = this.totalBandPadding / this.options.data.left.data.length
|
|
7365
|
+
this.totalBrushBandPadding = (this.plotHeight * this.options.data.left.padding)
|
|
7366
|
+
this.brushBandPadding = this.totalBandPadding / this.options.data.left.data.length
|
|
7367
|
+
}
|
|
7368
|
+
plotable = this.plotHeight - this.totalBandPadding
|
|
7369
|
+
noOfPoints = this.options.grouping === 'grouped' ? this.options.data.left.totalValueCount : this.options.data.left.data.length
|
|
7370
|
+
noOfGroups = this.options.data.left.data.length
|
|
7274
7371
|
}
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
return a +
|
|
7372
|
+
else {
|
|
7373
|
+
this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
|
|
7374
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7375
|
+
return a + 1
|
|
7376
|
+
}
|
|
7377
|
+
return a + b.valueCount
|
|
7378
|
+
}, 0)
|
|
7379
|
+
if (this.options.data.bottom.padding) {
|
|
7380
|
+
this.totalBandPadding = (this.plotWidth * this.options.data.bottom.padding)
|
|
7381
|
+
this.bandPadding = this.totalBandPadding / this.options.data.bottom.data.length
|
|
7382
|
+
this.totalBrushBandPadding = (this.plotWidth * this.options.data.bottom.padding)
|
|
7383
|
+
this.brushBandPadding = this.totalBandPadding / this.options.data.bottom.data.length
|
|
7384
|
+
}
|
|
7385
|
+
plotable = this.plotWidth - this.totalBandPadding
|
|
7386
|
+
noOfPoints = this.options.grouping === 'grouped' ? this.options.data.bottom.totalValueCount : this.options.data.bottom.data.length
|
|
7387
|
+
noOfGroups = this.options.data.bottom.data.length
|
|
7388
|
+
}
|
|
7389
|
+
if (plotable / noOfPoints > this.options.maxBandWidth) {
|
|
7390
|
+
maxBandWidthFits = true
|
|
7391
|
+
proposedBandWidth = this.options.maxBandWidth
|
|
7392
|
+
}
|
|
7393
|
+
if (!maxBandWidthFits) {
|
|
7394
|
+
// Check to see if all bars at the min allowed width will fit
|
|
7395
|
+
if (plotable / noOfPoints < this.options.minBandWidth) {
|
|
7396
|
+
this.brushNeeded = true
|
|
7397
|
+
proposedBandWidth = this.options.minBandWidth
|
|
7398
|
+
if (this.options.orientation === 'horizontal') {
|
|
7399
|
+
this.plotWidth -= this.options.brushHeight
|
|
7400
|
+
}
|
|
7401
|
+
else {
|
|
7402
|
+
this.plotHeight -= this.options.brushHeight
|
|
7403
|
+
}
|
|
7281
7404
|
}
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7405
|
+
else {
|
|
7406
|
+
proposedBandWidth = plotable / noOfPoints
|
|
7407
|
+
}
|
|
7408
|
+
}
|
|
7409
|
+
}
|
|
7410
|
+
// if (this.options.minBandWidth) {
|
|
7411
|
+
// this.widthForCalc = this.options.data.bottom.totalValueCount * this.options.minBandWidth
|
|
7412
|
+
// if (this.options.data.bottom.padding) {
|
|
7413
|
+
// this.widthForCalc += (this.options.minBandWidth * this.options.data.bottom.padding) * this.options.data.bottom.totalValueCount
|
|
7414
|
+
// this.widthForCalc += (this.options.data.bottom.data.length * this.options.groupPadding * 2)
|
|
7415
|
+
// }
|
|
7416
|
+
// }
|
|
7417
|
+
// if (this.options.orientation === 'vertical') {
|
|
7418
|
+
// this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
|
|
7419
|
+
// if (typeof b.valueCount === 'undefined') {
|
|
7420
|
+
// return a + 1
|
|
7421
|
+
// }
|
|
7422
|
+
// return a + b.valueCount
|
|
7423
|
+
// }, 0)
|
|
7424
|
+
// if (this.options.maxBandWidth) {
|
|
7425
|
+
// this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.totalValueCount) * this.options.maxBandWidth)
|
|
7426
|
+
// }
|
|
7427
|
+
// // some if to check if brushing is needed
|
|
7428
|
+
// if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
|
|
7429
|
+
// this.brushNeeded = true
|
|
7430
|
+
// this.plotHeight -= this.options.brushHeight
|
|
7431
|
+
// }
|
|
7432
|
+
// }
|
|
7433
|
+
// else {
|
|
7434
|
+
// // some if to check if brushing is needed
|
|
7435
|
+
// this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
|
|
7436
|
+
// if (typeof b.valueCount === 'undefined') {
|
|
7437
|
+
// return a + 1
|
|
7438
|
+
// }
|
|
7439
|
+
// return a + b.valueCount
|
|
7440
|
+
// }, 0)
|
|
7441
|
+
// if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
|
|
7442
|
+
// this.brushNeeded = true
|
|
7443
|
+
// this.plotWidth -= this.options.brushHeight
|
|
7444
|
+
// }
|
|
7445
|
+
// }
|
|
7289
7446
|
// Translate the layers
|
|
7290
7447
|
this.leftAxisLayer
|
|
7291
7448
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
|
|
@@ -7320,6 +7477,14 @@ else {
|
|
|
7320
7477
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
|
|
7321
7478
|
this.brushLayer
|
|
7322
7479
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height})`)
|
|
7480
|
+
this.clip
|
|
7481
|
+
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, 0)`)
|
|
7482
|
+
.attr('width', this.plotWidth)
|
|
7483
|
+
.attr('height', this.plotHeight + this.options.margin.top + this.options.margin.axisTop)
|
|
7484
|
+
this.xAxisClip
|
|
7485
|
+
.attr('transform', `translate(${this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
|
|
7486
|
+
.attr('width', this.plotWidth + this.options.margin.axisLeft)
|
|
7487
|
+
.attr('height', longestBottomBounds.height + 10)
|
|
7323
7488
|
this.brushClip
|
|
7324
7489
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height})`)
|
|
7325
7490
|
.attr('width', this.plotWidth)
|
|
@@ -7336,39 +7501,80 @@ else {
|
|
|
7336
7501
|
// this.tooltip.transform(this.options.margin.left + this.options.margin.axisLeft, this.options.margin.top + this.options.margin.axisTop)
|
|
7337
7502
|
// Configure the bottom axis
|
|
7338
7503
|
let bottomDomain = this.createDomain('bottom')
|
|
7339
|
-
let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7504
|
+
// let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7505
|
+
let bottomBrushDomain = this.createDomain('bottom')
|
|
7340
7506
|
let bottomRange = [0, this.plotWidth]
|
|
7507
|
+
let bottomBrushRange = [0, this.plotWidth]
|
|
7508
|
+
let leftRange = [this.plotHeight, 0]
|
|
7509
|
+
let leftBrushRange = [this.options.brushHeight, 0]
|
|
7510
|
+
if (this.options.orientation === 'horizontal') {
|
|
7511
|
+
leftBrushRange = [this.plotHeight, 0]
|
|
7512
|
+
}
|
|
7513
|
+
this.widthForCalc = (proposedBandWidth * noOfPoints) // + totalPadding
|
|
7341
7514
|
this.customBottomRange = []
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
this.options.
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7515
|
+
this.customBottomDetailRange = []
|
|
7516
|
+
this.customBottomBrushRange = []
|
|
7517
|
+
this.customLeftRange = []
|
|
7518
|
+
this.customLeftDetailRange = []
|
|
7519
|
+
this.customLeftBrushRange = []
|
|
7520
|
+
// if (this.options.allowUnevenBands === true) {
|
|
7521
|
+
// always allow uneven bands
|
|
7522
|
+
let customRangeSide = 'Bottom'
|
|
7523
|
+
let customRangeSideLC = 'bottom'
|
|
7524
|
+
if (this.options.orientation === 'horizontal') {
|
|
7525
|
+
customRangeSide = 'Left'
|
|
7526
|
+
customRangeSideLC = 'left'
|
|
7527
|
+
}
|
|
7528
|
+
if (this.options.data[customRangeSideLC].data && this.options.data[customRangeSideLC].data[0] && (this.options.data[customRangeSideLC].data[0].valueCount || 1) && this.options.data[customRangeSideLC].scale === 'Ordinal') {
|
|
7529
|
+
let acc = 0
|
|
7530
|
+
this[`custom${customRangeSide}Range`] = [0, ...this.options.data[customRangeSideLC].data.map((d, index, arr) => {
|
|
7531
|
+
let adjustment = (this.bandPadding * index) + this.bandPadding
|
|
7532
|
+
// if (this.options.data.bottom.padding) {
|
|
7533
|
+
// adjustment = (this.widthForCalc * this.options.data.bottom.padding) / (arr.length * 2)
|
|
7534
|
+
// }
|
|
7535
|
+
let start = (this.widthForCalc / noOfPoints) * acc
|
|
7536
|
+
for (let i = 0; i < (d.valueCount || 1); i++) {
|
|
7537
|
+
let pos = i * proposedBandWidth
|
|
7538
|
+
this[`custom${customRangeSide}DetailRange`].push(start + adjustment + pos)
|
|
7539
|
+
}
|
|
7540
|
+
acc += (this.options.grouping !== 'stacked' ? (d.valueCount || 1) : 1)
|
|
7541
|
+
let end = (this.widthForCalc / noOfPoints) * acc
|
|
7542
|
+
// this.customBottomBrushRange.push((end + adjustment) * (this.plotWidth / this.widthForCalc))
|
|
7543
|
+
return end + adjustment
|
|
7544
|
+
})]
|
|
7545
|
+
acc = 0
|
|
7546
|
+
this[`custom${customRangeSide}BrushRange`] = [0, ...this.options.data[customRangeSideLC].data.map((d, index, arr) => {
|
|
7547
|
+
let adjustment = (this.brushBandPadding * index) + this.brushBandPadding
|
|
7548
|
+
acc += (this.options.grouping !== 'stacked' ? (d.valueCount || 1) : 1)
|
|
7549
|
+
return ((this.options.orientation === 'vertical' ? this.plotWidth : this.plotHeight) / noOfPoints) * acc
|
|
7550
|
+
})]
|
|
7364
7551
|
}
|
|
7365
|
-
|
|
7552
|
+
// }
|
|
7553
|
+
let rangeLength = bottomDomain.length
|
|
7554
|
+
this.options.data.bottomBrush = {}
|
|
7555
|
+
this.options.data.leftBrush = {}
|
|
7556
|
+
if (this.options.orientation === 'vertical') {
|
|
7557
|
+
this.options.data.bottom.bandWidth = proposedBandWidth
|
|
7558
|
+
this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints
|
|
7559
|
+
}
|
|
7560
|
+
else {
|
|
7561
|
+
this.options.data.left.bandWidth = proposedBandWidth
|
|
7562
|
+
this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints
|
|
7563
|
+
}
|
|
7564
|
+
this.brushBandPadding = this.totalBandPadding / noOfGroups
|
|
7565
|
+
if (this.options.orientation === 'vertical') {
|
|
7566
|
+
bottomRange = [0, (this.widthForCalc + this.totalBandPadding)]
|
|
7567
|
+
}
|
|
7568
|
+
else {
|
|
7569
|
+
leftRange = [(this.widthForCalc + this.totalBandPadding), 0]
|
|
7570
|
+
}
|
|
7571
|
+
this.bottomAxis = d3[`scale${this.options.data.bottom.scale || 'Ordinal'}`]()
|
|
7366
7572
|
.domain(bottomDomain)
|
|
7367
7573
|
.range(bottomRange)
|
|
7368
7574
|
if (!this.brushInitialized) {
|
|
7369
|
-
this.bottomBrushAxis = d3[`scale${this.options.data.bottom.scale || '
|
|
7575
|
+
this.bottomBrushAxis = d3[`scale${this.options.data.bottom.scale || 'Ordinal'}`]()
|
|
7370
7576
|
.domain(bottomBrushDomain)
|
|
7371
|
-
.range(
|
|
7577
|
+
.range(bottomBrushRange)
|
|
7372
7578
|
}
|
|
7373
7579
|
if (this.bottomAxis.nice) {
|
|
7374
7580
|
// this.bottomAxis.nice()
|
|
@@ -7387,71 +7593,71 @@ else {
|
|
|
7387
7593
|
brushThickness = this.plotHeight
|
|
7388
7594
|
}
|
|
7389
7595
|
else {
|
|
7390
|
-
if (
|
|
7391
|
-
brushEnd = this.plotWidth * (
|
|
7596
|
+
if (this.brushNeeded) {
|
|
7597
|
+
brushEnd = this.plotWidth * (this.plotWidth / (this.widthForCalc + this.totalBandPadding))
|
|
7392
7598
|
}
|
|
7393
7599
|
}
|
|
7394
7600
|
this.brush = d3[brushMethod]()
|
|
7395
7601
|
.extent([
|
|
7396
7602
|
[0, 0],
|
|
7397
7603
|
[brushLength, brushThickness]
|
|
7398
|
-
])
|
|
7604
|
+
])
|
|
7399
7605
|
.on('brush end', this.brushed)
|
|
7400
|
-
const brushResizePath = d => {
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
}
|
|
7438
|
-
this.brushHandle = this.brushLayer
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
this.brushHandle = this.brushLayer
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7606
|
+
// const brushResizePath = d => {
|
|
7607
|
+
// let e = +(d.type === 'e')
|
|
7608
|
+
// let x = e ? 1 : -1
|
|
7609
|
+
// let y = this.options.brushHeight
|
|
7610
|
+
// return (
|
|
7611
|
+
// 'M' +
|
|
7612
|
+
// 0.5 * x +
|
|
7613
|
+
// ',' +
|
|
7614
|
+
// y +
|
|
7615
|
+
// 'A6,6 0 0 ' +
|
|
7616
|
+
// e +
|
|
7617
|
+
// ' ' +
|
|
7618
|
+
// 6.5 * x +
|
|
7619
|
+
// ',' +
|
|
7620
|
+
// (y + 6) +
|
|
7621
|
+
// 'V' +
|
|
7622
|
+
// (2 * y - 6) +
|
|
7623
|
+
// 'A6,6 0 0 ' +
|
|
7624
|
+
// e +
|
|
7625
|
+
// ' ' +
|
|
7626
|
+
// 0.5 * x +
|
|
7627
|
+
// ',' +
|
|
7628
|
+
// 2 * y +
|
|
7629
|
+
// 'Z' +
|
|
7630
|
+
// 'M' +
|
|
7631
|
+
// 2.5 * x +
|
|
7632
|
+
// ',' +
|
|
7633
|
+
// (y + 8) +
|
|
7634
|
+
// 'V' +
|
|
7635
|
+
// (2 * y - 8) +
|
|
7636
|
+
// 'M' +
|
|
7637
|
+
// 4.5 * x +
|
|
7638
|
+
// ',' +
|
|
7639
|
+
// (y + 8) +
|
|
7640
|
+
// 'V' +
|
|
7641
|
+
// (2 * y - 8)
|
|
7642
|
+
// )
|
|
7643
|
+
// }
|
|
7644
|
+
// this.brushHandle = this.brushLayer
|
|
7645
|
+
// .select('.brush')
|
|
7646
|
+
// .selectAll('.handle--custom')
|
|
7647
|
+
// .remove()
|
|
7648
|
+
// this.brushHandle = this.brushLayer
|
|
7649
|
+
// .select('.brush')
|
|
7650
|
+
// .selectAll('.handle--custom')
|
|
7651
|
+
// .data([{ type: 'w' }, { type: 'e' }])
|
|
7652
|
+
// .enter()
|
|
7653
|
+
// .append('path')
|
|
7654
|
+
// .attr('class', 'handle--custom')
|
|
7655
|
+
// .attr('stroke', 'transparent')
|
|
7656
|
+
// .attr('fill', 'transparent')
|
|
7657
|
+
// .attr('cursor', 'ew-resize')
|
|
7658
|
+
// .attr('d', brushResizePath)
|
|
7453
7659
|
// BRUSH END
|
|
7454
|
-
// this.
|
|
7660
|
+
// this.brushLayer.selectAll('.handle').remove()
|
|
7455
7661
|
if (this.brushNeeded) {
|
|
7456
7662
|
if (!this.brushInitialized) {
|
|
7457
7663
|
this.brushLayer.style('visibility', 'visible')
|
|
@@ -7461,11 +7667,14 @@ else {
|
|
|
7461
7667
|
.call(this.brush)
|
|
7462
7668
|
.call(this.brush.move, [0, brushEnd])
|
|
7463
7669
|
}
|
|
7670
|
+
else {
|
|
7671
|
+
this.brushLayer.style('visibility', 'visible')
|
|
7672
|
+
}
|
|
7464
7673
|
}
|
|
7465
7674
|
else {
|
|
7466
7675
|
this.brushLayer.style('visibility', 'hidden')
|
|
7467
7676
|
// this.brushLayer.selectAll().remove()
|
|
7468
|
-
this.brushArea.selectAll('*').remove()
|
|
7677
|
+
// this.brushArea.selectAll('*').remove()
|
|
7469
7678
|
}
|
|
7470
7679
|
if (this.options.margin.axisBottom > 0) {
|
|
7471
7680
|
let timeFormatPattern = ''
|
|
@@ -7551,10 +7760,10 @@ else {
|
|
|
7551
7760
|
let rightDomain = this.createDomain('right')
|
|
7552
7761
|
this.leftAxis = d3[`scale${this.options.data.left.scale || 'Linear'}`]()
|
|
7553
7762
|
.domain(leftDomain)
|
|
7554
|
-
.range(
|
|
7763
|
+
.range(leftRange)
|
|
7555
7764
|
this.leftBrushAxis = d3[`scale${this.options.data.left.scale || 'Linear'}`]()
|
|
7556
7765
|
.domain(leftBrushDomain)
|
|
7557
|
-
.range(
|
|
7766
|
+
.range(leftBrushRange)
|
|
7558
7767
|
if (this.leftAxis.padding && this.options.data.left.padding) {
|
|
7559
7768
|
this.leftAxis.padding(this.options.data.left.padding || 0)
|
|
7560
7769
|
}
|
|
@@ -7571,7 +7780,11 @@ else {
|
|
|
7571
7780
|
}
|
|
7572
7781
|
return d
|
|
7573
7782
|
})
|
|
7574
|
-
)
|
|
7783
|
+
)
|
|
7784
|
+
if (this.customLeftRange.length > 0) {
|
|
7785
|
+
this.leftAxisLayer.selectAll('g')
|
|
7786
|
+
.attr('transform', (d, i) => `translate(0, ${this.customLeftRange[i] + ((this.customLeftRange[i + 1] - this.customLeftRange[i]) / 2)})`)
|
|
7787
|
+
}
|
|
7575
7788
|
}
|
|
7576
7789
|
if (this.options.data.left && this.options.data.left.showTitle === true) {
|
|
7577
7790
|
this.leftAxisLabel.selectAll('.title').remove()
|
|
@@ -7667,7 +7880,11 @@ else {
|
|
|
7667
7880
|
for (const key in this.renderedKeys) {
|
|
7668
7881
|
if (newKeys.indexOf(key) === -1) {
|
|
7669
7882
|
// remove the components
|
|
7670
|
-
this[`remove${this.renderedKeys[key]}`](key)
|
|
7883
|
+
// this[`remove${this.renderedKeys[key]}`](key)
|
|
7884
|
+
this.removeline(key)
|
|
7885
|
+
this.removebar(key)
|
|
7886
|
+
this.removesymbol(key)
|
|
7887
|
+
this.removelabel(key)
|
|
7671
7888
|
}
|
|
7672
7889
|
}
|
|
7673
7890
|
this.renderComponents()
|
|
@@ -7702,7 +7919,13 @@ const drawArea = (xAxis, yAxis, curveStyle) => {
|
|
|
7702
7919
|
return d3
|
|
7703
7920
|
.area()
|
|
7704
7921
|
.x(d => {
|
|
7705
|
-
return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
7922
|
+
// return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
7923
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
7924
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
7925
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
7926
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
7927
|
+
}
|
|
7928
|
+
return xPos
|
|
7706
7929
|
})
|
|
7707
7930
|
.y0(d => {
|
|
7708
7931
|
return this[`${yAxis}Axis`](0)
|
|
@@ -7730,7 +7953,7 @@ areas
|
|
|
7730
7953
|
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
7731
7954
|
// .attr('id', `line_${series.key}`)
|
|
7732
7955
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
7733
|
-
|
|
7956
|
+
.attr('fill', d => d[0].y.color || series.color)
|
|
7734
7957
|
// .attr('stroke', 'transparent')
|
|
7735
7958
|
.transition(this.transition)
|
|
7736
7959
|
.attr('d', d => drawArea(xAxis, yAxis, series.curveStyle)(d))
|
|
@@ -7739,13 +7962,13 @@ areas.enter().append('path')
|
|
|
7739
7962
|
.attr('d', d => drawArea(xAxis, yAxis, series.curveStyle)(d))
|
|
7740
7963
|
.attr('class', `area_${series.key}`)
|
|
7741
7964
|
.attr('id', `area_${series.key}`)
|
|
7742
|
-
.attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis
|
|
7965
|
+
// .attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2) + ',0)')
|
|
7743
7966
|
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
7744
|
-
.attr('fill', series.color)
|
|
7967
|
+
.attr('fill', d => d[0].y.color || series.color)
|
|
7745
7968
|
// .style('fill-opacity', 0)
|
|
7746
7969
|
.attr('stroke', 'transparent')
|
|
7747
7970
|
// .transition(this.transition)
|
|
7748
|
-
.style('fill-opacity', series.opacity || 0.
|
|
7971
|
+
.style('fill-opacity', series.opacity || 0.3)
|
|
7749
7972
|
|
|
7750
7973
|
}
|
|
7751
7974
|
renderbar (series, index) {
|
|
@@ -7759,13 +7982,10 @@ if (this.options.orientation === 'horizontal') {
|
|
|
7759
7982
|
xAxis = 'left'
|
|
7760
7983
|
yAxis = 'bottom'
|
|
7761
7984
|
}
|
|
7762
|
-
|
|
7763
|
-
// barWidth = barWidth / this.options.data.series.length - 4
|
|
7764
|
-
// }
|
|
7765
|
-
function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
7985
|
+
function getBarHeight (d, i, yAxis, xAxis) {
|
|
7766
7986
|
let output
|
|
7767
7987
|
if (this.options.orientation === 'horizontal') {
|
|
7768
|
-
output = this.options.data[xAxis.
|
|
7988
|
+
output = Math.max(1, this.options.data[xAxis].bandWidth - (xAxis.indexOf('Brush') !== -1 ? 2 : this.options.groupPadding * 2))
|
|
7769
7989
|
}
|
|
7770
7990
|
else {
|
|
7771
7991
|
let x = getBarX.call(this, d, i, xAxis)
|
|
@@ -7782,37 +8002,33 @@ function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
|
7782
8002
|
function getBarWidth (d, i, xAxis) {
|
|
7783
8003
|
let output
|
|
7784
8004
|
if (this.options.orientation === 'horizontal') {
|
|
7785
|
-
|
|
7786
|
-
acummulativeY[d.y.index] += width
|
|
7787
|
-
output = width
|
|
8005
|
+
output = this[`${yAxis}Axis`](Math.abs(d.y.value))
|
|
7788
8006
|
}
|
|
7789
8007
|
else {
|
|
7790
8008
|
let x = getBarX.call(this, d, i, xAxis)
|
|
7791
8009
|
if (typeof x === 'undefined' || x === null) {
|
|
7792
8010
|
return null
|
|
7793
8011
|
}
|
|
7794
|
-
output = Math.max(1, this.options.data[xAxis.
|
|
8012
|
+
output = Math.max(1, this.options.data[xAxis].bandWidth - (xAxis.indexOf('Brush') !== -1 ? 2 : this.options.groupPadding * 2))
|
|
7795
8013
|
}
|
|
7796
8014
|
if (isNaN(output)) {
|
|
7797
8015
|
return 0
|
|
7798
8016
|
}
|
|
7799
8017
|
return output
|
|
7800
8018
|
}
|
|
7801
|
-
function getBarX (d, i, xAxis) {
|
|
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
|
|
8019
|
+
function getBarX (d, i, xAxis) {
|
|
7807
8020
|
let output
|
|
7808
8021
|
if (this.options.orientation === 'horizontal') {
|
|
7809
8022
|
if (this.options.grouping === 'stacked') {
|
|
7810
|
-
let h = getBarWidth.call(this, d, i, xAxis)
|
|
7811
|
-
let adjustment = 0
|
|
7812
|
-
if (d.y.accumulative && d.y.accumulative !== 0) {
|
|
7813
|
-
|
|
7814
|
-
}
|
|
7815
|
-
output = this[`${yAxis}Axis`](0) + (adjustment * (d.y.value < 0 ? 1 : 0)) + (h * (d.y.value < 0 ? 1 : 0))
|
|
8023
|
+
// let h = getBarWidth.call(this, d, i, xAxis)
|
|
8024
|
+
// let adjustment = 0
|
|
8025
|
+
// if (d.y.accumulative && d.y.accumulative !== 0) {
|
|
8026
|
+
// adjustment = this[`${yAxis}Axis`](d.y.accumulative || 0)
|
|
8027
|
+
// }
|
|
8028
|
+
// output = this[`${yAxis}Axis`](0) + (adjustment * (d.y.value < 0 ? 1 : 0)) + (h * (d.y.value < 0 ? 1 : 0))
|
|
8029
|
+
let accH = getBarWidth.call(this, {x: d.x, y: { value: d.y.accumulative }}, i, xAxis)
|
|
8030
|
+
// let h = getBarWidth.call(this, d, i, xAxis)
|
|
8031
|
+
output = (accH * (d.y.accumulative < 0 ? 0 : 1))
|
|
7816
8032
|
}
|
|
7817
8033
|
else {
|
|
7818
8034
|
let h = getBarWidth.call(this, d, i, xAxis)
|
|
@@ -7821,22 +8037,24 @@ function getBarX (d, i, xAxis) {
|
|
|
7821
8037
|
}
|
|
7822
8038
|
else {
|
|
7823
8039
|
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
|
|
7824
|
-
let adjustment = this.
|
|
8040
|
+
// let adjustment = this[`custom${xAxis.toInitialCaps()}Range`][i] + (i * this.options.data[xAxis].bandWidth)
|
|
7825
8041
|
if (this.options.grouping === 'grouped') {
|
|
7826
8042
|
let xIndex = 0
|
|
7827
8043
|
if (this.processedX[d.x.value]) {
|
|
7828
8044
|
xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel))
|
|
7829
8045
|
}
|
|
7830
|
-
let barAdjustment =
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
8046
|
+
// let barAdjustment =
|
|
8047
|
+
// (this.options.data[xAxis].bandWidth * xIndex) +
|
|
8048
|
+
// (xIndex * this.options.groupPadding * 2) + this.options.groupPadding +
|
|
8049
|
+
// (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
7834
8050
|
// let barAdjustment =
|
|
7835
8051
|
// (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
|
|
7836
8052
|
// this.options.groupPadding
|
|
7837
8053
|
// // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
7838
|
-
|
|
7839
|
-
|
|
8054
|
+
let barAdjustment = (this.options.data[xAxis].bandWidth * xIndex) + ((xAxis.indexOf('Brush') !== -1 ? this.brushBandPadding : this.bandPadding) / 2) + (xAxis.indexOf('Brush') !== -1 ? 1 : this.options.groupPadding)
|
|
8055
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`].length > 0) {
|
|
8056
|
+
output = this[`custom${xAxis.toInitialCaps()}Range`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
|
|
8057
|
+
// output = this[`custom${xAxis.toInitialCaps().replace('Brush', '')}DetailRange`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)]
|
|
7840
8058
|
}
|
|
7841
8059
|
else {
|
|
7842
8060
|
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + barAdjustment
|
|
@@ -7847,11 +8065,11 @@ function getBarX (d, i, xAxis) {
|
|
|
7847
8065
|
if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
|
|
7848
8066
|
this.processedX[d.x.value].push(d.y.tooltipLabel)
|
|
7849
8067
|
}
|
|
7850
|
-
console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
|
|
8068
|
+
// console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
|
|
7851
8069
|
}
|
|
7852
|
-
else {
|
|
7853
|
-
|
|
7854
|
-
output = this[
|
|
8070
|
+
else {
|
|
8071
|
+
let barAdjustment = ((xAxis.indexOf('Brush') !== -1 ? this.brushBandPadding : this.bandPadding) / 2) + (xAxis.indexOf('Brush') !== -1 ? 1 : this.options.groupPadding)
|
|
8072
|
+
output = this[`custom${xAxis.toInitialCaps()}Range`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
|
|
7855
8073
|
}
|
|
7856
8074
|
}
|
|
7857
8075
|
if (isNaN(output)) {
|
|
@@ -7859,13 +8077,12 @@ function getBarX (d, i, xAxis) {
|
|
|
7859
8077
|
}
|
|
7860
8078
|
return output
|
|
7861
8079
|
}
|
|
7862
|
-
function getBarY (d, i,
|
|
7863
|
-
// let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
7864
|
-
// let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
8080
|
+
function getBarY (d, i, yAxis, xAxis) {
|
|
7865
8081
|
let output
|
|
7866
8082
|
if (this.options.orientation === 'horizontal') {
|
|
7867
8083
|
if (this.options.grouping !== 'grouped') {
|
|
7868
|
-
|
|
8084
|
+
let barAdjustment = ((xAxis.indexOf('Brush') !== -1 ? this.brushBandPadding : this.bandPadding) / 2) + (xAxis.indexOf('Brush') !== -1 ? 1 : this.options.groupPadding)
|
|
8085
|
+
output = this[`custom${xAxis.toInitialCaps()}Range`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
|
|
7869
8086
|
}
|
|
7870
8087
|
else {
|
|
7871
8088
|
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + ((d.y.index || i) * this.options.data[xAxis.replace('Brush', '')].barWidth)
|
|
@@ -7873,10 +8090,12 @@ function getBarY (d, i, heightBounds, yAxis, xAxis) {
|
|
|
7873
8090
|
}
|
|
7874
8091
|
else {
|
|
7875
8092
|
if (this.options.grouping === 'stacked') {
|
|
7876
|
-
|
|
8093
|
+
let accH = getBarHeight.call(this, {x: d.x, y: { value: d.y.accumulative }}, i, yAxis, xAxis)
|
|
8094
|
+
let h = getBarHeight.call(this, d, i, yAxis, xAxis)
|
|
8095
|
+
output = (this[`${yAxis}Axis`](0)) - ((accH + h) * (d.y.accumulative < 0 ? 0 : 1))
|
|
7877
8096
|
}
|
|
7878
8097
|
else {
|
|
7879
|
-
let h = getBarHeight.call(this, d, i,
|
|
8098
|
+
let h = getBarHeight.call(this, d, i, yAxis, xAxis)
|
|
7880
8099
|
output = (this[`${yAxis}Axis`](0)) - (h * (d.y.value < 0 ? 0 : 1))
|
|
7881
8100
|
}
|
|
7882
8101
|
}
|
|
@@ -7893,9 +8112,9 @@ bars
|
|
|
7893
8112
|
|
|
7894
8113
|
bars
|
|
7895
8114
|
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
|
|
7896
|
-
.attr('height', (d, i) => getBarHeight.call(this, d, i,
|
|
8115
|
+
.attr('height', (d, i) => getBarHeight.call(this, d, i, yAxis, xAxis))
|
|
7897
8116
|
.attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
|
|
7898
|
-
.attr('y', (d, i) => getBarY.call(this, d, i,
|
|
8117
|
+
.attr('y', (d, i) => getBarY.call(this, d, i, yAxis, xAxis))
|
|
7899
8118
|
// .transition(this.transition)
|
|
7900
8119
|
.attr('fill', d => d.y.color || d.color || series.color)
|
|
7901
8120
|
|
|
@@ -7903,9 +8122,9 @@ bars
|
|
|
7903
8122
|
.enter()
|
|
7904
8123
|
.append('rect')
|
|
7905
8124
|
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
|
|
7906
|
-
.attr('height', (d, i) => getBarHeight.call(this, d, i,
|
|
8125
|
+
.attr('height', (d, i) => getBarHeight.call(this, d, i, yAxis, xAxis))
|
|
7907
8126
|
.attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
|
|
7908
|
-
.attr('y', (d, i) => getBarY.call(this, d, i,
|
|
8127
|
+
.attr('y', (d, i) => getBarY.call(this, d, i, yAxis, xAxis))
|
|
7909
8128
|
// .transition(this.transition)
|
|
7910
8129
|
.attr('fill', d => d.y.color || d.color || series.color)
|
|
7911
8130
|
.attr('class', d => {
|
|
@@ -7922,9 +8141,9 @@ if (!this.brushBarsInitialized[series.key]) {
|
|
|
7922
8141
|
|
|
7923
8142
|
brushBars
|
|
7924
8143
|
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
|
|
7925
|
-
.attr('height', (d, i) => getBarHeight.call(this, d, i,
|
|
8144
|
+
.attr('height', (d, i) => getBarHeight.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
7926
8145
|
.attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
|
|
7927
|
-
.attr('y', (d, i) => getBarY.call(this, d, i,
|
|
8146
|
+
.attr('y', (d, i) => getBarY.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
7928
8147
|
// .transition(this.transition)
|
|
7929
8148
|
.attr('fill', d => d.y.color || d.color || series.color)
|
|
7930
8149
|
|
|
@@ -7932,9 +8151,9 @@ if (!this.brushBarsInitialized[series.key]) {
|
|
|
7932
8151
|
.enter()
|
|
7933
8152
|
.append('rect')
|
|
7934
8153
|
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
|
|
7935
|
-
.attr('height', (d, i) => getBarHeight.call(this, d, i,
|
|
8154
|
+
.attr('height', (d, i) => getBarHeight.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
7936
8155
|
.attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
|
|
7937
|
-
.attr('y', (d, i) => getBarY.call(this, d, i,
|
|
8156
|
+
.attr('y', (d, i) => getBarY.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
7938
8157
|
// .transition(this.transition)
|
|
7939
8158
|
.attr('fill', d => d.y.color || d.color || series.color)
|
|
7940
8159
|
.attr('class', d => {
|
|
@@ -7953,12 +8172,12 @@ let bars = this.barLayer.selectAll(`.bar_${key}`)
|
|
|
7953
8172
|
}
|
|
7954
8173
|
renderLabels (series, index) {
|
|
7955
8174
|
/* global series index d3 WebsyDesigns */
|
|
7956
|
-
let xAxis = '
|
|
7957
|
-
let yAxis = '
|
|
8175
|
+
let xAxis = 'bottom'
|
|
8176
|
+
let yAxis = 'left'
|
|
7958
8177
|
let that = this
|
|
7959
8178
|
if (this.options.orientation === 'horizontal') {
|
|
7960
|
-
xAxis = '
|
|
7961
|
-
yAxis = '
|
|
8179
|
+
xAxis = 'left'
|
|
8180
|
+
yAxis = 'bottom'
|
|
7962
8181
|
}
|
|
7963
8182
|
if (this.options.showLabels === true || series.showLabels === true) {
|
|
7964
8183
|
// need to add logic to handle positioning options
|
|
@@ -8048,6 +8267,9 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
8048
8267
|
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
8049
8268
|
this.setAttribute('y', +(this.getAttribute('y')) + 8)
|
|
8050
8269
|
}
|
|
8270
|
+
if (series.labelPosition !== 'outside') {
|
|
8271
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
8272
|
+
}
|
|
8051
8273
|
}
|
|
8052
8274
|
})
|
|
8053
8275
|
}
|
|
@@ -8055,26 +8277,40 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
8055
8277
|
function getLabelX (d, labelPosition = 'inside') {
|
|
8056
8278
|
if (this.options.orientation === 'horizontal') {
|
|
8057
8279
|
if (this.options.grouping === 'stacked') {
|
|
8058
|
-
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
8280
|
+
return this[yAxis + 'Axis'](d.y.accumulative) + (this[yAxis + 'Axis'](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
8059
8281
|
}
|
|
8060
8282
|
else {
|
|
8061
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4
|
|
8283
|
+
return this[yAxis + 'Axis'](isNaN(d.y.value) ? 0 : d.y.value) + 4
|
|
8062
8284
|
}
|
|
8063
8285
|
}
|
|
8064
8286
|
else {
|
|
8065
|
-
return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
8287
|
+
// return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
8288
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8289
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8290
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8291
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8292
|
+
}
|
|
8293
|
+
return xPos
|
|
8066
8294
|
}
|
|
8067
8295
|
}
|
|
8068
8296
|
function getLabelY (d, labelPosition = 'inside') {
|
|
8069
8297
|
if (this.options.orientation === 'horizontal') {
|
|
8070
|
-
|
|
8298
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8299
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8300
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8301
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8302
|
+
}
|
|
8303
|
+
return xPos
|
|
8071
8304
|
}
|
|
8072
8305
|
else {
|
|
8073
8306
|
if (this.options.grouping === 'stacked') {
|
|
8074
|
-
|
|
8307
|
+
let accH = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.accumulative))
|
|
8308
|
+
let h = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
|
|
8309
|
+
return (this[`${yAxis}Axis`](0)) - ((accH + h - (labelPosition === 'inside' ? h / 2 : 0)) * (d.y.accumulative < 0 ? 0 : 1))
|
|
8310
|
+
// return (this[`${yAxis}Axis`](0)) - (this[yAxis + 'Axis'](d.y.accumulative) - (this[yAxis + 'Axis'](d.y.value))) // / (labelPosition === 'inside' ? 2 : 1)))
|
|
8075
8311
|
}
|
|
8076
8312
|
else {
|
|
8077
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize)
|
|
8313
|
+
return this[yAxis + 'Axis'](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize)
|
|
8078
8314
|
}
|
|
8079
8315
|
}
|
|
8080
8316
|
}
|
|
@@ -8090,13 +8326,19 @@ const drawLine = (xAxis, yAxis, curveStyle) => {
|
|
|
8090
8326
|
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
8091
8327
|
}
|
|
8092
8328
|
else {
|
|
8093
|
-
let
|
|
8094
|
-
|
|
8329
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8330
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8331
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8332
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8333
|
+
}
|
|
8334
|
+
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8335
|
+
// return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8336
|
+
return xPos
|
|
8095
8337
|
}
|
|
8096
8338
|
})
|
|
8097
8339
|
.y(d => {
|
|
8098
8340
|
if (this.options.orientation === 'horizontal') {
|
|
8099
|
-
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[
|
|
8341
|
+
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8100
8342
|
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8101
8343
|
}
|
|
8102
8344
|
else {
|
|
@@ -8131,7 +8373,7 @@ lines
|
|
|
8131
8373
|
.style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8132
8374
|
// .attr('id', `line_${series.key}`)
|
|
8133
8375
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8134
|
-
.attr('stroke', series.color)
|
|
8376
|
+
.attr('stroke', d => d[0].y.color || series.color)
|
|
8135
8377
|
.attr('fill', 'transparent')
|
|
8136
8378
|
.transition(this.transition)
|
|
8137
8379
|
.attr('d', d => drawLine(xAxis, yAxis, series.curveStyle)(d))
|
|
@@ -8142,7 +8384,7 @@ lines.enter().append('path')
|
|
|
8142
8384
|
.attr('id', `line_${series.key}`)
|
|
8143
8385
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8144
8386
|
.style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8145
|
-
.attr('stroke', series.color)
|
|
8387
|
+
.attr('stroke', d => d[0].y.color || series.color)
|
|
8146
8388
|
.attr('fill', 'transparent')
|
|
8147
8389
|
// .transition(this.transition)
|
|
8148
8390
|
.style('stroke-opacity', 1)
|
|
@@ -8233,6 +8475,26 @@ let lines = this.lineLayer.selectAll(`.line_${key}`)
|
|
|
8233
8475
|
.transition(this.transition)
|
|
8234
8476
|
.style('stroke-opacity', 1e-6)
|
|
8235
8477
|
.remove()
|
|
8478
|
+
let areas = this.areaLayer.selectAll(`.area_${key}`)
|
|
8479
|
+
.transition(this.transition)
|
|
8480
|
+
.style('stroke-opacity', 1e-6)
|
|
8481
|
+
.remove()
|
|
8482
|
+
|
|
8483
|
+
}
|
|
8484
|
+
removelabel (key) {
|
|
8485
|
+
/* global key d3 */
|
|
8486
|
+
let labels = this.labelLayer.selectAll(`.label_${key}`)
|
|
8487
|
+
.transition(this.transition)
|
|
8488
|
+
.style('stroke-opacity', 1e-6)
|
|
8489
|
+
.remove()
|
|
8490
|
+
|
|
8491
|
+
}
|
|
8492
|
+
removesymbol (key) {
|
|
8493
|
+
/* global key d3 */
|
|
8494
|
+
let symbols = this.symbolLayer.selectAll(`.symbol_${key}`)
|
|
8495
|
+
.transition(this.transition)
|
|
8496
|
+
.style('stroke-opacity', 1e-6)
|
|
8497
|
+
.remove()
|
|
8236
8498
|
|
|
8237
8499
|
}
|
|
8238
8500
|
rendersymbol (series, index) {
|
|
@@ -8265,12 +8527,25 @@ symbols
|
|
|
8265
8527
|
.attr('fill', series.fillSymbols ? series.color : 'white')
|
|
8266
8528
|
.attr('stroke', series.color)
|
|
8267
8529
|
.attr('transform', d => {
|
|
8268
|
-
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this[
|
|
8530
|
+
// let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8531
|
+
// if (this.options.orientation === 'horizontal') {
|
|
8532
|
+
// return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
|
|
8533
|
+
// }
|
|
8534
|
+
// else {
|
|
8535
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8536
|
+
// }
|
|
8537
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8538
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8539
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8540
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8541
|
+
}
|
|
8542
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8269
8543
|
if (this.options.orientation === 'horizontal') {
|
|
8270
|
-
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${
|
|
8544
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${xPos})`
|
|
8271
8545
|
}
|
|
8272
8546
|
else {
|
|
8273
|
-
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8547
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8548
|
+
return `translate(${xPos}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8274
8549
|
}
|
|
8275
8550
|
})
|
|
8276
8551
|
// Enter
|
|
@@ -8282,12 +8557,18 @@ symbols.enter()
|
|
|
8282
8557
|
.attr('stroke', series.color)
|
|
8283
8558
|
.attr('class', d => { return `symbol symbol_${series.key}` })
|
|
8284
8559
|
.attr('transform', d => {
|
|
8285
|
-
let
|
|
8560
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8561
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8562
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8563
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8564
|
+
}
|
|
8565
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8286
8566
|
if (this.options.orientation === 'horizontal') {
|
|
8287
|
-
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${
|
|
8567
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${xPos})`
|
|
8288
8568
|
}
|
|
8289
8569
|
else {
|
|
8290
|
-
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8570
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8571
|
+
return `translate(${xPos}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8291
8572
|
}
|
|
8292
8573
|
})
|
|
8293
8574
|
|