@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
|
@@ -1784,6 +1784,24 @@ class WebsyDropdown {
|
|
|
1784
1784
|
}
|
|
1785
1785
|
this.updateHeader(item)
|
|
1786
1786
|
}
|
|
1787
|
+
setValue (value) {
|
|
1788
|
+
this.selectedItems = []
|
|
1789
|
+
if (Array.isArray(value)) {
|
|
1790
|
+
this.options.items.forEach(d => {
|
|
1791
|
+
if (value.indexOf(d.value) !== -1) {
|
|
1792
|
+
this.selectedItems.push(d.index)
|
|
1793
|
+
}
|
|
1794
|
+
})
|
|
1795
|
+
}
|
|
1796
|
+
else {
|
|
1797
|
+
this.options.items.forEach(d => {
|
|
1798
|
+
if (d.value === value) {
|
|
1799
|
+
this.selectedItems.push(d.index)
|
|
1800
|
+
}
|
|
1801
|
+
})
|
|
1802
|
+
}
|
|
1803
|
+
this.render()
|
|
1804
|
+
}
|
|
1787
1805
|
updateHeader (item) {
|
|
1788
1806
|
const el = document.getElementById(this.elementId)
|
|
1789
1807
|
const headerEl = document.getElementById(`${this.elementId}_header`)
|
|
@@ -2184,6 +2202,7 @@ class WebsyForm {
|
|
|
2184
2202
|
return
|
|
2185
2203
|
}
|
|
2186
2204
|
this.apiService = new WebsyDesigns.APIService('')
|
|
2205
|
+
this.fieldMap = {}
|
|
2187
2206
|
this.elementId = elementId
|
|
2188
2207
|
const el = document.getElementById(elementId)
|
|
2189
2208
|
if (el) {
|
|
@@ -2232,6 +2251,15 @@ class WebsyForm {
|
|
|
2232
2251
|
}
|
|
2233
2252
|
})
|
|
2234
2253
|
}
|
|
2254
|
+
get data () {
|
|
2255
|
+
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2256
|
+
const data = {}
|
|
2257
|
+
const temp = new FormData(formEl)
|
|
2258
|
+
temp.forEach((value, key) => {
|
|
2259
|
+
data[key] = value
|
|
2260
|
+
})
|
|
2261
|
+
return data
|
|
2262
|
+
}
|
|
2235
2263
|
set data (d) {
|
|
2236
2264
|
if (!this.options.fields) {
|
|
2237
2265
|
this.options.fields = []
|
|
@@ -2311,6 +2339,7 @@ class WebsyForm {
|
|
|
2311
2339
|
<form id="${this.elementId}Form" class="websy-form ${this.options.classes || ''}">
|
|
2312
2340
|
`
|
|
2313
2341
|
this.options.fields.forEach((f, i) => {
|
|
2342
|
+
this.fieldMap[f.field] = f
|
|
2314
2343
|
if (f.component) {
|
|
2315
2344
|
componentsToProcess.push(f)
|
|
2316
2345
|
html += `
|
|
@@ -2381,6 +2410,25 @@ class WebsyForm {
|
|
|
2381
2410
|
})
|
|
2382
2411
|
}
|
|
2383
2412
|
}
|
|
2413
|
+
setValue (field, value) {
|
|
2414
|
+
if (this.fieldMap[field]) {
|
|
2415
|
+
if (this.fieldMap[field].instance) {
|
|
2416
|
+
this.fieldMap[field].instance.setValue(value)
|
|
2417
|
+
}
|
|
2418
|
+
else {
|
|
2419
|
+
const el = document.getElementById(`${this.elementId}_input_${field}`)
|
|
2420
|
+
if (el) {
|
|
2421
|
+
el.value = value
|
|
2422
|
+
}
|
|
2423
|
+
else {
|
|
2424
|
+
console.error(`Input for ${field} does not exist in form.`)
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
else {
|
|
2429
|
+
console.error(`Field ${field} does not exist in form.`)
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2384
2432
|
submitForm () {
|
|
2385
2433
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2386
2434
|
const buttonEl = formEl.querySelector('button.websy-btn.submit')
|
|
@@ -2709,6 +2757,9 @@ class WebsyLogin {
|
|
|
2709
2757
|
onSuccess: this.loginSuccess.bind(this),
|
|
2710
2758
|
onError: this.loginFail.bind(this)
|
|
2711
2759
|
}
|
|
2760
|
+
if (this.options.fields) {
|
|
2761
|
+
formOptions.fields = this.options.fields.concat(formOptions.fields)
|
|
2762
|
+
}
|
|
2712
2763
|
this.loginForm = new WebsyDesigns.WebsyForm(`${this.elementId}_container`, Object.assign({}, this.options, formOptions))
|
|
2713
2764
|
}
|
|
2714
2765
|
else {
|
|
@@ -4108,15 +4159,18 @@ class WebsyRouter {
|
|
|
4108
4159
|
let inputPath = this.currentView
|
|
4109
4160
|
if (this.options.urlPrefix) {
|
|
4110
4161
|
inputPath = `/${this.options.urlPrefix}/${inputPath}`
|
|
4162
|
+
}
|
|
4163
|
+
this.currentParams = {
|
|
4164
|
+
path: '',
|
|
4165
|
+
items: {}
|
|
4111
4166
|
}
|
|
4112
4167
|
if (reloadView === true) {
|
|
4113
4168
|
this.navigate(`${inputPath}`, 'main', null, noHistory)
|
|
4114
4169
|
}
|
|
4115
4170
|
else {
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
}
|
|
4171
|
+
history.replaceState({
|
|
4172
|
+
inputPath
|
|
4173
|
+
}, 'unused', inputPath)
|
|
4120
4174
|
}
|
|
4121
4175
|
}
|
|
4122
4176
|
buildUrlPath (params) {
|
|
@@ -4734,25 +4788,7 @@ class WebsySignup {
|
|
|
4734
4788
|
url: 'auth/signup'
|
|
4735
4789
|
}
|
|
4736
4790
|
this.elementId = elementId
|
|
4737
|
-
this.options = Object.assign({}, DEFAULTS, options)
|
|
4738
|
-
if (!this.options.fields) {
|
|
4739
|
-
this.options.fields = [
|
|
4740
|
-
{
|
|
4741
|
-
label: this.options.loginType === 'email' ? 'Email' : 'Username',
|
|
4742
|
-
placeholder: `Enter ${this.options.loginType === 'email' ? 'your email address' : 'your chosen Username'}`,
|
|
4743
|
-
field: this.options.loginType,
|
|
4744
|
-
type: this.options.loginType,
|
|
4745
|
-
required: true
|
|
4746
|
-
},
|
|
4747
|
-
{
|
|
4748
|
-
label: 'Password',
|
|
4749
|
-
placeholder: 'Enter your password',
|
|
4750
|
-
field: this.options.passwordField || 'password',
|
|
4751
|
-
type: 'password',
|
|
4752
|
-
required: true
|
|
4753
|
-
}
|
|
4754
|
-
]
|
|
4755
|
-
}
|
|
4791
|
+
this.options = Object.assign({}, DEFAULTS, options)
|
|
4756
4792
|
const el = document.getElementById(this.elementId)
|
|
4757
4793
|
if (el) {
|
|
4758
4794
|
const formOptions = {
|
|
@@ -4762,7 +4798,25 @@ class WebsySignup {
|
|
|
4762
4798
|
classes: (this.options.buttonClasses || []).join(' ') || ''
|
|
4763
4799
|
},
|
|
4764
4800
|
submitFn: this.submitForm.bind(this),
|
|
4765
|
-
fields:
|
|
4801
|
+
fields: [
|
|
4802
|
+
{
|
|
4803
|
+
label: this.options.loginType === 'email' ? 'Email' : 'Username',
|
|
4804
|
+
placeholder: `Enter ${this.options.loginType === 'email' ? 'your email address' : 'your chosen Username'}`,
|
|
4805
|
+
field: this.options.loginType,
|
|
4806
|
+
type: this.options.loginType,
|
|
4807
|
+
required: true
|
|
4808
|
+
},
|
|
4809
|
+
{
|
|
4810
|
+
label: 'Password',
|
|
4811
|
+
placeholder: 'Enter your password',
|
|
4812
|
+
field: this.options.passwordField || 'password',
|
|
4813
|
+
type: 'password',
|
|
4814
|
+
required: true
|
|
4815
|
+
}
|
|
4816
|
+
]
|
|
4817
|
+
}
|
|
4818
|
+
if (this.options.fields) {
|
|
4819
|
+
formOptions.fields = this.options.fields.concat(formOptions.fields)
|
|
4766
4820
|
}
|
|
4767
4821
|
this.signupForm = new WebsyDesigns.WebsyForm(this.elementId, Object.assign({}, this.options, formOptions))
|
|
4768
4822
|
}
|
|
@@ -6982,6 +7036,7 @@ class WebsyChart {
|
|
|
6982
7036
|
tooltipWidth: 200,
|
|
6983
7037
|
brushHeight: 50,
|
|
6984
7038
|
minBandWidth: 30,
|
|
7039
|
+
maxBandWidth: 100,
|
|
6985
7040
|
allowUnevenBands: true
|
|
6986
7041
|
}
|
|
6987
7042
|
this.elementId = elementId
|
|
@@ -7009,99 +7064,124 @@ class WebsyChart {
|
|
|
7009
7064
|
xAxis += 'Axis'
|
|
7010
7065
|
let output
|
|
7011
7066
|
let width = this.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth
|
|
7012
|
-
if (this.customBottomRange) {
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
output = index
|
|
7018
|
-
break
|
|
7019
|
-
}
|
|
7020
|
-
}
|
|
7021
|
-
else {
|
|
7067
|
+
// if (this.customBottomRange) {
|
|
7068
|
+
for (let index = 0; index < this.customBottomRange.length; index++) {
|
|
7069
|
+
if (input > this.customBottomRange[index]) {
|
|
7070
|
+
if (this.customBottomRange[index + 1]) {
|
|
7071
|
+
if (input < this.customBottomRange[index + 1]) {
|
|
7022
7072
|
output = index
|
|
7023
7073
|
break
|
|
7024
7074
|
}
|
|
7025
7075
|
}
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
else {
|
|
7029
|
-
let domain = [...this[xAxis].domain()]
|
|
7030
|
-
if (this.options.orientation === 'horizontal') {
|
|
7031
|
-
domain = domain.reverse()
|
|
7032
|
-
}
|
|
7033
|
-
for (let j = 0; j < domain.length; j++) {
|
|
7034
|
-
let breakA = this[xAxis](domain[j]) - (width / 2)
|
|
7035
|
-
let breakB = breakA + width
|
|
7036
|
-
if (input > breakA && input <= breakB) {
|
|
7037
|
-
output = j
|
|
7076
|
+
else {
|
|
7077
|
+
output = index
|
|
7038
7078
|
break
|
|
7039
7079
|
}
|
|
7040
|
-
}
|
|
7080
|
+
}
|
|
7041
7081
|
}
|
|
7082
|
+
// }
|
|
7083
|
+
// else {
|
|
7084
|
+
// let domain = [...this[xAxis].domain()]
|
|
7085
|
+
// if (this.options.orientation === 'horizontal') {
|
|
7086
|
+
// domain = domain.reverse()
|
|
7087
|
+
// }
|
|
7088
|
+
// for (let j = 0; j < domain.length; j++) {
|
|
7089
|
+
// let breakA = this[xAxis](domain[j]) - (width / 2)
|
|
7090
|
+
// let breakB = breakA + width
|
|
7091
|
+
// if (input > breakA && input <= breakB) {
|
|
7092
|
+
// output = j
|
|
7093
|
+
// break
|
|
7094
|
+
// }
|
|
7095
|
+
// }
|
|
7096
|
+
// }
|
|
7042
7097
|
return output
|
|
7043
7098
|
}
|
|
7044
7099
|
let that = this
|
|
7045
7100
|
this.brushed = function (event) {
|
|
7046
|
-
console.log('brushing', event)
|
|
7047
|
-
that.
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
if (that.options.orientation === 'horizontal') {
|
|
7051
|
-
xAxis = 'left'
|
|
7052
|
-
xAxisCaps = 'Left'
|
|
7053
|
-
}
|
|
7054
|
-
if (!that[`${xAxis}Axis`]) {
|
|
7055
|
-
return
|
|
7101
|
+
console.log('brushing', event)
|
|
7102
|
+
let newX = (that.options.margin.left + that.options.margin.axisLeft) + (1 - (event.selection[0] / ((that.plotWidth) / (that.widthForCalc + that.totalBandPadding))))
|
|
7103
|
+
if (that.plotArea) {
|
|
7104
|
+
that.plotArea.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
7056
7105
|
}
|
|
7057
|
-
if (
|
|
7058
|
-
that
|
|
7106
|
+
if (that.areaLayer) {
|
|
7107
|
+
that.areaLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
7059
7108
|
}
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
that.brushLayer
|
|
7063
|
-
.select('.brush')
|
|
7064
|
-
.call(that.brush)
|
|
7065
|
-
.call(that.brush.move, s)
|
|
7066
|
-
return
|
|
7109
|
+
if (that.lineLayer) {
|
|
7110
|
+
that.lineLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
7067
7111
|
}
|
|
7068
|
-
if (that.
|
|
7069
|
-
that.
|
|
7112
|
+
if (that.barLayer) {
|
|
7113
|
+
that.barLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
7070
7114
|
}
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
if (
|
|
7074
|
-
startEndOrdinal &&
|
|
7075
|
-
startEndOrdinal.length === 2 &&
|
|
7076
|
-
typeof startEndOrdinal[0] !== 'undefined' &&
|
|
7077
|
-
typeof startEndOrdinal[1] !== 'undefined'
|
|
7078
|
-
) {
|
|
7079
|
-
let domain = []
|
|
7080
|
-
let domainValues = [...that[`${xAxis}BrushAxis`].domain()]
|
|
7081
|
-
for (let i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
|
|
7082
|
-
// domain.push(that.xRange[i])
|
|
7083
|
-
that.brushedDomain.push(domainValues[i])
|
|
7084
|
-
}
|
|
7085
|
-
}
|
|
7115
|
+
if (that.labelLayer) {
|
|
7116
|
+
that.labelLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
7086
7117
|
}
|
|
7087
|
-
if (that.
|
|
7088
|
-
that
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
)
|
|
7092
|
-
}
|
|
7093
|
-
if (that.
|
|
7094
|
-
that.
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7118
|
+
if (that.symbolLayer) {
|
|
7119
|
+
that.symbolLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
7120
|
+
}
|
|
7121
|
+
if (that.refLineLayer) {
|
|
7122
|
+
that.refLineLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop})`)
|
|
7123
|
+
}
|
|
7124
|
+
if (that.bottomAxisLayer) {
|
|
7125
|
+
that.bottomAxisLayer.attr('transform', `translate(${newX}, ${that.options.margin.top + that.options.margin.axisTop + that.plotHeight})`)
|
|
7126
|
+
}
|
|
7127
|
+
// that.brushedDomain = []
|
|
7128
|
+
// let xAxis = 'bottom'
|
|
7129
|
+
// let xAxisCaps = 'Bottom'
|
|
7130
|
+
// if (that.options.orientation === 'horizontal') {
|
|
7131
|
+
// xAxis = 'left'
|
|
7132
|
+
// xAxisCaps = 'Left'
|
|
7133
|
+
// }
|
|
7134
|
+
// if (!that[`${xAxis}Axis`]) {
|
|
7135
|
+
// return
|
|
7136
|
+
// }
|
|
7137
|
+
// if (!that[`${xAxis}Axis`].invert) {
|
|
7138
|
+
// that[`${xAxis}Axis`].invert = that.invertOverride
|
|
7139
|
+
// }
|
|
7140
|
+
// let s = event.selection || that[`${xAxis}Axis`].range()
|
|
7141
|
+
// if (!event.selection || event.selection.length === 0) {
|
|
7142
|
+
// that.brushLayer
|
|
7143
|
+
// .select('.brush')
|
|
7144
|
+
// .call(that.brush)
|
|
7145
|
+
// .call(that.brush.move, s)
|
|
7146
|
+
// return
|
|
7147
|
+
// }
|
|
7148
|
+
// if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
|
|
7149
|
+
// that.brushedDomain = s.map(that[`${xAxis}BrushAxis`].invert, that[[`${xAxis}Axis`]])
|
|
7150
|
+
// }
|
|
7151
|
+
// else {
|
|
7152
|
+
// let startEndOrdinal = s.map((a, b) => that.bottomAxis.invert(a, b, true), that.bottomBrushAxis)
|
|
7153
|
+
// if (
|
|
7154
|
+
// startEndOrdinal &&
|
|
7155
|
+
// startEndOrdinal.length === 2 &&
|
|
7156
|
+
// typeof startEndOrdinal[0] !== 'undefined' &&
|
|
7157
|
+
// typeof startEndOrdinal[1] !== 'undefined'
|
|
7158
|
+
// ) {
|
|
7159
|
+
// let domain = []
|
|
7160
|
+
// let domainValues = [...that[`${xAxis}BrushAxis`].domain()]
|
|
7161
|
+
// for (let i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
|
|
7162
|
+
// // domain.push(that.xRange[i])
|
|
7163
|
+
// that.brushedDomain.push(domainValues[i])
|
|
7164
|
+
// }
|
|
7165
|
+
// }
|
|
7166
|
+
// }
|
|
7167
|
+
// if (that.brushedDomain.length > 0) {
|
|
7168
|
+
// that[`${xAxis}Axis`].domain(that.brushedDomain)
|
|
7169
|
+
// that[`${xAxis}AxisLayer`].call(
|
|
7170
|
+
// d3[`axis${xAxisCaps}`](that[`${xAxis}Axis`])
|
|
7171
|
+
// )
|
|
7172
|
+
// }
|
|
7173
|
+
// if (that.leftAxis && that.bottomAxis) {
|
|
7174
|
+
// that.renderComponents()
|
|
7175
|
+
// if (that.options.orientation === 'vertical') {
|
|
7176
|
+
// // that.bottomAxisLayer.call(that.bAxisFunc)
|
|
7177
|
+
// if (that.options.data.bottom.rotate) {
|
|
7178
|
+
// that.bottomAxisLayer.selectAll('text')
|
|
7179
|
+
// .attr('transform', `rotate(${((that.options.data.bottom && that.options.data.bottom.rotate) || 0)})`)
|
|
7180
|
+
// .style('text-anchor', `${((that.options.data.bottom && that.options.data.bottom.rotate) || 0) === 0 ? 'middle' : 'end'}`)
|
|
7181
|
+
// .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`)
|
|
7182
|
+
// }
|
|
7183
|
+
// }
|
|
7184
|
+
// }
|
|
7105
7185
|
}
|
|
7106
7186
|
const el = document.getElementById(this.elementId)
|
|
7107
7187
|
if (el) {
|
|
@@ -7243,12 +7323,12 @@ else {
|
|
|
7243
7323
|
}
|
|
7244
7324
|
this.options.data.series.forEach(s => {
|
|
7245
7325
|
if (this.options.data[xData].scale !== 'Time') {
|
|
7246
|
-
if (this.customBottomRange && this.customBottomRange.length > 0) {
|
|
7247
|
-
|
|
7248
|
-
}
|
|
7249
|
-
else {
|
|
7250
|
-
|
|
7251
|
-
}
|
|
7326
|
+
// if (this.customBottomRange && this.customBottomRange.length > 0) {
|
|
7327
|
+
xPoint = this.customBottomRange[x0] + ((this.customBottomRange[x0 + 1] - this.customBottomRange[x0]) / 2)
|
|
7328
|
+
// }
|
|
7329
|
+
// else {
|
|
7330
|
+
// xPoint = this[xAxis](this.parseX(xLabel))
|
|
7331
|
+
// }
|
|
7252
7332
|
s.data.forEach(d => {
|
|
7253
7333
|
if (d.x.value === xLabel) {
|
|
7254
7334
|
if (!tooltipTitle) {
|
|
@@ -7370,6 +7450,10 @@ else {
|
|
|
7370
7450
|
}
|
|
7371
7451
|
}
|
|
7372
7452
|
this.tooltip.setHeight(this.plotHeight)
|
|
7453
|
+
if (isNaN(posOptions.left)) {
|
|
7454
|
+
this.tooltip.hide()
|
|
7455
|
+
return
|
|
7456
|
+
}
|
|
7373
7457
|
this.options.showTooltip && this.tooltip.show(tooltipTitle, tooltipHTML, posOptions)
|
|
7374
7458
|
// }
|
|
7375
7459
|
// else {
|
|
@@ -7404,20 +7488,22 @@ else {
|
|
|
7404
7488
|
/* global d3 WebsyDesigns */
|
|
7405
7489
|
this.defs = this.svg.append('defs')
|
|
7406
7490
|
this.clip = this.defs.append('clipPath').attr('id', `${this.elementId}_clip`).append('rect')
|
|
7491
|
+
this.xAxisClip = this.defs.append('clipPath').attr('id', `${this.elementId}_xAxisClip`).append('rect')
|
|
7407
7492
|
this.brushClip = this.defs.append('clipPath').attr('id', `${this.elementId}_brushclip`).append('rect')
|
|
7408
7493
|
this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer')
|
|
7409
7494
|
this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer')
|
|
7410
|
-
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer')
|
|
7495
|
+
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer').attr('clip-path', `url(#${this.elementId}_xAxisClip)`).append('g')
|
|
7411
7496
|
this.leftAxisLabel = this.svg.append('g').attr('class', 'left-axis-label-layer')
|
|
7412
7497
|
this.rightAxisLabel = this.svg.append('g').attr('class', 'right-axis-label-layer')
|
|
7413
7498
|
this.bottomAxisLabel = this.svg.append('g').attr('class', 'bottom-axis-label-layer')
|
|
7414
|
-
this.plotArea = this.svg.append('g').attr('class', 'plot-layer')
|
|
7415
|
-
this.areaLayer = this.svg.append('g').attr('class', 'area-layer')
|
|
7416
|
-
this.lineLayer = this.svg.append('g').attr('class', 'line-layer')
|
|
7417
|
-
this.barLayer = this.svg.append('g').attr('class', 'bar-layer')
|
|
7418
|
-
|
|
7419
|
-
this.
|
|
7420
|
-
this.
|
|
7499
|
+
this.plotArea = this.svg.append('g').attr('class', 'plot-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7500
|
+
this.areaLayer = this.svg.append('g').attr('class', 'area-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7501
|
+
this.lineLayer = this.svg.append('g').attr('class', 'line-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7502
|
+
this.barLayer = this.svg.append('g').attr('class', 'bar-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7503
|
+
// this.barLayer.attr('clip-path', `url(#${this.elementId}_clip)`)
|
|
7504
|
+
this.labelLayer = this.svg.append('g').attr('class', 'label-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7505
|
+
this.symbolLayer = this.svg.append('g').attr('class', 'symbol-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7506
|
+
this.refLineLayer = this.svg.append('g').attr('class', 'refline-layer').attr('clip-path', `url(#${this.elementId}_clip)`).append('g')
|
|
7421
7507
|
this.trackingLineLayer = this.svg.append('g').attr('class', 'tracking-line-layer')
|
|
7422
7508
|
this.trackingLineLayer.append('line').attr('class', 'tracking-line')
|
|
7423
7509
|
this.tooltip = new WebsyDesigns.WebsyChartTooltip(this.svg)
|
|
@@ -7665,39 +7751,113 @@ else {
|
|
|
7665
7751
|
this.options.margin.axisBottom = 0
|
|
7666
7752
|
}
|
|
7667
7753
|
}
|
|
7754
|
+
// At some point before this we need to add in logic to make space for any data point labels
|
|
7668
7755
|
// Define the plot size
|
|
7669
7756
|
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
|
|
7670
7757
|
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
|
|
7671
7758
|
this.brushNeeded = false
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
if (this.
|
|
7684
|
-
this.
|
|
7685
|
-
|
|
7759
|
+
let proposedBandWidth // distance between x axis data points.
|
|
7760
|
+
let maxBandWidthFits = false
|
|
7761
|
+
// Check to see if all bars at the max allowed width will fit
|
|
7762
|
+
this.bandPadding = 0
|
|
7763
|
+
this.totalBandPadding = 0
|
|
7764
|
+
this.brushBandPadding = 0
|
|
7765
|
+
this.totalBrushBandPadding = 0
|
|
7766
|
+
let noOfPoints = 0
|
|
7767
|
+
let noOfGroups = 0
|
|
7768
|
+
let plotable = 0
|
|
7769
|
+
if (this.options.maxBandWidth) {
|
|
7770
|
+
if (this.options.orientation === 'horizontal') {
|
|
7771
|
+
this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
|
|
7772
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7773
|
+
return a + 1
|
|
7774
|
+
}
|
|
7775
|
+
return a + b.valueCount
|
|
7776
|
+
}, 0)
|
|
7777
|
+
if (this.options.data.left.padding) {
|
|
7778
|
+
this.totalBandPadding = (this.plotHeight * this.options.data.left.padding)
|
|
7779
|
+
this.bandPadding = this.totalBandPadding / this.options.data.left.data.length
|
|
7780
|
+
this.totalBrushBandPadding = (this.plotHeight * this.options.data.left.padding)
|
|
7781
|
+
this.brushBandPadding = this.totalBandPadding / this.options.data.left.data.length
|
|
7782
|
+
}
|
|
7783
|
+
plotable = this.plotHeight - this.totalBandPadding
|
|
7784
|
+
noOfPoints = this.options.grouping === 'grouped' ? this.options.data.left.totalValueCount : this.options.data.left.data.length
|
|
7785
|
+
noOfGroups = this.options.data.left.data.length
|
|
7686
7786
|
}
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
return a +
|
|
7787
|
+
else {
|
|
7788
|
+
this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
|
|
7789
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7790
|
+
return a + 1
|
|
7791
|
+
}
|
|
7792
|
+
return a + b.valueCount
|
|
7793
|
+
}, 0)
|
|
7794
|
+
if (this.options.data.bottom.padding) {
|
|
7795
|
+
this.totalBandPadding = (this.plotWidth * this.options.data.bottom.padding)
|
|
7796
|
+
this.bandPadding = this.totalBandPadding / this.options.data.bottom.data.length
|
|
7797
|
+
this.totalBrushBandPadding = (this.plotWidth * this.options.data.bottom.padding)
|
|
7798
|
+
this.brushBandPadding = this.totalBandPadding / this.options.data.bottom.data.length
|
|
7799
|
+
}
|
|
7800
|
+
plotable = this.plotWidth - this.totalBandPadding
|
|
7801
|
+
noOfPoints = this.options.grouping === 'grouped' ? this.options.data.bottom.totalValueCount : this.options.data.bottom.data.length
|
|
7802
|
+
noOfGroups = this.options.data.bottom.data.length
|
|
7803
|
+
}
|
|
7804
|
+
if (plotable / noOfPoints > this.options.maxBandWidth) {
|
|
7805
|
+
maxBandWidthFits = true
|
|
7806
|
+
proposedBandWidth = this.options.maxBandWidth
|
|
7807
|
+
}
|
|
7808
|
+
if (!maxBandWidthFits) {
|
|
7809
|
+
// Check to see if all bars at the min allowed width will fit
|
|
7810
|
+
if (plotable / noOfPoints < this.options.minBandWidth) {
|
|
7811
|
+
this.brushNeeded = true
|
|
7812
|
+
proposedBandWidth = this.options.minBandWidth
|
|
7813
|
+
if (this.options.orientation === 'horizontal') {
|
|
7814
|
+
this.plotWidth -= this.options.brushHeight
|
|
7815
|
+
}
|
|
7816
|
+
else {
|
|
7817
|
+
this.plotHeight -= this.options.brushHeight
|
|
7818
|
+
}
|
|
7693
7819
|
}
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7820
|
+
else {
|
|
7821
|
+
proposedBandWidth = plotable / noOfPoints
|
|
7822
|
+
}
|
|
7823
|
+
}
|
|
7824
|
+
}
|
|
7825
|
+
// if (this.options.minBandWidth) {
|
|
7826
|
+
// this.widthForCalc = this.options.data.bottom.totalValueCount * this.options.minBandWidth
|
|
7827
|
+
// if (this.options.data.bottom.padding) {
|
|
7828
|
+
// this.widthForCalc += (this.options.minBandWidth * this.options.data.bottom.padding) * this.options.data.bottom.totalValueCount
|
|
7829
|
+
// this.widthForCalc += (this.options.data.bottom.data.length * this.options.groupPadding * 2)
|
|
7830
|
+
// }
|
|
7831
|
+
// }
|
|
7832
|
+
// if (this.options.orientation === 'vertical') {
|
|
7833
|
+
// this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
|
|
7834
|
+
// if (typeof b.valueCount === 'undefined') {
|
|
7835
|
+
// return a + 1
|
|
7836
|
+
// }
|
|
7837
|
+
// return a + b.valueCount
|
|
7838
|
+
// }, 0)
|
|
7839
|
+
// if (this.options.maxBandWidth) {
|
|
7840
|
+
// this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.totalValueCount) * this.options.maxBandWidth)
|
|
7841
|
+
// }
|
|
7842
|
+
// // some if to check if brushing is needed
|
|
7843
|
+
// if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
|
|
7844
|
+
// this.brushNeeded = true
|
|
7845
|
+
// this.plotHeight -= this.options.brushHeight
|
|
7846
|
+
// }
|
|
7847
|
+
// }
|
|
7848
|
+
// else {
|
|
7849
|
+
// // some if to check if brushing is needed
|
|
7850
|
+
// this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
|
|
7851
|
+
// if (typeof b.valueCount === 'undefined') {
|
|
7852
|
+
// return a + 1
|
|
7853
|
+
// }
|
|
7854
|
+
// return a + b.valueCount
|
|
7855
|
+
// }, 0)
|
|
7856
|
+
// if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
|
|
7857
|
+
// this.brushNeeded = true
|
|
7858
|
+
// this.plotWidth -= this.options.brushHeight
|
|
7859
|
+
// }
|
|
7860
|
+
// }
|
|
7701
7861
|
// Translate the layers
|
|
7702
7862
|
this.leftAxisLayer
|
|
7703
7863
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
|
|
@@ -7732,6 +7892,14 @@ else {
|
|
|
7732
7892
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop})`)
|
|
7733
7893
|
this.brushLayer
|
|
7734
7894
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height})`)
|
|
7895
|
+
this.clip
|
|
7896
|
+
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, 0)`)
|
|
7897
|
+
.attr('width', this.plotWidth)
|
|
7898
|
+
.attr('height', this.plotHeight + this.options.margin.top + this.options.margin.axisTop)
|
|
7899
|
+
this.xAxisClip
|
|
7900
|
+
.attr('transform', `translate(${this.options.margin.left}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight})`)
|
|
7901
|
+
.attr('width', this.plotWidth + this.options.margin.axisLeft)
|
|
7902
|
+
.attr('height', longestBottomBounds.height + 10)
|
|
7735
7903
|
this.brushClip
|
|
7736
7904
|
.attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height})`)
|
|
7737
7905
|
.attr('width', this.plotWidth)
|
|
@@ -7748,39 +7916,80 @@ else {
|
|
|
7748
7916
|
// this.tooltip.transform(this.options.margin.left + this.options.margin.axisLeft, this.options.margin.top + this.options.margin.axisTop)
|
|
7749
7917
|
// Configure the bottom axis
|
|
7750
7918
|
let bottomDomain = this.createDomain('bottom')
|
|
7751
|
-
let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7919
|
+
// let bottomBrushDomain = this.createDomain('bottom', true)
|
|
7920
|
+
let bottomBrushDomain = this.createDomain('bottom')
|
|
7752
7921
|
let bottomRange = [0, this.plotWidth]
|
|
7922
|
+
let bottomBrushRange = [0, this.plotWidth]
|
|
7923
|
+
let leftRange = [this.plotHeight, 0]
|
|
7924
|
+
let leftBrushRange = [this.options.brushHeight, 0]
|
|
7925
|
+
if (this.options.orientation === 'horizontal') {
|
|
7926
|
+
leftBrushRange = [this.plotHeight, 0]
|
|
7927
|
+
}
|
|
7928
|
+
this.widthForCalc = (proposedBandWidth * noOfPoints) // + totalPadding
|
|
7753
7929
|
this.customBottomRange = []
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
this.options.
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7930
|
+
this.customBottomDetailRange = []
|
|
7931
|
+
this.customBottomBrushRange = []
|
|
7932
|
+
this.customLeftRange = []
|
|
7933
|
+
this.customLeftDetailRange = []
|
|
7934
|
+
this.customLeftBrushRange = []
|
|
7935
|
+
// if (this.options.allowUnevenBands === true) {
|
|
7936
|
+
// always allow uneven bands
|
|
7937
|
+
let customRangeSide = 'Bottom'
|
|
7938
|
+
let customRangeSideLC = 'bottom'
|
|
7939
|
+
if (this.options.orientation === 'horizontal') {
|
|
7940
|
+
customRangeSide = 'Left'
|
|
7941
|
+
customRangeSideLC = 'left'
|
|
7942
|
+
}
|
|
7943
|
+
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') {
|
|
7944
|
+
let acc = 0
|
|
7945
|
+
this[`custom${customRangeSide}Range`] = [0, ...this.options.data[customRangeSideLC].data.map((d, index, arr) => {
|
|
7946
|
+
let adjustment = (this.bandPadding * index) + this.bandPadding
|
|
7947
|
+
// if (this.options.data.bottom.padding) {
|
|
7948
|
+
// adjustment = (this.widthForCalc * this.options.data.bottom.padding) / (arr.length * 2)
|
|
7949
|
+
// }
|
|
7950
|
+
let start = (this.widthForCalc / noOfPoints) * acc
|
|
7951
|
+
for (let i = 0; i < (d.valueCount || 1); i++) {
|
|
7952
|
+
let pos = i * proposedBandWidth
|
|
7953
|
+
this[`custom${customRangeSide}DetailRange`].push(start + adjustment + pos)
|
|
7954
|
+
}
|
|
7955
|
+
acc += (this.options.grouping !== 'stacked' ? (d.valueCount || 1) : 1)
|
|
7956
|
+
let end = (this.widthForCalc / noOfPoints) * acc
|
|
7957
|
+
// this.customBottomBrushRange.push((end + adjustment) * (this.plotWidth / this.widthForCalc))
|
|
7958
|
+
return end + adjustment
|
|
7959
|
+
})]
|
|
7960
|
+
acc = 0
|
|
7961
|
+
this[`custom${customRangeSide}BrushRange`] = [0, ...this.options.data[customRangeSideLC].data.map((d, index, arr) => {
|
|
7962
|
+
let adjustment = (this.brushBandPadding * index) + this.brushBandPadding
|
|
7963
|
+
acc += (this.options.grouping !== 'stacked' ? (d.valueCount || 1) : 1)
|
|
7964
|
+
return ((this.options.orientation === 'vertical' ? this.plotWidth : this.plotHeight) / noOfPoints) * acc
|
|
7965
|
+
})]
|
|
7776
7966
|
}
|
|
7777
|
-
|
|
7967
|
+
// }
|
|
7968
|
+
let rangeLength = bottomDomain.length
|
|
7969
|
+
this.options.data.bottomBrush = {}
|
|
7970
|
+
this.options.data.leftBrush = {}
|
|
7971
|
+
if (this.options.orientation === 'vertical') {
|
|
7972
|
+
this.options.data.bottom.bandWidth = proposedBandWidth
|
|
7973
|
+
this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints
|
|
7974
|
+
}
|
|
7975
|
+
else {
|
|
7976
|
+
this.options.data.left.bandWidth = proposedBandWidth
|
|
7977
|
+
this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints
|
|
7978
|
+
}
|
|
7979
|
+
this.brushBandPadding = this.totalBandPadding / noOfGroups
|
|
7980
|
+
if (this.options.orientation === 'vertical') {
|
|
7981
|
+
bottomRange = [0, (this.widthForCalc + this.totalBandPadding)]
|
|
7982
|
+
}
|
|
7983
|
+
else {
|
|
7984
|
+
leftRange = [(this.widthForCalc + this.totalBandPadding), 0]
|
|
7985
|
+
}
|
|
7986
|
+
this.bottomAxis = d3[`scale${this.options.data.bottom.scale || 'Ordinal'}`]()
|
|
7778
7987
|
.domain(bottomDomain)
|
|
7779
7988
|
.range(bottomRange)
|
|
7780
7989
|
if (!this.brushInitialized) {
|
|
7781
|
-
this.bottomBrushAxis = d3[`scale${this.options.data.bottom.scale || '
|
|
7990
|
+
this.bottomBrushAxis = d3[`scale${this.options.data.bottom.scale || 'Ordinal'}`]()
|
|
7782
7991
|
.domain(bottomBrushDomain)
|
|
7783
|
-
.range(
|
|
7992
|
+
.range(bottomBrushRange)
|
|
7784
7993
|
}
|
|
7785
7994
|
if (this.bottomAxis.nice) {
|
|
7786
7995
|
// this.bottomAxis.nice()
|
|
@@ -7799,71 +8008,71 @@ else {
|
|
|
7799
8008
|
brushThickness = this.plotHeight
|
|
7800
8009
|
}
|
|
7801
8010
|
else {
|
|
7802
|
-
if (
|
|
7803
|
-
brushEnd = this.plotWidth * (
|
|
8011
|
+
if (this.brushNeeded) {
|
|
8012
|
+
brushEnd = this.plotWidth * (this.plotWidth / (this.widthForCalc + this.totalBandPadding))
|
|
7804
8013
|
}
|
|
7805
8014
|
}
|
|
7806
8015
|
this.brush = d3[brushMethod]()
|
|
7807
8016
|
.extent([
|
|
7808
8017
|
[0, 0],
|
|
7809
8018
|
[brushLength, brushThickness]
|
|
7810
|
-
])
|
|
8019
|
+
])
|
|
7811
8020
|
.on('brush end', this.brushed)
|
|
7812
|
-
const brushResizePath = d => {
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
}
|
|
7850
|
-
this.brushHandle = this.brushLayer
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
this.brushHandle = this.brushLayer
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
8021
|
+
// const brushResizePath = d => {
|
|
8022
|
+
// let e = +(d.type === 'e')
|
|
8023
|
+
// let x = e ? 1 : -1
|
|
8024
|
+
// let y = this.options.brushHeight
|
|
8025
|
+
// return (
|
|
8026
|
+
// 'M' +
|
|
8027
|
+
// 0.5 * x +
|
|
8028
|
+
// ',' +
|
|
8029
|
+
// y +
|
|
8030
|
+
// 'A6,6 0 0 ' +
|
|
8031
|
+
// e +
|
|
8032
|
+
// ' ' +
|
|
8033
|
+
// 6.5 * x +
|
|
8034
|
+
// ',' +
|
|
8035
|
+
// (y + 6) +
|
|
8036
|
+
// 'V' +
|
|
8037
|
+
// (2 * y - 6) +
|
|
8038
|
+
// 'A6,6 0 0 ' +
|
|
8039
|
+
// e +
|
|
8040
|
+
// ' ' +
|
|
8041
|
+
// 0.5 * x +
|
|
8042
|
+
// ',' +
|
|
8043
|
+
// 2 * y +
|
|
8044
|
+
// 'Z' +
|
|
8045
|
+
// 'M' +
|
|
8046
|
+
// 2.5 * x +
|
|
8047
|
+
// ',' +
|
|
8048
|
+
// (y + 8) +
|
|
8049
|
+
// 'V' +
|
|
8050
|
+
// (2 * y - 8) +
|
|
8051
|
+
// 'M' +
|
|
8052
|
+
// 4.5 * x +
|
|
8053
|
+
// ',' +
|
|
8054
|
+
// (y + 8) +
|
|
8055
|
+
// 'V' +
|
|
8056
|
+
// (2 * y - 8)
|
|
8057
|
+
// )
|
|
8058
|
+
// }
|
|
8059
|
+
// this.brushHandle = this.brushLayer
|
|
8060
|
+
// .select('.brush')
|
|
8061
|
+
// .selectAll('.handle--custom')
|
|
8062
|
+
// .remove()
|
|
8063
|
+
// this.brushHandle = this.brushLayer
|
|
8064
|
+
// .select('.brush')
|
|
8065
|
+
// .selectAll('.handle--custom')
|
|
8066
|
+
// .data([{ type: 'w' }, { type: 'e' }])
|
|
8067
|
+
// .enter()
|
|
8068
|
+
// .append('path')
|
|
8069
|
+
// .attr('class', 'handle--custom')
|
|
8070
|
+
// .attr('stroke', 'transparent')
|
|
8071
|
+
// .attr('fill', 'transparent')
|
|
8072
|
+
// .attr('cursor', 'ew-resize')
|
|
8073
|
+
// .attr('d', brushResizePath)
|
|
7865
8074
|
// BRUSH END
|
|
7866
|
-
// this.
|
|
8075
|
+
// this.brushLayer.selectAll('.handle').remove()
|
|
7867
8076
|
if (this.brushNeeded) {
|
|
7868
8077
|
if (!this.brushInitialized) {
|
|
7869
8078
|
this.brushLayer.style('visibility', 'visible')
|
|
@@ -7873,11 +8082,14 @@ else {
|
|
|
7873
8082
|
.call(this.brush)
|
|
7874
8083
|
.call(this.brush.move, [0, brushEnd])
|
|
7875
8084
|
}
|
|
8085
|
+
else {
|
|
8086
|
+
this.brushLayer.style('visibility', 'visible')
|
|
8087
|
+
}
|
|
7876
8088
|
}
|
|
7877
8089
|
else {
|
|
7878
8090
|
this.brushLayer.style('visibility', 'hidden')
|
|
7879
8091
|
// this.brushLayer.selectAll().remove()
|
|
7880
|
-
this.brushArea.selectAll('*').remove()
|
|
8092
|
+
// this.brushArea.selectAll('*').remove()
|
|
7881
8093
|
}
|
|
7882
8094
|
if (this.options.margin.axisBottom > 0) {
|
|
7883
8095
|
let timeFormatPattern = ''
|
|
@@ -7963,10 +8175,10 @@ else {
|
|
|
7963
8175
|
let rightDomain = this.createDomain('right')
|
|
7964
8176
|
this.leftAxis = d3[`scale${this.options.data.left.scale || 'Linear'}`]()
|
|
7965
8177
|
.domain(leftDomain)
|
|
7966
|
-
.range(
|
|
8178
|
+
.range(leftRange)
|
|
7967
8179
|
this.leftBrushAxis = d3[`scale${this.options.data.left.scale || 'Linear'}`]()
|
|
7968
8180
|
.domain(leftBrushDomain)
|
|
7969
|
-
.range(
|
|
8181
|
+
.range(leftBrushRange)
|
|
7970
8182
|
if (this.leftAxis.padding && this.options.data.left.padding) {
|
|
7971
8183
|
this.leftAxis.padding(this.options.data.left.padding || 0)
|
|
7972
8184
|
}
|
|
@@ -7983,7 +8195,11 @@ else {
|
|
|
7983
8195
|
}
|
|
7984
8196
|
return d
|
|
7985
8197
|
})
|
|
7986
|
-
)
|
|
8198
|
+
)
|
|
8199
|
+
if (this.customLeftRange.length > 0) {
|
|
8200
|
+
this.leftAxisLayer.selectAll('g')
|
|
8201
|
+
.attr('transform', (d, i) => `translate(0, ${this.customLeftRange[i] + ((this.customLeftRange[i + 1] - this.customLeftRange[i]) / 2)})`)
|
|
8202
|
+
}
|
|
7987
8203
|
}
|
|
7988
8204
|
if (this.options.data.left && this.options.data.left.showTitle === true) {
|
|
7989
8205
|
this.leftAxisLabel.selectAll('.title').remove()
|
|
@@ -8079,7 +8295,11 @@ else {
|
|
|
8079
8295
|
for (const key in this.renderedKeys) {
|
|
8080
8296
|
if (newKeys.indexOf(key) === -1) {
|
|
8081
8297
|
// remove the components
|
|
8082
|
-
this[`remove${this.renderedKeys[key]}`](key)
|
|
8298
|
+
// this[`remove${this.renderedKeys[key]}`](key)
|
|
8299
|
+
this.removeline(key)
|
|
8300
|
+
this.removebar(key)
|
|
8301
|
+
this.removesymbol(key)
|
|
8302
|
+
this.removelabel(key)
|
|
8083
8303
|
}
|
|
8084
8304
|
}
|
|
8085
8305
|
this.renderComponents()
|
|
@@ -8114,7 +8334,13 @@ const drawArea = (xAxis, yAxis, curveStyle) => {
|
|
|
8114
8334
|
return d3
|
|
8115
8335
|
.area()
|
|
8116
8336
|
.x(d => {
|
|
8117
|
-
return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
8337
|
+
// return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
8338
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8339
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8340
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8341
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8342
|
+
}
|
|
8343
|
+
return xPos
|
|
8118
8344
|
})
|
|
8119
8345
|
.y0(d => {
|
|
8120
8346
|
return this[`${yAxis}Axis`](0)
|
|
@@ -8142,7 +8368,7 @@ areas
|
|
|
8142
8368
|
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8143
8369
|
// .attr('id', `line_${series.key}`)
|
|
8144
8370
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8145
|
-
|
|
8371
|
+
.attr('fill', d => d[0].y.color || series.color)
|
|
8146
8372
|
// .attr('stroke', 'transparent')
|
|
8147
8373
|
.transition(this.transition)
|
|
8148
8374
|
.attr('d', d => drawArea(xAxis, yAxis, series.curveStyle)(d))
|
|
@@ -8151,13 +8377,13 @@ areas.enter().append('path')
|
|
|
8151
8377
|
.attr('d', d => drawArea(xAxis, yAxis, series.curveStyle)(d))
|
|
8152
8378
|
.attr('class', `area_${series.key}`)
|
|
8153
8379
|
.attr('id', `area_${series.key}`)
|
|
8154
|
-
.attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis
|
|
8380
|
+
// .attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2) + ',0)')
|
|
8155
8381
|
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8156
|
-
.attr('fill', series.color)
|
|
8382
|
+
.attr('fill', d => d[0].y.color || series.color)
|
|
8157
8383
|
// .style('fill-opacity', 0)
|
|
8158
8384
|
.attr('stroke', 'transparent')
|
|
8159
8385
|
// .transition(this.transition)
|
|
8160
|
-
.style('fill-opacity', series.opacity || 0.
|
|
8386
|
+
.style('fill-opacity', series.opacity || 0.3)
|
|
8161
8387
|
|
|
8162
8388
|
}
|
|
8163
8389
|
renderbar (series, index) {
|
|
@@ -8171,13 +8397,10 @@ if (this.options.orientation === 'horizontal') {
|
|
|
8171
8397
|
xAxis = 'left'
|
|
8172
8398
|
yAxis = 'bottom'
|
|
8173
8399
|
}
|
|
8174
|
-
|
|
8175
|
-
// barWidth = barWidth / this.options.data.series.length - 4
|
|
8176
|
-
// }
|
|
8177
|
-
function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
8400
|
+
function getBarHeight (d, i, yAxis, xAxis) {
|
|
8178
8401
|
let output
|
|
8179
8402
|
if (this.options.orientation === 'horizontal') {
|
|
8180
|
-
output = this.options.data[xAxis.
|
|
8403
|
+
output = Math.max(1, this.options.data[xAxis].bandWidth - (xAxis.indexOf('Brush') !== -1 ? 2 : this.options.groupPadding * 2))
|
|
8181
8404
|
}
|
|
8182
8405
|
else {
|
|
8183
8406
|
let x = getBarX.call(this, d, i, xAxis)
|
|
@@ -8194,37 +8417,33 @@ function getBarHeight (d, i, heightBounds, yAxis, xAxis) {
|
|
|
8194
8417
|
function getBarWidth (d, i, xAxis) {
|
|
8195
8418
|
let output
|
|
8196
8419
|
if (this.options.orientation === 'horizontal') {
|
|
8197
|
-
|
|
8198
|
-
acummulativeY[d.y.index] += width
|
|
8199
|
-
output = width
|
|
8420
|
+
output = this[`${yAxis}Axis`](Math.abs(d.y.value))
|
|
8200
8421
|
}
|
|
8201
8422
|
else {
|
|
8202
8423
|
let x = getBarX.call(this, d, i, xAxis)
|
|
8203
8424
|
if (typeof x === 'undefined' || x === null) {
|
|
8204
8425
|
return null
|
|
8205
8426
|
}
|
|
8206
|
-
output = Math.max(1, this.options.data[xAxis.
|
|
8427
|
+
output = Math.max(1, this.options.data[xAxis].bandWidth - (xAxis.indexOf('Brush') !== -1 ? 2 : this.options.groupPadding * 2))
|
|
8207
8428
|
}
|
|
8208
8429
|
if (isNaN(output)) {
|
|
8209
8430
|
return 0
|
|
8210
8431
|
}
|
|
8211
8432
|
return output
|
|
8212
8433
|
}
|
|
8213
|
-
function getBarX (d, i, xAxis) {
|
|
8214
|
-
// let barWidth = this.plotWidth / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
8215
|
-
// if (this.options.data[xAxis.replace('Brush', '')].padding) {
|
|
8216
|
-
// barWidth = barWidth - (barWidth * this.options.data[xAxis.replace('Brush', '')].padding)
|
|
8217
|
-
// }
|
|
8218
|
-
// let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
8434
|
+
function getBarX (d, i, xAxis) {
|
|
8219
8435
|
let output
|
|
8220
8436
|
if (this.options.orientation === 'horizontal') {
|
|
8221
8437
|
if (this.options.grouping === 'stacked') {
|
|
8222
|
-
let h = getBarWidth.call(this, d, i, xAxis)
|
|
8223
|
-
let adjustment = 0
|
|
8224
|
-
if (d.y.accumulative && d.y.accumulative !== 0) {
|
|
8225
|
-
|
|
8226
|
-
}
|
|
8227
|
-
output = this[`${yAxis}Axis`](0) + (adjustment * (d.y.value < 0 ? 1 : 0)) + (h * (d.y.value < 0 ? 1 : 0))
|
|
8438
|
+
// let h = getBarWidth.call(this, d, i, xAxis)
|
|
8439
|
+
// let adjustment = 0
|
|
8440
|
+
// if (d.y.accumulative && d.y.accumulative !== 0) {
|
|
8441
|
+
// adjustment = this[`${yAxis}Axis`](d.y.accumulative || 0)
|
|
8442
|
+
// }
|
|
8443
|
+
// output = this[`${yAxis}Axis`](0) + (adjustment * (d.y.value < 0 ? 1 : 0)) + (h * (d.y.value < 0 ? 1 : 0))
|
|
8444
|
+
let accH = getBarWidth.call(this, {x: d.x, y: { value: d.y.accumulative }}, i, xAxis)
|
|
8445
|
+
// let h = getBarWidth.call(this, d, i, xAxis)
|
|
8446
|
+
output = (accH * (d.y.accumulative < 0 ? 0 : 1))
|
|
8228
8447
|
}
|
|
8229
8448
|
else {
|
|
8230
8449
|
let h = getBarWidth.call(this, d, i, xAxis)
|
|
@@ -8233,22 +8452,24 @@ function getBarX (d, i, xAxis) {
|
|
|
8233
8452
|
}
|
|
8234
8453
|
else {
|
|
8235
8454
|
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
|
|
8236
|
-
let adjustment = this.
|
|
8455
|
+
// let adjustment = this[`custom${xAxis.toInitialCaps()}Range`][i] + (i * this.options.data[xAxis].bandWidth)
|
|
8237
8456
|
if (this.options.grouping === 'grouped') {
|
|
8238
8457
|
let xIndex = 0
|
|
8239
8458
|
if (this.processedX[d.x.value]) {
|
|
8240
8459
|
xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel))
|
|
8241
8460
|
}
|
|
8242
|
-
let barAdjustment =
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8461
|
+
// let barAdjustment =
|
|
8462
|
+
// (this.options.data[xAxis].bandWidth * xIndex) +
|
|
8463
|
+
// (xIndex * this.options.groupPadding * 2) + this.options.groupPadding +
|
|
8464
|
+
// (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
8246
8465
|
// let barAdjustment =
|
|
8247
8466
|
// (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
|
|
8248
8467
|
// this.options.groupPadding
|
|
8249
8468
|
// // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
8250
|
-
|
|
8251
|
-
|
|
8469
|
+
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)
|
|
8470
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`].length > 0) {
|
|
8471
|
+
output = this[`custom${xAxis.toInitialCaps()}Range`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
|
|
8472
|
+
// output = this[`custom${xAxis.toInitialCaps().replace('Brush', '')}DetailRange`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)]
|
|
8252
8473
|
}
|
|
8253
8474
|
else {
|
|
8254
8475
|
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + barAdjustment
|
|
@@ -8259,11 +8480,11 @@ function getBarX (d, i, xAxis) {
|
|
|
8259
8480
|
if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
|
|
8260
8481
|
this.processedX[d.x.value].push(d.y.tooltipLabel)
|
|
8261
8482
|
}
|
|
8262
|
-
console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
|
|
8483
|
+
// console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
|
|
8263
8484
|
}
|
|
8264
|
-
else {
|
|
8265
|
-
|
|
8266
|
-
output = this[
|
|
8485
|
+
else {
|
|
8486
|
+
let barAdjustment = ((xAxis.indexOf('Brush') !== -1 ? this.brushBandPadding : this.bandPadding) / 2) + (xAxis.indexOf('Brush') !== -1 ? 1 : this.options.groupPadding)
|
|
8487
|
+
output = this[`custom${xAxis.toInitialCaps()}Range`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
|
|
8267
8488
|
}
|
|
8268
8489
|
}
|
|
8269
8490
|
if (isNaN(output)) {
|
|
@@ -8271,13 +8492,12 @@ function getBarX (d, i, xAxis) {
|
|
|
8271
8492
|
}
|
|
8272
8493
|
return output
|
|
8273
8494
|
}
|
|
8274
|
-
function getBarY (d, i,
|
|
8275
|
-
// let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
8276
|
-
// let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
8495
|
+
function getBarY (d, i, yAxis, xAxis) {
|
|
8277
8496
|
let output
|
|
8278
8497
|
if (this.options.orientation === 'horizontal') {
|
|
8279
8498
|
if (this.options.grouping !== 'grouped') {
|
|
8280
|
-
|
|
8499
|
+
let barAdjustment = ((xAxis.indexOf('Brush') !== -1 ? this.brushBandPadding : this.bandPadding) / 2) + (xAxis.indexOf('Brush') !== -1 ? 1 : this.options.groupPadding)
|
|
8500
|
+
output = this[`custom${xAxis.toInitialCaps()}Range`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment
|
|
8281
8501
|
}
|
|
8282
8502
|
else {
|
|
8283
8503
|
output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + ((d.y.index || i) * this.options.data[xAxis.replace('Brush', '')].barWidth)
|
|
@@ -8285,10 +8505,12 @@ function getBarY (d, i, heightBounds, yAxis, xAxis) {
|
|
|
8285
8505
|
}
|
|
8286
8506
|
else {
|
|
8287
8507
|
if (this.options.grouping === 'stacked') {
|
|
8288
|
-
|
|
8508
|
+
let accH = getBarHeight.call(this, {x: d.x, y: { value: d.y.accumulative }}, i, yAxis, xAxis)
|
|
8509
|
+
let h = getBarHeight.call(this, d, i, yAxis, xAxis)
|
|
8510
|
+
output = (this[`${yAxis}Axis`](0)) - ((accH + h) * (d.y.accumulative < 0 ? 0 : 1))
|
|
8289
8511
|
}
|
|
8290
8512
|
else {
|
|
8291
|
-
let h = getBarHeight.call(this, d, i,
|
|
8513
|
+
let h = getBarHeight.call(this, d, i, yAxis, xAxis)
|
|
8292
8514
|
output = (this[`${yAxis}Axis`](0)) - (h * (d.y.value < 0 ? 0 : 1))
|
|
8293
8515
|
}
|
|
8294
8516
|
}
|
|
@@ -8305,9 +8527,9 @@ bars
|
|
|
8305
8527
|
|
|
8306
8528
|
bars
|
|
8307
8529
|
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
|
|
8308
|
-
.attr('height', (d, i) => getBarHeight.call(this, d, i,
|
|
8530
|
+
.attr('height', (d, i) => getBarHeight.call(this, d, i, yAxis, xAxis))
|
|
8309
8531
|
.attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
|
|
8310
|
-
.attr('y', (d, i) => getBarY.call(this, d, i,
|
|
8532
|
+
.attr('y', (d, i) => getBarY.call(this, d, i, yAxis, xAxis))
|
|
8311
8533
|
// .transition(this.transition)
|
|
8312
8534
|
.attr('fill', d => d.y.color || d.color || series.color)
|
|
8313
8535
|
|
|
@@ -8315,9 +8537,9 @@ bars
|
|
|
8315
8537
|
.enter()
|
|
8316
8538
|
.append('rect')
|
|
8317
8539
|
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, xAxis)))
|
|
8318
|
-
.attr('height', (d, i) => getBarHeight.call(this, d, i,
|
|
8540
|
+
.attr('height', (d, i) => getBarHeight.call(this, d, i, yAxis, xAxis))
|
|
8319
8541
|
.attr('x', (d, i) => getBarX.call(this, d, i, xAxis))
|
|
8320
|
-
.attr('y', (d, i) => getBarY.call(this, d, i,
|
|
8542
|
+
.attr('y', (d, i) => getBarY.call(this, d, i, yAxis, xAxis))
|
|
8321
8543
|
// .transition(this.transition)
|
|
8322
8544
|
.attr('fill', d => d.y.color || d.color || series.color)
|
|
8323
8545
|
.attr('class', d => {
|
|
@@ -8334,9 +8556,9 @@ if (!this.brushBarsInitialized[series.key]) {
|
|
|
8334
8556
|
|
|
8335
8557
|
brushBars
|
|
8336
8558
|
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
|
|
8337
|
-
.attr('height', (d, i) => getBarHeight.call(this, d, i,
|
|
8559
|
+
.attr('height', (d, i) => getBarHeight.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
8338
8560
|
.attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
|
|
8339
|
-
.attr('y', (d, i) => getBarY.call(this, d, i,
|
|
8561
|
+
.attr('y', (d, i) => getBarY.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
8340
8562
|
// .transition(this.transition)
|
|
8341
8563
|
.attr('fill', d => d.y.color || d.color || series.color)
|
|
8342
8564
|
|
|
@@ -8344,9 +8566,9 @@ if (!this.brushBarsInitialized[series.key]) {
|
|
|
8344
8566
|
.enter()
|
|
8345
8567
|
.append('rect')
|
|
8346
8568
|
.attr('width', (d, i) => Math.abs(getBarWidth.call(this, d, i, `${xAxis}Brush`)))
|
|
8347
|
-
.attr('height', (d, i) => getBarHeight.call(this, d, i,
|
|
8569
|
+
.attr('height', (d, i) => getBarHeight.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
8348
8570
|
.attr('x', (d, i) => getBarX.call(this, d, i, `${xAxis}Brush`))
|
|
8349
|
-
.attr('y', (d, i) => getBarY.call(this, d, i,
|
|
8571
|
+
.attr('y', (d, i) => getBarY.call(this, d, i, `${yAxis}Brush`, `${xAxis}Brush`))
|
|
8350
8572
|
// .transition(this.transition)
|
|
8351
8573
|
.attr('fill', d => d.y.color || d.color || series.color)
|
|
8352
8574
|
.attr('class', d => {
|
|
@@ -8365,12 +8587,12 @@ let bars = this.barLayer.selectAll(`.bar_${key}`)
|
|
|
8365
8587
|
}
|
|
8366
8588
|
renderLabels (series, index) {
|
|
8367
8589
|
/* global series index d3 WebsyDesigns */
|
|
8368
|
-
let xAxis = '
|
|
8369
|
-
let yAxis = '
|
|
8590
|
+
let xAxis = 'bottom'
|
|
8591
|
+
let yAxis = 'left'
|
|
8370
8592
|
let that = this
|
|
8371
8593
|
if (this.options.orientation === 'horizontal') {
|
|
8372
|
-
xAxis = '
|
|
8373
|
-
yAxis = '
|
|
8594
|
+
xAxis = 'left'
|
|
8595
|
+
yAxis = 'bottom'
|
|
8374
8596
|
}
|
|
8375
8597
|
if (this.options.showLabels === true || series.showLabels === true) {
|
|
8376
8598
|
// need to add logic to handle positioning options
|
|
@@ -8460,6 +8682,9 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
8460
8682
|
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
8461
8683
|
this.setAttribute('y', +(this.getAttribute('y')) + 8)
|
|
8462
8684
|
}
|
|
8685
|
+
if (series.labelPosition !== 'outside') {
|
|
8686
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
8687
|
+
}
|
|
8463
8688
|
}
|
|
8464
8689
|
})
|
|
8465
8690
|
}
|
|
@@ -8467,26 +8692,40 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
8467
8692
|
function getLabelX (d, labelPosition = 'inside') {
|
|
8468
8693
|
if (this.options.orientation === 'horizontal') {
|
|
8469
8694
|
if (this.options.grouping === 'stacked') {
|
|
8470
|
-
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
8695
|
+
return this[yAxis + 'Axis'](d.y.accumulative) + (this[yAxis + 'Axis'](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
8471
8696
|
}
|
|
8472
8697
|
else {
|
|
8473
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4
|
|
8698
|
+
return this[yAxis + 'Axis'](isNaN(d.y.value) ? 0 : d.y.value) + 4
|
|
8474
8699
|
}
|
|
8475
8700
|
}
|
|
8476
8701
|
else {
|
|
8477
|
-
return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
8702
|
+
// return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
8703
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8704
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8705
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8706
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8707
|
+
}
|
|
8708
|
+
return xPos
|
|
8478
8709
|
}
|
|
8479
8710
|
}
|
|
8480
8711
|
function getLabelY (d, labelPosition = 'inside') {
|
|
8481
8712
|
if (this.options.orientation === 'horizontal') {
|
|
8482
|
-
|
|
8713
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8714
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8715
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8716
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8717
|
+
}
|
|
8718
|
+
return xPos
|
|
8483
8719
|
}
|
|
8484
8720
|
else {
|
|
8485
8721
|
if (this.options.grouping === 'stacked') {
|
|
8486
|
-
|
|
8722
|
+
let accH = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.accumulative))
|
|
8723
|
+
let h = (this[`${yAxis}Axis`](0)) - this[`${yAxis}Axis`](Math.abs(d.y.value))
|
|
8724
|
+
return (this[`${yAxis}Axis`](0)) - ((accH + h - (labelPosition === 'inside' ? h / 2 : 0)) * (d.y.accumulative < 0 ? 0 : 1))
|
|
8725
|
+
// return (this[`${yAxis}Axis`](0)) - (this[yAxis + 'Axis'](d.y.accumulative) - (this[yAxis + 'Axis'](d.y.value))) // / (labelPosition === 'inside' ? 2 : 1)))
|
|
8487
8726
|
}
|
|
8488
8727
|
else {
|
|
8489
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize)
|
|
8728
|
+
return this[yAxis + 'Axis'](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize)
|
|
8490
8729
|
}
|
|
8491
8730
|
}
|
|
8492
8731
|
}
|
|
@@ -8502,13 +8741,19 @@ const drawLine = (xAxis, yAxis, curveStyle) => {
|
|
|
8502
8741
|
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
8503
8742
|
}
|
|
8504
8743
|
else {
|
|
8505
|
-
let
|
|
8506
|
-
|
|
8744
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8745
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8746
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8747
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8748
|
+
}
|
|
8749
|
+
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8750
|
+
// return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8751
|
+
return xPos
|
|
8507
8752
|
}
|
|
8508
8753
|
})
|
|
8509
8754
|
.y(d => {
|
|
8510
8755
|
if (this.options.orientation === 'horizontal') {
|
|
8511
|
-
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this[
|
|
8756
|
+
let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8512
8757
|
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
8513
8758
|
}
|
|
8514
8759
|
else {
|
|
@@ -8543,7 +8788,7 @@ lines
|
|
|
8543
8788
|
.style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8544
8789
|
// .attr('id', `line_${series.key}`)
|
|
8545
8790
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8546
|
-
.attr('stroke', series.color)
|
|
8791
|
+
.attr('stroke', d => d[0].y.color || series.color)
|
|
8547
8792
|
.attr('fill', 'transparent')
|
|
8548
8793
|
.transition(this.transition)
|
|
8549
8794
|
.attr('d', d => drawLine(xAxis, yAxis, series.curveStyle)(d))
|
|
@@ -8554,7 +8799,7 @@ lines.enter().append('path')
|
|
|
8554
8799
|
.attr('id', `line_${series.key}`)
|
|
8555
8800
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8556
8801
|
.style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8557
|
-
.attr('stroke', series.color)
|
|
8802
|
+
.attr('stroke', d => d[0].y.color || series.color)
|
|
8558
8803
|
.attr('fill', 'transparent')
|
|
8559
8804
|
// .transition(this.transition)
|
|
8560
8805
|
.style('stroke-opacity', 1)
|
|
@@ -8645,6 +8890,26 @@ let lines = this.lineLayer.selectAll(`.line_${key}`)
|
|
|
8645
8890
|
.transition(this.transition)
|
|
8646
8891
|
.style('stroke-opacity', 1e-6)
|
|
8647
8892
|
.remove()
|
|
8893
|
+
let areas = this.areaLayer.selectAll(`.area_${key}`)
|
|
8894
|
+
.transition(this.transition)
|
|
8895
|
+
.style('stroke-opacity', 1e-6)
|
|
8896
|
+
.remove()
|
|
8897
|
+
|
|
8898
|
+
}
|
|
8899
|
+
removelabel (key) {
|
|
8900
|
+
/* global key d3 */
|
|
8901
|
+
let labels = this.labelLayer.selectAll(`.label_${key}`)
|
|
8902
|
+
.transition(this.transition)
|
|
8903
|
+
.style('stroke-opacity', 1e-6)
|
|
8904
|
+
.remove()
|
|
8905
|
+
|
|
8906
|
+
}
|
|
8907
|
+
removesymbol (key) {
|
|
8908
|
+
/* global key d3 */
|
|
8909
|
+
let symbols = this.symbolLayer.selectAll(`.symbol_${key}`)
|
|
8910
|
+
.transition(this.transition)
|
|
8911
|
+
.style('stroke-opacity', 1e-6)
|
|
8912
|
+
.remove()
|
|
8648
8913
|
|
|
8649
8914
|
}
|
|
8650
8915
|
rendersymbol (series, index) {
|
|
@@ -8677,12 +8942,25 @@ symbols
|
|
|
8677
8942
|
.attr('fill', series.fillSymbols ? series.color : 'white')
|
|
8678
8943
|
.attr('stroke', series.color)
|
|
8679
8944
|
.attr('transform', d => {
|
|
8680
|
-
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this[
|
|
8945
|
+
// let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8946
|
+
// if (this.options.orientation === 'horizontal') {
|
|
8947
|
+
// return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
|
|
8948
|
+
// }
|
|
8949
|
+
// else {
|
|
8950
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8951
|
+
// }
|
|
8952
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8953
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8954
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8955
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8956
|
+
}
|
|
8957
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8681
8958
|
if (this.options.orientation === 'horizontal') {
|
|
8682
|
-
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${
|
|
8959
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${xPos})`
|
|
8683
8960
|
}
|
|
8684
8961
|
else {
|
|
8685
|
-
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8962
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8963
|
+
return `translate(${xPos}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8686
8964
|
}
|
|
8687
8965
|
})
|
|
8688
8966
|
// Enter
|
|
@@ -8694,12 +8972,18 @@ symbols.enter()
|
|
|
8694
8972
|
.attr('stroke', series.color)
|
|
8695
8973
|
.attr('class', d => { return `symbol symbol_${series.key}` })
|
|
8696
8974
|
.attr('transform', d => {
|
|
8697
|
-
let
|
|
8975
|
+
let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
|
|
8976
|
+
let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
|
|
8977
|
+
if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
|
|
8978
|
+
xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
|
|
8979
|
+
}
|
|
8980
|
+
let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
8698
8981
|
if (this.options.orientation === 'horizontal') {
|
|
8699
|
-
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${
|
|
8982
|
+
return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${xPos})`
|
|
8700
8983
|
}
|
|
8701
8984
|
else {
|
|
8702
|
-
return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8985
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8986
|
+
return `translate(${xPos}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
8703
8987
|
}
|
|
8704
8988
|
})
|
|
8705
8989
|
|
|
@@ -9366,3 +9650,9 @@ function usePayPal () {
|
|
|
9366
9650
|
pps.src = '//www.paypal.com/sdk/js'
|
|
9367
9651
|
document.getElementsByTagName('body')[0].appendChild(pps)
|
|
9368
9652
|
}
|
|
9653
|
+
|
|
9654
|
+
String.prototype.toInitialCaps = function () {
|
|
9655
|
+
let letters = this.split('')
|
|
9656
|
+
let initial = letters.shift().toUpperCase()
|
|
9657
|
+
return initial + letters.join('')
|
|
9658
|
+
}
|