@websy/websy-designs 1.3.0 → 1.3.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/routes/v1/shop.js +52 -15
- package/dist/websy-designs-es6.debug.js +134 -55
- package/dist/websy-designs-es6.js +146 -54
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +134 -55
- package/dist/websy-designs.js +146 -54
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -562,6 +562,7 @@ class WebsyDatePicker {
|
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
564
|
close (confirm, isRange = false) {
|
|
565
|
+
console.trace()
|
|
565
566
|
const maskEl = document.getElementById(`${this.elementId}_mask`)
|
|
566
567
|
const contentEl = document.getElementById(`${this.elementId}_content`)
|
|
567
568
|
const el = document.getElementById(this.elementId)
|
|
@@ -578,19 +579,19 @@ class WebsyDatePicker {
|
|
|
578
579
|
for (let i = this.selectedRangeDates[0]; i < this.selectedRangeDates[1] + 1; i++) {
|
|
579
580
|
hoursOut.push(this.options.hours[i])
|
|
580
581
|
}
|
|
581
|
-
this.options.onChange(hoursOut, true)
|
|
582
|
+
this.options.onChange(hoursOut, true, this.selectedRange)
|
|
582
583
|
}
|
|
583
584
|
else {
|
|
584
|
-
this.options.onChange(this.selectedRangeDates, true)
|
|
585
|
+
this.options.onChange(this.selectedRangeDates, true, this.selectedRange)
|
|
585
586
|
}
|
|
586
587
|
}
|
|
587
588
|
else {
|
|
588
589
|
if (this.options.mode === 'hour') {
|
|
589
590
|
let hoursOut = this.currentselection.map(h => this.options.hours[h])
|
|
590
|
-
this.options.onChange(hoursOut, true)
|
|
591
|
+
this.options.onChange(hoursOut, true, this.selectedRange)
|
|
591
592
|
}
|
|
592
593
|
else {
|
|
593
|
-
this.options.onChange(this.currentselection, isRange)
|
|
594
|
+
this.options.onChange(this.currentselection, isRange, this.selectedRange)
|
|
594
595
|
}
|
|
595
596
|
}
|
|
596
597
|
}
|
|
@@ -613,7 +614,7 @@ class WebsyDatePicker {
|
|
|
613
614
|
d = new Date(d)
|
|
614
615
|
}
|
|
615
616
|
// d.setTime(d.getTime() + d.getTimezoneOffset() * 60000)
|
|
616
|
-
return new Date(d.
|
|
617
|
+
return new Date(d.setUTCHours(12, 0, 0, 0))
|
|
617
618
|
}
|
|
618
619
|
handleClick (event) {
|
|
619
620
|
if (event.target.classList.contains('websy-date-picker-header')) {
|
|
@@ -736,7 +737,7 @@ class WebsyDatePicker {
|
|
|
736
737
|
let rangeEnd
|
|
737
738
|
if (this.options.mode === 'date') {
|
|
738
739
|
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
|
|
739
|
-
d.
|
|
740
|
+
d.setUTCHours(12, 0, 0, 0)
|
|
740
741
|
d = d.getTime()
|
|
741
742
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
742
743
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
@@ -795,9 +796,11 @@ class WebsyDatePicker {
|
|
|
795
796
|
else if (this.options.mode === 'hour') {
|
|
796
797
|
dateEl = document.getElementById(`${this.elementId}_${d}_hour`)
|
|
797
798
|
}
|
|
798
|
-
dateEl
|
|
799
|
-
|
|
800
|
-
|
|
799
|
+
if (dateEl) {
|
|
800
|
+
dateEl.classList.add('selected')
|
|
801
|
+
dateEl.classList.add('first')
|
|
802
|
+
dateEl.classList.add('last')
|
|
803
|
+
}
|
|
801
804
|
})
|
|
802
805
|
}
|
|
803
806
|
}
|
|
@@ -1019,7 +1022,7 @@ class WebsyDatePicker {
|
|
|
1019
1022
|
yearList.reverse()
|
|
1020
1023
|
}
|
|
1021
1024
|
html += `<div id='${this.elementId}_dateList' class='websy-dp-date-list'><ul>`
|
|
1022
|
-
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('')
|
|
1025
|
+
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('')
|
|
1023
1026
|
html += `</ul></div>`
|
|
1024
1027
|
}
|
|
1025
1028
|
else if (this.options.mode === 'monthyear') {
|
|
@@ -1036,7 +1039,7 @@ class WebsyDatePicker {
|
|
|
1036
1039
|
}
|
|
1037
1040
|
html += paddedMonths.join('')
|
|
1038
1041
|
}
|
|
1039
|
-
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('')
|
|
1042
|
+
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('')
|
|
1040
1043
|
html += `</ul>`
|
|
1041
1044
|
}
|
|
1042
1045
|
html += `</div>`
|
|
@@ -1129,15 +1132,6 @@ class WebsyDatePicker {
|
|
|
1129
1132
|
this.selectedRangeDates = [...this.options.ranges[this.options.mode][index].range]
|
|
1130
1133
|
this.currentselection = this.options.ranges[this.options.mode][index].range.map(d => d.getTime())
|
|
1131
1134
|
this.selectedRange = +index
|
|
1132
|
-
const el = document.getElementById(`${this.elementId}_header`)
|
|
1133
|
-
if (el) {
|
|
1134
|
-
if (this.selectedRange === 0) {
|
|
1135
|
-
el.classList.remove('range-selected')
|
|
1136
|
-
}
|
|
1137
|
-
else {
|
|
1138
|
-
el.classList.add('range-selected')
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
1135
|
this.highlightRange()
|
|
1142
1136
|
this.updateRange()
|
|
1143
1137
|
this.close(confirm, true)
|
|
@@ -1146,14 +1140,16 @@ class WebsyDatePicker {
|
|
|
1146
1140
|
selectCustomRange (rangeInput) {
|
|
1147
1141
|
this.selectedRange = -1
|
|
1148
1142
|
let isContinuousRange = true
|
|
1149
|
-
if (rangeInput.length === 1) {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
}
|
|
1153
|
-
else if (rangeInput.length === 2) {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
}
|
|
1143
|
+
// if (rangeInput.length === 1) {
|
|
1144
|
+
// this.selectedRangeDates = [...rangeInput]
|
|
1145
|
+
// this.customRangeSelected = true
|
|
1146
|
+
// }
|
|
1147
|
+
// else if (rangeInput.length === 2) {
|
|
1148
|
+
// this.selectedRangeDates = [...rangeInput]
|
|
1149
|
+
// this.customRangeSelected = true
|
|
1150
|
+
// }
|
|
1151
|
+
this.selectedRangeDates = [...rangeInput]
|
|
1152
|
+
this.customRangeSelected = true
|
|
1157
1153
|
rangeInput.forEach((r, i) => {
|
|
1158
1154
|
if (i > 0) {
|
|
1159
1155
|
if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
|
|
@@ -1291,6 +1287,15 @@ class WebsyDatePicker {
|
|
|
1291
1287
|
if (labelEl) {
|
|
1292
1288
|
labelEl.innerHTML = range.label
|
|
1293
1289
|
}
|
|
1290
|
+
const headerEl = document.getElementById(`${this.elementId}_header`)
|
|
1291
|
+
if (headerEl) {
|
|
1292
|
+
if (this.selectedRange === 0) {
|
|
1293
|
+
headerEl.classList.remove('range-selected')
|
|
1294
|
+
}
|
|
1295
|
+
else {
|
|
1296
|
+
headerEl.classList.add('range-selected')
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1294
1299
|
}
|
|
1295
1300
|
}
|
|
1296
1301
|
|
|
@@ -1767,7 +1772,8 @@ class WebsyDragDrop {
|
|
|
1767
1772
|
const DEFAULTS = {
|
|
1768
1773
|
items: [],
|
|
1769
1774
|
orientation: 'horizontal',
|
|
1770
|
-
dropPlaceholder: 'Drop item here'
|
|
1775
|
+
dropPlaceholder: 'Drop item here',
|
|
1776
|
+
accepts: 'application/wd-item'
|
|
1771
1777
|
}
|
|
1772
1778
|
this.busy = false
|
|
1773
1779
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
@@ -1826,7 +1832,7 @@ class WebsyDragDrop {
|
|
|
1826
1832
|
item.id = WebsyDesigns.Utils.createIdentity()
|
|
1827
1833
|
}
|
|
1828
1834
|
let html = `
|
|
1829
|
-
<div id='${item.id}_item' class='websy-dragdrop-item' draggable='true' data-id='${item.id}'>
|
|
1835
|
+
<div id='${item.id}_item' class='websy-dragdrop-item ${(item.classes || []).join(' ')}' draggable='true' data-id='${item.id}'>
|
|
1830
1836
|
<div id='${item.id}_itemInner' class='websy-dragdrop-item-inner' data-id='${item.id}'>
|
|
1831
1837
|
`
|
|
1832
1838
|
if (item.component) {
|
|
@@ -1855,20 +1861,23 @@ class WebsyDragDrop {
|
|
|
1855
1861
|
}
|
|
1856
1862
|
handleDragStart (event) {
|
|
1857
1863
|
this.draggedId = event.target.getAttribute('data-id')
|
|
1858
|
-
event.dataTransfer.effectAllowed = 'move'
|
|
1859
|
-
event.dataTransfer.setData(
|
|
1860
|
-
|
|
1861
|
-
event.target.style.opacity = 0.5
|
|
1864
|
+
event.dataTransfer.effectAllowed = 'move'
|
|
1865
|
+
event.dataTransfer.setData(this.options.accepts, JSON.stringify({el: event.target.id, id: this.elementId, itemId: this.draggedId}))
|
|
1866
|
+
event.target.classList.add('dragging')
|
|
1867
|
+
// event.target.style.opacity = 0.5
|
|
1862
1868
|
this.dragging = true
|
|
1863
1869
|
}
|
|
1864
|
-
handleDragOver (event) {
|
|
1865
|
-
// console.log('drag over', event.target.classList)
|
|
1870
|
+
handleDragOver (event) {
|
|
1866
1871
|
if (event.preventDefault) {
|
|
1867
1872
|
event.preventDefault()
|
|
1868
1873
|
}
|
|
1874
|
+
console.log('drag', event.target.classList)
|
|
1869
1875
|
if (!event.target.classList.contains('droppable')) {
|
|
1870
1876
|
return
|
|
1871
1877
|
}
|
|
1878
|
+
if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
|
|
1879
|
+
return
|
|
1880
|
+
}
|
|
1872
1881
|
event.target.classList.add('drag-over')
|
|
1873
1882
|
}
|
|
1874
1883
|
handleDragLeave (event) {
|
|
@@ -1884,14 +1893,17 @@ class WebsyDragDrop {
|
|
|
1884
1893
|
}
|
|
1885
1894
|
handleDrop (event) {
|
|
1886
1895
|
// console.log('drag drop')
|
|
1887
|
-
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1888
|
-
const data = JSON.parse(event.dataTransfer.getData(
|
|
1896
|
+
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1897
|
+
const data = JSON.parse(event.dataTransfer.getData(this.options.accepts))
|
|
1889
1898
|
if (event.preventDefault) {
|
|
1890
1899
|
event.preventDefault()
|
|
1891
1900
|
}
|
|
1892
1901
|
if (!event.target.classList.contains('droppable')) {
|
|
1893
1902
|
return
|
|
1894
1903
|
}
|
|
1904
|
+
if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
|
|
1905
|
+
return
|
|
1906
|
+
}
|
|
1895
1907
|
let side = event.target.getAttribute('data-side')
|
|
1896
1908
|
let id = event.target.getAttribute('data-id')
|
|
1897
1909
|
let index = this.getItemIndex(id)
|
|
@@ -1941,6 +1953,7 @@ class WebsyDragDrop {
|
|
|
1941
1953
|
handleDragEnd (event) {
|
|
1942
1954
|
// console.log('drag end')
|
|
1943
1955
|
event.target.style.opacity = 1
|
|
1956
|
+
event.target.classList.remove('dragging')
|
|
1944
1957
|
this.draggedId = null
|
|
1945
1958
|
this.dragging = false
|
|
1946
1959
|
const startEl = document.getElementById(`${this.elementId}start_item`)
|
|
@@ -5619,10 +5632,16 @@ class WebsyTable3 {
|
|
|
5619
5632
|
data.forEach(row => {
|
|
5620
5633
|
bodyHtml += `<tr class="websy-table-row">`
|
|
5621
5634
|
row.forEach((cell, cellIndex) => {
|
|
5635
|
+
if (typeof sizingColumns[cellIndex] === 'undefined') {
|
|
5636
|
+
return // need to revisit this logic
|
|
5637
|
+
}
|
|
5622
5638
|
let style = ''
|
|
5623
5639
|
if (cell.style) {
|
|
5624
5640
|
style += cell.style
|
|
5625
5641
|
}
|
|
5642
|
+
if (useWidths === true) {
|
|
5643
|
+
style += `max-width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important;`
|
|
5644
|
+
}
|
|
5626
5645
|
if (cell.backgroundColor) {
|
|
5627
5646
|
style += `background-color: ${cell.backgroundColor}; `
|
|
5628
5647
|
if (!cell.color) {
|
|
@@ -5632,8 +5651,9 @@ class WebsyTable3 {
|
|
|
5632
5651
|
if (cell.color) {
|
|
5633
5652
|
style += `color: ${cell.color}; `
|
|
5634
5653
|
}
|
|
5654
|
+
console.log('rowspan', cell.rowspan)
|
|
5635
5655
|
bodyHtml += `<td
|
|
5636
|
-
class='websy-table-cell'
|
|
5656
|
+
class='websy-table-cell ${(cell.classes || []).join(' ')}'
|
|
5637
5657
|
style='${style}'
|
|
5638
5658
|
data-info='${cell.value}'
|
|
5639
5659
|
colspan='${cell.colspan || 1}'
|
|
@@ -5792,11 +5812,13 @@ class WebsyTable3 {
|
|
|
5792
5812
|
}
|
|
5793
5813
|
})
|
|
5794
5814
|
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
5815
|
+
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)
|
|
5795
5816
|
const outerSize = outerEl.getBoundingClientRect()
|
|
5796
5817
|
if (this.sizes.totalWidth < outerSize.width) {
|
|
5797
5818
|
this.sizes.totalWidth = 0
|
|
5819
|
+
this.sizes.totalNonPinnedWidth = 0
|
|
5798
5820
|
let equalWidth = outerSize.width / this.options.columns[this.options.columns.length - 1].length
|
|
5799
|
-
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5821
|
+
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5800
5822
|
if (!c.width) {
|
|
5801
5823
|
if (c.actualWidth < equalWidth) {
|
|
5802
5824
|
// adjust the width
|
|
@@ -5804,6 +5826,9 @@ class WebsyTable3 {
|
|
|
5804
5826
|
}
|
|
5805
5827
|
}
|
|
5806
5828
|
this.sizes.totalWidth += c.width || c.actualWidth
|
|
5829
|
+
if (i < this.pinnedColumns) {
|
|
5830
|
+
this.sizes.totalNonPinnedWidth += c.width || c.actualWidth
|
|
5831
|
+
}
|
|
5807
5832
|
equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
|
|
5808
5833
|
})
|
|
5809
5834
|
}
|
|
@@ -5824,9 +5849,15 @@ class WebsyTable3 {
|
|
|
5824
5849
|
if (this.sizes.rowsToRender < this.totalRowCount) {
|
|
5825
5850
|
this.vScrollRequired = true
|
|
5826
5851
|
}
|
|
5852
|
+
else {
|
|
5853
|
+
this.vScrollRequired = false
|
|
5854
|
+
}
|
|
5827
5855
|
if (this.sizes.totalWidth > this.sizes.outer.width) {
|
|
5828
5856
|
this.hScrollRequired = true
|
|
5829
5857
|
}
|
|
5858
|
+
else {
|
|
5859
|
+
this.hScrollRequired = false
|
|
5860
|
+
}
|
|
5830
5861
|
this.options.allColumns = this.options.columns.map(c => c)
|
|
5831
5862
|
console.log('sizes', this.sizes)
|
|
5832
5863
|
return this.sizes
|
|
@@ -5971,10 +6002,10 @@ class WebsyTable3 {
|
|
|
5971
6002
|
if (this.hScrollRequired === true) {
|
|
5972
6003
|
hScrollEl.style.left = `${this.sizes.table.width - this.sizes.scrollableWidth}px`
|
|
5973
6004
|
hScrollEl.style.width = `${this.sizes.scrollableWidth - 20}px`
|
|
5974
|
-
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.
|
|
6005
|
+
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalNonPinnedWidth)) + 'px'
|
|
5975
6006
|
}
|
|
5976
6007
|
else {
|
|
5977
|
-
hHandleEl.style.
|
|
6008
|
+
hHandleEl.style.width = '0px'
|
|
5978
6009
|
}
|
|
5979
6010
|
}
|
|
5980
6011
|
}
|
|
@@ -6004,9 +6035,7 @@ class WebsyTable3 {
|
|
|
6004
6035
|
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
6005
6036
|
if (el) {
|
|
6006
6037
|
el.classList.add('has-error')
|
|
6007
|
-
}
|
|
6008
|
-
const tableEl = document.getElementById(`${this.elementId}_tableInner`)
|
|
6009
|
-
tableEl.classList.add('hidden')
|
|
6038
|
+
}
|
|
6010
6039
|
const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
|
|
6011
6040
|
if (containerEl) {
|
|
6012
6041
|
containerEl.classList.add('active')
|
|
@@ -6025,6 +6054,19 @@ class WebsyTable3 {
|
|
|
6025
6054
|
}
|
|
6026
6055
|
}
|
|
6027
6056
|
scrollX (diff) {
|
|
6057
|
+
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
6058
|
+
if (!el.classList.contains('scrolling')) {
|
|
6059
|
+
el.classList.add('scrolling')
|
|
6060
|
+
}
|
|
6061
|
+
if (this.scrollTimeoutFn) {
|
|
6062
|
+
clearTimeout(this.scrollTimeoutFn)
|
|
6063
|
+
}
|
|
6064
|
+
this.scrollTimeoutFn = setTimeout(() => {
|
|
6065
|
+
el.classList.remove('scrolling')
|
|
6066
|
+
}, 200)
|
|
6067
|
+
if (this.hScrollRequired === false) {
|
|
6068
|
+
return
|
|
6069
|
+
}
|
|
6028
6070
|
const scrollContainerEl = document.getElementById(`${this.elementId}_hScrollContainer`)
|
|
6029
6071
|
const scrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
6030
6072
|
let handlePos
|
|
@@ -6038,11 +6080,11 @@ class WebsyTable3 {
|
|
|
6038
6080
|
console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width)
|
|
6039
6081
|
scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px'
|
|
6040
6082
|
if (this.options.onScroll) {
|
|
6041
|
-
let actualLeft = (this.sizes.
|
|
6083
|
+
let actualLeft = (this.sizes.totalNonPinnedWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace)
|
|
6042
6084
|
let cumulativeWidth = 0
|
|
6043
6085
|
this.startCol = 0
|
|
6044
6086
|
this.endCol = 0
|
|
6045
|
-
for (let i =
|
|
6087
|
+
for (let i = this.pinnedColumns; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
6046
6088
|
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
|
|
6047
6089
|
console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
6048
6090
|
if (actualLeft < cumulativeWidth) {
|
|
@@ -6068,6 +6110,19 @@ class WebsyTable3 {
|
|
|
6068
6110
|
}
|
|
6069
6111
|
}
|
|
6070
6112
|
scrollY (diff) {
|
|
6113
|
+
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
6114
|
+
if (!el.classList.contains('scrolling')) {
|
|
6115
|
+
el.classList.add('scrolling')
|
|
6116
|
+
}
|
|
6117
|
+
if (this.scrollTimeoutFn) {
|
|
6118
|
+
clearTimeout(this.scrollTimeoutFn)
|
|
6119
|
+
}
|
|
6120
|
+
this.scrollTimeoutFn = setTimeout(() => {
|
|
6121
|
+
el.classList.remove('scrolling')
|
|
6122
|
+
}, 200)
|
|
6123
|
+
if (this.vScrollRequired === false) {
|
|
6124
|
+
return
|
|
6125
|
+
}
|
|
6071
6126
|
const scrollContainerEl = document.getElementById(`${this.elementId}_vScrollContainer`)
|
|
6072
6127
|
const scrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
6073
6128
|
let handlePos
|
|
@@ -7019,7 +7074,7 @@ bars
|
|
|
7019
7074
|
.attr('x', getBarX.bind(this))
|
|
7020
7075
|
.attr('y', getBarY.bind(this))
|
|
7021
7076
|
.transition(this.transition)
|
|
7022
|
-
.attr('fill', d => d.color || series.color)
|
|
7077
|
+
.attr('fill', d => d.y.color || d.color || series.color)
|
|
7023
7078
|
|
|
7024
7079
|
bars
|
|
7025
7080
|
.enter()
|
|
@@ -7029,7 +7084,7 @@ bars
|
|
|
7029
7084
|
.attr('x', getBarX.bind(this))
|
|
7030
7085
|
.attr('y', getBarY.bind(this))
|
|
7031
7086
|
// .transition(this.transition)
|
|
7032
|
-
.attr('fill', d => d.color || series.color)
|
|
7087
|
+
.attr('fill', d => d.y.color || d.color || series.color)
|
|
7033
7088
|
.attr('class', d => {
|
|
7034
7089
|
return `bar bar_${series.key}`
|
|
7035
7090
|
})
|
|
@@ -7044,7 +7099,7 @@ if (this.options.orientation === 'horizontal') {
|
|
|
7044
7099
|
xAxis = 'leftAxis'
|
|
7045
7100
|
yAxis = 'bottomAxis'
|
|
7046
7101
|
}
|
|
7047
|
-
if (this.options.showLabels) {
|
|
7102
|
+
if (this.options.showLabels === true || series.showLabels === true) {
|
|
7048
7103
|
// need to add logic to handle positioning options
|
|
7049
7104
|
// e.g. Inside, Outide, Auto (this will also affect the available plot space)
|
|
7050
7105
|
// We currently only support 'Auto'
|
|
@@ -7058,10 +7113,30 @@ if (this.options.showLabels) {
|
|
|
7058
7113
|
.attr('x', getLabelX.bind(this))
|
|
7059
7114
|
.attr('y', getLabelY.bind(this))
|
|
7060
7115
|
.attr('class', `label_${series.key}`)
|
|
7061
|
-
.
|
|
7062
|
-
.style('
|
|
7116
|
+
.attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
7117
|
+
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
7063
7118
|
.transition(this.transition)
|
|
7064
7119
|
.text(d => d.y.label || d.y.value)
|
|
7120
|
+
.each(function (d, i) {
|
|
7121
|
+
if (that.options.orientation === 'horizontal') {
|
|
7122
|
+
if (that.options.grouping === 'stacked') {
|
|
7123
|
+
this.setAttribute('text-anchor', 'middle')
|
|
7124
|
+
}
|
|
7125
|
+
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
7126
|
+
this.setAttribute('text-anchor', 'end')
|
|
7127
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
7128
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
7129
|
+
}
|
|
7130
|
+
else {
|
|
7131
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
7132
|
+
}
|
|
7133
|
+
}
|
|
7134
|
+
else {
|
|
7135
|
+
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
7136
|
+
this.setAttribute('y', +(this.getAttribute('y')) + 8)
|
|
7137
|
+
}
|
|
7138
|
+
}
|
|
7139
|
+
})
|
|
7065
7140
|
|
|
7066
7141
|
labels
|
|
7067
7142
|
.enter()
|
|
@@ -7071,8 +7146,8 @@ if (this.options.showLabels) {
|
|
|
7071
7146
|
.attr('y', getLabelY.bind(this))
|
|
7072
7147
|
.attr('alignment-baseline', 'central')
|
|
7073
7148
|
.attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle')
|
|
7074
|
-
.
|
|
7075
|
-
.style('
|
|
7149
|
+
.attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
7150
|
+
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
7076
7151
|
.text(d => d.y.label || d.y.value)
|
|
7077
7152
|
.each(function (d, i) {
|
|
7078
7153
|
if (that.options.orientation === 'horizontal') {
|
|
@@ -7081,8 +7156,12 @@ if (this.options.showLabels) {
|
|
|
7081
7156
|
}
|
|
7082
7157
|
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
7083
7158
|
this.setAttribute('text-anchor', 'end')
|
|
7084
|
-
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
7159
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
7160
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
7085
7161
|
}
|
|
7162
|
+
else {
|
|
7163
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
7164
|
+
}
|
|
7086
7165
|
}
|
|
7087
7166
|
else {
|
|
7088
7167
|
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|