@websy/websy-designs 1.3.0 → 1.3.2
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/pdfHelper.js +13 -4
- package/dist/server/routes/v1/shop.js +52 -15
- package/dist/websy-designs-es6.debug.js +154 -62
- package/dist/websy-designs-es6.js +168 -60
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +154 -62
- package/dist/websy-designs.js +168 -60
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -375,6 +375,7 @@ class WebsyDatePicker {
|
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
close (confirm, isRange = false) {
|
|
378
|
+
console.trace()
|
|
378
379
|
const maskEl = document.getElementById(`${this.elementId}_mask`)
|
|
379
380
|
const contentEl = document.getElementById(`${this.elementId}_content`)
|
|
380
381
|
const el = document.getElementById(this.elementId)
|
|
@@ -391,19 +392,19 @@ class WebsyDatePicker {
|
|
|
391
392
|
for (let i = this.selectedRangeDates[0]; i < this.selectedRangeDates[1] + 1; i++) {
|
|
392
393
|
hoursOut.push(this.options.hours[i])
|
|
393
394
|
}
|
|
394
|
-
this.options.onChange(hoursOut, true)
|
|
395
|
+
this.options.onChange(hoursOut, true, this.selectedRange)
|
|
395
396
|
}
|
|
396
397
|
else {
|
|
397
|
-
this.options.onChange(this.selectedRangeDates, true)
|
|
398
|
+
this.options.onChange(this.selectedRangeDates, true, this.selectedRange)
|
|
398
399
|
}
|
|
399
400
|
}
|
|
400
401
|
else {
|
|
401
402
|
if (this.options.mode === 'hour') {
|
|
402
403
|
let hoursOut = this.currentselection.map(h => this.options.hours[h])
|
|
403
|
-
this.options.onChange(hoursOut, true)
|
|
404
|
+
this.options.onChange(hoursOut, true, this.selectedRange)
|
|
404
405
|
}
|
|
405
406
|
else {
|
|
406
|
-
this.options.onChange(this.currentselection, isRange)
|
|
407
|
+
this.options.onChange(this.currentselection, isRange, this.selectedRange)
|
|
407
408
|
}
|
|
408
409
|
}
|
|
409
410
|
}
|
|
@@ -426,7 +427,7 @@ class WebsyDatePicker {
|
|
|
426
427
|
d = new Date(d)
|
|
427
428
|
}
|
|
428
429
|
// d.setTime(d.getTime() + d.getTimezoneOffset() * 60000)
|
|
429
|
-
return new Date(d.
|
|
430
|
+
return new Date(d.setUTCHours(12, 0, 0, 0))
|
|
430
431
|
}
|
|
431
432
|
handleClick (event) {
|
|
432
433
|
if (event.target.classList.contains('websy-date-picker-header')) {
|
|
@@ -549,8 +550,9 @@ class WebsyDatePicker {
|
|
|
549
550
|
let rangeEnd
|
|
550
551
|
if (this.options.mode === 'date') {
|
|
551
552
|
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
|
|
552
|
-
d.
|
|
553
|
+
// d.setUTCHours(12, 0, 0, 0)
|
|
553
554
|
d = d.getTime()
|
|
555
|
+
// console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
554
556
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
555
557
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
556
558
|
}
|
|
@@ -559,8 +561,10 @@ class WebsyDatePicker {
|
|
|
559
561
|
rangeStart = this.selectedRangeDates[0]
|
|
560
562
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
|
|
561
563
|
}
|
|
562
|
-
else if (this.options.mode === 'monthyear') {
|
|
563
|
-
d = new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i)
|
|
564
|
+
else if (this.options.mode === 'monthyear') {
|
|
565
|
+
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i))
|
|
566
|
+
d = d.getTime()
|
|
567
|
+
console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
564
568
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
565
569
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
566
570
|
}
|
|
@@ -608,9 +612,11 @@ class WebsyDatePicker {
|
|
|
608
612
|
else if (this.options.mode === 'hour') {
|
|
609
613
|
dateEl = document.getElementById(`${this.elementId}_${d}_hour`)
|
|
610
614
|
}
|
|
611
|
-
dateEl
|
|
612
|
-
|
|
613
|
-
|
|
615
|
+
if (dateEl) {
|
|
616
|
+
dateEl.classList.add('selected')
|
|
617
|
+
dateEl.classList.add('first')
|
|
618
|
+
dateEl.classList.add('last')
|
|
619
|
+
}
|
|
614
620
|
})
|
|
615
621
|
}
|
|
616
622
|
}
|
|
@@ -832,7 +838,7 @@ class WebsyDatePicker {
|
|
|
832
838
|
yearList.reverse()
|
|
833
839
|
}
|
|
834
840
|
html += `<div id='${this.elementId}_dateList' class='websy-dp-date-list'><ul>`
|
|
835
|
-
html += yearList.map(d => `<li id='${this.elementId}_${d.id}_year' class='websy-dp-date websy-dp-year ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.year}</li>`).join('')
|
|
841
|
+
html += yearList.map(d => `<li id='${this.elementId}_${d.id}_year' data-id='${d.id}' class='websy-dp-date websy-dp-year ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.year}</li>`).join('')
|
|
836
842
|
html += `</ul></div>`
|
|
837
843
|
}
|
|
838
844
|
else if (this.options.mode === 'monthyear') {
|
|
@@ -849,7 +855,7 @@ class WebsyDatePicker {
|
|
|
849
855
|
}
|
|
850
856
|
html += paddedMonths.join('')
|
|
851
857
|
}
|
|
852
|
-
html += this.monthYears[year].map(d => `<li id='${this.elementId}_${d.id}_monthyear' data-year='${d.year}' class='websy-dp-date websy-dp-monthyear'>${d.month}</li>`).join('')
|
|
858
|
+
html += this.monthYears[year].map(d => `<li id='${this.elementId}_${d.id}_monthyear' data-id='${d.id}' data-year='${d.year}' class='websy-dp-date websy-dp-monthyear'>${d.month}</li>`).join('')
|
|
853
859
|
html += `</ul>`
|
|
854
860
|
}
|
|
855
861
|
html += `</div>`
|
|
@@ -942,15 +948,6 @@ class WebsyDatePicker {
|
|
|
942
948
|
this.selectedRangeDates = [...this.options.ranges[this.options.mode][index].range]
|
|
943
949
|
this.currentselection = this.options.ranges[this.options.mode][index].range.map(d => d.getTime())
|
|
944
950
|
this.selectedRange = +index
|
|
945
|
-
const el = document.getElementById(`${this.elementId}_header`)
|
|
946
|
-
if (el) {
|
|
947
|
-
if (this.selectedRange === 0) {
|
|
948
|
-
el.classList.remove('range-selected')
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
el.classList.add('range-selected')
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
951
|
this.highlightRange()
|
|
955
952
|
this.updateRange()
|
|
956
953
|
this.close(confirm, true)
|
|
@@ -959,14 +956,16 @@ class WebsyDatePicker {
|
|
|
959
956
|
selectCustomRange (rangeInput) {
|
|
960
957
|
this.selectedRange = -1
|
|
961
958
|
let isContinuousRange = true
|
|
962
|
-
if (rangeInput.length === 1) {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
}
|
|
966
|
-
else if (rangeInput.length === 2) {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}
|
|
959
|
+
// if (rangeInput.length === 1) {
|
|
960
|
+
// this.selectedRangeDates = [...rangeInput]
|
|
961
|
+
// this.customRangeSelected = true
|
|
962
|
+
// }
|
|
963
|
+
// else if (rangeInput.length === 2) {
|
|
964
|
+
// this.selectedRangeDates = [...rangeInput]
|
|
965
|
+
// this.customRangeSelected = true
|
|
966
|
+
// }
|
|
967
|
+
this.selectedRangeDates = [...rangeInput]
|
|
968
|
+
this.customRangeSelected = true
|
|
970
969
|
rangeInput.forEach((r, i) => {
|
|
971
970
|
if (i > 0) {
|
|
972
971
|
if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
|
|
@@ -1104,6 +1103,15 @@ class WebsyDatePicker {
|
|
|
1104
1103
|
if (labelEl) {
|
|
1105
1104
|
labelEl.innerHTML = range.label
|
|
1106
1105
|
}
|
|
1106
|
+
const headerEl = document.getElementById(`${this.elementId}_header`)
|
|
1107
|
+
if (headerEl) {
|
|
1108
|
+
if (this.selectedRange === 0) {
|
|
1109
|
+
headerEl.classList.remove('range-selected')
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
headerEl.classList.add('range-selected')
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1107
1115
|
}
|
|
1108
1116
|
}
|
|
1109
1117
|
|
|
@@ -1117,7 +1125,8 @@ class WebsyDragDrop {
|
|
|
1117
1125
|
const DEFAULTS = {
|
|
1118
1126
|
items: [],
|
|
1119
1127
|
orientation: 'horizontal',
|
|
1120
|
-
dropPlaceholder: 'Drop item here'
|
|
1128
|
+
dropPlaceholder: 'Drop item here',
|
|
1129
|
+
accepts: 'application/wd-item'
|
|
1121
1130
|
}
|
|
1122
1131
|
this.busy = false
|
|
1123
1132
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
@@ -1176,7 +1185,7 @@ class WebsyDragDrop {
|
|
|
1176
1185
|
item.id = WebsyDesigns.Utils.createIdentity()
|
|
1177
1186
|
}
|
|
1178
1187
|
let html = `
|
|
1179
|
-
<div id='${item.id}_item' class='websy-dragdrop-item' draggable='true' data-id='${item.id}'>
|
|
1188
|
+
<div id='${item.id}_item' class='websy-dragdrop-item ${(item.classes || []).join(' ')}' draggable='true' data-id='${item.id}'>
|
|
1180
1189
|
<div id='${item.id}_itemInner' class='websy-dragdrop-item-inner' data-id='${item.id}'>
|
|
1181
1190
|
`
|
|
1182
1191
|
if (item.component) {
|
|
@@ -1205,20 +1214,23 @@ class WebsyDragDrop {
|
|
|
1205
1214
|
}
|
|
1206
1215
|
handleDragStart (event) {
|
|
1207
1216
|
this.draggedId = event.target.getAttribute('data-id')
|
|
1208
|
-
event.dataTransfer.effectAllowed = 'move'
|
|
1209
|
-
event.dataTransfer.setData(
|
|
1210
|
-
|
|
1211
|
-
event.target.style.opacity = 0.5
|
|
1217
|
+
event.dataTransfer.effectAllowed = 'move'
|
|
1218
|
+
event.dataTransfer.setData(this.options.accepts, JSON.stringify({el: event.target.id, id: this.elementId, itemId: this.draggedId}))
|
|
1219
|
+
event.target.classList.add('dragging')
|
|
1220
|
+
// event.target.style.opacity = 0.5
|
|
1212
1221
|
this.dragging = true
|
|
1213
1222
|
}
|
|
1214
|
-
handleDragOver (event) {
|
|
1215
|
-
// console.log('drag over', event.target.classList)
|
|
1223
|
+
handleDragOver (event) {
|
|
1216
1224
|
if (event.preventDefault) {
|
|
1217
1225
|
event.preventDefault()
|
|
1218
1226
|
}
|
|
1227
|
+
console.log('drag', event.target.classList)
|
|
1219
1228
|
if (!event.target.classList.contains('droppable')) {
|
|
1220
1229
|
return
|
|
1221
1230
|
}
|
|
1231
|
+
if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
|
|
1232
|
+
return
|
|
1233
|
+
}
|
|
1222
1234
|
event.target.classList.add('drag-over')
|
|
1223
1235
|
}
|
|
1224
1236
|
handleDragLeave (event) {
|
|
@@ -1234,14 +1246,17 @@ class WebsyDragDrop {
|
|
|
1234
1246
|
}
|
|
1235
1247
|
handleDrop (event) {
|
|
1236
1248
|
// console.log('drag drop')
|
|
1237
|
-
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1238
|
-
const data = JSON.parse(event.dataTransfer.getData(
|
|
1249
|
+
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1250
|
+
const data = JSON.parse(event.dataTransfer.getData(this.options.accepts))
|
|
1239
1251
|
if (event.preventDefault) {
|
|
1240
1252
|
event.preventDefault()
|
|
1241
1253
|
}
|
|
1242
1254
|
if (!event.target.classList.contains('droppable')) {
|
|
1243
1255
|
return
|
|
1244
1256
|
}
|
|
1257
|
+
if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
|
|
1258
|
+
return
|
|
1259
|
+
}
|
|
1245
1260
|
let side = event.target.getAttribute('data-side')
|
|
1246
1261
|
let id = event.target.getAttribute('data-id')
|
|
1247
1262
|
let index = this.getItemIndex(id)
|
|
@@ -1291,6 +1306,7 @@ class WebsyDragDrop {
|
|
|
1291
1306
|
handleDragEnd (event) {
|
|
1292
1307
|
// console.log('drag end')
|
|
1293
1308
|
event.target.style.opacity = 1
|
|
1309
|
+
event.target.classList.remove('dragging')
|
|
1294
1310
|
this.draggedId = null
|
|
1295
1311
|
this.dragging = false
|
|
1296
1312
|
const startEl = document.getElementById(`${this.elementId}start_item`)
|
|
@@ -5271,10 +5287,16 @@ class WebsyTable3 {
|
|
|
5271
5287
|
data.forEach(row => {
|
|
5272
5288
|
bodyHtml += `<tr class="websy-table-row">`
|
|
5273
5289
|
row.forEach((cell, cellIndex) => {
|
|
5290
|
+
if (typeof sizingColumns[cellIndex] === 'undefined') {
|
|
5291
|
+
return // need to revisit this logic
|
|
5292
|
+
}
|
|
5274
5293
|
let style = ''
|
|
5275
5294
|
if (cell.style) {
|
|
5276
5295
|
style += cell.style
|
|
5277
5296
|
}
|
|
5297
|
+
if (useWidths === true) {
|
|
5298
|
+
style += `max-width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important;`
|
|
5299
|
+
}
|
|
5278
5300
|
if (cell.backgroundColor) {
|
|
5279
5301
|
style += `background-color: ${cell.backgroundColor}; `
|
|
5280
5302
|
if (!cell.color) {
|
|
@@ -5284,8 +5306,9 @@ class WebsyTable3 {
|
|
|
5284
5306
|
if (cell.color) {
|
|
5285
5307
|
style += `color: ${cell.color}; `
|
|
5286
5308
|
}
|
|
5309
|
+
console.log('rowspan', cell.rowspan)
|
|
5287
5310
|
bodyHtml += `<td
|
|
5288
|
-
class='websy-table-cell'
|
|
5311
|
+
class='websy-table-cell ${(cell.classes || []).join(' ')}'
|
|
5289
5312
|
style='${style}'
|
|
5290
5313
|
data-info='${cell.value}'
|
|
5291
5314
|
colspan='${cell.colspan || 1}'
|
|
@@ -5444,11 +5467,13 @@ class WebsyTable3 {
|
|
|
5444
5467
|
}
|
|
5445
5468
|
})
|
|
5446
5469
|
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
5470
|
+
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)
|
|
5447
5471
|
const outerSize = outerEl.getBoundingClientRect()
|
|
5448
5472
|
if (this.sizes.totalWidth < outerSize.width) {
|
|
5449
5473
|
this.sizes.totalWidth = 0
|
|
5474
|
+
this.sizes.totalNonPinnedWidth = 0
|
|
5450
5475
|
let equalWidth = outerSize.width / this.options.columns[this.options.columns.length - 1].length
|
|
5451
|
-
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5476
|
+
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5452
5477
|
if (!c.width) {
|
|
5453
5478
|
if (c.actualWidth < equalWidth) {
|
|
5454
5479
|
// adjust the width
|
|
@@ -5456,6 +5481,9 @@ class WebsyTable3 {
|
|
|
5456
5481
|
}
|
|
5457
5482
|
}
|
|
5458
5483
|
this.sizes.totalWidth += c.width || c.actualWidth
|
|
5484
|
+
if (i < this.pinnedColumns) {
|
|
5485
|
+
this.sizes.totalNonPinnedWidth += c.width || c.actualWidth
|
|
5486
|
+
}
|
|
5459
5487
|
equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
|
|
5460
5488
|
})
|
|
5461
5489
|
}
|
|
@@ -5476,9 +5504,15 @@ class WebsyTable3 {
|
|
|
5476
5504
|
if (this.sizes.rowsToRender < this.totalRowCount) {
|
|
5477
5505
|
this.vScrollRequired = true
|
|
5478
5506
|
}
|
|
5507
|
+
else {
|
|
5508
|
+
this.vScrollRequired = false
|
|
5509
|
+
}
|
|
5479
5510
|
if (this.sizes.totalWidth > this.sizes.outer.width) {
|
|
5480
5511
|
this.hScrollRequired = true
|
|
5481
5512
|
}
|
|
5513
|
+
else {
|
|
5514
|
+
this.hScrollRequired = false
|
|
5515
|
+
}
|
|
5482
5516
|
this.options.allColumns = this.options.columns.map(c => c)
|
|
5483
5517
|
console.log('sizes', this.sizes)
|
|
5484
5518
|
return this.sizes
|
|
@@ -5623,10 +5657,10 @@ class WebsyTable3 {
|
|
|
5623
5657
|
if (this.hScrollRequired === true) {
|
|
5624
5658
|
hScrollEl.style.left = `${this.sizes.table.width - this.sizes.scrollableWidth}px`
|
|
5625
5659
|
hScrollEl.style.width = `${this.sizes.scrollableWidth - 20}px`
|
|
5626
|
-
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.
|
|
5660
|
+
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalNonPinnedWidth)) + 'px'
|
|
5627
5661
|
}
|
|
5628
5662
|
else {
|
|
5629
|
-
hHandleEl.style.
|
|
5663
|
+
hHandleEl.style.width = '0px'
|
|
5630
5664
|
}
|
|
5631
5665
|
}
|
|
5632
5666
|
}
|
|
@@ -5656,9 +5690,7 @@ class WebsyTable3 {
|
|
|
5656
5690
|
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
5657
5691
|
if (el) {
|
|
5658
5692
|
el.classList.add('has-error')
|
|
5659
|
-
}
|
|
5660
|
-
const tableEl = document.getElementById(`${this.elementId}_tableInner`)
|
|
5661
|
-
tableEl.classList.add('hidden')
|
|
5693
|
+
}
|
|
5662
5694
|
const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
|
|
5663
5695
|
if (containerEl) {
|
|
5664
5696
|
containerEl.classList.add('active')
|
|
@@ -5677,6 +5709,19 @@ class WebsyTable3 {
|
|
|
5677
5709
|
}
|
|
5678
5710
|
}
|
|
5679
5711
|
scrollX (diff) {
|
|
5712
|
+
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
5713
|
+
if (!el.classList.contains('scrolling')) {
|
|
5714
|
+
el.classList.add('scrolling')
|
|
5715
|
+
}
|
|
5716
|
+
if (this.scrollTimeoutFn) {
|
|
5717
|
+
clearTimeout(this.scrollTimeoutFn)
|
|
5718
|
+
}
|
|
5719
|
+
this.scrollTimeoutFn = setTimeout(() => {
|
|
5720
|
+
el.classList.remove('scrolling')
|
|
5721
|
+
}, 200)
|
|
5722
|
+
if (this.hScrollRequired === false) {
|
|
5723
|
+
return
|
|
5724
|
+
}
|
|
5680
5725
|
const scrollContainerEl = document.getElementById(`${this.elementId}_hScrollContainer`)
|
|
5681
5726
|
const scrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
5682
5727
|
let handlePos
|
|
@@ -5690,11 +5735,11 @@ class WebsyTable3 {
|
|
|
5690
5735
|
console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width)
|
|
5691
5736
|
scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px'
|
|
5692
5737
|
if (this.options.onScroll) {
|
|
5693
|
-
let actualLeft = (this.sizes.
|
|
5738
|
+
let actualLeft = (this.sizes.totalNonPinnedWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace)
|
|
5694
5739
|
let cumulativeWidth = 0
|
|
5695
5740
|
this.startCol = 0
|
|
5696
5741
|
this.endCol = 0
|
|
5697
|
-
for (let i =
|
|
5742
|
+
for (let i = this.pinnedColumns; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
5698
5743
|
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
|
|
5699
5744
|
console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
5700
5745
|
if (actualLeft < cumulativeWidth) {
|
|
@@ -5720,6 +5765,19 @@ class WebsyTable3 {
|
|
|
5720
5765
|
}
|
|
5721
5766
|
}
|
|
5722
5767
|
scrollY (diff) {
|
|
5768
|
+
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
5769
|
+
if (!el.classList.contains('scrolling')) {
|
|
5770
|
+
el.classList.add('scrolling')
|
|
5771
|
+
}
|
|
5772
|
+
if (this.scrollTimeoutFn) {
|
|
5773
|
+
clearTimeout(this.scrollTimeoutFn)
|
|
5774
|
+
}
|
|
5775
|
+
this.scrollTimeoutFn = setTimeout(() => {
|
|
5776
|
+
el.classList.remove('scrolling')
|
|
5777
|
+
}, 200)
|
|
5778
|
+
if (this.vScrollRequired === false) {
|
|
5779
|
+
return
|
|
5780
|
+
}
|
|
5723
5781
|
const scrollContainerEl = document.getElementById(`${this.elementId}_vScrollContainer`)
|
|
5724
5782
|
const scrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
5725
5783
|
let handlePos
|
|
@@ -6671,7 +6729,7 @@ bars
|
|
|
6671
6729
|
.attr('x', getBarX.bind(this))
|
|
6672
6730
|
.attr('y', getBarY.bind(this))
|
|
6673
6731
|
.transition(this.transition)
|
|
6674
|
-
.attr('fill', d => d.color || series.color)
|
|
6732
|
+
.attr('fill', d => d.y.color || d.color || series.color)
|
|
6675
6733
|
|
|
6676
6734
|
bars
|
|
6677
6735
|
.enter()
|
|
@@ -6681,7 +6739,7 @@ bars
|
|
|
6681
6739
|
.attr('x', getBarX.bind(this))
|
|
6682
6740
|
.attr('y', getBarY.bind(this))
|
|
6683
6741
|
// .transition(this.transition)
|
|
6684
|
-
.attr('fill', d => d.color || series.color)
|
|
6742
|
+
.attr('fill', d => d.y.color || d.color || series.color)
|
|
6685
6743
|
.attr('class', d => {
|
|
6686
6744
|
return `bar bar_${series.key}`
|
|
6687
6745
|
})
|
|
@@ -6696,7 +6754,7 @@ if (this.options.orientation === 'horizontal') {
|
|
|
6696
6754
|
xAxis = 'leftAxis'
|
|
6697
6755
|
yAxis = 'bottomAxis'
|
|
6698
6756
|
}
|
|
6699
|
-
if (this.options.showLabels) {
|
|
6757
|
+
if (this.options.showLabels === true || series.showLabels === true) {
|
|
6700
6758
|
// need to add logic to handle positioning options
|
|
6701
6759
|
// e.g. Inside, Outide, Auto (this will also affect the available plot space)
|
|
6702
6760
|
// We currently only support 'Auto'
|
|
@@ -6710,10 +6768,35 @@ if (this.options.showLabels) {
|
|
|
6710
6768
|
.attr('x', getLabelX.bind(this))
|
|
6711
6769
|
.attr('y', getLabelY.bind(this))
|
|
6712
6770
|
.attr('class', `label_${series.key}`)
|
|
6713
|
-
.
|
|
6714
|
-
.style('
|
|
6771
|
+
.attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6772
|
+
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
6715
6773
|
.transition(this.transition)
|
|
6716
6774
|
.text(d => d.y.label || d.y.value)
|
|
6775
|
+
.each(function (d, i) {
|
|
6776
|
+
if (that.options.orientation === 'horizontal') {
|
|
6777
|
+
if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
|
|
6778
|
+
this.setAttribute('text-anchor', 'middle')
|
|
6779
|
+
}
|
|
6780
|
+
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
6781
|
+
this.setAttribute('text-anchor', 'end')
|
|
6782
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6783
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6784
|
+
}
|
|
6785
|
+
else if (series.labelPosition === 'outside') {
|
|
6786
|
+
this.setAttribute('text-anchor', 'start')
|
|
6787
|
+
this.setAttribute('x', +(this.getAttribute('x')) + 8)
|
|
6788
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6789
|
+
}
|
|
6790
|
+
else {
|
|
6791
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6792
|
+
}
|
|
6793
|
+
}
|
|
6794
|
+
else {
|
|
6795
|
+
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
6796
|
+
this.setAttribute('y', +(this.getAttribute('y')) + 8)
|
|
6797
|
+
}
|
|
6798
|
+
}
|
|
6799
|
+
})
|
|
6717
6800
|
|
|
6718
6801
|
labels
|
|
6719
6802
|
.enter()
|
|
@@ -6723,18 +6806,27 @@ if (this.options.showLabels) {
|
|
|
6723
6806
|
.attr('y', getLabelY.bind(this))
|
|
6724
6807
|
.attr('alignment-baseline', 'central')
|
|
6725
6808
|
.attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle')
|
|
6726
|
-
.
|
|
6727
|
-
.style('
|
|
6809
|
+
.attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6810
|
+
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
6728
6811
|
.text(d => d.y.label || d.y.value)
|
|
6729
6812
|
.each(function (d, i) {
|
|
6730
6813
|
if (that.options.orientation === 'horizontal') {
|
|
6731
|
-
if (that.options.grouping === 'stacked') {
|
|
6814
|
+
if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
|
|
6732
6815
|
this.setAttribute('text-anchor', 'middle')
|
|
6733
6816
|
}
|
|
6734
6817
|
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
6735
6818
|
this.setAttribute('text-anchor', 'end')
|
|
6736
|
-
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6819
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6820
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6737
6821
|
}
|
|
6822
|
+
else if (series.labelPosition === 'outside') {
|
|
6823
|
+
this.setAttribute('text-anchor', 'start')
|
|
6824
|
+
this.setAttribute('x', +(this.getAttribute('x')) + 8)
|
|
6825
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6826
|
+
}
|
|
6827
|
+
else {
|
|
6828
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6829
|
+
}
|
|
6738
6830
|
}
|
|
6739
6831
|
else {
|
|
6740
6832
|
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
@@ -6744,10 +6836,10 @@ if (this.options.showLabels) {
|
|
|
6744
6836
|
})
|
|
6745
6837
|
}
|
|
6746
6838
|
|
|
6747
|
-
function getLabelX (d) {
|
|
6839
|
+
function getLabelX (d, labelPosition = 'inside') {
|
|
6748
6840
|
if (this.options.orientation === 'horizontal') {
|
|
6749
6841
|
if (this.options.grouping === 'stacked') {
|
|
6750
|
-
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / 2)
|
|
6842
|
+
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
6751
6843
|
}
|
|
6752
6844
|
else {
|
|
6753
6845
|
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4
|
|
@@ -6757,13 +6849,13 @@ function getLabelX (d) {
|
|
|
6757
6849
|
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
|
|
6758
6850
|
}
|
|
6759
6851
|
}
|
|
6760
|
-
function getLabelY (d) {
|
|
6852
|
+
function getLabelY (d, labelPosition = 'inside') {
|
|
6761
6853
|
if (this.options.orientation === 'horizontal') {
|
|
6762
6854
|
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
|
|
6763
6855
|
}
|
|
6764
6856
|
else {
|
|
6765
6857
|
if (this.options.grouping === 'stacked') {
|
|
6766
|
-
|
|
6858
|
+
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
6767
6859
|
}
|
|
6768
6860
|
else {
|
|
6769
6861
|
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - 4
|