@websy/websy-designs 1.3.1 → 1.3.3
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 +2 -1
- package/dist/websy-designs-es6.debug.js +78 -19
- package/dist/websy-designs-es6.js +86 -13
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +79 -20
- package/dist/websy-designs.js +87 -14
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -81,7 +81,7 @@ let convertHTMLToPDF = (html, name, callback, options_in = null, displayHeaderFo
|
|
|
81
81
|
// page.on('request', request => request.continue())
|
|
82
82
|
// })
|
|
83
83
|
page.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36').then(() => {
|
|
84
|
-
page.setContent(html, {waitUntil: ['load', 'domcontentloaded', 'networkidle2', 'networkidle0']}).then(() => {
|
|
84
|
+
page.setContent(html, {waitUntil: process.env.PDF_WAIT_FOR || ['load', 'domcontentloaded', 'networkidle2', 'networkidle0']}).then(() => {
|
|
85
85
|
page.evaluateHandle('document.fonts.ready').then(() => {
|
|
86
86
|
report.pdfPage(page, options).then(pdf => {
|
|
87
87
|
browser.close()
|
|
@@ -92,9 +92,18 @@ let convertHTMLToPDF = (html, name, callback, options_in = null, displayHeaderFo
|
|
|
92
92
|
browser.close()
|
|
93
93
|
callback(error)
|
|
94
94
|
})
|
|
95
|
-
}, err =>
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
}, err => {
|
|
96
|
+
console.log('error evaluating handle in puppeteer', err)
|
|
97
|
+
callback(err)
|
|
98
|
+
})
|
|
99
|
+
}, err => {
|
|
100
|
+
console.log('error setting content in puppeteer', err)
|
|
101
|
+
callback(err)
|
|
102
|
+
})
|
|
103
|
+
}, err => {
|
|
104
|
+
console.log('error setting user agent in puppeteer', err)
|
|
105
|
+
callback(err)
|
|
106
|
+
})
|
|
98
107
|
// page.goto(process.env.PDF_PAGE || 'http://localhost:4000', {waitUntil: ['load', 'domcontentloaded', 'networkidle2', 'networkidle0']}).then(gotoResponse => {
|
|
99
108
|
// page.setViewport({width: 1500, height: 2000, deviceScaleFactor: 1}).then(() => {
|
|
100
109
|
// options.path = `${process.env.APP_ROOT}/pdf/${pdfId}.pdf`
|
|
@@ -550,8 +550,9 @@ class WebsyDatePicker {
|
|
|
550
550
|
let rangeEnd
|
|
551
551
|
if (this.options.mode === 'date') {
|
|
552
552
|
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
|
|
553
|
-
d.setUTCHours(12, 0, 0, 0)
|
|
553
|
+
// d.setUTCHours(12, 0, 0, 0)
|
|
554
554
|
d = d.getTime()
|
|
555
|
+
// console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
555
556
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
556
557
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
557
558
|
}
|
|
@@ -560,8 +561,10 @@ class WebsyDatePicker {
|
|
|
560
561
|
rangeStart = this.selectedRangeDates[0]
|
|
561
562
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
|
|
562
563
|
}
|
|
563
|
-
else if (this.options.mode === 'monthyear') {
|
|
564
|
-
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)
|
|
565
568
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
566
569
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
567
570
|
}
|
|
@@ -3059,6 +3062,7 @@ class WebsyResultList {
|
|
|
3059
3062
|
this.rows = []
|
|
3060
3063
|
this.apiService = new WebsyDesigns.APIService('/api')
|
|
3061
3064
|
this.templateService = new WebsyDesigns.APIService('')
|
|
3065
|
+
this.activeTemplate = ''
|
|
3062
3066
|
if (!elementId) {
|
|
3063
3067
|
console.log('No element Id provided for Websy Search List')
|
|
3064
3068
|
return
|
|
@@ -3080,16 +3084,17 @@ class WebsyResultList {
|
|
|
3080
3084
|
appendData (d) {
|
|
3081
3085
|
let startIndex = this.rows.length
|
|
3082
3086
|
this.rows = this.rows.concat(d)
|
|
3087
|
+
this.activeTemplate = this.options.template
|
|
3083
3088
|
const html = this.buildHTML(d, startIndex)
|
|
3084
3089
|
const el = document.getElementById(this.elementId)
|
|
3085
3090
|
el.innerHTML += html.replace(/\n/g, '')
|
|
3086
3091
|
}
|
|
3087
|
-
buildHTML (d, startIndex = 0) {
|
|
3092
|
+
buildHTML (d, startIndex = 0, inputTemplate) {
|
|
3088
3093
|
let html = ``
|
|
3089
3094
|
if (this.options.template) {
|
|
3090
3095
|
if (d.length > 0) {
|
|
3091
3096
|
d.forEach((row, ix) => {
|
|
3092
|
-
let template = `${ix > 0 ? '-->' : ''}${this.options.template}${ix < d.length - 1 ? '<!--' : ''}`
|
|
3097
|
+
let template = `${ix > 0 ? '-->' : ''}${inputTemplate || this.options.template}${ix < d.length - 1 ? '<!--' : ''}`
|
|
3093
3098
|
// find conditional elements
|
|
3094
3099
|
let ifMatches = [...template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g)]
|
|
3095
3100
|
ifMatches.forEach(m => {
|
|
@@ -3168,16 +3173,39 @@ class WebsyResultList {
|
|
|
3168
3173
|
}
|
|
3169
3174
|
}
|
|
3170
3175
|
})
|
|
3176
|
+
let forMatches = [...template.matchAll(/<\s*for[^>]*>([\s\S]*?)<\s*\/\s*for>/g)]
|
|
3177
|
+
forMatches.forEach(m => {
|
|
3178
|
+
let itemsMatch = m[0].match(/(items=["|']\w.+)["|']/g)
|
|
3179
|
+
let forMarkup = m[0].match(/<\s*for[^>]*>/)
|
|
3180
|
+
let withoutFor = m[0].replace(forMarkup, '').replace('</for>', '').replace(/<\s*for[^>]*>/g, '')
|
|
3181
|
+
if (itemsMatch && itemsMatch[0]) {
|
|
3182
|
+
let c = itemsMatch[0].trim().replace('items=', '')
|
|
3183
|
+
if (c.split('')[0] === '"') {
|
|
3184
|
+
c = c.replace(/"/g, '')
|
|
3185
|
+
}
|
|
3186
|
+
else if (c.split('')[0] === '\'') {
|
|
3187
|
+
c = c.replace(/'/g, '')
|
|
3188
|
+
}
|
|
3189
|
+
let items = row
|
|
3190
|
+
let parts = c.split('.')
|
|
3191
|
+
parts.forEach(p => {
|
|
3192
|
+
items = items[p]
|
|
3193
|
+
})
|
|
3194
|
+
template = template.replace(m[0], this.buildHTML(items, 0, withoutFor))
|
|
3195
|
+
}
|
|
3196
|
+
})
|
|
3171
3197
|
let tagMatches = [...template.matchAll(/(\sdata-event=["|']\w.+)["|']/g)]
|
|
3172
3198
|
tagMatches.forEach(m => {
|
|
3173
3199
|
if (m[0] && m.index > -1) {
|
|
3174
3200
|
template = template.replace(m[0], `${m[0]} data-id=${startIndex + ix}`)
|
|
3175
3201
|
}
|
|
3176
|
-
})
|
|
3177
|
-
|
|
3202
|
+
})
|
|
3203
|
+
let flatRow = this.flattenObject(row)
|
|
3204
|
+
for (let key in flatRow) {
|
|
3178
3205
|
let rg = new RegExp(`{${key}}`, 'gm')
|
|
3179
|
-
template = template.replace(rg,
|
|
3206
|
+
template = template.replace(rg, flatRow[key] || '')
|
|
3180
3207
|
}
|
|
3208
|
+
template = template.replace(/\{(.*?)\}/g, '')
|
|
3181
3209
|
html += template
|
|
3182
3210
|
})
|
|
3183
3211
|
}
|
|
@@ -3202,6 +3230,27 @@ class WebsyResultList {
|
|
|
3202
3230
|
}
|
|
3203
3231
|
return null
|
|
3204
3232
|
}
|
|
3233
|
+
flattenObject (obj) {
|
|
3234
|
+
const toReturn = {}
|
|
3235
|
+
for (const i in obj) {
|
|
3236
|
+
if (!obj.hasOwnProperty(i)) {
|
|
3237
|
+
continue
|
|
3238
|
+
}
|
|
3239
|
+
if (typeof obj[i] === 'object') {
|
|
3240
|
+
const flatObject = this.flattenObject(obj[i])
|
|
3241
|
+
for (const x in flatObject) {
|
|
3242
|
+
if (!flatObject.hasOwnProperty(x)) {
|
|
3243
|
+
continue
|
|
3244
|
+
}
|
|
3245
|
+
toReturn[i + '.' + x] = flatObject[x]
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
else {
|
|
3249
|
+
toReturn[i] = obj[i]
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
return JSON.parse(JSON.stringify(toReturn))
|
|
3253
|
+
}
|
|
3205
3254
|
handleClick (event) {
|
|
3206
3255
|
if (event.target.classList.contains('clickable')) {
|
|
3207
3256
|
let l = event.target.getAttribute('data-event')
|
|
@@ -3287,7 +3336,7 @@ class WebsyRouter {
|
|
|
3287
3336
|
if (this.options.onHide) {
|
|
3288
3337
|
this.on('hide', this.options.onHide)
|
|
3289
3338
|
}
|
|
3290
|
-
this.init()
|
|
3339
|
+
// this.init()
|
|
3291
3340
|
}
|
|
3292
3341
|
addGroup (group) {
|
|
3293
3342
|
if (!this.groups[group]) {
|
|
@@ -6771,15 +6820,20 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
6771
6820
|
.text(d => d.y.label || d.y.value)
|
|
6772
6821
|
.each(function (d, i) {
|
|
6773
6822
|
if (that.options.orientation === 'horizontal') {
|
|
6774
|
-
if (that.options.grouping === 'stacked') {
|
|
6823
|
+
if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
|
|
6775
6824
|
this.setAttribute('text-anchor', 'middle')
|
|
6776
6825
|
}
|
|
6777
6826
|
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
6778
6827
|
this.setAttribute('text-anchor', 'end')
|
|
6779
|
-
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6828
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6780
6829
|
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6781
6830
|
}
|
|
6782
|
-
else {
|
|
6831
|
+
else if (series.labelPosition === 'outside') {
|
|
6832
|
+
this.setAttribute('text-anchor', 'start')
|
|
6833
|
+
this.setAttribute('x', +(this.getAttribute('x')) + 8)
|
|
6834
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6835
|
+
}
|
|
6836
|
+
else {
|
|
6783
6837
|
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6784
6838
|
}
|
|
6785
6839
|
}
|
|
@@ -6803,15 +6857,20 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
6803
6857
|
.text(d => d.y.label || d.y.value)
|
|
6804
6858
|
.each(function (d, i) {
|
|
6805
6859
|
if (that.options.orientation === 'horizontal') {
|
|
6806
|
-
if (that.options.grouping === 'stacked') {
|
|
6860
|
+
if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
|
|
6807
6861
|
this.setAttribute('text-anchor', 'middle')
|
|
6808
6862
|
}
|
|
6809
6863
|
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
6810
6864
|
this.setAttribute('text-anchor', 'end')
|
|
6811
|
-
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6865
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6812
6866
|
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6813
6867
|
}
|
|
6814
|
-
else {
|
|
6868
|
+
else if (series.labelPosition === 'outside') {
|
|
6869
|
+
this.setAttribute('text-anchor', 'start')
|
|
6870
|
+
this.setAttribute('x', +(this.getAttribute('x')) + 8)
|
|
6871
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6872
|
+
}
|
|
6873
|
+
else {
|
|
6815
6874
|
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6816
6875
|
}
|
|
6817
6876
|
}
|
|
@@ -6823,10 +6882,10 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
6823
6882
|
})
|
|
6824
6883
|
}
|
|
6825
6884
|
|
|
6826
|
-
function getLabelX (d) {
|
|
6885
|
+
function getLabelX (d, labelPosition = 'inside') {
|
|
6827
6886
|
if (this.options.orientation === 'horizontal') {
|
|
6828
6887
|
if (this.options.grouping === 'stacked') {
|
|
6829
|
-
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / 2)
|
|
6888
|
+
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
6830
6889
|
}
|
|
6831
6890
|
else {
|
|
6832
6891
|
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4
|
|
@@ -6836,13 +6895,13 @@ function getLabelX (d) {
|
|
|
6836
6895
|
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
|
|
6837
6896
|
}
|
|
6838
6897
|
}
|
|
6839
|
-
function getLabelY (d) {
|
|
6898
|
+
function getLabelY (d, labelPosition = 'inside') {
|
|
6840
6899
|
if (this.options.orientation === 'horizontal') {
|
|
6841
6900
|
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
|
|
6842
6901
|
}
|
|
6843
6902
|
else {
|
|
6844
6903
|
if (this.options.grouping === 'stacked') {
|
|
6845
|
-
|
|
6904
|
+
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
6846
6905
|
}
|
|
6847
6906
|
else {
|
|
6848
6907
|
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - 4
|
|
@@ -614,9 +614,10 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
614
614
|
var rangeEnd = void 0;
|
|
615
615
|
|
|
616
616
|
if (this.options.mode === 'date') {
|
|
617
|
-
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + _i * this.oneDay));
|
|
618
|
-
|
|
619
|
-
d = d.getTime();
|
|
617
|
+
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + _i * this.oneDay)); // d.setUTCHours(12, 0, 0, 0)
|
|
618
|
+
|
|
619
|
+
d = d.getTime(); // console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
620
|
+
|
|
620
621
|
rangeStart = this.selectedRangeDates[0].getTime();
|
|
621
622
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime();
|
|
622
623
|
} else if (this.options.mode === 'year') {
|
|
@@ -624,7 +625,9 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
624
625
|
rangeStart = this.selectedRangeDates[0];
|
|
625
626
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1];
|
|
626
627
|
} else if (this.options.mode === 'monthyear') {
|
|
627
|
-
d = new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + _i);
|
|
628
|
+
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + _i));
|
|
629
|
+
d = d.getTime();
|
|
630
|
+
console.log('highlighting', this.selectedRangeDates[0].getTime(), d);
|
|
628
631
|
rangeStart = this.selectedRangeDates[0].getTime();
|
|
629
632
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime();
|
|
630
633
|
} else if (this.options.mode === 'hour') {
|
|
@@ -3343,6 +3346,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3343
3346
|
this.rows = [];
|
|
3344
3347
|
this.apiService = new WebsyDesigns.APIService('/api');
|
|
3345
3348
|
this.templateService = new WebsyDesigns.APIService('');
|
|
3349
|
+
this.activeTemplate = '';
|
|
3346
3350
|
|
|
3347
3351
|
if (!elementId) {
|
|
3348
3352
|
console.log('No element Id provided for Websy Search List');
|
|
@@ -3371,6 +3375,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3371
3375
|
value: function appendData(d) {
|
|
3372
3376
|
var startIndex = this.rows.length;
|
|
3373
3377
|
this.rows = this.rows.concat(d);
|
|
3378
|
+
this.activeTemplate = this.options.template;
|
|
3374
3379
|
var html = this.buildHTML(d, startIndex);
|
|
3375
3380
|
var el = document.getElementById(this.elementId);
|
|
3376
3381
|
el.innerHTML += html.replace(/\n/g, '');
|
|
@@ -3381,12 +3386,13 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3381
3386
|
var _this21 = this;
|
|
3382
3387
|
|
|
3383
3388
|
var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
3389
|
+
var inputTemplate = arguments.length > 2 ? arguments[2] : undefined;
|
|
3384
3390
|
var html = "";
|
|
3385
3391
|
|
|
3386
3392
|
if (this.options.template) {
|
|
3387
3393
|
if (d.length > 0) {
|
|
3388
3394
|
d.forEach(function (row, ix) {
|
|
3389
|
-
var template = "".concat(ix > 0 ? '-->' : '').concat(_this21.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
|
|
3395
|
+
var template = "".concat(ix > 0 ? '-->' : '').concat(inputTemplate || _this21.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
|
|
3390
3396
|
|
|
3391
3397
|
var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
|
|
3392
3398
|
|
|
@@ -3470,6 +3476,31 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3470
3476
|
}
|
|
3471
3477
|
});
|
|
3472
3478
|
|
|
3479
|
+
var forMatches = _toConsumableArray(template.matchAll(/<\s*for[^>]*>([\s\S]*?)<\s*\/\s*for>/g));
|
|
3480
|
+
|
|
3481
|
+
forMatches.forEach(function (m) {
|
|
3482
|
+
var itemsMatch = m[0].match(/(items=["|']\w.+)["|']/g);
|
|
3483
|
+
var forMarkup = m[0].match(/<\s*for[^>]*>/);
|
|
3484
|
+
var withoutFor = m[0].replace(forMarkup, '').replace('</for>', '').replace(/<\s*for[^>]*>/g, '');
|
|
3485
|
+
|
|
3486
|
+
if (itemsMatch && itemsMatch[0]) {
|
|
3487
|
+
var c = itemsMatch[0].trim().replace('items=', '');
|
|
3488
|
+
|
|
3489
|
+
if (c.split('')[0] === '"') {
|
|
3490
|
+
c = c.replace(/"/g, '');
|
|
3491
|
+
} else if (c.split('')[0] === '\'') {
|
|
3492
|
+
c = c.replace(/'/g, '');
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
var items = row;
|
|
3496
|
+
var parts = c.split('.');
|
|
3497
|
+
parts.forEach(function (p) {
|
|
3498
|
+
items = items[p];
|
|
3499
|
+
});
|
|
3500
|
+
template = template.replace(m[0], _this21.buildHTML(items, 0, withoutFor));
|
|
3501
|
+
}
|
|
3502
|
+
});
|
|
3503
|
+
|
|
3473
3504
|
var tagMatches = _toConsumableArray(template.matchAll(/(\sdata-event=["|']\w.+)["|']/g));
|
|
3474
3505
|
|
|
3475
3506
|
tagMatches.forEach(function (m) {
|
|
@@ -3478,11 +3509,14 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3478
3509
|
}
|
|
3479
3510
|
});
|
|
3480
3511
|
|
|
3481
|
-
|
|
3512
|
+
var flatRow = _this21.flattenObject(row);
|
|
3513
|
+
|
|
3514
|
+
for (var key in flatRow) {
|
|
3482
3515
|
var rg = new RegExp("{".concat(key, "}"), 'gm');
|
|
3483
|
-
template = template.replace(rg,
|
|
3516
|
+
template = template.replace(rg, flatRow[key] || '');
|
|
3484
3517
|
}
|
|
3485
3518
|
|
|
3519
|
+
template = template.replace(/\{(.*?)\}/g, '');
|
|
3486
3520
|
html += template;
|
|
3487
3521
|
});
|
|
3488
3522
|
} else if (this.options.noRowsHTML) {
|
|
@@ -3503,6 +3537,33 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3503
3537
|
|
|
3504
3538
|
return null;
|
|
3505
3539
|
}
|
|
3540
|
+
}, {
|
|
3541
|
+
key: "flattenObject",
|
|
3542
|
+
value: function flattenObject(obj) {
|
|
3543
|
+
var toReturn = {};
|
|
3544
|
+
|
|
3545
|
+
for (var i in obj) {
|
|
3546
|
+
if (!obj.hasOwnProperty(i)) {
|
|
3547
|
+
continue;
|
|
3548
|
+
}
|
|
3549
|
+
|
|
3550
|
+
if (_typeof(obj[i]) === 'object') {
|
|
3551
|
+
var flatObject = this.flattenObject(obj[i]);
|
|
3552
|
+
|
|
3553
|
+
for (var x in flatObject) {
|
|
3554
|
+
if (!flatObject.hasOwnProperty(x)) {
|
|
3555
|
+
continue;
|
|
3556
|
+
}
|
|
3557
|
+
|
|
3558
|
+
toReturn[i + '.' + x] = flatObject[x];
|
|
3559
|
+
}
|
|
3560
|
+
} else {
|
|
3561
|
+
toReturn[i] = obj[i];
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3565
|
+
return JSON.parse(JSON.stringify(toReturn));
|
|
3566
|
+
}
|
|
3506
3567
|
}, {
|
|
3507
3568
|
key: "handleClick",
|
|
3508
3569
|
value: function handleClick(event) {
|
|
@@ -3624,9 +3685,8 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
3624
3685
|
|
|
3625
3686
|
if (this.options.onHide) {
|
|
3626
3687
|
this.on('hide', this.options.onHide);
|
|
3627
|
-
}
|
|
3688
|
+
} // this.init()
|
|
3628
3689
|
|
|
3629
|
-
this.init();
|
|
3630
3690
|
}
|
|
3631
3691
|
|
|
3632
3692
|
_createClass(WebsyRouter, [{
|
|
@@ -7431,12 +7491,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7431
7491
|
return d.y.label || d.y.value;
|
|
7432
7492
|
}).each(function (d, i) {
|
|
7433
7493
|
if (that.options.orientation === 'horizontal') {
|
|
7434
|
-
if (that.options.grouping === 'stacked') {
|
|
7494
|
+
if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
|
|
7435
7495
|
this.setAttribute('text-anchor', 'middle');
|
|
7436
7496
|
} else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
7437
7497
|
this.setAttribute('text-anchor', 'end');
|
|
7438
7498
|
this.setAttribute('x', +this.getAttribute('x') - 8);
|
|
7439
7499
|
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color));
|
|
7500
|
+
} else if (series.labelPosition === 'outside') {
|
|
7501
|
+
this.setAttribute('text-anchor', 'start');
|
|
7502
|
+
this.setAttribute('x', +this.getAttribute('x') + 8);
|
|
7503
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
|
|
7440
7504
|
} else {
|
|
7441
7505
|
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
|
|
7442
7506
|
}
|
|
@@ -7452,12 +7516,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7452
7516
|
return d.y.label || d.y.value;
|
|
7453
7517
|
}).each(function (d, i) {
|
|
7454
7518
|
if (that.options.orientation === 'horizontal') {
|
|
7455
|
-
if (that.options.grouping === 'stacked') {
|
|
7519
|
+
if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
|
|
7456
7520
|
this.setAttribute('text-anchor', 'middle');
|
|
7457
7521
|
} else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
7458
7522
|
this.setAttribute('text-anchor', 'end');
|
|
7459
7523
|
this.setAttribute('x', +this.getAttribute('x') - 8);
|
|
7460
7524
|
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color));
|
|
7525
|
+
} else if (series.labelPosition === 'outside') {
|
|
7526
|
+
this.setAttribute('text-anchor', 'start');
|
|
7527
|
+
this.setAttribute('x', +this.getAttribute('x') + 8);
|
|
7528
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
|
|
7461
7529
|
} else {
|
|
7462
7530
|
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
|
|
7463
7531
|
}
|
|
@@ -7470,9 +7538,11 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7470
7538
|
}
|
|
7471
7539
|
|
|
7472
7540
|
function getLabelX(d) {
|
|
7541
|
+
var labelPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inside';
|
|
7542
|
+
|
|
7473
7543
|
if (this.options.orientation === 'horizontal') {
|
|
7474
7544
|
if (this.options.grouping === 'stacked') {
|
|
7475
|
-
return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / 2;
|
|
7545
|
+
return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1);
|
|
7476
7546
|
} else {
|
|
7477
7547
|
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4;
|
|
7478
7548
|
}
|
|
@@ -7482,10 +7552,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7482
7552
|
}
|
|
7483
7553
|
|
|
7484
7554
|
function getLabelY(d) {
|
|
7555
|
+
var labelPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inside';
|
|
7556
|
+
|
|
7485
7557
|
if (this.options.orientation === 'horizontal') {
|
|
7486
7558
|
return this[xAxis](this.parseX(d.x.value)) + this[xAxis].bandwidth() / 2;
|
|
7487
7559
|
} else {
|
|
7488
|
-
if (this.options.grouping === 'stacked') {
|
|
7560
|
+
if (this.options.grouping === 'stacked') {
|
|
7561
|
+
return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1);
|
|
7489
7562
|
} else {
|
|
7490
7563
|
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - 4;
|
|
7491
7564
|
}
|