@websy/websy-designs 1.5.1 → 1.6.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/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 +497 -254
- package/dist/websy-designs-es6.js +767 -443
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +526 -274
- package/dist/websy-designs.js +801 -466
- 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')
|
|
@@ -6570,6 +6618,7 @@ class WebsyChart {
|
|
|
6570
6618
|
tooltipWidth: 200,
|
|
6571
6619
|
brushHeight: 50,
|
|
6572
6620
|
minBandWidth: 30,
|
|
6621
|
+
maxBandWidth: 100,
|
|
6573
6622
|
allowUnevenBands: true
|
|
6574
6623
|
}
|
|
6575
6624
|
this.elementId = elementId
|
|
@@ -6597,99 +6646,124 @@ class WebsyChart {
|
|
|
6597
6646
|
xAxis += 'Axis'
|
|
6598
6647
|
let output
|
|
6599
6648
|
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 {
|
|
6649
|
+
// if (this.customBottomRange) {
|
|
6650
|
+
for (let index = 0; index < this.customBottomRange.length; index++) {
|
|
6651
|
+
if (input > this.customBottomRange[index]) {
|
|
6652
|
+
if (this.customBottomRange[index + 1]) {
|
|
6653
|
+
if (input < this.customBottomRange[index + 1]) {
|
|
6610
6654
|
output = index
|
|
6611
6655
|
break
|
|
6612
6656
|
}
|
|
6613
6657
|
}
|
|
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
|
|
6658
|
+
else {
|
|
6659
|
+
output = index
|
|
6626
6660
|
break
|
|
6627
6661
|
}
|
|
6628
|
-
}
|
|
6662
|
+
}
|
|
6629
6663
|
}
|
|
6664
|
+
// }
|
|
6665
|
+
// else {
|
|
6666
|
+
// let domain = [...this[xAxis].domain()]
|
|
6667
|
+
// if (this.options.orientation === 'horizontal') {
|
|
6668
|
+
// domain = domain.reverse()
|
|
6669
|
+
// }
|
|
6670
|
+
// for (let j = 0; j < domain.length; j++) {
|
|
6671
|
+
// let breakA = this[xAxis](domain[j]) - (width / 2)
|
|
6672
|
+
// let breakB = breakA + width
|
|
6673
|
+
// if (input > breakA && input <= breakB) {
|
|
6674
|
+
// output = j
|
|
6675
|
+
// break
|
|
6676
|
+
// }
|
|
6677
|
+
// }
|
|
6678
|
+
// }
|
|
6630
6679
|
return output
|
|
6631
6680
|
}
|
|
6632
6681
|
let that = this
|
|
6633
6682
|
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
|
|
6683
|
+
console.log('brushing', event)
|
|
6684
|
+
let newX = (that.options.margin.left + that.options.margin.axisLeft) + (1 - (event.selection[0] / ((that.plotWidth) / (that.widthForCalc + that.totalBandPadding))))
|
|
6685
|
+
if (that.plotArea) {
|
|
6686
|
+
that.plotArea.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6644
6687
|
}
|
|
6645
|
-
if (
|
|
6646
|
-
that
|
|
6688
|
+
if (that.areaLayer) {
|
|
6689
|
+
that.areaLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6647
6690
|
}
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
that.brushLayer
|
|
6651
|
-
.select('.brush')
|
|
6652
|
-
.call(that.brush)
|
|
6653
|
-
.call(that.brush.move, s)
|
|
6654
|
-
return
|
|
6691
|
+
if (that.lineLayer) {
|
|
6692
|
+
that.lineLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6655
6693
|
}
|
|
6656
|
-
if (that.
|
|
6657
|
-
that.
|
|
6694
|
+
if (that.barLayer) {
|
|
6695
|
+
that.barLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6658
6696
|
}
|
|
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
|
-
}
|
|
6697
|
+
if (that.labelLayer) {
|
|
6698
|
+
that.labelLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6674
6699
|
}
|
|
6675
|
-
if (that.
|
|
6676
|
-
that
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
)
|
|
6680
|
-
}
|
|
6681
|
-
if (that.
|
|
6682
|
-
that.
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6700
|
+
if (that.symbolLayer) {
|
|
6701
|
+
that.symbolLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6702
|
+
}
|
|
6703
|
+
if (that.refLineLayer) {
|
|
6704
|
+
that.refLineLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
6705
|
+
}
|
|
6706
|
+
if (that.bottomAxisLayer) {
|
|
6707
|
+
that.bottomAxisLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop + that.plotHeight})`)
|
|
6708
|
+
}
|
|
6709
|
+
// that.brushedDomain = []
|
|
6710
|
+
// let xAxis = 'bottom'
|
|
6711
|
+
// let xAxisCaps = 'Bottom'
|
|
6712
|
+
// if (that.options.orientation === 'horizontal') {
|
|
6713
|
+
// xAxis = 'left'
|
|
6714
|
+
// xAxisCaps = 'Left'
|
|
6715
|
+
// }
|
|
6716
|
+
// if (!that[`${xAxis}Axis`]) {
|
|
6717
|
+
// return
|
|
6718
|
+
// }
|
|
6719
|
+
// if (!that[`${xAxis}Axis`].invert) {
|
|
6720
|
+
// that[`${xAxis}Axis`].invert = that.invertOverride
|
|
6721
|
+
// }
|
|
6722
|
+
// let s = event.selection || that[`${xAxis}Axis`].range()
|
|
6723
|
+
// if (!event.selection || event.selection.length === 0) {
|
|
6724
|
+
// that.brushLayer
|
|
6725
|
+
// .select('.brush')
|
|
6726
|
+
// .call(that.brush)
|
|
6727
|
+
// .call(that.brush.move, s)
|
|
6728
|
+
// return
|
|
6729
|
+
// }
|
|
6730
|
+
// if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
|
|
6731
|
+
// that.brushedDomain = s.map(that[`${xAxis}BrushAxis`].invert, that[[`${xAxis}Axis`]])
|
|
6732
|
+
// }
|
|
6733
|
+
// else {
|
|
6734
|
+
// let startEndOrdinal = s.map((a, b) => that.bottomAxis.invert(a, b, true), that.bottomBrushAxis)
|
|
6735
|
+
// if (
|
|
6736
|
+
// startEndOrdinal &&
|
|
6737
|
+
// startEndOrdinal.length === 2 &&
|
|
6738
|
+
// typeof startEndOrdinal[0] !== 'undefined' &&
|
|
6739
|
+
// typeof startEndOrdinal[1] !== 'undefined'
|
|
6740
|
+
// ) {
|
|
6741
|
+
// let domain = []
|
|
6742
|
+
// let domainValues = [...that[`${xAxis}BrushAxis`].domain()]
|
|
6743
|
+
// for (let i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
|
|
6744
|
+
// // domain.push(that.xRange[i])
|
|
6745
|
+
// that.brushedDomain.push(domainValues[i])
|
|
6746
|
+
// }
|
|
6747
|
+
// }
|
|
6748
|
+
// }
|
|
6749
|
+
// if (that.brushedDomain.length > 0) {
|
|
6750
|
+
// that[`${xAxis}Axis`].domain(that.brushedDomain)
|
|
6751
|
+
// that[`${xAxis}AxisLayer`].call(
|
|
6752
|
+
// d3[`axis${xAxisCaps}`](that[`${xAxis}Axis`])
|
|
6753
|
+
// )
|
|
6754
|
+
// }
|
|
6755
|
+
// if (that.leftAxis && that.bottomAxis) {
|
|
6756
|
+
// that.renderComponents()
|
|
6757
|
+
// if (that.options.orientation === 'vertical') {
|
|
6758
|
+
// // that.bottomAxisLayer.call(that.bAxisFunc)
|
|
6759
|
+
// if (that.options.data.bottom.rotate) {
|
|
6760
|
+
// that.bottomAxisLayer.selectAll('text')
|
|
6761
|
+
// .attr('transform', `rotate(${((that.options.data.bottom && that.options.data.bottom.rotate) || 0)})`)
|
|
6762
|
+
// .style('text-anchor', `${((that.options.data.bottom && that.options.data.bottom.rotate) || 0) === 0 ? 'middle' : 'end'}`)
|
|
6763
|
+
// .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`)
|
|
6764
|
+
// }
|
|
6765
|
+
// }
|
|
6766
|
+
// }
|
|
6693
6767
|
}
|
|
6694
6768
|
const el = document.getElementById(this.elementId)
|
|
6695
6769
|
if (el) {
|
|
@@ -6831,12 +6905,12 @@ else {
|
|
|
6831
6905
|
}
|
|
6832
6906
|
this.options.data.series.forEach(s => {
|
|
6833
6907
|
if (this.options.data[xData].scale !== 'Time') {
|
|
6834
|
-
if (this.customBottomRange && this.customBottomRange.length > 0) {
|
|
6835
|
-
|
|
6836
|
-
}
|
|
6837
|
-
else {
|
|
6838
|
-
|
|
6839
|
-
}
|
|
6908
|
+
// if (this.customBottomRange && this.customBottomRange.length > 0) {
|
|
6909
|
+
xPoint = this.customBottomRange[x0] + ((this.customBottomRange[x0 + 1] - this.customBottomRange[x0]) / 2)
|
|
6910
|
+
// }
|
|
6911
|
+
// else {
|
|
6912
|
+
// xPoint = this[xAxis](this.parseX(xLabel))
|
|
6913
|
+
// }
|
|
6840
6914
|
s.data.forEach(d => {
|
|
6841
6915
|
if (d.x.value === xLabel) {
|
|
6842
6916
|
if (!tooltipTitle) {
|
|
@@ -6958,6 +7032,10 @@ else {
|
|
|
6958
7032
|
}
|
|
6959
7033
|
}
|
|
6960
7034
|
this.tooltip.setHeight(this.plotHeight)
|
|
7035
|
+
if (isNaN(posOptions.left)) {
|
|
7036
|
+
this.tooltip.hide()
|
|
7037
|
+
return
|
|
7038
|
+
}
|
|
6961
7039
|
this.options.showTooltip && this.tooltip.show(tooltipTitle, tooltipHTML, posOptions)
|
|
6962
7040
|
// }
|
|
6963
7041
|
// else {
|
|
@@ -6992,20 +7070,22 @@ else {
|
|
|
6992
7070
|
/* global d3 WebsyDesigns */
|
|
6993
7071
|
this.defs = this.svg.append('defs')
|
|
6994
7072
|
this.clip = this.defs.append('clipPath').attr('id', `${this.elementId}_clip`).append('rect')
|
|
7073
|
+
this.xAxisClip = this.defs.append('clipPath').attr('id', `${this.elementId}_xAxisClip`).append('rect')
|
|
6995
7074
|
this.brushClip = this.defs.append('clipPath').attr('id', `${this.elementId}_brushclip`).append('rect')
|
|
6996
7075
|
this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer')
|
|
6997
7076
|
this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer')
|
|
6998
|
-
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer')
|
|
7077
|
+
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer').attr('clip-path', `url(#${this.elementId}_xAxisClip)`).append('g')
|
|
6999
7078
|
this.leftAxisLabel = this.svg.append('g').attr('class', 'left-axis-label-layer')
|
|
7000
7079
|
this.rightAxisLabel = this.svg.append('g').attr('class', 'right-axis-label-layer')
|
|
7001
7080
|
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.
|
|
7081
|
+
this.plotArea = this.svg.append('g').attr('class', 'plot-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7082
|
+
this.areaLayer = this.svg.append('g').attr('class', 'area-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7083
|
+
this.lineLayer = this.svg.append('g').attr('class', 'line-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7084
|
+
this.barLayer = this.svg.append('g').attr('class', 'bar-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7085
|
+
// this.barLayer.attr('clip-path', `url(#${this.elementId}_clip)`)
|
|
7086
|
+
this.labelLayer = this.svg.append('g').attr('class', 'label-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7087
|
+
this.symbolLayer = this.svg.append('g').attr('class', 'symbol-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7088
|
+
this.refLineLayer = this.svg.append('g').attr('class', 'refline-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7009
7089
|
this.trackingLineLayer = this.svg.append('g').attr('class', 'tracking-line-layer')
|
|
7010
7090
|
this.trackingLineLayer.append('line').attr('class', 'tracking-line')
|
|
7011
7091
|
this.tooltip = new WebsyDesigns.WebsyChartTooltip(this.svg)
|
|
@@ -7253,39 +7333,113 @@ else {
|
|
|
7253
7333
|
this.options.margin.axisBottom = 0
|
|
7254
7334
|
}
|
|
7255
7335
|
}
|
|
7336
|
+
// At some point before this we need to add in logic to make space for any data point labels
|
|
7256
7337
|
// Define the plot size
|
|
7257
7338
|
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
7339
|
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
7340
|
this.brushNeeded = false
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
if (this.
|
|
7272
|
-
this.
|
|
7273
|
-
|
|
7341
|
+
let proposedBandWidth // distance between x axis data points.
|
|
7342
|
+
let maxBandWidthFits = false
|
|
7343
|
+
// Check to see if all bars at the max allowed width will fit
|
|
7344
|
+
this.bandPadding = 0
|
|
7345
|
+
this.totalBandPadding = 0
|
|
7346
|
+
this.brushBandPadding = 0
|
|
7347
|
+
this.totalBrushBandPadding = 0
|
|
7348
|
+
let noOfPoints = 0
|
|
7349
|
+
let noOfGroups = 0
|
|
7350
|
+
let plotable = 0
|
|
7351
|
+
if (this.options.maxBandWidth) {
|
|
7352
|
+
if (this.options.orientation === 'horizontal') {
|
|
7353
|
+
this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
|
|
7354
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7355
|
+
return a + 1
|
|
7356
|
+
}
|
|
7357
|
+
return a + b.valueCount
|
|
7358
|
+
}, 0)
|
|
7359
|
+
if (this.options.data.left.padding) {
|
|
7360
|
+
this.totalBandPadding = (this.plotHeight * this.options.data.left.padding)
|
|
7361
|
+
this.bandPadding = this.totalBandPadding / this.options.data.left.data.length
|
|
7362
|
+
this.totalBrushBandPadding = (this.plotHeight * this.options.data.left.padding)
|
|
7363
|
+
this.brushBandPadding = this.totalBandPadding / this.options.data.left.data.length
|
|
7364
|
+
}
|
|
7365
|
+
plotable = this.plotHeight - this.totalBandPadding
|
|
7366
|
+
noOfPoints = this.options.grouping === 'grouped' ? this.options.data.left.totalValueCount : this.options.data.left.data.length
|
|
7367
|
+
noOfGroups = this.options.data.left.data.length
|
|
7274
7368
|
}
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
return a +
|
|
7369
|
+
else {
|
|
7370
|
+
this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
|
|
7371
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7372
|
+
return a + 1
|
|
7373
|
+
}
|
|
7374
|
+
return a + b.valueCount
|
|
7375
|
+
}, 0)
|
|
7376
|
+
if (this.options.data.bottom.padding) {
|
|
7377
|
+
this.totalBandPadding = (this.plotWidth * this.options.data.bottom.padding)
|
|
7378
|
+
this.bandPadding = this.totalBandPadding / this.options.data.bottom.data.length
|
|
7379
|
+
this.totalBrushBandPadding = (this.plotWidth * this.options.data.bottom.padding)
|
|
7380
|
+
this.brushBandPadding = this.totalBandPadding / this.options.data.bottom.data.length
|
|
7381
|
+
}
|
|
7382
|
+
plotable = this.plotWidth - this.totalBandPadding
|
|
7383
|
+
noOfPoints = this.options.grouping === 'grouped' ? this.options.data.bottom.totalValueCount : this.options.data.bottom.data.length
|
|
7384
|
+
noOfGroups = this.options.data.bottom.data.length
|
|
7385
|
+
}
|
|
7386
|
+
if (plotable / noOfPoints > this.options.maxBandWidth) {
|
|
7387
|
+
maxBandWidthFits = true
|
|
7388
|
+
proposedBandWidth = this.options.maxBandWidth
|
|
7389
|
+
}
|
|
7390
|
+
if (!maxBandWidthFits) {
|
|
7391
|
+
// Check to see if all bars at the min allowed width will fit
|
|
7392
|
+
if (plotable / noOfPoints < this.options.minBandWidth) {
|
|
7393
|
+
this.brushNeeded = true
|
|
7394
|
+
proposedBandWidth = this.options.minBandWidth
|
|
7395
|
+
if (this.options.orientation === 'horizontal') {
|
|
7396
|
+
this.plotWidth -= this.options.brushHeight
|
|
7397
|
+
}
|
|
7398
|
+
else {
|
|
7399
|
+
this.plotHeight -= this.options.brushHeight
|
|
7400
|
+
}
|
|
7281
7401
|
}
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7402
|
+
else {
|
|
7403
|
+
proposedBandWidth = plotable / noOfPoints
|
|
7404
|
+
}
|
|
7405
|
+
}
|
|
7406
|
+
}
|
|
7407
|
+
// if (this.options.minBandWidth) {
|
|
7408
|
+
// this.widthForCalc = this.options.data.bottom.totalValueCount * this.options.minBandWidth
|
|
7409
|
+
// if (this.options.data.bottom.padding) {
|
|
7410
|
+
// this.widthForCalc += (this.options.minBandWidth * this.options.data.bottom.padding) * this.options.data.bottom.totalValueCount
|
|
7411
|
+
// this.widthForCalc += (this.options.data.bottom.data.length * this.options.groupPadding * 2)
|
|
7412
|
+
// }
|
|
7413
|
+
// }
|
|
7414
|
+
// if (this.options.orientation === 'vertical') {
|
|
7415
|
+
// this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
|
|
7416
|
+
// if (typeof b.valueCount === 'undefined') {
|
|
7417
|
+
// return a + 1
|
|
7418
|
+
// }
|
|
7419
|
+
// return a + b.valueCount
|
|
7420
|
+
// }, 0)
|
|
7421
|
+
// if (this.options.maxBandWidth) {
|
|
7422
|
+
// this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.totalValueCount) * this.options.maxBandWidth)
|
|
7423
|
+
// }
|
|
7424
|
+
// // some if to check if brushing is needed
|
|
7425
|
+
// if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
|
|
7426
|
+
// this.brushNeeded = true
|
|
7427
|
+
// this.plotHeight -= this.options.brushHeight
|
|
7428
|
+
// }
|
|
7429
|
+
// }
|
|
7430
|
+
// else {
|
|
7431
|
+
// // some if to check if brushing is needed
|
|
7432
|
+
// this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
|
|
7433
|
+
// if (typeof b.valueCount === 'undefined') {
|
|
7434
|
+
// return a + 1
|
|
7435
|
+
// }
|
|
7436
|
+
// return a + b.valueCount
|
|
7437
|
+
// }, 0)
|
|
7438
|
+
// if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
|
|
7439
|
+
// this.brushNeeded = true
|
|
7440
|
+
// this.plotWidth -= this.options.brushHeight
|
|
7441
|
+
// }
|
|
7442
|
+
// }
|
|
7289
7443
|
// Translate the layers
|
|
7290
7444
|
this.leftAxisLayer
|
|
7291
7445
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
|
|
@@ -7320,6 +7474,14 @@ else {
|
|
|
7320
7474
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
|
|
7321
7475
|
this.brushLayer
|
|
7322
7476
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height})`)
|
|
7477
|
+
this.clip
|
|
7478
|
+
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
|
|
7479
|
+
.attr('width', this.plotWidth)
|
|
7480
|
+
.attr('height', this.plotHeight)
|
|
7481
|
+
this.xAxisClip
|
|
7482
|
+
.attr('transform', `translate(${this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
|
|
7483
|
+
.attr('width', this.plotWidth + this.options.margin.axisLeft)
|
|
7484
|
+
.attr('height', longestBottomBounds.height + 10)
|
|
7323
7485
|
this.brushClip
|
|
7324
7486
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height})`)
|
|
7325
7487
|
.attr('width', this.plotWidth)
|
|
@@ -7336,39 +7498,80 @@ else {
|
|
|
7336
7498
|
// this.tooltip.transform(this.options.margin.left + this.options.margin.axisLeft, this.options.margin.top + this.options.margin.axisTop)
|
|
7337
7499
|
// Configure the bottom axis
|
|
7338
7500
|
let bottomDomain = this.createDomain('bottom')
|
|
7339
|
-
let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7501
|
+
// let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7502
|
+
let bottomBrushDomain = this.createDomain('bottom')
|
|
7340
7503
|
let bottomRange = [0, this.plotWidth]
|
|
7504
|
+
let bottomBrushRange = [0, this.plotWidth]
|
|
7505
|
+
let leftRange = [this.plotHeight, 0]
|
|
7506
|
+
let leftBrushRange = [this.options.brushHeight, 0]
|
|
7507
|
+
if (this.options.orientation === 'horizontal') {
|
|
7508
|
+
leftBrushRange = [this.plotHeight, 0]
|
|
7509
|
+
}
|
|
7510
|
+
this.widthForCalc = (proposedBandWidth * noOfPoints) // + totalPadding
|
|
7341
7511
|
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
|
-
|
|
7512
|
+
this.customBottomDetailRange = []
|
|
7513
|
+
this.customBottomBrushRange = []
|
|
7514
|
+
this.customLeftRange = []
|
|
7515
|
+
this.customLeftDetailRange = []
|
|
7516
|
+
this.customLeftBrushRange = []
|
|
7517
|
+
// if (this.options.allowUnevenBands === true) {
|
|
7518
|
+
// always allow uneven bands
|
|
7519
|
+
let customRangeSide = 'Bottom'
|
|
7520
|
+
let customRangeSideLC = 'bottom'
|
|
7521
|
+
if (this.options.orientation === 'horizontal') {
|
|
7522
|
+
customRangeSide = 'Left'
|
|
7523
|
+
customRangeSideLC = 'left'
|
|
7524
|
+
}
|
|
7525
|
+
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') {
|
|
7526
|
+
let acc = 0
|
|
7527
|
+
this[`custom${customRangeSide}Range`] = [0, ...this.options.data[customRangeSideLC].data.map((d, index, arr) => {
|
|
7528
|
+
let adjustment = (this.bandPadding * index) + this.bandPadding
|
|
7529
|
+
// if (this.options.data.bottom.padding) {
|
|
7530
|
+
// adjustment = (this.widthForCalc * this.options.data.bottom.padding) / (arr.length * 2)
|
|
7531
|
+
// }
|
|
7532
|
+
let start = (this.widthForCalc / noOfPoints) * acc
|
|
7533
|
+
for (let i = 0; i < (d.valueCount || 1); i++) {
|
|
7534
|
+
let pos = i * proposedBandWidth
|
|
7535
|
+
this[`custom${customRangeSide}DetailRange`].push(start + adjustment + pos)
|
|
7536
|
+
}
|
|
7537
|
+
acc += (this.options.grouping !== 'stacked' ? (d.valueCount || 1) : 1)
|
|
7538
|
+
let end = (this.widthForCalc / noOfPoints) * acc
|
|
7539
|
+
// this.customBottomBrushRange.push((end + adjustment) * (this.plotWidth / this.widthForCalc))
|
|
7540
|
+
return end + adjustment
|
|
7541
|
+
})]
|
|
7542
|
+
acc = 0
|
|
7543
|
+
this[`custom${customRangeSide}BrushRange`] = [0, ...this.options.data[customRangeSideLC].data.map((d, index, arr) => {
|
|
7544
|
+
let adjustment = (this.brushBandPadding * index) + this.brushBandPadding
|
|
7545
|
+
acc += (this.options.grouping !== 'stacked' ? (d.valueCount || 1) : 1)
|
|
7546
|
+
return ((this.options.orientation === 'vertical' ? this.plotWidth : this.plotHeight) / noOfPoints) * acc
|
|
7547
|
+
})]
|
|
7548
|
+
}
|
|
7549
|
+
// }
|
|
7550
|
+
let rangeLength = bottomDomain.length
|
|
7551
|
+
this.options.data.bottomBrush = {}
|
|
7552
|
+
this.options.data.leftBrush = {}
|
|
7553
|
+
if (this.options.orientation === 'vertical') {
|
|
7554
|
+
this.options.data.bottom.bandWidth = proposedBandWidth
|
|
7555
|
+
this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints
|
|
7556
|
+
}
|
|
7557
|
+
else {
|
|
7558
|
+
this.options.data.left.bandWidth = proposedBandWidth
|
|
7559
|
+
this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints
|
|
7560
|
+
}
|
|
7561
|
+
this.brushBandPadding = this.totalBandPadding / noOfGroups
|
|
7562
|
+
if (this.options.orientation === 'vertical') {
|
|
7563
|
+
bottomRange = [0, (this.widthForCalc + this.totalBandPadding)]
|
|
7564
|
+
}
|
|
7565
|
+
else {
|
|
7566
|
+
leftRange = [(this.widthForCalc + this.totalBandPadding), 0]
|
|
7364
7567
|
}
|
|
7365
|
-
this.bottomAxis = d3[`scale${this.options.data.bottom.scale || '
|
|
7568
|
+
this.bottomAxis = d3[`scale${this.options.data.bottom.scale || 'Ordinal'}`]()
|
|
7366
7569
|
.domain(bottomDomain)
|
|
7367
7570
|
.range(bottomRange)
|
|
7368
7571
|
if (!this.brushInitialized) {
|
|
7369
|
-
this.bottomBrushAxis = d3[`scale${this.options.data.bottom.scale || '
|
|
7572
|
+
this.bottomBrushAxis = d3[`scale${this.options.data.bottom.scale || 'Ordinal'}`]()
|
|
7370
7573
|
.domain(bottomBrushDomain)
|
|
7371
|
-
.range(
|
|
7574
|
+
.range(bottomBrushRange)
|
|
7372
7575
|
}
|
|
7373
7576
|
if (this.bottomAxis.nice) {
|
|
7374
7577
|
// this.bottomAxis.nice()
|
|
@@ -7387,71 +7590,71 @@ else {
|
|
|
7387
7590
|
brushThickness = this.plotHeight
|
|
7388
7591
|
}
|
|
7389
7592
|
else {
|
|
7390
|
-
if (
|
|
7391
|
-
brushEnd = this.plotWidth * (
|
|
7593
|
+
if (this.brushNeeded) {
|
|
7594
|
+
brushEnd = this.plotWidth * (this.plotWidth / (this.widthForCalc + this.totalBandPadding))
|
|
7392
7595
|
}
|
|
7393
7596
|
}
|
|
7394
7597
|
this.brush = d3[brushMethod]()
|
|
7395
7598
|
.extent([
|
|
7396
7599
|
[0, 0],
|
|
7397
7600
|
[brushLength, brushThickness]
|
|
7398
|
-
])
|
|
7601
|
+
])
|
|
7399
7602
|
.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
|
-
|
|
7603
|
+
// const brushResizePath = d => {
|
|
7604
|
+
// let e = +(d.type === 'e')
|
|
7605
|
+
// let x = e ? 1 : -1
|
|
7606
|
+
// let y = this.options.brushHeight
|
|
7607
|
+
// return (
|
|
7608
|
+
// 'M' +
|
|
7609
|
+
// 0.5 * x +
|
|
7610
|
+
// ',' +
|
|
7611
|
+
// y +
|
|
7612
|
+
// 'A6,6 0 0 ' +
|
|
7613
|
+
// e +
|
|
7614
|
+
// ' ' +
|
|
7615
|
+
// 6.5 * x +
|
|
7616
|
+
// ',' +
|
|
7617
|
+
// (y + 6) +
|
|
7618
|
+
// 'V' +
|
|
7619
|
+
// (2 * y - 6) +
|
|
7620
|
+
// 'A6,6 0 0 ' +
|
|
7621
|
+
// e +
|
|
7622
|
+
// ' ' +
|
|
7623
|
+
// 0.5 * x +
|
|
7624
|
+
// ',' +
|
|
7625
|
+
// 2 * y +
|
|
7626
|
+
// 'Z' +
|
|
7627
|
+
// 'M' +
|
|
7628
|
+
// 2.5 * x +
|
|
7629
|
+
// ',' +
|
|
7630
|
+
// (y + 8) +
|
|
7631
|
+
// 'V' +
|
|
7632
|
+
// (2 * y - 8) +
|
|
7633
|
+
// 'M' +
|
|
7634
|
+
// 4.5 * x +
|
|
7635
|
+
// ',' +
|
|
7636
|
+
// (y + 8) +
|
|
7637
|
+
// 'V' +
|
|
7638
|
+
// (2 * y - 8)
|
|
7639
|
+
// )
|
|
7640
|
+
// }
|
|
7641
|
+
// this.brushHandle = this.brushLayer
|
|
7642
|
+
// .select('.brush')
|
|
7643
|
+
// .selectAll('.handle--custom')
|
|
7644
|
+
// .remove()
|
|
7645
|
+
// this.brushHandle = this.brushLayer
|
|
7646
|
+
// .select('.brush')
|
|
7647
|
+
// .selectAll('.handle--custom')
|
|
7648
|
+
// .data([{ type: 'w' }, { type: 'e' }])
|
|
7649
|
+
// .enter()
|
|
7650
|
+
// .append('path')
|
|
7651
|
+
// .attr('class', 'handle--custom')
|
|
7652
|
+
// .attr('stroke', 'transparent')
|
|
7653
|
+
// .attr('fill', 'transparent')
|
|
7654
|
+
// .attr('cursor', 'ew-resize')
|
|
7655
|
+
// .attr('d', brushResizePath)
|
|
7453
7656
|
// BRUSH END
|
|
7454
|
-
// this.
|
|
7657
|
+
// this.brushLayer.selectAll('.handle').remove()
|
|
7455
7658
|
if (this.brushNeeded) {
|
|
7456
7659
|
if (!this.brushInitialized) {
|
|
7457
7660
|
this.brushLayer.style('visibility', 'visible')
|
|
@@ -7461,11 +7664,14 @@ else {
|
|
|
7461
7664
|
.call(this.brush)
|
|
7462
7665
|
.call(this.brush.move, [0, brushEnd])
|
|
7463
7666
|
}
|
|
7667
|
+
else {
|
|
7668
|
+
this.brushLayer.style('visibility', 'visible')
|
|
7669
|
+
}
|
|
7464
7670
|
}
|
|
7465
7671
|
else {
|
|
7466
7672
|
this.brushLayer.style('visibility', 'hidden')
|
|
7467
7673
|
// this.brushLayer.selectAll().remove()
|
|
7468
|
-
this.brushArea.selectAll('*').remove()
|
|
7674
|
+
// this.brushArea.selectAll('*').remove()
|
|
7469
7675
|
}
|
|
7470
7676
|
if (this.options.margin.axisBottom > 0) {
|
|
7471
7677
|
let timeFormatPattern = ''
|
|
@@ -7551,10 +7757,10 @@ else {
|
|
|
7551
7757
|
let rightDomain = this.createDomain('right')
|
|
7552
7758
|
this.leftAxis = d3[`scale${this.options.data.left.scale || 'Linear'}`]()
|
|
7553
7759
|
.domain(leftDomain)
|
|
7554
|
-
.range(
|
|
7760
|
+
.range(leftRange)
|
|
7555
7761
|
this.leftBrushAxis = d3[`scale${this.options.data.left.scale || 'Linear'}`]()
|
|
7556
7762
|
.domain(leftBrushDomain)
|
|
7557
|
-
.range(
|
|
7763
|
+
.range(leftBrushRange)
|
|
7558
7764
|
if (this.leftAxis.padding && this.options.data.left.padding) {
|
|
7559
7765
|
this.leftAxis.padding(this.options.data.left.padding || 0)
|
|
7560
7766
|
}
|
|
@@ -7702,7 +7908,13 @@ const drawArea = (xAxis, yAxis, curveStyle) => {
|
|
|
7702
7908
|
return d3
|
|
7703
7909
|
.area()
|
|
7704
7910
|
.x(d => {
|
|
7705
|
-
return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
7911
|
+
// return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
7912
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
7913
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
7914
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
7915
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
7916
|
+
}
|
|
7917
|
+
return xPos
|
|
7706
7918
|
})
|
|
7707
7919
|
.y0(d => {
|
|
7708
7920
|
return this[`${yAxis}Axis`](0)
|
|
@@ -7730,7 +7942,7 @@ areas
|
|
|
7730
7942
|
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
7731
7943
|
// .attr('id', `line_${series.key}`)
|
|
7732
7944
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
7733
|
-
|
|
7945
|
+
.attr('fill', d => d[0].y.color || series.color)
|
|
7734
7946
|
// .attr('stroke', 'transparent')
|
|
7735
7947
|
.transition(this.transition)
|
|
7736
7948
|
.attr('d', d => drawArea(xAxis, yAxis, series.curveStyle)(d))
|
|
@@ -7739,13 +7951,13 @@ areas.enter().append('path')
|
|
|
7739
7951
|
.attr('d', d => drawArea(xAxis, yAxis, series.curveStyle)(d))
|
|
7740
7952
|
.attr('class', `area_${series.key}`)
|
|
7741
7953
|
.attr('id', `area_${series.key}`)
|
|
7742
|
-
.attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis
|
|
7954
|
+
// .attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2) + ',0)')
|
|
7743
7955
|
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
7744
|
-
.attr('fill', series.color)
|
|
7956
|
+
.attr('fill', d => d[0].y.color || series.color)
|
|
7745
7957
|
// .style('fill-opacity', 0)
|
|
7746
7958
|
.attr('stroke', 'transparent')
|
|
7747
7959
|
// .transition(this.transition)
|
|
7748
|
-
.style('fill-opacity', series.opacity || 0.
|
|
7960
|
+
.style('fill-opacity', series.opacity || 0.3)
|
|
7749
7961
|
|
|
7750
7962
|
}
|
|
7751
7963
|
renderbar (series, index) {
|
|
@@ -7759,13 +7971,10 @@ if (this.options.orientation === 'horizontal') {
|
|
|
7759
7971
|
xAxis = 'left'
|
|
7760
7972
|
yAxis = 'bottom'
|
|
7761
7973
|
}
|
|
7762
|
-
// if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
7763
|
-
// barWidth = barWidth / this.options.data.series.length - 4
|
|
7764
|
-
// }
|
|
7765
7974
|
function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
7766
7975
|
let output
|
|
7767
7976
|
if (this.options.orientation === 'horizontal') {
|
|
7768
|
-
output = this.options.data[xAxis
|
|
7977
|
+
output = this.options.data[xAxis].bandWidth
|
|
7769
7978
|
}
|
|
7770
7979
|
else {
|
|
7771
7980
|
let x = getBarX.call(this, d, i, xAxis)
|
|
@@ -7791,19 +8000,14 @@ function getBarWidth (d, i, xAxis) {
|
|
|
7791
8000
|
if (typeof x === 'undefined' || x === null) {
|
|
7792
8001
|
return null
|
|
7793
8002
|
}
|
|
7794
|
-
output = Math.max(1, this.options.data[xAxis.
|
|
8003
|
+
output = Math.max(1, this.options.data[xAxis].bandWidth - (xAxis.indexOf('Brush') !== -1 ? 2 : this.options.groupPadding * 2))
|
|
7795
8004
|
}
|
|
7796
8005
|
if (isNaN(output)) {
|
|
7797
8006
|
return 0
|
|
7798
8007
|
}
|
|
7799
8008
|
return output
|
|
7800
8009
|
}
|
|
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
|
|
8010
|
+
function getBarX (d, i, xAxis) {
|
|
7807
8011
|
let output
|
|
7808
8012
|
if (this.options.orientation === 'horizontal') {
|
|
7809
8013
|
if (this.options.grouping === 'stacked') {
|
|
@@ -7821,22 +8025,24 @@ function getBarX (d, i, xAxis) {
|
|
|
7821
8025
|
}
|
|
7822
8026
|
else {
|
|
7823
8027
|
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
|
|
7824
|
-
let adjustment = this.
|
|
8028
|
+
// let adjustment = this[`custom${xAxis.toInitialCaps()}Range`][i] + (i * this.options.data[xAxis].bandWidth)
|
|
7825
8029
|
if (this.options.grouping === 'grouped') {
|
|
7826
8030
|
let xIndex = 0
|
|
7827
8031
|
if (this.processedX[d.x.value]) {
|
|
7828
8032
|
xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel))
|
|
7829
8033
|
}
|
|
7830
|
-
let barAdjustment =
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
8034
|
+
// let barAdjustment =
|
|
8035
|
+
// (this.options.data[xAxis].bandWidth * xIndex) +
|
|
8036
|
+
// (xIndex * this.options.groupPadding * 2) + this.options.groupPadding +
|
|
8037
|
+
// (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
7834
8038
|
// let barAdjustment =
|
|
7835
8039
|
// (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
|
|
7836
8040
|
// this.options.groupPadding
|
|
7837
8041
|
// // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
7838
|
-
|
|
7839
|
-
|
|
8042
|
+
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)
|
|
8043
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`].length > 0) {
|
|
8044
|
+
output = this[`custom${xAxis.toInitialCaps()}Range`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
|
|
8045
|
+
// output = this[`custom${xAxis.toInitialCaps().replace('Brush', '')}DetailRange`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)]
|
|
7840
8046
|
}
|
|
7841
8047
|
else {
|
|
7842
8048
|
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + barAdjustment
|
|
@@ -7847,11 +8053,10 @@ function getBarX (d, i, xAxis) {
|
|
|
7847
8053
|
if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
|
|
7848
8054
|
this.processedX[d.x.value].push(d.y.tooltipLabel)
|
|
7849
8055
|
}
|
|
7850
|
-
console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
|
|
8056
|
+
// console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
|
|
7851
8057
|
}
|
|
7852
|
-
else {
|
|
7853
|
-
|
|
7854
|
-
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) // + (i * barWidth)
|
|
8058
|
+
else {
|
|
8059
|
+
output = this[`custom${xAxis.toInitialCaps()}Range`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)]
|
|
7855
8060
|
}
|
|
7856
8061
|
}
|
|
7857
8062
|
if (isNaN(output)) {
|
|
@@ -7859,9 +8064,7 @@ function getBarX (d, i, xAxis) {
|
|
|
7859
8064
|
}
|
|
7860
8065
|
return output
|
|
7861
8066
|
}
|
|
7862
|
-
function getBarY (d, i, heightBounds, yAxis, xAxis) {
|
|
7863
|
-
// let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
7864
|
-
// let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
8067
|
+
function getBarY (d, i, heightBounds, yAxis, xAxis) {
|
|
7865
8068
|
let output
|
|
7866
8069
|
if (this.options.orientation === 'horizontal') {
|
|
7867
8070
|
if (this.options.grouping !== 'grouped') {
|
|
@@ -7873,7 +8076,10 @@ function getBarY (d, i, heightBounds, yAxis, xAxis) {
|
|
|
7873
8076
|
}
|
|
7874
8077
|
else {
|
|
7875
8078
|
if (this.options.grouping === 'stacked') {
|
|
7876
|
-
|
|
8079
|
+
let accH = getBarHeight.call(this, {x: d.x, y: { value: d.y.accumulative }}, i, heightBounds, yAxis, xAxis)
|
|
8080
|
+
let h = getBarHeight.call(this, d, i, heightBounds, yAxis, xAxis)
|
|
8081
|
+
// output = heightBounds - this[`${yAxis}Axis`](d.y.accumulative)
|
|
8082
|
+
output = (this[`${yAxis}Axis`](0)) - ((accH + h) * (d.y.accumulative < 0 ? 0 : 1))
|
|
7877
8083
|
}
|
|
7878
8084
|
else {
|
|
7879
8085
|
let h = getBarHeight.call(this, d, i, heightBounds, yAxis, xAxis)
|
|
@@ -7953,12 +8159,12 @@ let bars = this.barLayer.selectAll(`.bar_${key}`)
|
|
|
7953
8159
|
}
|
|
7954
8160
|
renderLabels (series, index) {
|
|
7955
8161
|
/* global series index d3 WebsyDesigns */
|
|
7956
|
-
let xAxis = '
|
|
7957
|
-
let yAxis = '
|
|
8162
|
+
let xAxis = 'bottom'
|
|
8163
|
+
let yAxis = 'left'
|
|
7958
8164
|
let that = this
|
|
7959
8165
|
if (this.options.orientation === 'horizontal') {
|
|
7960
|
-
xAxis = '
|
|
7961
|
-
yAxis = '
|
|
8166
|
+
xAxis = 'left'
|
|
8167
|
+
yAxis = 'bottom'
|
|
7962
8168
|
}
|
|
7963
8169
|
if (this.options.showLabels === true || series.showLabels === true) {
|
|
7964
8170
|
// need to add logic to handle positioning options
|
|
@@ -8048,6 +8254,9 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
8048
8254
|
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
8049
8255
|
this.setAttribute('y', +(this.getAttribute('y')) + 8)
|
|
8050
8256
|
}
|
|
8257
|
+
if (series.labelPosition !== 'outside') {
|
|
8258
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
8259
|
+
}
|
|
8051
8260
|
}
|
|
8052
8261
|
})
|
|
8053
8262
|
}
|
|
@@ -8062,19 +8271,28 @@ function getLabelX (d, labelPosition = 'inside') {
|
|
|
8062
8271
|
}
|
|
8063
8272
|
}
|
|
8064
8273
|
else {
|
|
8065
|
-
return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
8274
|
+
// return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
8275
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8276
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8277
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8278
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8279
|
+
}
|
|
8280
|
+
return xPos
|
|
8066
8281
|
}
|
|
8067
8282
|
}
|
|
8068
8283
|
function getLabelY (d, labelPosition = 'inside') {
|
|
8069
8284
|
if (this.options.orientation === 'horizontal') {
|
|
8070
|
-
return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis
|
|
8285
|
+
return this[xAxis + 'Axis'](this.parseX(d.x.value)) + (this.options.data[xAxis].bandWidth / 2)
|
|
8071
8286
|
}
|
|
8072
8287
|
else {
|
|
8073
8288
|
if (this.options.grouping === 'stacked') {
|
|
8074
|
-
|
|
8289
|
+
let accH = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.accumulative))
|
|
8290
|
+
let h = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
|
|
8291
|
+
return (this[`${yAxis}Axis`](0)) - ((accH + h - (labelPosition === 'inside' ? h / 2 : 0)) * (d.y.accumulative < 0 ? 0 : 1))
|
|
8292
|
+
// return (this[`${yAxis}Axis`](0)) - (this[yAxis + 'Axis'](d.y.accumulative) - (this[yAxis + 'Axis'](d.y.value))) // / (labelPosition === 'inside' ? 2 : 1)))
|
|
8075
8293
|
}
|
|
8076
8294
|
else {
|
|
8077
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize)
|
|
8295
|
+
return this[yAxis + 'Axis'](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize)
|
|
8078
8296
|
}
|
|
8079
8297
|
}
|
|
8080
8298
|
}
|
|
@@ -8090,13 +8308,19 @@ const drawLine = (xAxis, yAxis, curveStyle) => {
|
|
|
8090
8308
|
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
8091
8309
|
}
|
|
8092
8310
|
else {
|
|
8093
|
-
let
|
|
8094
|
-
|
|
8311
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8312
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8313
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8314
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8315
|
+
}
|
|
8316
|
+
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8317
|
+
// return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8318
|
+
return xPos
|
|
8095
8319
|
}
|
|
8096
8320
|
})
|
|
8097
8321
|
.y(d => {
|
|
8098
8322
|
if (this.options.orientation === 'horizontal') {
|
|
8099
|
-
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[
|
|
8323
|
+
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8100
8324
|
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8101
8325
|
}
|
|
8102
8326
|
else {
|
|
@@ -8131,7 +8355,7 @@ lines
|
|
|
8131
8355
|
.style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8132
8356
|
// .attr('id', `line_${series.key}`)
|
|
8133
8357
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8134
|
-
.attr('stroke', series.color)
|
|
8358
|
+
.attr('stroke', d => d[0].y.color || series.color)
|
|
8135
8359
|
.attr('fill', 'transparent')
|
|
8136
8360
|
.transition(this.transition)
|
|
8137
8361
|
.attr('d', d => drawLine(xAxis, yAxis, series.curveStyle)(d))
|
|
@@ -8142,7 +8366,7 @@ lines.enter().append('path')
|
|
|
8142
8366
|
.attr('id', `line_${series.key}`)
|
|
8143
8367
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8144
8368
|
.style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8145
|
-
.attr('stroke', series.color)
|
|
8369
|
+
.attr('stroke', d => d[0].y.color || series.color)
|
|
8146
8370
|
.attr('fill', 'transparent')
|
|
8147
8371
|
// .transition(this.transition)
|
|
8148
8372
|
.style('stroke-opacity', 1)
|
|
@@ -8265,12 +8489,25 @@ symbols
|
|
|
8265
8489
|
.attr('fill', series.fillSymbols ? series.color : 'white')
|
|
8266
8490
|
.attr('stroke', series.color)
|
|
8267
8491
|
.attr('transform', d => {
|
|
8268
|
-
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this[
|
|
8492
|
+
// let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8493
|
+
// if (this.options.orientation === 'horizontal') {
|
|
8494
|
+
// return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
|
|
8495
|
+
// }
|
|
8496
|
+
// else {
|
|
8497
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8498
|
+
// }
|
|
8499
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8500
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8501
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8502
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8503
|
+
}
|
|
8504
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8269
8505
|
if (this.options.orientation === 'horizontal') {
|
|
8270
|
-
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${
|
|
8506
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${xPos})`
|
|
8271
8507
|
}
|
|
8272
8508
|
else {
|
|
8273
|
-
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8509
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8510
|
+
return `translate(${xPos}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8274
8511
|
}
|
|
8275
8512
|
})
|
|
8276
8513
|
// Enter
|
|
@@ -8282,12 +8519,18 @@ symbols.enter()
|
|
|
8282
8519
|
.attr('stroke', series.color)
|
|
8283
8520
|
.attr('class', d => { return `symbol symbol_${series.key}` })
|
|
8284
8521
|
.attr('transform', d => {
|
|
8285
|
-
let
|
|
8522
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8523
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8524
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8525
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8526
|
+
}
|
|
8527
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8286
8528
|
if (this.options.orientation === 'horizontal') {
|
|
8287
|
-
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${
|
|
8529
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${xPos})`
|
|
8288
8530
|
}
|
|
8289
8531
|
else {
|
|
8290
|
-
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8532
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8533
|
+
return `translate(${xPos}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8291
8534
|
}
|
|
8292
8535
|
})
|
|
8293
8536
|
|