@websy/websy-designs 1.3.12 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/websy-designs-es6.debug.js +197 -76
- package/dist/websy-designs-es6.js +192 -71
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +206 -76
- package/dist/websy-designs.js +203 -71
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -2465,6 +2465,33 @@ const WebsyIcons = {
|
|
|
2465
2465
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 500 500">
|
|
2466
2466
|
<path d="M15,255.1v-10.3c0-5.5,4.5-10,10-10h450c5.5,0,10,4.5,10,10v10.3c0,5.5-4.5,10-10,10H25C19.5,265.1,15,260.7,15,255.1z"/>
|
|
2467
2467
|
</svg>
|
|
2468
|
+
`,
|
|
2469
|
+
'PlusFilled': `
|
|
2470
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2471
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
2472
|
+
viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
|
|
2473
|
+
<style type="text/css">
|
|
2474
|
+
.st0{fill:#FFFFFF;}
|
|
2475
|
+
</style>
|
|
2476
|
+
<circle cx="249.6" cy="251" r="235"/>
|
|
2477
|
+
<path class="st0" d="M422.3,234.8H264.7V78.7c0-4.2-4.5-7.7-10-7.7h-10.3c-5.5,0-10,3.4-10,7.7v156.1H77.7c-4.2,0-7.7,4.5-7.7,10
|
|
2478
|
+
v10.3c0,5.6,3.4,10,7.7,10h156.7v158.2c0,4.2,4.5,7.7,10,7.7h10.3c5.5,0,9.9-3.4,10-7.7V265.1h157.6c4.2,0,7.7-4.5,7.7-10v-10.3
|
|
2479
|
+
C430,239.3,426.6,234.8,422.3,234.8z"/>
|
|
2480
|
+
</svg>
|
|
2481
|
+
|
|
2482
|
+
`,
|
|
2483
|
+
'MinusFilled': `
|
|
2484
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2485
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
2486
|
+
viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
|
|
2487
|
+
<style type="text/css">
|
|
2488
|
+
.st0{fill:#FFFFFF;}
|
|
2489
|
+
</style>
|
|
2490
|
+
<circle cx="250.1" cy="255.4" r="235"/>
|
|
2491
|
+
<path class="st0" d="M70,255.1v-10.3c0-5.5,3.4-10,7.7-10h344.7c4.2,0,7.7,4.5,7.7,10v10.3c0,5.5-3.4,10-7.7,10H77.7
|
|
2492
|
+
C73.4,265.1,70,260.7,70,255.1z"/>
|
|
2493
|
+
</svg>
|
|
2494
|
+
|
|
2468
2495
|
`
|
|
2469
2496
|
}
|
|
2470
2497
|
|
|
@@ -3870,7 +3897,9 @@ class WebsyRouter {
|
|
|
3870
3897
|
const parts = params.split('&')
|
|
3871
3898
|
for (let i = 0; i < parts.length; i++) {
|
|
3872
3899
|
const bits = parts[i].split('=')
|
|
3873
|
-
|
|
3900
|
+
if (bits[0] && bits[0] !== '' && bits[1] && bits[1] !== '') {
|
|
3901
|
+
output.items[bits[0]] = bits[1]
|
|
3902
|
+
}
|
|
3874
3903
|
}
|
|
3875
3904
|
this.currentParams = output
|
|
3876
3905
|
return output
|
|
@@ -3957,18 +3986,30 @@ class WebsyRouter {
|
|
|
3957
3986
|
this.publish('hide', [children[c].view])
|
|
3958
3987
|
}
|
|
3959
3988
|
}
|
|
3960
|
-
hideView (view, group) {
|
|
3989
|
+
hideView (view, group) {
|
|
3990
|
+
if (view === '/' || view === '') {
|
|
3991
|
+
view = this.options.defaultView
|
|
3992
|
+
}
|
|
3961
3993
|
this.hideChildren(view, group)
|
|
3962
|
-
if (this.previousView !== this.currentView) {
|
|
3994
|
+
if (this.previousView !== this.currentView || group !== this.options.defaultGroup) {
|
|
3963
3995
|
this.hideTriggerItems(view, group)
|
|
3964
3996
|
this.hideViewItems(view, group)
|
|
3965
3997
|
this.publish('hide', [view])
|
|
3998
|
+
if (this.options.views && this.options.views[view]) {
|
|
3999
|
+
this.options.views[view].components.forEach(c => {
|
|
4000
|
+
if (typeof c.instance !== 'undefined') {
|
|
4001
|
+
if (c.instance.close) {
|
|
4002
|
+
c.instance.close()
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
})
|
|
4006
|
+
}
|
|
3966
4007
|
}
|
|
3967
|
-
else if (group !== this.options.defaultGroup) {
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
}
|
|
4008
|
+
// else if (group !== this.options.defaultGroup) {
|
|
4009
|
+
// this.hideTriggerItems(view, group)
|
|
4010
|
+
// this.hideViewItems(view, group)
|
|
4011
|
+
// this.publish('hide', [view])
|
|
4012
|
+
// }
|
|
3972
4013
|
}
|
|
3973
4014
|
// registerElements (root) {
|
|
3974
4015
|
// if (root.nodeName === '#document') {
|
|
@@ -4311,6 +4352,7 @@ class WebsySearch {
|
|
|
4311
4352
|
// el.addEventListener('click', this.handleClick.bind(this))
|
|
4312
4353
|
el.addEventListener('click', this.handleClick.bind(this))
|
|
4313
4354
|
el.addEventListener('keyup', this.handleKeyUp.bind(this))
|
|
4355
|
+
el.addEventListener('keyup', this.handleKeyDown.bind(this))
|
|
4314
4356
|
el.innerHTML = `
|
|
4315
4357
|
<div class='websy-search-input-container'>
|
|
4316
4358
|
${this.options.searchIcon}
|
|
@@ -4332,6 +4374,14 @@ class WebsySearch {
|
|
|
4332
4374
|
this.options.onSearch('')
|
|
4333
4375
|
}
|
|
4334
4376
|
}
|
|
4377
|
+
handleKeyDown (event) {
|
|
4378
|
+
if (event.key === 'Enter') {
|
|
4379
|
+
if (this.options.onSubmit) {
|
|
4380
|
+
this.options.onSubmit(event.target.value)
|
|
4381
|
+
return false
|
|
4382
|
+
}
|
|
4383
|
+
}
|
|
4384
|
+
}
|
|
4335
4385
|
handleKeyUp (event) {
|
|
4336
4386
|
if (event.target.classList.contains('websy-search-input')) {
|
|
4337
4387
|
if (this.searchTimeoutFn) {
|
|
@@ -5900,16 +5950,19 @@ class WebsyTable3 {
|
|
|
5900
5950
|
data.forEach((row, rowIndex) => {
|
|
5901
5951
|
bodyHtml += `<tr class="websy-table-row">`
|
|
5902
5952
|
row.forEach((cell, cellIndex) => {
|
|
5903
|
-
|
|
5953
|
+
let sizeIndex = cell.level || cellIndex
|
|
5954
|
+
if (typeof sizingColumns[sizeIndex] === 'undefined') {
|
|
5904
5955
|
return // need to revisit this logic
|
|
5905
5956
|
}
|
|
5906
|
-
let style =
|
|
5957
|
+
let style = `width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important; `
|
|
5958
|
+
let divStyle = style
|
|
5907
5959
|
if (cell.style) {
|
|
5908
5960
|
style += cell.style
|
|
5909
5961
|
}
|
|
5910
5962
|
if (useWidths === true) {
|
|
5911
|
-
style += `max-width: ${sizingColumns[
|
|
5912
|
-
|
|
5963
|
+
style += `max-width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important;`
|
|
5964
|
+
divStyle += `max-width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important;`
|
|
5965
|
+
}
|
|
5913
5966
|
if (cell.backgroundColor) {
|
|
5914
5967
|
style += `background-color: ${cell.backgroundColor}; `
|
|
5915
5968
|
if (!cell.color) {
|
|
@@ -5919,7 +5972,7 @@ class WebsyTable3 {
|
|
|
5919
5972
|
if (cell.color) {
|
|
5920
5973
|
style += `color: ${cell.color}; `
|
|
5921
5974
|
}
|
|
5922
|
-
console.log('rowspan', cell.rowspan)
|
|
5975
|
+
// console.log('rowspan', cell.rowspan)
|
|
5923
5976
|
bodyHtml += `<td
|
|
5924
5977
|
class='websy-table-cell ${(cell.classes || []).join(' ')}'
|
|
5925
5978
|
style='${style}'
|
|
@@ -5936,24 +5989,24 @@ class WebsyTable3 {
|
|
|
5936
5989
|
// `
|
|
5937
5990
|
// }
|
|
5938
5991
|
bodyHtml += `
|
|
5939
|
-
>`
|
|
5992
|
+
><div style='${divStyle}'>`
|
|
5940
5993
|
if (cell.expandable === true) {
|
|
5941
5994
|
bodyHtml += `<i
|
|
5942
5995
|
data-row-index='${rowIndex}'
|
|
5943
|
-
data-col-index='${cellIndex}'
|
|
5996
|
+
data-col-index='${cell.level || cellIndex}'
|
|
5944
5997
|
class='websy-table-cell-expand'
|
|
5945
|
-
>${WebsyDesigns.Icons.
|
|
5998
|
+
>${WebsyDesigns.Icons.PlusFilled}</i>`
|
|
5946
5999
|
}
|
|
5947
6000
|
if (cell.collapsable === true) {
|
|
5948
6001
|
bodyHtml += `<i
|
|
5949
6002
|
data-row-index='${rowIndex}'
|
|
5950
|
-
data-col-index='${cellIndex}'
|
|
6003
|
+
data-col-index='${cell.level || cellIndex}'
|
|
5951
6004
|
class='websy-table-cell-collapse'
|
|
5952
|
-
>${WebsyDesigns.Icons.
|
|
6005
|
+
>${WebsyDesigns.Icons.MinusFilled}</i>`
|
|
5953
6006
|
}
|
|
5954
6007
|
bodyHtml += `
|
|
5955
6008
|
${cell.value}
|
|
5956
|
-
</td>`
|
|
6009
|
+
</div></td>`
|
|
5957
6010
|
})
|
|
5958
6011
|
bodyHtml += `</tr>`
|
|
5959
6012
|
})
|
|
@@ -5979,9 +6032,18 @@ class WebsyTable3 {
|
|
|
5979
6032
|
}
|
|
5980
6033
|
headerHtml += `<tr class="websy-table-row websy-table-header-row">`
|
|
5981
6034
|
row.forEach((col, colIndex) => {
|
|
6035
|
+
let style = `width: ${sizingColumns[colIndex].width || sizingColumns[colIndex].actualWidth}px!important; `
|
|
6036
|
+
let divStyle = style
|
|
6037
|
+
if (useWidths === true) {
|
|
6038
|
+
style += `max-width: ${sizingColumns[colIndex].width || sizingColumns[colIndex].actualWidth}px!important;`
|
|
6039
|
+
divStyle += `max-width: ${sizingColumns[colIndex].width || sizingColumns[colIndex].actualWidth}px!important;`
|
|
6040
|
+
}
|
|
6041
|
+
if (col.style) {
|
|
6042
|
+
style += col.style
|
|
6043
|
+
}
|
|
5982
6044
|
headerHtml += `<td
|
|
5983
6045
|
class='websy-table-cell'
|
|
5984
|
-
style='${
|
|
6046
|
+
style='${style}'
|
|
5985
6047
|
colspan='${col.colspan || 1}'
|
|
5986
6048
|
rowspan='${col.rowspan || 1}'
|
|
5987
6049
|
`
|
|
@@ -5991,13 +6053,7 @@ class WebsyTable3 {
|
|
|
5991
6053
|
// width='${col.width || col.actualWidth}'
|
|
5992
6054
|
// `
|
|
5993
6055
|
// }
|
|
5994
|
-
headerHtml +=
|
|
5995
|
-
>
|
|
5996
|
-
<div>
|
|
5997
|
-
${col.name}
|
|
5998
|
-
${col.searchable === true ? this.buildSearchIcon(col, colIndex) : ''}
|
|
5999
|
-
</div>
|
|
6000
|
-
</td>`
|
|
6056
|
+
headerHtml += `><div style='${divStyle}'>${col.name}${col.searchable === true ? this.buildSearchIcon(col, colIndex) : ''}</div></td>`
|
|
6001
6057
|
})
|
|
6002
6058
|
headerHtml += `</tr>`
|
|
6003
6059
|
})
|
|
@@ -6016,11 +6072,9 @@ class WebsyTable3 {
|
|
|
6016
6072
|
return headerHtml
|
|
6017
6073
|
}
|
|
6018
6074
|
buildSearchIcon (col, index) {
|
|
6019
|
-
return
|
|
6020
|
-
<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
|
|
6075
|
+
return `<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
|
|
6021
6076
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512"><title>ionicons-v5-f</title><path d="M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><line x1="338.29" y1="338.29" x2="448" y2="448" style="fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px"/></svg>
|
|
6022
|
-
</div
|
|
6023
|
-
`
|
|
6077
|
+
</div>`
|
|
6024
6078
|
}
|
|
6025
6079
|
buildTotalHtml (useWidths = false) {
|
|
6026
6080
|
if (!this.options.totals) {
|
|
@@ -6078,6 +6132,7 @@ class WebsyTable3 {
|
|
|
6078
6132
|
const rows = Array.from(tableEl.querySelectorAll('.websy-table-row'))
|
|
6079
6133
|
let totalWidth = 0
|
|
6080
6134
|
this.sizes.scrollableWidth = this.sizes.outer.width
|
|
6135
|
+
let firstNonPinnedColumnWidth = 0
|
|
6081
6136
|
rows.forEach((row, rowIndex) => {
|
|
6082
6137
|
Array.from(row.children).forEach((col, colIndex) => {
|
|
6083
6138
|
let colSize = col.getBoundingClientRect()
|
|
@@ -6087,7 +6142,10 @@ class WebsyTable3 {
|
|
|
6087
6142
|
this.options.columns[this.options.columns.length - 1][colIndex].actualWidth = 0
|
|
6088
6143
|
}
|
|
6089
6144
|
this.options.columns[this.options.columns.length - 1][colIndex].actualWidth = Math.min(Math.max(this.options.columns[this.options.columns.length - 1][colIndex].actualWidth, colSize.width), maxWidth)
|
|
6090
|
-
this.options.columns[this.options.columns.length - 1][colIndex].cellHeight = colSize.height
|
|
6145
|
+
this.options.columns[this.options.columns.length - 1][colIndex].cellHeight = colSize.height
|
|
6146
|
+
if (colIndex >= this.pinnedColumns) {
|
|
6147
|
+
firstNonPinnedColumnWidth = this.options.columns[this.options.columns.length - 1][colIndex].actualWidth
|
|
6148
|
+
}
|
|
6091
6149
|
}
|
|
6092
6150
|
})
|
|
6093
6151
|
})
|
|
@@ -6096,8 +6154,9 @@ class WebsyTable3 {
|
|
|
6096
6154
|
this.sizes.scrollableWidth -= col.actualWidth
|
|
6097
6155
|
}
|
|
6098
6156
|
})
|
|
6099
|
-
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
6157
|
+
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
6100
6158
|
this.sizes.totalNonPinnedWidth = this.options.columns[this.options.columns.length - 1].filter((c, i) => i >= this.pinnedColumns).reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
6159
|
+
this.sizes.pinnedWidth = this.sizes.totalWidth - this.sizes.totalNonPinnedWidth
|
|
6101
6160
|
// const outerSize = outerEl.getBoundingClientRect()
|
|
6102
6161
|
if (this.sizes.totalWidth < this.sizes.outer.width) {
|
|
6103
6162
|
let equalWidth = (this.sizes.outer.width - this.sizes.totalWidth) / this.options.columns[this.options.columns.length - 1].length
|
|
@@ -6120,6 +6179,19 @@ class WebsyTable3 {
|
|
|
6120
6179
|
// equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
|
|
6121
6180
|
})
|
|
6122
6181
|
}
|
|
6182
|
+
// check that we have enough from for all of the pinned columns plus 1 non pinned column
|
|
6183
|
+
if (this.sizes.pinnedWidth > (this.sizes.outer.width - firstNonPinnedColumnWidth)) {
|
|
6184
|
+
this.sizes.totalWidth = 0
|
|
6185
|
+
let diff = this.sizes.pinnedWidth - (this.sizes.outer.width - firstNonPinnedColumnWidth)
|
|
6186
|
+
// let colDiff = diff / this.pinnedColumns
|
|
6187
|
+
for (let i = 0; i < this.options.columns[this.options.columns.length - 1].length; i++) {
|
|
6188
|
+
if (i < this.pinnedColumns) {
|
|
6189
|
+
let colDiff = (this.options.columns[this.options.columns.length - 1][i].actualWidth / this.sizes.pinnedWidth) * diff
|
|
6190
|
+
this.options.columns[this.options.columns.length - 1][i].actualWidth -= colDiff
|
|
6191
|
+
}
|
|
6192
|
+
this.sizes.totalWidth += this.options.columns[this.options.columns.length - 1][i].width || this.options.columns[this.options.columns.length - 1][i].actualWidth
|
|
6193
|
+
}
|
|
6194
|
+
}
|
|
6123
6195
|
// take the height of the last cell as the official height for data cells
|
|
6124
6196
|
// this.sizes.dataCellHeight = this.options.columns[this.options.columns.length - 1].cellHeight
|
|
6125
6197
|
headEl.innerHTML = ''
|
|
@@ -6147,7 +6219,7 @@ class WebsyTable3 {
|
|
|
6147
6219
|
this.hScrollRequired = false
|
|
6148
6220
|
}
|
|
6149
6221
|
this.options.allColumns = this.options.columns.map(c => c)
|
|
6150
|
-
console.log('sizes', this.sizes)
|
|
6222
|
+
// console.log('sizes', this.sizes)
|
|
6151
6223
|
return this.sizes
|
|
6152
6224
|
}
|
|
6153
6225
|
createSample (data) {
|
|
@@ -6175,7 +6247,7 @@ class WebsyTable3 {
|
|
|
6175
6247
|
const colIndex = +event.target.getAttribute('data-col-index')
|
|
6176
6248
|
const rowIndex = +event.target.getAttribute('data-row-index')
|
|
6177
6249
|
if (event.target.classList.contains('websy-table-search-icon')) {
|
|
6178
|
-
console.log('clicked on search icon')
|
|
6250
|
+
// console.log('clicked on search icon')
|
|
6179
6251
|
if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
|
|
6180
6252
|
this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex])
|
|
6181
6253
|
}
|
|
@@ -6205,8 +6277,8 @@ class WebsyTable3 {
|
|
|
6205
6277
|
const scrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
6206
6278
|
this.handleYStart = scrollHandleEl.offsetTop
|
|
6207
6279
|
this.mouseYStart = event.pageY
|
|
6208
|
-
console.log('mouse down', this.handleYStart, this.mouseYStart)
|
|
6209
|
-
console.log(scrollHandleEl.offsetTop)
|
|
6280
|
+
// console.log('mouse down', this.handleYStart, this.mouseYStart)
|
|
6281
|
+
// console.log(scrollHandleEl.offsetTop)
|
|
6210
6282
|
}
|
|
6211
6283
|
else if (event.target.classList.contains('websy-scroll-handle-x')) {
|
|
6212
6284
|
this.scrollDragging = true
|
|
@@ -6239,7 +6311,7 @@ class WebsyTable3 {
|
|
|
6239
6311
|
}
|
|
6240
6312
|
handleScrollWheel (event) {
|
|
6241
6313
|
event.preventDefault()
|
|
6242
|
-
console.log('scrollwheel', event)
|
|
6314
|
+
// console.log('scrollwheel', event)
|
|
6243
6315
|
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
|
6244
6316
|
this.scrollX(Math.max(-5, Math.min(5, event.deltaX)))
|
|
6245
6317
|
}
|
|
@@ -6277,7 +6349,7 @@ class WebsyTable3 {
|
|
|
6277
6349
|
const sample = this.createSample(data)
|
|
6278
6350
|
this.calculateSizes(sample, data.length, (data[0] || []).length, 0)
|
|
6279
6351
|
}
|
|
6280
|
-
console.log(this.options.columns)
|
|
6352
|
+
// console.log(this.options.columns)
|
|
6281
6353
|
const tableInnerEl = document.getElementById(`${this.elementId}_tableInner`)
|
|
6282
6354
|
if (tableInnerEl) {
|
|
6283
6355
|
tableInnerEl.style.width = `${this.sizes.totalWidth}px`
|
|
@@ -6382,7 +6454,7 @@ class WebsyTable3 {
|
|
|
6382
6454
|
handlePos = scrollHandleEl.offsetLeft + diff
|
|
6383
6455
|
}
|
|
6384
6456
|
const scrollableSpace = scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width
|
|
6385
|
-
console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width)
|
|
6457
|
+
// console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width)
|
|
6386
6458
|
scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px'
|
|
6387
6459
|
if (this.options.onScroll) {
|
|
6388
6460
|
let actualLeft = (this.sizes.totalNonPinnedWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace)
|
|
@@ -6391,7 +6463,7 @@ class WebsyTable3 {
|
|
|
6391
6463
|
this.endCol = 0
|
|
6392
6464
|
for (let i = this.pinnedColumns; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
6393
6465
|
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
|
|
6394
|
-
console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
6466
|
+
// console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
6395
6467
|
if (actualLeft < cumulativeWidth) {
|
|
6396
6468
|
this.startCol = i
|
|
6397
6469
|
break
|
|
@@ -6407,11 +6479,11 @@ class WebsyTable3 {
|
|
|
6407
6479
|
if (this.endCol < this.options.allColumns[this.options.allColumns.length - 1].length - 1) {
|
|
6408
6480
|
this.endCol += 1
|
|
6409
6481
|
}
|
|
6410
|
-
if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.
|
|
6482
|
+
if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.scrollableWidth && actualLeft > 0) {
|
|
6411
6483
|
this.startCol += 1
|
|
6412
6484
|
}
|
|
6413
6485
|
this.endCol = Math.max(this.startCol, this.endCol)
|
|
6414
|
-
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol)
|
|
6486
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns)
|
|
6415
6487
|
}
|
|
6416
6488
|
}
|
|
6417
6489
|
scrollY (diff) {
|
|
@@ -6435,11 +6507,11 @@ class WebsyTable3 {
|
|
|
6435
6507
|
handlePos = this.handleYStart + diff
|
|
6436
6508
|
}
|
|
6437
6509
|
else {
|
|
6438
|
-
console.log('appending not resetting')
|
|
6510
|
+
// console.log('appending not resetting')
|
|
6439
6511
|
handlePos = scrollHandleEl.offsetTop + diff
|
|
6440
6512
|
}
|
|
6441
6513
|
const scrollableSpace = scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height
|
|
6442
|
-
console.log('dragging y', (diff), scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height)
|
|
6514
|
+
// console.log('dragging y', (diff), scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height)
|
|
6443
6515
|
scrollHandleEl.style.top = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px'
|
|
6444
6516
|
if (this.options.onScroll) {
|
|
6445
6517
|
this.startRow = Math.min(this.totalRowCount - this.sizes.rowsToRender, Math.max(0, Math.round((this.totalRowCount - this.sizes.rowsToRender) * (handlePos / scrollableSpace))))
|
|
@@ -6447,7 +6519,7 @@ class WebsyTable3 {
|
|
|
6447
6519
|
if (this.endRow === this.totalRowCount) {
|
|
6448
6520
|
this.startRow += 1
|
|
6449
6521
|
}
|
|
6450
|
-
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol)
|
|
6522
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns)
|
|
6451
6523
|
}
|
|
6452
6524
|
}
|
|
6453
6525
|
showLoading (options) {
|
|
@@ -6480,8 +6552,9 @@ class WebsyChart {
|
|
|
6480
6552
|
curveStyle: 'curveLinear',
|
|
6481
6553
|
lineWidth: 2,
|
|
6482
6554
|
forceZero: true,
|
|
6555
|
+
grouping: 'grouped',
|
|
6483
6556
|
fontSize: 14,
|
|
6484
|
-
symbolSize: 20,
|
|
6557
|
+
symbolSize: 20,
|
|
6485
6558
|
showTrackingLine: true,
|
|
6486
6559
|
showTooltip: true,
|
|
6487
6560
|
showLegend: false,
|
|
@@ -6494,6 +6567,7 @@ class WebsyChart {
|
|
|
6494
6567
|
this.rightAxis = null
|
|
6495
6568
|
this.topAxis = null
|
|
6496
6569
|
this.bottomAxis = null
|
|
6570
|
+
this.renderedKeys = {}
|
|
6497
6571
|
if (!elementId) {
|
|
6498
6572
|
console.log('No element Id provided for Websy Chart')
|
|
6499
6573
|
return
|
|
@@ -6717,11 +6791,18 @@ if (this.options.data[side].scale === 'Time') {
|
|
|
6717
6791
|
onLeft: xPoint > this.plotWidth / 2
|
|
6718
6792
|
}
|
|
6719
6793
|
if (xPoint > this.plotWidth / 2) {
|
|
6720
|
-
posOptions.left = xPoint - this.options.tooltipWidth
|
|
6794
|
+
posOptions.left = xPoint - this.options.tooltipWidth + this.options.margin.left + this.options.margin.axisLeft + 15
|
|
6795
|
+
if (this.options.data[xData].scale !== 'Time') {
|
|
6796
|
+
// posOptions.left -= (this[xAxis].bandwidth())
|
|
6797
|
+
posOptions.left += 10
|
|
6798
|
+
}
|
|
6721
6799
|
}
|
|
6722
6800
|
else {
|
|
6723
6801
|
posOptions.left = xPoint + this.options.margin.left + this.options.margin.axisLeft + 15
|
|
6724
|
-
|
|
6802
|
+
if (this.options.data[xData].scale !== 'Time') {
|
|
6803
|
+
posOptions.left += (this[xAxis].bandwidth() / 2)
|
|
6804
|
+
}
|
|
6805
|
+
}
|
|
6725
6806
|
posOptions.top = this.options.margin.top + this.options.margin.axisTop
|
|
6726
6807
|
if (this.options.orientation === 'horizontal') {
|
|
6727
6808
|
delete posOptions.onLeft
|
|
@@ -6855,8 +6936,10 @@ else {
|
|
|
6855
6936
|
let legendData = this.options.data.series.map((s, i) => ({value: s.label || s.key, color: s.color || this.options.colors[i % this.options.colors.length]}))
|
|
6856
6937
|
if (this.options.legendPosition === 'top' || this.options.legendPosition === 'bottom') {
|
|
6857
6938
|
this.legendArea.style('width', '100%')
|
|
6939
|
+
this.legend.options.align = 'center'
|
|
6858
6940
|
}
|
|
6859
6941
|
if (this.options.legendPosition === 'left' || this.options.legendPosition === 'right') {
|
|
6942
|
+
this.legend.options.align = 'left'
|
|
6860
6943
|
this.legendArea.style('height', '100%')
|
|
6861
6944
|
this.legendArea.style('width', this.legend.testWidth(d3.max(legendData.map(d => d.value))) + 'px')
|
|
6862
6945
|
}
|
|
@@ -6890,6 +6973,7 @@ else {
|
|
|
6890
6973
|
this.longestLeft = 0
|
|
6891
6974
|
this.longestRight = 0
|
|
6892
6975
|
this.longestBottom = 0
|
|
6976
|
+
let firstBottom = ''
|
|
6893
6977
|
if (this.options.data.bottom && this.options.data.bottom.data && typeof this.options.data.bottom.max === 'undefined') {
|
|
6894
6978
|
// this.options.data.bottom.max = this.options.data.bottom.data.reduce((a, b) => a.length > b.value.length ? a : b.value, '')
|
|
6895
6979
|
// this.options.data.bottom.min = this.options.data.bottom.data.reduce((a, b) => a.length < b.value.length ? a : b.value, this.options.data.bottom.max)
|
|
@@ -6900,9 +6984,17 @@ else {
|
|
|
6900
6984
|
this.longestBottom = this.options.data.bottom.max.toString()
|
|
6901
6985
|
if (this.options.data.bottom.formatter) {
|
|
6902
6986
|
this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString()
|
|
6987
|
+
firstBottom = this.longestBottom
|
|
6903
6988
|
}
|
|
6904
6989
|
else {
|
|
6905
|
-
this.
|
|
6990
|
+
if (this.options.data.bottom.scale === 'Time') {
|
|
6991
|
+
this.longestBottom = '01/01/2000'
|
|
6992
|
+
firstBottom = '01/01/2000'
|
|
6993
|
+
}
|
|
6994
|
+
else {
|
|
6995
|
+
this.longestBottom = this.options.data.bottom.data.reduce((a, b) => a.length > b.value.length ? a : b.value, '')
|
|
6996
|
+
firstBottom = this.options.data.bottom.data[0].value
|
|
6997
|
+
}
|
|
6906
6998
|
}
|
|
6907
6999
|
}
|
|
6908
7000
|
if (this.options.data.left && this.options.data.left.data && this.options.data.left.max === 'undefined') {
|
|
@@ -6938,7 +7030,20 @@ else {
|
|
|
6938
7030
|
let longestLeftBounds = WebsyUtils.measureText(this.longestLeft, 0, ((this.options.data.left && this.options.data.left.fontSize) || this.options.fontSize))
|
|
6939
7031
|
let longestRightBounds = WebsyUtils.measureText(this.longestRight, 0, ((this.options.data.right && this.options.data.right.fontSize) || this.options.fontSize))
|
|
6940
7032
|
let longestBottomBounds = WebsyUtils.measureText(this.longestBottom, ((this.options.data.bottom && this.options.data.bottom.rotate) || 0), ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize))
|
|
6941
|
-
|
|
7033
|
+
let firstBottomWidth = 0
|
|
7034
|
+
if (this.options.orientation === 'vertical') {
|
|
7035
|
+
firstBottomWidth = WebsyUtils.measureText(firstBottom, ((this.options.data.bottom && this.options.data.bottom.rotate) || 0), ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize)).width
|
|
7036
|
+
if (Math.abs((this.options.data.bottom && this.options.data.bottom.rotate) || 0) !== 90) {
|
|
7037
|
+
firstBottomWidth = firstBottomWidth / 2
|
|
7038
|
+
}
|
|
7039
|
+
else if (Math.abs((this.options.data.bottom && this.options.data.bottom.rotate) || 0) === 90) {
|
|
7040
|
+
firstBottomWidth = 0
|
|
7041
|
+
}
|
|
7042
|
+
if (this.options.data.bottom.scale !== 'Time') {
|
|
7043
|
+
firstBottom = Math.max(0, firstBottomWidth)
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth)
|
|
6942
7047
|
this.options.margin.axisRight = longestRightBounds.width
|
|
6943
7048
|
this.options.margin.axisBottom = longestBottomBounds.height + 10
|
|
6944
7049
|
this.options.margin.axisTop = 0
|
|
@@ -7154,7 +7259,7 @@ else {
|
|
|
7154
7259
|
.append('text')
|
|
7155
7260
|
.attr('class', 'title')
|
|
7156
7261
|
.attr('x', (1 - this.plotHeight / 2))
|
|
7157
|
-
.attr('y',
|
|
7262
|
+
.attr('y', (this.options.data.left.titleFontSize || 10) / 2 + 2)
|
|
7158
7263
|
.attr('font-size', this.options.data.left.titleFontSize || 10)
|
|
7159
7264
|
.attr('fill', this.options.data.left.titleColor || '#888888')
|
|
7160
7265
|
.attr('text-anchor', 'middle')
|
|
@@ -7235,7 +7340,16 @@ else {
|
|
|
7235
7340
|
// put the title horizontally on the top
|
|
7236
7341
|
}
|
|
7237
7342
|
}
|
|
7343
|
+
// Remove the unnecessary series
|
|
7344
|
+
let newKeys = this.options.data.series.map(s => s.key)
|
|
7345
|
+
for (const key in this.renderedKeys) {
|
|
7346
|
+
if (newKeys.indexOf(key) === -1) {
|
|
7347
|
+
// remove the components
|
|
7348
|
+
this[`remove${this.renderedKeys[key]}`](key)
|
|
7349
|
+
}
|
|
7350
|
+
}
|
|
7238
7351
|
// Draw the series data
|
|
7352
|
+
this.renderedKeys = {}
|
|
7239
7353
|
this.options.data.series.forEach((series, index) => {
|
|
7240
7354
|
if (!series.key) {
|
|
7241
7355
|
series.key = this.createIdentity()
|
|
@@ -7245,6 +7359,7 @@ else {
|
|
|
7245
7359
|
}
|
|
7246
7360
|
this[`render${series.type || 'bar'}`](series, index)
|
|
7247
7361
|
this.renderLabels(series, index)
|
|
7362
|
+
this.renderedKeys[series.key] = series.type
|
|
7248
7363
|
})
|
|
7249
7364
|
}
|
|
7250
7365
|
}
|
|
@@ -7304,69 +7419,75 @@ areas.enter().append('path')
|
|
|
7304
7419
|
}
|
|
7305
7420
|
renderbar (series, index) {
|
|
7306
7421
|
/* global series index d3 */
|
|
7307
|
-
let xAxis = '
|
|
7308
|
-
let yAxis = '
|
|
7422
|
+
let xAxis = 'bottom'
|
|
7423
|
+
let yAxis = 'left'
|
|
7309
7424
|
let bars = this.barLayer.selectAll(`.bar_${series.key}`).data(series.data)
|
|
7310
7425
|
let acummulativeY = new Array(this.options.data.series.length).fill(0)
|
|
7311
7426
|
if (this.options.orientation === 'horizontal') {
|
|
7312
|
-
xAxis = '
|
|
7313
|
-
yAxis = '
|
|
7314
|
-
}
|
|
7315
|
-
let barWidth = this[xAxis].bandwidth()
|
|
7316
|
-
if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
7317
|
-
barWidth = barWidth / this.options.data.series.length - 4
|
|
7427
|
+
xAxis = 'left'
|
|
7428
|
+
yAxis = 'bottom'
|
|
7318
7429
|
}
|
|
7430
|
+
let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
7431
|
+
let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
7432
|
+
// if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
7433
|
+
// barWidth = barWidth / this.options.data.series.length - 4
|
|
7434
|
+
// }
|
|
7319
7435
|
function getBarHeight (d, i) {
|
|
7320
7436
|
if (this.options.orientation === 'horizontal') {
|
|
7321
7437
|
return barWidth
|
|
7322
7438
|
}
|
|
7323
7439
|
else {
|
|
7324
|
-
return this[yAxis](d.y.value)
|
|
7440
|
+
return this[`${yAxis}Axis`](d.y.value)
|
|
7325
7441
|
}
|
|
7326
7442
|
}
|
|
7327
7443
|
function getBarWidth (d, i) {
|
|
7328
7444
|
if (this.options.orientation === 'horizontal') {
|
|
7329
|
-
let width = this[yAxis](d.y.value)
|
|
7445
|
+
let width = this[`${yAxis}Axis`](d.y.value)
|
|
7330
7446
|
acummulativeY[d.y.index] += width
|
|
7331
7447
|
return width
|
|
7332
7448
|
}
|
|
7333
7449
|
else {
|
|
7450
|
+
if (this.options.grouping === 'grouped') {
|
|
7451
|
+
return groupedBarWidth
|
|
7452
|
+
}
|
|
7334
7453
|
return barWidth
|
|
7335
7454
|
}
|
|
7336
7455
|
}
|
|
7337
7456
|
function getBarX (d, i) {
|
|
7338
7457
|
if (this.options.orientation === 'horizontal') {
|
|
7339
7458
|
if (this.options.grouping === 'stacked') {
|
|
7340
|
-
return this[yAxis](d.y.accumulative)
|
|
7459
|
+
return this[`${yAxis}Axis`](d.y.accumulative)
|
|
7341
7460
|
}
|
|
7342
7461
|
else {
|
|
7343
7462
|
return 0
|
|
7344
7463
|
}
|
|
7345
7464
|
}
|
|
7346
7465
|
else {
|
|
7347
|
-
|
|
7348
|
-
|
|
7466
|
+
let adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
7467
|
+
if (this.options.grouping === 'grouped') {
|
|
7468
|
+
let barAdjustment = groupedBarWidth * index + 5 // + (index > 0 ? 4 : 0)
|
|
7469
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + barAdjustment
|
|
7349
7470
|
}
|
|
7350
7471
|
else {
|
|
7351
|
-
return this[xAxis](this.parseX(d.x.value)) + (i * barWidth)
|
|
7472
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
|
|
7352
7473
|
}
|
|
7353
7474
|
}
|
|
7354
7475
|
}
|
|
7355
7476
|
function getBarY (d, i) {
|
|
7356
7477
|
if (this.options.orientation === 'horizontal') {
|
|
7357
7478
|
if (this.options.grouping !== 'grouped') {
|
|
7358
|
-
return this[xAxis](this.parseX(d.x.value))
|
|
7479
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
7359
7480
|
}
|
|
7360
7481
|
else {
|
|
7361
|
-
return this[xAxis](this.parseX(d.x.value)) + ((d.y.index || i) * barWidth)
|
|
7482
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + ((d.y.index || i) * barWidth)
|
|
7362
7483
|
}
|
|
7363
7484
|
}
|
|
7364
7485
|
else {
|
|
7365
7486
|
if (this.options.grouping === 'stacked') {
|
|
7366
|
-
return this[yAxis](d.y.accumulative)
|
|
7487
|
+
return this[`${yAxis}Axis`](d.y.accumulative)
|
|
7367
7488
|
}
|
|
7368
7489
|
else {
|
|
7369
|
-
return
|
|
7490
|
+
return this.plotHeight - getBarHeight.call(this, d, i)
|
|
7370
7491
|
}
|
|
7371
7492
|
}
|
|
7372
7493
|
}
|
|
@@ -7523,18 +7644,19 @@ const drawLine = (xAxis, yAxis, curveStyle) => {
|
|
|
7523
7644
|
return d3
|
|
7524
7645
|
.line()
|
|
7525
7646
|
.x(d => {
|
|
7526
|
-
|
|
7647
|
+
let adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this[`${xAxis}Axis`].bandwidth() / 2
|
|
7648
|
+
return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
7527
7649
|
})
|
|
7528
7650
|
.y(d => {
|
|
7529
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value)
|
|
7651
|
+
return this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)
|
|
7530
7652
|
})
|
|
7531
7653
|
.curve(d3[curveStyle || this.options.curveStyle])
|
|
7532
7654
|
}
|
|
7533
|
-
let xAxis = '
|
|
7534
|
-
let yAxis = series.axis === 'secondary' ? '
|
|
7655
|
+
let xAxis = 'bottom'
|
|
7656
|
+
let yAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
7535
7657
|
if (this.options.orienation === 'horizontal') {
|
|
7536
|
-
xAxis = series.axis === 'secondary' ? '
|
|
7537
|
-
yAxis = '
|
|
7658
|
+
xAxis = series.axis === 'secondary' ? 'right' : 'left'
|
|
7659
|
+
yAxis = 'bottom'
|
|
7538
7660
|
}
|
|
7539
7661
|
let lines = this.lineLayer.selectAll(`.line_${series.key}`)
|
|
7540
7662
|
.data([series.data])
|
|
@@ -7571,6 +7693,14 @@ if (series.showSymbols === true) {
|
|
|
7571
7693
|
this.rendersymbol(series, index)
|
|
7572
7694
|
}
|
|
7573
7695
|
|
|
7696
|
+
}
|
|
7697
|
+
removeline (key) {
|
|
7698
|
+
/* global key d3 */
|
|
7699
|
+
let lines = this.lineLayer.selectAll(`.line_${key}`)
|
|
7700
|
+
.transition(this.transition)
|
|
7701
|
+
.style('stroke-opacity', 1e-6)
|
|
7702
|
+
.remove()
|
|
7703
|
+
|
|
7574
7704
|
}
|
|
7575
7705
|
rendersymbol (series, index) {
|
|
7576
7706
|
/* global d3 series index series.key */
|