@websy/websy-designs 1.5.2 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/helpers/v1/authHelper.js +1 -1
- package/dist/server/helpers/v1/pgHelper.js +49 -0
- package/dist/server/routes/v1/shop.js +1 -0
- package/dist/websy-designs-es6.debug.js +563 -282
- package/dist/websy-designs-es6.js +829 -466
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +592 -302
- package/dist/websy-designs.js +863 -489
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -2035,6 +2035,29 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
2035
2035
|
|
|
2036
2036
|
this.updateHeader(item);
|
|
2037
2037
|
}
|
|
2038
|
+
}, {
|
|
2039
|
+
key: "setValue",
|
|
2040
|
+
value: function setValue(value) {
|
|
2041
|
+
var _this11 = this;
|
|
2042
|
+
|
|
2043
|
+
this.selectedItems = [];
|
|
2044
|
+
|
|
2045
|
+
if (Array.isArray(value)) {
|
|
2046
|
+
this.options.items.forEach(function (d) {
|
|
2047
|
+
if (value.indexOf(d.value) !== -1) {
|
|
2048
|
+
_this11.selectedItems.push(d.index);
|
|
2049
|
+
}
|
|
2050
|
+
});
|
|
2051
|
+
} else {
|
|
2052
|
+
this.options.items.forEach(function (d) {
|
|
2053
|
+
if (d.value === value) {
|
|
2054
|
+
_this11.selectedItems.push(d.index);
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
this.render();
|
|
2060
|
+
}
|
|
2038
2061
|
}, {
|
|
2039
2062
|
key: "updateHeader",
|
|
2040
2063
|
value: function updateHeader(item) {
|
|
@@ -2228,6 +2251,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2228
2251
|
}
|
|
2229
2252
|
|
|
2230
2253
|
this.apiService = new WebsyDesigns.APIService('');
|
|
2254
|
+
this.fieldMap = {};
|
|
2231
2255
|
this.elementId = elementId;
|
|
2232
2256
|
var el = document.getElementById(elementId);
|
|
2233
2257
|
|
|
@@ -2255,19 +2279,19 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2255
2279
|
}, {
|
|
2256
2280
|
key: "checkRecaptcha",
|
|
2257
2281
|
value: function checkRecaptcha() {
|
|
2258
|
-
var
|
|
2282
|
+
var _this12 = this;
|
|
2259
2283
|
|
|
2260
2284
|
return new Promise(function (resolve, reject) {
|
|
2261
|
-
if (
|
|
2262
|
-
if (
|
|
2285
|
+
if (_this12.options.useRecaptcha === true) {
|
|
2286
|
+
if (_this12.recaptchaValue) {
|
|
2263
2287
|
// grecaptcha.ready(() => {
|
|
2264
2288
|
// grecaptcha.execute(this.recaptchaValue, { action: 'submit' }).then(token => {
|
|
2265
|
-
|
|
2266
|
-
grecaptcharesponse:
|
|
2289
|
+
_this12.apiService.add('google/checkrecaptcha', {
|
|
2290
|
+
grecaptcharesponse: _this12.recaptchaValue
|
|
2267
2291
|
}).then(function (response) {
|
|
2268
2292
|
if (response.success && response.success === true) {
|
|
2269
2293
|
resolve(true);
|
|
2270
|
-
grecaptcha.reset("".concat(
|
|
2294
|
+
grecaptcha.reset("".concat(_this12.elementId, "_recaptcha"), {
|
|
2271
2295
|
sitekey: ENVIRONMENT.RECAPTCHA_KEY
|
|
2272
2296
|
});
|
|
2273
2297
|
} else {
|
|
@@ -2328,14 +2352,14 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2328
2352
|
}, {
|
|
2329
2353
|
key: "processComponents",
|
|
2330
2354
|
value: function processComponents(components, callbackFn) {
|
|
2331
|
-
var
|
|
2355
|
+
var _this13 = this;
|
|
2332
2356
|
|
|
2333
2357
|
if (components.length === 0) {
|
|
2334
2358
|
callbackFn();
|
|
2335
2359
|
} else {
|
|
2336
2360
|
components.forEach(function (c) {
|
|
2337
2361
|
if (typeof WebsyDesigns[c.component] !== 'undefined') {
|
|
2338
|
-
c.instance = new WebsyDesigns[c.component]("".concat(
|
|
2362
|
+
c.instance = new WebsyDesigns[c.component]("".concat(_this13.elementId, "_input_").concat(c.field, "_component"), c.options);
|
|
2339
2363
|
} else {// some user feedback here
|
|
2340
2364
|
}
|
|
2341
2365
|
});
|
|
@@ -2344,15 +2368,15 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2344
2368
|
}, {
|
|
2345
2369
|
key: "recaptchaReady",
|
|
2346
2370
|
value: function recaptchaReady() {
|
|
2347
|
-
var
|
|
2371
|
+
var _this14 = this;
|
|
2348
2372
|
|
|
2349
2373
|
var el = document.getElementById("".concat(this.elementId, "_recaptcha"));
|
|
2350
2374
|
|
|
2351
2375
|
if (el) {
|
|
2352
2376
|
grecaptcha.ready(function () {
|
|
2353
|
-
grecaptcha.render("".concat(
|
|
2377
|
+
grecaptcha.render("".concat(_this14.elementId, "_recaptcha"), {
|
|
2354
2378
|
sitekey: ENVIRONMENT.RECAPTCHA_KEY,
|
|
2355
|
-
callback:
|
|
2379
|
+
callback: _this14.validateRecaptcha.bind(_this14)
|
|
2356
2380
|
});
|
|
2357
2381
|
});
|
|
2358
2382
|
}
|
|
@@ -2360,7 +2384,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2360
2384
|
}, {
|
|
2361
2385
|
key: "render",
|
|
2362
2386
|
value: function render(update, data) {
|
|
2363
|
-
var
|
|
2387
|
+
var _this15 = this;
|
|
2364
2388
|
|
|
2365
2389
|
var el = document.getElementById(this.elementId);
|
|
2366
2390
|
var componentsToProcess = [];
|
|
@@ -2368,13 +2392,15 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2368
2392
|
if (el) {
|
|
2369
2393
|
var html = "\n <form id=\"".concat(this.elementId, "Form\" class=\"websy-form ").concat(this.options.classes || '', "\">\n ");
|
|
2370
2394
|
this.options.fields.forEach(function (f, i) {
|
|
2395
|
+
_this15.fieldMap[f.field] = f;
|
|
2396
|
+
|
|
2371
2397
|
if (f.component) {
|
|
2372
2398
|
componentsToProcess.push(f);
|
|
2373
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <div id='").concat(
|
|
2399
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <div id='").concat(_this15.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
|
|
2374
2400
|
} else if (f.type === 'longtext') {
|
|
2375
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <textarea\n id=\"").concat(
|
|
2401
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <textarea\n id=\"").concat(_this15.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea\"\n ></textarea>\n </div><!--\n ");
|
|
2376
2402
|
} else {
|
|
2377
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <input \n id=\"").concat(
|
|
2403
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <input \n id=\"").concat(_this15.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
|
|
2378
2404
|
}
|
|
2379
2405
|
});
|
|
2380
2406
|
|
|
@@ -2391,16 +2417,35 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2391
2417
|
html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
|
|
2392
2418
|
el.innerHTML = html;
|
|
2393
2419
|
this.processComponents(componentsToProcess, function () {
|
|
2394
|
-
if (
|
|
2395
|
-
|
|
2420
|
+
if (_this15.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
|
|
2421
|
+
_this15.recaptchaReady();
|
|
2396
2422
|
}
|
|
2397
2423
|
});
|
|
2398
2424
|
}
|
|
2399
2425
|
}
|
|
2426
|
+
}, {
|
|
2427
|
+
key: "setValue",
|
|
2428
|
+
value: function setValue(field, value) {
|
|
2429
|
+
if (this.fieldMap[field]) {
|
|
2430
|
+
if (this.fieldMap[field].instance) {
|
|
2431
|
+
this.fieldMap[field].instance.setValue(value);
|
|
2432
|
+
} else {
|
|
2433
|
+
var el = document.getElementById("".concat(this.elementId, "_input_").concat(field));
|
|
2434
|
+
|
|
2435
|
+
if (el) {
|
|
2436
|
+
el.value = value;
|
|
2437
|
+
} else {
|
|
2438
|
+
console.error("Input for ".concat(field, " does not exist in form."));
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
} else {
|
|
2442
|
+
console.error("Field ".concat(field, " does not exist in form."));
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2400
2445
|
}, {
|
|
2401
2446
|
key: "submitForm",
|
|
2402
2447
|
value: function submitForm() {
|
|
2403
|
-
var
|
|
2448
|
+
var _this16 = this;
|
|
2404
2449
|
|
|
2405
2450
|
var formEl = document.getElementById("".concat(this.elementId, "Form"));
|
|
2406
2451
|
var buttonEl = formEl.querySelector('button.websy-btn.submit');
|
|
@@ -2428,34 +2473,34 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2428
2473
|
data[key] = value;
|
|
2429
2474
|
});
|
|
2430
2475
|
|
|
2431
|
-
if (
|
|
2432
|
-
var
|
|
2476
|
+
if (_this16.options.url) {
|
|
2477
|
+
var _this16$apiService;
|
|
2433
2478
|
|
|
2434
|
-
var params = [
|
|
2479
|
+
var params = [_this16.options.url];
|
|
2435
2480
|
|
|
2436
|
-
if (
|
|
2437
|
-
params.push(
|
|
2481
|
+
if (_this16.options.mode === 'update') {
|
|
2482
|
+
params.push(_this16.options.id);
|
|
2438
2483
|
}
|
|
2439
2484
|
|
|
2440
2485
|
params.push(data);
|
|
2441
2486
|
|
|
2442
|
-
(
|
|
2443
|
-
if (
|
|
2487
|
+
(_this16$apiService = _this16.apiService)[_this16.options.mode].apply(_this16$apiService, params).then(function (result) {
|
|
2488
|
+
if (_this16.options.clearAfterSave === true) {
|
|
2444
2489
|
// this.render()
|
|
2445
2490
|
formEl.reset();
|
|
2446
2491
|
}
|
|
2447
2492
|
|
|
2448
2493
|
buttonEl.removeAttribute('disabled');
|
|
2449
2494
|
|
|
2450
|
-
|
|
2495
|
+
_this16.options.onSuccess.call(_this16, result);
|
|
2451
2496
|
}, function (err) {
|
|
2452
2497
|
console.log('Error submitting form data:', err);
|
|
2453
2498
|
|
|
2454
|
-
|
|
2499
|
+
_this16.options.onError.call(_this16, err);
|
|
2455
2500
|
});
|
|
2456
|
-
} else if (
|
|
2457
|
-
|
|
2458
|
-
if (
|
|
2501
|
+
} else if (_this16.options.submitFn) {
|
|
2502
|
+
_this16.options.submitFn(data, function () {
|
|
2503
|
+
if (_this16.options.clearAfterSave === true) {
|
|
2459
2504
|
// this.render()
|
|
2460
2505
|
formEl.reset();
|
|
2461
2506
|
}
|
|
@@ -2480,18 +2525,27 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2480
2525
|
}
|
|
2481
2526
|
}, {
|
|
2482
2527
|
key: "data",
|
|
2528
|
+
get: function get() {
|
|
2529
|
+
var formEl = document.getElementById("".concat(this.elementId, "Form"));
|
|
2530
|
+
var data = {};
|
|
2531
|
+
var temp = new FormData(formEl);
|
|
2532
|
+
temp.forEach(function (value, key) {
|
|
2533
|
+
data[key] = value;
|
|
2534
|
+
});
|
|
2535
|
+
return data;
|
|
2536
|
+
},
|
|
2483
2537
|
set: function set(d) {
|
|
2484
|
-
var
|
|
2538
|
+
var _this17 = this;
|
|
2485
2539
|
|
|
2486
2540
|
if (!this.options.fields) {
|
|
2487
2541
|
this.options.fields = [];
|
|
2488
2542
|
}
|
|
2489
2543
|
|
|
2490
2544
|
var _loop = function _loop(key) {
|
|
2491
|
-
|
|
2545
|
+
_this17.options.fields.forEach(function (f) {
|
|
2492
2546
|
if (f.field === key) {
|
|
2493
2547
|
f.value = d[key];
|
|
2494
|
-
var el = document.getElementById("".concat(
|
|
2548
|
+
var el = document.getElementById("".concat(_this17.elementId, "_input_").concat(f.field));
|
|
2495
2549
|
el.value = f.value;
|
|
2496
2550
|
}
|
|
2497
2551
|
});
|
|
@@ -2744,7 +2798,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
2744
2798
|
}, {
|
|
2745
2799
|
key: "handleSearch",
|
|
2746
2800
|
value: function handleSearch(searchText) {
|
|
2747
|
-
var
|
|
2801
|
+
var _this18 = this;
|
|
2748
2802
|
|
|
2749
2803
|
var el = document.getElementById(this.elementId); // let lowestItems = this.flatItems.filter(d => d.level === this.maxLevel)
|
|
2750
2804
|
|
|
@@ -2757,7 +2811,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
2757
2811
|
if (searchText && searchText.length > 1) {
|
|
2758
2812
|
defaultMethod = 'add';
|
|
2759
2813
|
visibleItems = lowestItems.filter(function (d) {
|
|
2760
|
-
return d[
|
|
2814
|
+
return d[_this18.options.searchProp].toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
|
|
2761
2815
|
});
|
|
2762
2816
|
} // hide everything
|
|
2763
2817
|
|
|
@@ -2985,7 +3039,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
2985
3039
|
|
|
2986
3040
|
var Pager = /*#__PURE__*/function () {
|
|
2987
3041
|
function Pager(elementId, options) {
|
|
2988
|
-
var
|
|
3042
|
+
var _this19 = this;
|
|
2989
3043
|
|
|
2990
3044
|
_classCallCheck(this, Pager);
|
|
2991
3045
|
|
|
@@ -3038,8 +3092,8 @@ var Pager = /*#__PURE__*/function () {
|
|
|
3038
3092
|
allowClear: false,
|
|
3039
3093
|
disableSearch: true,
|
|
3040
3094
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
3041
|
-
if (
|
|
3042
|
-
|
|
3095
|
+
if (_this19.options.onChangePageSize) {
|
|
3096
|
+
_this19.options.onChangePageSize(selectedItem.value);
|
|
3043
3097
|
}
|
|
3044
3098
|
}
|
|
3045
3099
|
});
|
|
@@ -3063,13 +3117,13 @@ var Pager = /*#__PURE__*/function () {
|
|
|
3063
3117
|
}, {
|
|
3064
3118
|
key: "render",
|
|
3065
3119
|
value: function render() {
|
|
3066
|
-
var
|
|
3120
|
+
var _this20 = this;
|
|
3067
3121
|
|
|
3068
3122
|
var el = document.getElementById("".concat(this.elementId, "_pageList"));
|
|
3069
3123
|
|
|
3070
3124
|
if (el) {
|
|
3071
3125
|
var pages = this.options.pages.map(function (item, index) {
|
|
3072
|
-
return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
3126
|
+
return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this20.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
3073
3127
|
});
|
|
3074
3128
|
var startIndex = 0;
|
|
3075
3129
|
|
|
@@ -3137,58 +3191,58 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
3137
3191
|
_createClass(WebsyPDFButton, [{
|
|
3138
3192
|
key: "handleClick",
|
|
3139
3193
|
value: function handleClick(event) {
|
|
3140
|
-
var
|
|
3194
|
+
var _this21 = this;
|
|
3141
3195
|
|
|
3142
3196
|
if (event.target.classList.contains('websy-pdf-button')) {
|
|
3143
3197
|
this.loader.show();
|
|
3144
3198
|
setTimeout(function () {
|
|
3145
|
-
if (
|
|
3146
|
-
var el = document.getElementById(
|
|
3199
|
+
if (_this21.options.targetId) {
|
|
3200
|
+
var el = document.getElementById(_this21.options.targetId);
|
|
3147
3201
|
|
|
3148
3202
|
if (el) {
|
|
3149
3203
|
var pdfData = {
|
|
3150
3204
|
options: {}
|
|
3151
3205
|
};
|
|
3152
3206
|
|
|
3153
|
-
if (
|
|
3154
|
-
pdfData.options = _extends({},
|
|
3207
|
+
if (_this21.options.pdfOptions) {
|
|
3208
|
+
pdfData.options = _extends({}, _this21.options.pdfOptions);
|
|
3155
3209
|
}
|
|
3156
3210
|
|
|
3157
|
-
if (
|
|
3158
|
-
if (
|
|
3159
|
-
var headerEl = document.getElementById(
|
|
3211
|
+
if (_this21.options.header) {
|
|
3212
|
+
if (_this21.options.header.elementId) {
|
|
3213
|
+
var headerEl = document.getElementById(_this21.options.header.elementId);
|
|
3160
3214
|
|
|
3161
3215
|
if (headerEl) {
|
|
3162
3216
|
pdfData.header = headerEl.outerHTML;
|
|
3163
3217
|
|
|
3164
|
-
if (
|
|
3165
|
-
pdfData.options.headerCSS =
|
|
3218
|
+
if (_this21.options.header.css) {
|
|
3219
|
+
pdfData.options.headerCSS = _this21.options.header.css;
|
|
3166
3220
|
}
|
|
3167
3221
|
}
|
|
3168
|
-
} else if (
|
|
3169
|
-
pdfData.header =
|
|
3222
|
+
} else if (_this21.options.header.html) {
|
|
3223
|
+
pdfData.header = _this21.options.header.html;
|
|
3170
3224
|
|
|
3171
|
-
if (
|
|
3172
|
-
pdfData.options.headerCSS =
|
|
3225
|
+
if (_this21.options.header.css) {
|
|
3226
|
+
pdfData.options.headerCSS = _this21.options.header.css;
|
|
3173
3227
|
}
|
|
3174
3228
|
} else {
|
|
3175
|
-
pdfData.header =
|
|
3229
|
+
pdfData.header = _this21.options.header;
|
|
3176
3230
|
}
|
|
3177
3231
|
}
|
|
3178
3232
|
|
|
3179
|
-
if (
|
|
3180
|
-
if (
|
|
3181
|
-
var footerEl = document.getElementById(
|
|
3233
|
+
if (_this21.options.footer) {
|
|
3234
|
+
if (_this21.options.footer.elementId) {
|
|
3235
|
+
var footerEl = document.getElementById(_this21.options.footer.elementId);
|
|
3182
3236
|
|
|
3183
3237
|
if (footerEl) {
|
|
3184
3238
|
pdfData.footer = footerEl.outerHTML;
|
|
3185
3239
|
|
|
3186
|
-
if (
|
|
3187
|
-
pdfData.options.footerCSS =
|
|
3240
|
+
if (_this21.options.footer.css) {
|
|
3241
|
+
pdfData.options.footerCSS = _this21.options.footer.css;
|
|
3188
3242
|
}
|
|
3189
3243
|
}
|
|
3190
3244
|
} else {
|
|
3191
|
-
pdfData.footer =
|
|
3245
|
+
pdfData.footer = _this21.options.footer;
|
|
3192
3246
|
}
|
|
3193
3247
|
}
|
|
3194
3248
|
|
|
@@ -3197,31 +3251,31 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
3197
3251
|
// document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
|
|
3198
3252
|
// document.getElementById(`${this.elementId}_form`).submit()
|
|
3199
3253
|
|
|
3200
|
-
|
|
3254
|
+
_this21.service.add('', pdfData, {
|
|
3201
3255
|
responseType: 'blob'
|
|
3202
3256
|
}).then(function (response) {
|
|
3203
|
-
|
|
3257
|
+
_this21.loader.hide();
|
|
3204
3258
|
|
|
3205
3259
|
var blob = new Blob([response], {
|
|
3206
3260
|
type: 'application/pdf'
|
|
3207
3261
|
});
|
|
3208
3262
|
var msg = "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'\n ");
|
|
3209
3263
|
|
|
3210
|
-
if (
|
|
3264
|
+
if (_this21.options.directDownload === true) {
|
|
3211
3265
|
var fileName;
|
|
3212
3266
|
|
|
3213
|
-
if (typeof
|
|
3214
|
-
fileName =
|
|
3267
|
+
if (typeof _this21.options.fileName === 'function') {
|
|
3268
|
+
fileName = _this21.options.fileName() || 'Export';
|
|
3215
3269
|
} else {
|
|
3216
|
-
fileName =
|
|
3270
|
+
fileName = _this21.options.fileName || 'Export';
|
|
3217
3271
|
}
|
|
3218
3272
|
|
|
3219
3273
|
msg += "download='".concat(fileName, ".pdf'");
|
|
3220
3274
|
}
|
|
3221
3275
|
|
|
3222
|
-
msg += "\n >\n <button class='websy-btn download-pdf'>".concat(
|
|
3276
|
+
msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this21.options.buttonText, "</button>\n </a>\n </div>\n ");
|
|
3223
3277
|
|
|
3224
|
-
|
|
3278
|
+
_this21.popup.show({
|
|
3225
3279
|
message: msg,
|
|
3226
3280
|
mask: true
|
|
3227
3281
|
});
|
|
@@ -3422,7 +3476,7 @@ var WebsyPubSub = /*#__PURE__*/function () {
|
|
|
3422
3476
|
|
|
3423
3477
|
var ResponsiveText = /*#__PURE__*/function () {
|
|
3424
3478
|
function ResponsiveText(elementId, options) {
|
|
3425
|
-
var
|
|
3479
|
+
var _this22 = this;
|
|
3426
3480
|
|
|
3427
3481
|
_classCallCheck(this, ResponsiveText);
|
|
3428
3482
|
|
|
@@ -3435,7 +3489,7 @@ var ResponsiveText = /*#__PURE__*/function () {
|
|
|
3435
3489
|
this.elementId = elementId;
|
|
3436
3490
|
this.canvas = document.createElement('canvas');
|
|
3437
3491
|
window.addEventListener('resize', function () {
|
|
3438
|
-
return
|
|
3492
|
+
return _this22.render();
|
|
3439
3493
|
});
|
|
3440
3494
|
var el = document.getElementById(this.elementId);
|
|
3441
3495
|
|
|
@@ -3654,7 +3708,7 @@ var ResponsiveText = /*#__PURE__*/function () {
|
|
|
3654
3708
|
|
|
3655
3709
|
var WebsyResultList = /*#__PURE__*/function () {
|
|
3656
3710
|
function WebsyResultList(elementId, options) {
|
|
3657
|
-
var
|
|
3711
|
+
var _this23 = this;
|
|
3658
3712
|
|
|
3659
3713
|
_classCallCheck(this, WebsyResultList);
|
|
3660
3714
|
|
|
@@ -3686,9 +3740,9 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3686
3740
|
|
|
3687
3741
|
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
3688
3742
|
this.templateService.get(options.template.url).then(function (templateString) {
|
|
3689
|
-
|
|
3743
|
+
_this23.options.template = templateString;
|
|
3690
3744
|
|
|
3691
|
-
|
|
3745
|
+
_this23.render();
|
|
3692
3746
|
});
|
|
3693
3747
|
} else {
|
|
3694
3748
|
this.render();
|
|
@@ -3708,7 +3762,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3708
3762
|
}, {
|
|
3709
3763
|
key: "buildHTML",
|
|
3710
3764
|
value: function buildHTML(d) {
|
|
3711
|
-
var
|
|
3765
|
+
var _this24 = this;
|
|
3712
3766
|
|
|
3713
3767
|
var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
3714
3768
|
var inputTemplate = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -3718,7 +3772,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3718
3772
|
if (this.options.template) {
|
|
3719
3773
|
if (d.length > 0) {
|
|
3720
3774
|
d.forEach(function (row, ix) {
|
|
3721
|
-
var template = "".concat(ix > 0 ? '-->' : '').concat(inputTemplate ||
|
|
3775
|
+
var template = "".concat(ix > 0 ? '-->' : '').concat(inputTemplate || _this24.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
|
|
3722
3776
|
|
|
3723
3777
|
var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
|
|
3724
3778
|
|
|
@@ -3823,7 +3877,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3823
3877
|
parts.forEach(function (p) {
|
|
3824
3878
|
items = items[p];
|
|
3825
3879
|
});
|
|
3826
|
-
template = template.replace(m[0],
|
|
3880
|
+
template = template.replace(m[0], _this24.buildHTML(items, 0, withoutFor, [].concat(_toConsumableArray(locator), ["".concat(startIndex + ix, ":").concat(c)])));
|
|
3827
3881
|
}
|
|
3828
3882
|
});
|
|
3829
3883
|
|
|
@@ -3835,7 +3889,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3835
3889
|
}
|
|
3836
3890
|
});
|
|
3837
3891
|
|
|
3838
|
-
var flatRow =
|
|
3892
|
+
var flatRow = _this24.flattenObject(row);
|
|
3839
3893
|
|
|
3840
3894
|
for (var key in flatRow) {
|
|
3841
3895
|
var rg = new RegExp("{".concat(key, "}"), 'gm');
|
|
@@ -3970,13 +4024,13 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3970
4024
|
}, {
|
|
3971
4025
|
key: "render",
|
|
3972
4026
|
value: function render() {
|
|
3973
|
-
var
|
|
4027
|
+
var _this25 = this;
|
|
3974
4028
|
|
|
3975
4029
|
if (this.options.entity) {
|
|
3976
4030
|
this.apiService.get(this.options.entity).then(function (results) {
|
|
3977
|
-
|
|
4031
|
+
_this25.rows = results.rows;
|
|
3978
4032
|
|
|
3979
|
-
|
|
4033
|
+
_this25.resize();
|
|
3980
4034
|
});
|
|
3981
4035
|
} else {
|
|
3982
4036
|
this.resize();
|
|
@@ -4062,14 +4116,14 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
4062
4116
|
_createClass(WebsyRouter, [{
|
|
4063
4117
|
key: "addGroup",
|
|
4064
4118
|
value: function addGroup(group) {
|
|
4065
|
-
var
|
|
4119
|
+
var _this26 = this;
|
|
4066
4120
|
|
|
4067
4121
|
if (!this.groups[group]) {
|
|
4068
4122
|
var els = document.querySelectorAll(".websy-view[data-group=\"".concat(group, "\"]"));
|
|
4069
4123
|
|
|
4070
4124
|
if (els) {
|
|
4071
4125
|
this.getClosestParent(els[0], function (parent) {
|
|
4072
|
-
|
|
4126
|
+
_this26.groups[group] = {
|
|
4073
4127
|
activeView: '',
|
|
4074
4128
|
views: [],
|
|
4075
4129
|
parent: parent.getAttribute('data-view')
|
|
@@ -4132,7 +4186,7 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
4132
4186
|
}, {
|
|
4133
4187
|
key: "removeUrlParams",
|
|
4134
4188
|
value: function removeUrlParams() {
|
|
4135
|
-
var
|
|
4189
|
+
var _this27 = this;
|
|
4136
4190
|
|
|
4137
4191
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
4138
4192
|
var reloadView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -4146,7 +4200,7 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
4146
4200
|
|
|
4147
4201
|
if (this.currentParams && this.currentParams.items) {
|
|
4148
4202
|
params.forEach(function (p) {
|
|
4149
|
-
delete
|
|
4203
|
+
delete _this27.currentParams.items[p];
|
|
4150
4204
|
});
|
|
4151
4205
|
path = this.buildUrlPath(this.currentParams.items);
|
|
4152
4206
|
}
|
|
@@ -4178,13 +4232,17 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
4178
4232
|
inputPath = "/".concat(this.options.urlPrefix, "/").concat(inputPath);
|
|
4179
4233
|
}
|
|
4180
4234
|
|
|
4235
|
+
this.currentParams = {
|
|
4236
|
+
path: '',
|
|
4237
|
+
items: {}
|
|
4238
|
+
};
|
|
4239
|
+
|
|
4181
4240
|
if (reloadView === true) {
|
|
4182
4241
|
this.navigate("".concat(inputPath), 'main', null, noHistory);
|
|
4183
4242
|
} else {
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
};
|
|
4243
|
+
history.replaceState({
|
|
4244
|
+
inputPath: inputPath
|
|
4245
|
+
}, 'unused', inputPath);
|
|
4188
4246
|
}
|
|
4189
4247
|
}
|
|
4190
4248
|
}, {
|
|
@@ -4510,12 +4568,12 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
4510
4568
|
}, {
|
|
4511
4569
|
key: "showComponents",
|
|
4512
4570
|
value: function showComponents(view) {
|
|
4513
|
-
var
|
|
4571
|
+
var _this28 = this;
|
|
4514
4572
|
|
|
4515
4573
|
if (this.options.views && this.options.views[view] && this.options.views[view].components) {
|
|
4516
4574
|
this.options.views[view].components.forEach(function (c) {
|
|
4517
4575
|
if (typeof c.instance === 'undefined') {
|
|
4518
|
-
|
|
4576
|
+
_this28.prepComponent(c.elementId, c.options);
|
|
4519
4577
|
|
|
4520
4578
|
c.instance = new c.Component(c.elementId, c.options);
|
|
4521
4579
|
} else if (c.instance.render) {
|
|
@@ -4894,7 +4952,7 @@ var Switch = /*#__PURE__*/function () {
|
|
|
4894
4952
|
|
|
4895
4953
|
var WebsyTemplate = /*#__PURE__*/function () {
|
|
4896
4954
|
function WebsyTemplate(elementId, options) {
|
|
4897
|
-
var
|
|
4955
|
+
var _this29 = this;
|
|
4898
4956
|
|
|
4899
4957
|
_classCallCheck(this, WebsyTemplate);
|
|
4900
4958
|
|
|
@@ -4920,9 +4978,9 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4920
4978
|
|
|
4921
4979
|
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
4922
4980
|
this.templateService.get(options.template.url).then(function (templateString) {
|
|
4923
|
-
|
|
4981
|
+
_this29.options.template = templateString;
|
|
4924
4982
|
|
|
4925
|
-
|
|
4983
|
+
_this29.render();
|
|
4926
4984
|
});
|
|
4927
4985
|
} else {
|
|
4928
4986
|
this.render();
|
|
@@ -4932,7 +4990,7 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4932
4990
|
_createClass(WebsyTemplate, [{
|
|
4933
4991
|
key: "buildHTML",
|
|
4934
4992
|
value: function buildHTML() {
|
|
4935
|
-
var
|
|
4993
|
+
var _this30 = this;
|
|
4936
4994
|
|
|
4937
4995
|
var html = "";
|
|
4938
4996
|
|
|
@@ -4994,14 +5052,14 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4994
5052
|
}
|
|
4995
5053
|
|
|
4996
5054
|
if (polarity === true) {
|
|
4997
|
-
if (typeof
|
|
5055
|
+
if (typeof _this30.options.data[parts[0]] !== 'undefined' && _this30.options.data[parts[0]] === parts[1]) {
|
|
4998
5056
|
// remove the <if> tags
|
|
4999
5057
|
removeAll = false;
|
|
5000
5058
|
} else if (parts[0] === parts[1]) {
|
|
5001
5059
|
removeAll = false;
|
|
5002
5060
|
}
|
|
5003
5061
|
} else if (polarity === false) {
|
|
5004
|
-
if (typeof
|
|
5062
|
+
if (typeof _this30.options.data[parts[0]] !== 'undefined' && _this30.options.data[parts[0]] !== parts[1]) {
|
|
5005
5063
|
// remove the <if> tags
|
|
5006
5064
|
removeAll = false;
|
|
5007
5065
|
}
|
|
@@ -5294,7 +5352,7 @@ var WebsyUtils = {
|
|
|
5294
5352
|
|
|
5295
5353
|
var WebsyTable = /*#__PURE__*/function () {
|
|
5296
5354
|
function WebsyTable(elementId, options) {
|
|
5297
|
-
var
|
|
5355
|
+
var _this31 = this;
|
|
5298
5356
|
|
|
5299
5357
|
_classCallCheck(this, WebsyTable);
|
|
5300
5358
|
|
|
@@ -5332,8 +5390,8 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5332
5390
|
allowClear: false,
|
|
5333
5391
|
disableSearch: true,
|
|
5334
5392
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
5335
|
-
if (
|
|
5336
|
-
|
|
5393
|
+
if (_this31.options.onChangePageSize) {
|
|
5394
|
+
_this31.options.onChangePageSize(selectedItem.value);
|
|
5337
5395
|
}
|
|
5338
5396
|
}
|
|
5339
5397
|
});
|
|
@@ -5354,7 +5412,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5354
5412
|
_createClass(WebsyTable, [{
|
|
5355
5413
|
key: "appendRows",
|
|
5356
5414
|
value: function appendRows(data) {
|
|
5357
|
-
var
|
|
5415
|
+
var _this32 = this;
|
|
5358
5416
|
|
|
5359
5417
|
this.hideError();
|
|
5360
5418
|
var bodyHTML = '';
|
|
@@ -5362,15 +5420,15 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5362
5420
|
if (data) {
|
|
5363
5421
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
5364
5422
|
return '<tr>' + r.map(function (c, i) {
|
|
5365
|
-
if (
|
|
5423
|
+
if (_this32.options.columns[i].show !== false) {
|
|
5366
5424
|
var style = '';
|
|
5367
5425
|
|
|
5368
5426
|
if (c.style) {
|
|
5369
5427
|
style += c.style;
|
|
5370
5428
|
}
|
|
5371
5429
|
|
|
5372
|
-
if (
|
|
5373
|
-
style += "width: ".concat(
|
|
5430
|
+
if (_this32.options.columns[i].width) {
|
|
5431
|
+
style += "width: ".concat(_this32.options.columns[i].width, "; ");
|
|
5374
5432
|
}
|
|
5375
5433
|
|
|
5376
5434
|
if (c.backgroundColor) {
|
|
@@ -5385,18 +5443,18 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5385
5443
|
style += "color: ".concat(c.color, "; ");
|
|
5386
5444
|
}
|
|
5387
5445
|
|
|
5388
|
-
if (
|
|
5389
|
-
return "\n <td \n data-row-index='".concat(
|
|
5390
|
-
} else if ((
|
|
5391
|
-
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(
|
|
5446
|
+
if (_this32.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
5447
|
+
return "\n <td \n data-row-index='".concat(_this32.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this32.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this32.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this32.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
|
|
5448
|
+
} else if ((_this32.options.columns[i].showAsNavigatorLink === true || _this32.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
5449
|
+
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this32.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this32.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this32.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this32.options.columns[i].linkText || c.value, "</td>\n ");
|
|
5392
5450
|
} else {
|
|
5393
5451
|
var info = c.value;
|
|
5394
5452
|
|
|
5395
|
-
if (
|
|
5453
|
+
if (_this32.options.columns[i].showAsImage === true) {
|
|
5396
5454
|
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
5397
5455
|
}
|
|
5398
5456
|
|
|
5399
|
-
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(
|
|
5457
|
+
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this32.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this32.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
|
|
5400
5458
|
}
|
|
5401
5459
|
}
|
|
5402
5460
|
}).join('') + '</tr>';
|
|
@@ -5568,7 +5626,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5568
5626
|
}, {
|
|
5569
5627
|
key: "render",
|
|
5570
5628
|
value: function render(data) {
|
|
5571
|
-
var
|
|
5629
|
+
var _this33 = this;
|
|
5572
5630
|
|
|
5573
5631
|
if (!this.options.columns) {
|
|
5574
5632
|
return;
|
|
@@ -5603,7 +5661,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5603
5661
|
style += "width: ".concat(c.width || 'auto', ";");
|
|
5604
5662
|
}
|
|
5605
5663
|
|
|
5606
|
-
return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ?
|
|
5664
|
+
return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ? _this33.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
|
|
5607
5665
|
}
|
|
5608
5666
|
}).join('') + '</tr>';
|
|
5609
5667
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -5622,7 +5680,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5622
5680
|
|
|
5623
5681
|
if (pagingEl) {
|
|
5624
5682
|
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
5625
|
-
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
5683
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this33.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
5626
5684
|
});
|
|
5627
5685
|
var startIndex = 0;
|
|
5628
5686
|
|
|
@@ -5690,7 +5748,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5690
5748
|
|
|
5691
5749
|
var WebsyTable2 = /*#__PURE__*/function () {
|
|
5692
5750
|
function WebsyTable2(elementId, options) {
|
|
5693
|
-
var
|
|
5751
|
+
var _this34 = this;
|
|
5694
5752
|
|
|
5695
5753
|
_classCallCheck(this, WebsyTable2);
|
|
5696
5754
|
|
|
@@ -5731,8 +5789,8 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5731
5789
|
allowClear: false,
|
|
5732
5790
|
disableSearch: true,
|
|
5733
5791
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
5734
|
-
if (
|
|
5735
|
-
|
|
5792
|
+
if (_this34.options.onChangePageSize) {
|
|
5793
|
+
_this34.options.onChangePageSize(selectedItem.value);
|
|
5736
5794
|
}
|
|
5737
5795
|
}
|
|
5738
5796
|
});
|
|
@@ -5756,7 +5814,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5756
5814
|
_createClass(WebsyTable2, [{
|
|
5757
5815
|
key: "appendRows",
|
|
5758
5816
|
value: function appendRows(data) {
|
|
5759
|
-
var
|
|
5817
|
+
var _this35 = this;
|
|
5760
5818
|
|
|
5761
5819
|
this.hideError();
|
|
5762
5820
|
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
@@ -5765,15 +5823,15 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5765
5823
|
if (data) {
|
|
5766
5824
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
5767
5825
|
return '<tr>' + r.map(function (c, i) {
|
|
5768
|
-
if (
|
|
5769
|
-
var style = "height: ".concat(
|
|
5826
|
+
if (_this35.options.columns[i].show !== false) {
|
|
5827
|
+
var style = "height: ".concat(_this35.options.cellSize, "px; line-height: ").concat(_this35.options.cellSize, "px;");
|
|
5770
5828
|
|
|
5771
5829
|
if (c.style) {
|
|
5772
5830
|
style += c.style;
|
|
5773
5831
|
}
|
|
5774
5832
|
|
|
5775
|
-
if (
|
|
5776
|
-
style += "width: ".concat(
|
|
5833
|
+
if (_this35.options.columns[i].width) {
|
|
5834
|
+
style += "width: ".concat(_this35.options.columns[i].width, "; ");
|
|
5777
5835
|
}
|
|
5778
5836
|
|
|
5779
5837
|
if (c.backgroundColor) {
|
|
@@ -5788,18 +5846,18 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5788
5846
|
style += "color: ".concat(c.color, "; ");
|
|
5789
5847
|
}
|
|
5790
5848
|
|
|
5791
|
-
if (
|
|
5792
|
-
return "\n <td \n data-row-index='".concat(
|
|
5793
|
-
} else if ((
|
|
5794
|
-
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(
|
|
5849
|
+
if (_this35.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
5850
|
+
return "\n <td \n data-row-index='".concat(_this35.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this35.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this35.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this35.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
|
|
5851
|
+
} else if ((_this35.options.columns[i].showAsNavigatorLink === true || _this35.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
5852
|
+
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this35.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this35.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this35.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this35.options.columns[i].linkText || c.value, "</td>\n ");
|
|
5795
5853
|
} else {
|
|
5796
5854
|
var info = c.value;
|
|
5797
5855
|
|
|
5798
|
-
if (
|
|
5856
|
+
if (_this35.options.columns[i].showAsImage === true) {
|
|
5799
5857
|
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
5800
5858
|
}
|
|
5801
5859
|
|
|
5802
|
-
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(
|
|
5860
|
+
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this35.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this35.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
|
|
5803
5861
|
}
|
|
5804
5862
|
}
|
|
5805
5863
|
}).join('') + '</tr>';
|
|
@@ -6062,7 +6120,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
6062
6120
|
}, {
|
|
6063
6121
|
key: "render",
|
|
6064
6122
|
value: function render(data) {
|
|
6065
|
-
var
|
|
6123
|
+
var _this36 = this;
|
|
6066
6124
|
|
|
6067
6125
|
if (!this.options.columns) {
|
|
6068
6126
|
return;
|
|
@@ -6098,7 +6156,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
6098
6156
|
style += "width: ".concat(c.width || 'auto', "; ");
|
|
6099
6157
|
}
|
|
6100
6158
|
|
|
6101
|
-
return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\n data-index=\"").concat(i, "\"\n data-sort=\"").concat(c.sort, "\"\n style=\"").concat(c.style || '', "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ?
|
|
6159
|
+
return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\n data-index=\"").concat(i, "\"\n data-sort=\"").concat(c.sort, "\"\n style=\"").concat(c.style || '', "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ? _this36.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
|
|
6102
6160
|
}
|
|
6103
6161
|
}).join('') + '</tr>';
|
|
6104
6162
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -6109,7 +6167,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
6109
6167
|
var dropdownHTML = "";
|
|
6110
6168
|
this.options.columns.forEach(function (c, i) {
|
|
6111
6169
|
if (c.searchable && c.searchField) {
|
|
6112
|
-
dropdownHTML += "\n <div id=\"".concat(
|
|
6170
|
+
dropdownHTML += "\n <div id=\"".concat(_this36.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
|
|
6113
6171
|
}
|
|
6114
6172
|
});
|
|
6115
6173
|
dropdownEl.innerHTML = dropdownHTML;
|
|
@@ -6131,7 +6189,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
6131
6189
|
|
|
6132
6190
|
if (pagingEl) {
|
|
6133
6191
|
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
6134
|
-
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
6192
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this36.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
6135
6193
|
});
|
|
6136
6194
|
var startIndex = 0;
|
|
6137
6195
|
|
|
@@ -6222,7 +6280,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
6222
6280
|
}, {
|
|
6223
6281
|
key: "getColumnParameters",
|
|
6224
6282
|
value: function getColumnParameters(values) {
|
|
6225
|
-
var
|
|
6283
|
+
var _this37 = this;
|
|
6226
6284
|
|
|
6227
6285
|
var tableEl = document.getElementById("".concat(this.elementId, "_table"));
|
|
6228
6286
|
tableEl.style.tableLayout = 'auto';
|
|
@@ -6230,10 +6288,10 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
6230
6288
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
6231
6289
|
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
6232
6290
|
headEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c, i) {
|
|
6233
|
-
return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ?
|
|
6291
|
+
return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ? _this37.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
|
|
6234
6292
|
}).join('') + '</tr>';
|
|
6235
6293
|
bodyEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c) {
|
|
6236
|
-
return "\n <td \n style='height: ".concat(
|
|
6294
|
+
return "\n <td \n style='height: ".concat(_this37.options.cellSize, "px; line-height: ").concat(_this37.options.cellSize, "px; padding: 10px 5px;'\n >").concat(c.value || ' ', "</td>\n ");
|
|
6237
6295
|
}).join('') + '</tr>'; // get height of the first data cell
|
|
6238
6296
|
|
|
6239
6297
|
var cells = bodyEl.querySelectorAll("tr:first-of-type td");
|
|
@@ -6364,7 +6422,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6364
6422
|
}, {
|
|
6365
6423
|
key: "buildBodyHtml",
|
|
6366
6424
|
value: function buildBodyHtml() {
|
|
6367
|
-
var
|
|
6425
|
+
var _this38 = this;
|
|
6368
6426
|
|
|
6369
6427
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
6370
6428
|
var useWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -6427,7 +6485,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6427
6485
|
} // console.log('rowspan', cell.rowspan)
|
|
6428
6486
|
|
|
6429
6487
|
|
|
6430
|
-
bodyHtml += "<td \n class='websy-table-cell ".concat(sizeIndex <
|
|
6488
|
+
bodyHtml += "<td \n class='websy-table-cell ".concat(sizeIndex < _this38.pinnedColumns ? 'pinned' : 'unpinned', " ").concat((cell.classes || []).join(' '), " ").concat((sizingColumns[sizeIndex].classes || []).join(' '), "'\n style='").concat(style, "'\n data-info='").concat(cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n data-row-index='").concat(rowIndex, "'\n data-cell-index='").concat(cellIndex, "'\n data-col-index='").concat(sizeIndex, "'\n "); // if (useWidths === true) {
|
|
6431
6489
|
// bodyHtml += `
|
|
6432
6490
|
// style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
|
|
6433
6491
|
// width='${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}'
|
|
@@ -6437,11 +6495,11 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6437
6495
|
bodyHtml += "\n ><div \n style='".concat(divStyle, "' \n class='websy-table-cell-content'\n data-row-index='").concat(rowIndex, "'\n data-cell-index='").concat(cellIndex, "'\n data-col-index='").concat(sizeIndex, "'\n >");
|
|
6438
6496
|
|
|
6439
6497
|
if (cell.expandable === true) {
|
|
6440
|
-
bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-expand'\n >").concat(
|
|
6498
|
+
bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-expand'\n >").concat(_this38.options.plusIcon, "</i>");
|
|
6441
6499
|
}
|
|
6442
6500
|
|
|
6443
6501
|
if (cell.collapsable === true) {
|
|
6444
|
-
bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-collapse'\n >").concat(
|
|
6502
|
+
bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-collapse'\n >").concat(_this38.options.minusIcon, "</i>");
|
|
6445
6503
|
}
|
|
6446
6504
|
|
|
6447
6505
|
if (sizingColumns[sizeIndex].showAsLink === true && cell.value.trim() !== '') {
|
|
@@ -6466,7 +6524,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6466
6524
|
}, {
|
|
6467
6525
|
key: "buildHeaderHtml",
|
|
6468
6526
|
value: function buildHeaderHtml() {
|
|
6469
|
-
var
|
|
6527
|
+
var _this39 = this;
|
|
6470
6528
|
|
|
6471
6529
|
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
6472
6530
|
|
|
@@ -6486,7 +6544,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6486
6544
|
}
|
|
6487
6545
|
|
|
6488
6546
|
this.options.columns.forEach(function (row, rowIndex) {
|
|
6489
|
-
if (useWidths === false && rowIndex !==
|
|
6547
|
+
if (useWidths === false && rowIndex !== _this39.options.columns.length - 1) {
|
|
6490
6548
|
// if we're calculating the size we only want to render the last row of column headers
|
|
6491
6549
|
return;
|
|
6492
6550
|
}
|
|
@@ -6505,25 +6563,25 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6505
6563
|
style += col.style;
|
|
6506
6564
|
}
|
|
6507
6565
|
|
|
6508
|
-
headerHtml += "<td \n class='websy-table-cell ".concat(colIndex <
|
|
6566
|
+
headerHtml += "<td \n class='websy-table-cell ".concat(colIndex < _this39.pinnedColumns ? 'pinned' : 'unpinned', " ").concat((col.classes || []).join(' '), "' \n style='").concat(style, "' \n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n "); // if (useWidths === true && rowIndex === this.options.columns.length - 1) {
|
|
6509
6567
|
// headerHtml += `
|
|
6510
6568
|
// style='width: ${col.width || col.actualWidth}px'
|
|
6511
6569
|
// width='${col.width || col.actualWidth}'
|
|
6512
6570
|
// `
|
|
6513
6571
|
// }
|
|
6514
6572
|
|
|
6515
|
-
headerHtml += ">\n <div \n style='".concat(divStyle, "'\n data-col-index=\"").concat(colIndex, "\"\n class='").concat(['asc', 'desc'].indexOf(col.sort) !== -1 ? 'sortable-column' : '', "'\n >\n ").concat(col.name).concat(col.activeSort ?
|
|
6573
|
+
headerHtml += ">\n <div \n style='".concat(divStyle, "'\n data-col-index=\"").concat(colIndex, "\"\n class='").concat(['asc', 'desc'].indexOf(col.sort) !== -1 ? 'sortable-column' : '', "'\n >\n ").concat(col.name).concat(col.activeSort ? _this39.buildSortIcon(col.sort, colIndex) : '').concat(col.searchable === true ? _this39.buildSearchIcon(col, colIndex) : '', "\n </div>\n </td>");
|
|
6516
6574
|
});
|
|
6517
6575
|
headerHtml += "</tr>";
|
|
6518
6576
|
});
|
|
6519
6577
|
var dropdownEl = document.getElementById("".concat(this.elementId, "_dropdownContainer"));
|
|
6520
6578
|
this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
|
|
6521
6579
|
if (c.searchable && c.isExternalSearch === true) {
|
|
6522
|
-
var testEl = document.getElementById("".concat(
|
|
6580
|
+
var testEl = document.getElementById("".concat(_this39.elementId, "_columnSearch_").concat(c.dimId || i));
|
|
6523
6581
|
|
|
6524
6582
|
if (!testEl) {
|
|
6525
6583
|
var newE = document.createElement('div');
|
|
6526
|
-
newE.id = "".concat(
|
|
6584
|
+
newE.id = "".concat(_this39.elementId, "_columnSearch_").concat(c.dimId || i);
|
|
6527
6585
|
newE.className = 'websy-modal-dropdown';
|
|
6528
6586
|
dropdownEl.appendChild(newE);
|
|
6529
6587
|
}
|
|
@@ -6546,7 +6604,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6546
6604
|
}, {
|
|
6547
6605
|
key: "buildTotalHtml",
|
|
6548
6606
|
value: function buildTotalHtml() {
|
|
6549
|
-
var
|
|
6607
|
+
var _this40 = this;
|
|
6550
6608
|
|
|
6551
6609
|
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
6552
6610
|
|
|
@@ -6559,7 +6617,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6559
6617
|
totalHtml += "<td \n class='websy-table-cell ".concat((col.classes || []).join(' '), "'\n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n ");
|
|
6560
6618
|
|
|
6561
6619
|
if (useWidths === true) {
|
|
6562
|
-
totalHtml += "\n style='width: ".concat(
|
|
6620
|
+
totalHtml += "\n style='width: ".concat(_this40.options.columns[_this40.options.columns.length - 1][colIndex].width || _this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth, "px'\n width='").concat(col.width || col.actualWidth, "'\n ");
|
|
6563
6621
|
}
|
|
6564
6622
|
|
|
6565
6623
|
totalHtml += " \n >\n ".concat(col.value, "\n </td>");
|
|
@@ -6570,7 +6628,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6570
6628
|
}, {
|
|
6571
6629
|
key: "calculateSizes",
|
|
6572
6630
|
value: function calculateSizes() {
|
|
6573
|
-
var
|
|
6631
|
+
var _this41 = this;
|
|
6574
6632
|
|
|
6575
6633
|
var sample = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
6576
6634
|
var totalRowCount = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -6619,32 +6677,32 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6619
6677
|
rows.forEach(function (row, rowIndex) {
|
|
6620
6678
|
Array.from(row.children).forEach(function (col, colIndex) {
|
|
6621
6679
|
var colSize = col.getBoundingClientRect();
|
|
6622
|
-
|
|
6680
|
+
_this41.sizes.cellHeight = colSize.height;
|
|
6623
6681
|
|
|
6624
|
-
if (
|
|
6625
|
-
if (!
|
|
6626
|
-
|
|
6682
|
+
if (_this41.options.columns[_this41.options.columns.length - 1][colIndex]) {
|
|
6683
|
+
if (!_this41.options.columns[_this41.options.columns.length - 1][colIndex].actualWidth) {
|
|
6684
|
+
_this41.options.columns[_this41.options.columns.length - 1][colIndex].actualWidth = 0;
|
|
6627
6685
|
}
|
|
6628
6686
|
|
|
6629
|
-
|
|
6630
|
-
|
|
6687
|
+
_this41.options.columns[_this41.options.columns.length - 1][colIndex].actualWidth = Math.min(Math.max(_this41.options.columns[_this41.options.columns.length - 1][colIndex].actualWidth, colSize.width), maxWidth);
|
|
6688
|
+
_this41.options.columns[_this41.options.columns.length - 1][colIndex].cellHeight = colSize.height;
|
|
6631
6689
|
|
|
6632
|
-
if (colIndex >=
|
|
6633
|
-
firstNonPinnedColumnWidth =
|
|
6690
|
+
if (colIndex >= _this41.pinnedColumns) {
|
|
6691
|
+
firstNonPinnedColumnWidth = _this41.options.columns[_this41.options.columns.length - 1][colIndex].actualWidth;
|
|
6634
6692
|
}
|
|
6635
6693
|
}
|
|
6636
6694
|
});
|
|
6637
6695
|
});
|
|
6638
6696
|
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
6639
|
-
if (colIndex <
|
|
6640
|
-
|
|
6697
|
+
if (colIndex < _this41.pinnedColumns) {
|
|
6698
|
+
_this41.sizes.scrollableWidth -= col.actualWidth;
|
|
6641
6699
|
}
|
|
6642
6700
|
});
|
|
6643
6701
|
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce(function (a, b) {
|
|
6644
6702
|
return a + (b.width || b.actualWidth);
|
|
6645
6703
|
}, 0);
|
|
6646
6704
|
this.sizes.totalNonPinnedWidth = this.options.columns[this.options.columns.length - 1].filter(function (c, i) {
|
|
6647
|
-
return i >=
|
|
6705
|
+
return i >= _this41.pinnedColumns;
|
|
6648
6706
|
}).reduce(function (a, b) {
|
|
6649
6707
|
return a + (b.width || b.actualWidth);
|
|
6650
6708
|
}, 0);
|
|
@@ -6665,10 +6723,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6665
6723
|
c.actualWidth += equalWidth; // }
|
|
6666
6724
|
// }
|
|
6667
6725
|
|
|
6668
|
-
|
|
6726
|
+
_this41.sizes.totalWidth += c.width || c.actualWidth;
|
|
6669
6727
|
|
|
6670
|
-
if (i <
|
|
6671
|
-
|
|
6728
|
+
if (i < _this41.pinnedColumns) {
|
|
6729
|
+
_this41.sizes.totalNonPinnedWidth += c.width || c.actualWidth;
|
|
6672
6730
|
} // equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
|
|
6673
6731
|
|
|
6674
6732
|
});
|
|
@@ -6731,7 +6789,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6731
6789
|
}, {
|
|
6732
6790
|
key: "createSample",
|
|
6733
6791
|
value: function createSample(data) {
|
|
6734
|
-
var
|
|
6792
|
+
var _this42 = this;
|
|
6735
6793
|
|
|
6736
6794
|
var output = [];
|
|
6737
6795
|
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
@@ -6743,7 +6801,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6743
6801
|
var longest = '';
|
|
6744
6802
|
|
|
6745
6803
|
for (var i = 0; i < Math.min(data.length, 1000); i++) {
|
|
6746
|
-
if (data[i].length ===
|
|
6804
|
+
if (data[i].length === _this42.options.columns[_this42.options.columns.length - 1].length) {
|
|
6747
6805
|
if (longest.length < data[i][colIndex].value.length) {
|
|
6748
6806
|
longest = data[i][colIndex].value;
|
|
6749
6807
|
}
|
|
@@ -7171,7 +7229,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7171
7229
|
|
|
7172
7230
|
var WebsyChart = /*#__PURE__*/function () {
|
|
7173
7231
|
function WebsyChart(elementId, options) {
|
|
7174
|
-
var
|
|
7232
|
+
var _this43 = this;
|
|
7175
7233
|
|
|
7176
7234
|
_classCallCheck(this, WebsyChart);
|
|
7177
7235
|
|
|
@@ -7208,6 +7266,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7208
7266
|
tooltipWidth: 200,
|
|
7209
7267
|
brushHeight: 50,
|
|
7210
7268
|
minBandWidth: 30,
|
|
7269
|
+
maxBandWidth: 100,
|
|
7211
7270
|
allowUnevenBands: true
|
|
7212
7271
|
};
|
|
7213
7272
|
this.elementId = elementId;
|
|
@@ -7230,7 +7289,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7230
7289
|
var forBrush = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
7231
7290
|
var xAxis = 'bottom';
|
|
7232
7291
|
|
|
7233
|
-
if (
|
|
7292
|
+
if (_this43.options.orientation === 'horizontal') {
|
|
7234
7293
|
xAxis = 'left';
|
|
7235
7294
|
}
|
|
7236
7295
|
|
|
@@ -7241,39 +7300,37 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7241
7300
|
xAxis += 'Axis';
|
|
7242
7301
|
var output;
|
|
7243
7302
|
|
|
7244
|
-
var width =
|
|
7303
|
+
var width = _this43.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth; // if (this.customBottomRange) {
|
|
7245
7304
|
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
output = index;
|
|
7252
|
-
break;
|
|
7253
|
-
}
|
|
7254
|
-
} else {
|
|
7305
|
+
|
|
7306
|
+
for (var index = 0; index < _this43.customBottomRange.length; index++) {
|
|
7307
|
+
if (input > _this43.customBottomRange[index]) {
|
|
7308
|
+
if (_this43.customBottomRange[index + 1]) {
|
|
7309
|
+
if (input < _this43.customBottomRange[index + 1]) {
|
|
7255
7310
|
output = index;
|
|
7256
7311
|
break;
|
|
7257
7312
|
}
|
|
7258
|
-
}
|
|
7259
|
-
|
|
7260
|
-
} else {
|
|
7261
|
-
var domain = _toConsumableArray(_this42[xAxis].domain());
|
|
7262
|
-
|
|
7263
|
-
if (_this42.options.orientation === 'horizontal') {
|
|
7264
|
-
domain = domain.reverse();
|
|
7265
|
-
}
|
|
7266
|
-
|
|
7267
|
-
for (var j = 0; j < domain.length; j++) {
|
|
7268
|
-
var breakA = _this42[xAxis](domain[j]) - width / 2;
|
|
7269
|
-
var breakB = breakA + width;
|
|
7270
|
-
|
|
7271
|
-
if (input > breakA && input <= breakB) {
|
|
7272
|
-
output = j;
|
|
7313
|
+
} else {
|
|
7314
|
+
output = index;
|
|
7273
7315
|
break;
|
|
7274
7316
|
}
|
|
7275
7317
|
}
|
|
7276
|
-
}
|
|
7318
|
+
} // }
|
|
7319
|
+
// else {
|
|
7320
|
+
// let domain = [...this[xAxis].domain()]
|
|
7321
|
+
// if (this.options.orientation === 'horizontal') {
|
|
7322
|
+
// domain = domain.reverse()
|
|
7323
|
+
// }
|
|
7324
|
+
// for (let j = 0; j < domain.length; j++) {
|
|
7325
|
+
// let breakA = this[xAxis](domain[j]) - (width / 2)
|
|
7326
|
+
// let breakB = breakA + width
|
|
7327
|
+
// if (input > breakA && input <= breakB) {
|
|
7328
|
+
// output = j
|
|
7329
|
+
// break
|
|
7330
|
+
// }
|
|
7331
|
+
// }
|
|
7332
|
+
// }
|
|
7333
|
+
|
|
7277
7334
|
|
|
7278
7335
|
return output;
|
|
7279
7336
|
};
|
|
@@ -7282,64 +7339,97 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7282
7339
|
|
|
7283
7340
|
this.brushed = function (event) {
|
|
7284
7341
|
console.log('brushing', event);
|
|
7285
|
-
that.
|
|
7286
|
-
var xAxis = 'bottom';
|
|
7287
|
-
var xAxisCaps = 'Bottom';
|
|
7342
|
+
var newX = that.options.margin.left + that.options.margin.axisLeft + (1 - event.selection[0] / (that.plotWidth / (that.widthForCalc + that.totalBandPadding)));
|
|
7288
7343
|
|
|
7289
|
-
if (that.
|
|
7290
|
-
|
|
7291
|
-
xAxisCaps = 'Left';
|
|
7344
|
+
if (that.plotArea) {
|
|
7345
|
+
that.plotArea.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
|
|
7292
7346
|
}
|
|
7293
7347
|
|
|
7294
|
-
if (
|
|
7295
|
-
|
|
7348
|
+
if (that.areaLayer) {
|
|
7349
|
+
that.areaLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
|
|
7296
7350
|
}
|
|
7297
7351
|
|
|
7298
|
-
if (
|
|
7299
|
-
that
|
|
7352
|
+
if (that.lineLayer) {
|
|
7353
|
+
that.lineLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
|
|
7300
7354
|
}
|
|
7301
7355
|
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
if (!event.selection || event.selection.length === 0) {
|
|
7305
|
-
that.brushLayer.select('.brush').call(that.brush).call(that.brush.move, s);
|
|
7306
|
-
return;
|
|
7356
|
+
if (that.barLayer) {
|
|
7357
|
+
that.barLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
|
|
7307
7358
|
}
|
|
7308
7359
|
|
|
7309
|
-
if (that.
|
|
7310
|
-
that.
|
|
7311
|
-
}
|
|
7312
|
-
var startEndOrdinal = s.map(function (a, b) {
|
|
7313
|
-
return that.bottomAxis.invert(a, b, true);
|
|
7314
|
-
}, that.bottomBrushAxis);
|
|
7315
|
-
|
|
7316
|
-
if (startEndOrdinal && startEndOrdinal.length === 2 && typeof startEndOrdinal[0] !== 'undefined' && typeof startEndOrdinal[1] !== 'undefined') {
|
|
7317
|
-
var domain = [];
|
|
7318
|
-
|
|
7319
|
-
var domainValues = _toConsumableArray(that["".concat(xAxis, "BrushAxis")].domain());
|
|
7360
|
+
if (that.labelLayer) {
|
|
7361
|
+
that.labelLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
|
|
7362
|
+
}
|
|
7320
7363
|
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
that.brushedDomain.push(domainValues[i]);
|
|
7324
|
-
}
|
|
7325
|
-
}
|
|
7364
|
+
if (that.symbolLayer) {
|
|
7365
|
+
that.symbolLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
|
|
7326
7366
|
}
|
|
7327
7367
|
|
|
7328
|
-
if (that.
|
|
7329
|
-
that
|
|
7330
|
-
that["".concat(xAxis, "AxisLayer")].call(d3["axis".concat(xAxisCaps)](that["".concat(xAxis, "Axis")]));
|
|
7368
|
+
if (that.refLineLayer) {
|
|
7369
|
+
that.refLineLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
|
|
7331
7370
|
}
|
|
7332
7371
|
|
|
7333
|
-
if (that.
|
|
7334
|
-
that.
|
|
7372
|
+
if (that.bottomAxisLayer) {
|
|
7373
|
+
that.bottomAxisLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop + that.plotHeight, ")"));
|
|
7374
|
+
} // that.brushedDomain = []
|
|
7375
|
+
// let xAxis = 'bottom'
|
|
7376
|
+
// let xAxisCaps = 'Bottom'
|
|
7377
|
+
// if (that.options.orientation === 'horizontal') {
|
|
7378
|
+
// xAxis = 'left'
|
|
7379
|
+
// xAxisCaps = 'Left'
|
|
7380
|
+
// }
|
|
7381
|
+
// if (!that[`${xAxis}Axis`]) {
|
|
7382
|
+
// return
|
|
7383
|
+
// }
|
|
7384
|
+
// if (!that[`${xAxis}Axis`].invert) {
|
|
7385
|
+
// that[`${xAxis}Axis`].invert = that.invertOverride
|
|
7386
|
+
// }
|
|
7387
|
+
// let s = event.selection || that[`${xAxis}Axis`].range()
|
|
7388
|
+
// if (!event.selection || event.selection.length === 0) {
|
|
7389
|
+
// that.brushLayer
|
|
7390
|
+
// .select('.brush')
|
|
7391
|
+
// .call(that.brush)
|
|
7392
|
+
// .call(that.brush.move, s)
|
|
7393
|
+
// return
|
|
7394
|
+
// }
|
|
7395
|
+
// if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
|
|
7396
|
+
// that.brushedDomain = s.map(that[`${xAxis}BrushAxis`].invert, that[[`${xAxis}Axis`]])
|
|
7397
|
+
// }
|
|
7398
|
+
// else {
|
|
7399
|
+
// let startEndOrdinal = s.map((a, b) => that.bottomAxis.invert(a, b, true), that.bottomBrushAxis)
|
|
7400
|
+
// if (
|
|
7401
|
+
// startEndOrdinal &&
|
|
7402
|
+
// startEndOrdinal.length === 2 &&
|
|
7403
|
+
// typeof startEndOrdinal[0] !== 'undefined' &&
|
|
7404
|
+
// typeof startEndOrdinal[1] !== 'undefined'
|
|
7405
|
+
// ) {
|
|
7406
|
+
// let domain = []
|
|
7407
|
+
// let domainValues = [...that[`${xAxis}BrushAxis`].domain()]
|
|
7408
|
+
// for (let i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
|
|
7409
|
+
// // domain.push(that.xRange[i])
|
|
7410
|
+
// that.brushedDomain.push(domainValues[i])
|
|
7411
|
+
// }
|
|
7412
|
+
// }
|
|
7413
|
+
// }
|
|
7414
|
+
// if (that.brushedDomain.length > 0) {
|
|
7415
|
+
// that[`${xAxis}Axis`].domain(that.brushedDomain)
|
|
7416
|
+
// that[`${xAxis}AxisLayer`].call(
|
|
7417
|
+
// d3[`axis${xAxisCaps}`](that[`${xAxis}Axis`])
|
|
7418
|
+
// )
|
|
7419
|
+
// }
|
|
7420
|
+
// if (that.leftAxis && that.bottomAxis) {
|
|
7421
|
+
// that.renderComponents()
|
|
7422
|
+
// if (that.options.orientation === 'vertical') {
|
|
7423
|
+
// // that.bottomAxisLayer.call(that.bAxisFunc)
|
|
7424
|
+
// if (that.options.data.bottom.rotate) {
|
|
7425
|
+
// that.bottomAxisLayer.selectAll('text')
|
|
7426
|
+
// .attr('transform', `rotate(${((that.options.data.bottom && that.options.data.bottom.rotate) || 0)})`)
|
|
7427
|
+
// .style('text-anchor', `${((that.options.data.bottom && that.options.data.bottom.rotate) || 0) === 0 ? 'middle' : 'end'}`)
|
|
7428
|
+
// .style('transform-origin', ((that.options.data.bottom && that.options.data.bottom.rotate) || 0) === 0 ? '0 0' : `0 ${((that.options.data.bottom && that.options.data.bottom.fontSize) || that.options.fontSize)}px`)
|
|
7429
|
+
// }
|
|
7430
|
+
// }
|
|
7431
|
+
// }
|
|
7335
7432
|
|
|
7336
|
-
if (that.options.orientation === 'vertical') {
|
|
7337
|
-
// that.bottomAxisLayer.call(that.bAxisFunc)
|
|
7338
|
-
if (that.options.data.bottom.rotate) {
|
|
7339
|
-
that.bottomAxisLayer.selectAll('text').attr('transform', "rotate(".concat(that.options.data.bottom && that.options.data.bottom.rotate || 0, ")")).style('text-anchor', "".concat((that.options.data.bottom && that.options.data.bottom.rotate || 0) === 0 ? 'middle' : 'end')).style('transform-origin', (that.options.data.bottom && that.options.data.bottom.rotate || 0) === 0 ? '0 0' : "0 ".concat(that.options.data.bottom && that.options.data.bottom.fontSize || that.options.fontSize, "px"));
|
|
7340
|
-
}
|
|
7341
|
-
}
|
|
7342
|
-
}
|
|
7343
7433
|
};
|
|
7344
7434
|
|
|
7345
7435
|
var el = document.getElementById(this.elementId);
|
|
@@ -7454,10 +7544,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7454
7544
|
}, {
|
|
7455
7545
|
key: "handleEventMouseMove",
|
|
7456
7546
|
value: function handleEventMouseMove(event, d) {
|
|
7457
|
-
var
|
|
7547
|
+
var _this44 = this;
|
|
7458
7548
|
|
|
7459
7549
|
var bisectDate = d3.bisector(function (d) {
|
|
7460
|
-
return
|
|
7550
|
+
return _this44.parseX(d.x.value);
|
|
7461
7551
|
}).left;
|
|
7462
7552
|
|
|
7463
7553
|
if (this.options.showTrackingLine === true && d3.pointer(event)) {
|
|
@@ -7496,12 +7586,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7496
7586
|
}
|
|
7497
7587
|
|
|
7498
7588
|
this.options.data.series.forEach(function (s) {
|
|
7499
|
-
if (
|
|
7500
|
-
if (
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
}
|
|
7589
|
+
if (_this44.options.data[xData].scale !== 'Time') {
|
|
7590
|
+
// if (this.customBottomRange && this.customBottomRange.length > 0) {
|
|
7591
|
+
xPoint = _this44.customBottomRange[x0] + (_this44.customBottomRange[x0 + 1] - _this44.customBottomRange[x0]) / 2; // }
|
|
7592
|
+
// else {
|
|
7593
|
+
// xPoint = this[xAxis](this.parseX(xLabel))
|
|
7594
|
+
// }
|
|
7505
7595
|
|
|
7506
7596
|
s.data.forEach(function (d) {
|
|
7507
7597
|
if (d.x.value === xLabel) {
|
|
@@ -7521,13 +7611,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7521
7611
|
var pointA = s.data[index - 1];
|
|
7522
7612
|
var pointB = s.data[index];
|
|
7523
7613
|
|
|
7524
|
-
if (
|
|
7614
|
+
if (_this44.options.orientation === 'horizontal') {
|
|
7525
7615
|
pointA = _toConsumableArray(s.data).reverse()[index - 1];
|
|
7526
7616
|
pointB = _toConsumableArray(s.data).reverse()[index];
|
|
7527
7617
|
}
|
|
7528
7618
|
|
|
7529
7619
|
if (pointA && !pointB) {
|
|
7530
|
-
xPoint =
|
|
7620
|
+
xPoint = _this44[xAxis](_this44.parseX(pointA.x.value));
|
|
7531
7621
|
tooltipTitle = pointA.x.value;
|
|
7532
7622
|
|
|
7533
7623
|
if (!pointA.y.color) {
|
|
@@ -7537,12 +7627,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7537
7627
|
tooltipData.push(pointA.y);
|
|
7538
7628
|
|
|
7539
7629
|
if (typeof pointA.x.value.getTime !== 'undefined') {
|
|
7540
|
-
tooltipTitle = d3.timeFormat(
|
|
7630
|
+
tooltipTitle = d3.timeFormat(_this44.options.dateFormat || _this44.options.calculatedTimeFormatPattern)(pointA.x.value);
|
|
7541
7631
|
}
|
|
7542
7632
|
}
|
|
7543
7633
|
|
|
7544
7634
|
if (pointB && !pointA) {
|
|
7545
|
-
xPoint =
|
|
7635
|
+
xPoint = _this44[xAxis](_this44.parseX(pointB.x.value));
|
|
7546
7636
|
tooltipTitle = pointB.x.value;
|
|
7547
7637
|
|
|
7548
7638
|
if (!pointB.y.color) {
|
|
@@ -7552,14 +7642,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7552
7642
|
tooltipData.push(pointB.y);
|
|
7553
7643
|
|
|
7554
7644
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
7555
|
-
tooltipTitle = d3.timeFormat(
|
|
7645
|
+
tooltipTitle = d3.timeFormat(_this44.options.dateFormat || _this44.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
7556
7646
|
}
|
|
7557
7647
|
}
|
|
7558
7648
|
|
|
7559
7649
|
if (pointA && pointB) {
|
|
7560
|
-
var d0 =
|
|
7650
|
+
var d0 = _this44[xAxis](_this44.parseX(pointA.x.value));
|
|
7561
7651
|
|
|
7562
|
-
var d1 =
|
|
7652
|
+
var d1 = _this44[xAxis](_this44.parseX(pointB.x.value));
|
|
7563
7653
|
|
|
7564
7654
|
var mid = Math.abs(d0 - d1) / 2;
|
|
7565
7655
|
|
|
@@ -7568,7 +7658,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7568
7658
|
tooltipTitle = pointB.x.value;
|
|
7569
7659
|
|
|
7570
7660
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
7571
|
-
tooltipTitle = d3.timeFormat(
|
|
7661
|
+
tooltipTitle = d3.timeFormat(_this44.options.dateFormat || _this44.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
7572
7662
|
}
|
|
7573
7663
|
|
|
7574
7664
|
if (!pointB.y.color) {
|
|
@@ -7581,7 +7671,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7581
7671
|
tooltipTitle = pointA.x.value;
|
|
7582
7672
|
|
|
7583
7673
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
7584
|
-
tooltipTitle = d3.timeFormat(
|
|
7674
|
+
tooltipTitle = d3.timeFormat(_this44.options.dateFormat || _this44.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
7585
7675
|
}
|
|
7586
7676
|
|
|
7587
7677
|
if (!pointA.y.color) {
|
|
@@ -7645,6 +7735,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7645
7735
|
}
|
|
7646
7736
|
|
|
7647
7737
|
this.tooltip.setHeight(this.plotHeight);
|
|
7738
|
+
|
|
7739
|
+
if (isNaN(posOptions.left)) {
|
|
7740
|
+
this.tooltip.hide();
|
|
7741
|
+
return;
|
|
7742
|
+
}
|
|
7743
|
+
|
|
7648
7744
|
this.options.showTooltip && this.tooltip.show(tooltipTitle, tooltipHTML, posOptions); // }
|
|
7649
7745
|
// else {
|
|
7650
7746
|
// xPoint = x0
|
|
@@ -7675,20 +7771,22 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7675
7771
|
/* global d3 WebsyDesigns */
|
|
7676
7772
|
this.defs = this.svg.append('defs');
|
|
7677
7773
|
this.clip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_clip")).append('rect');
|
|
7774
|
+
this.xAxisClip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_xAxisClip")).append('rect');
|
|
7678
7775
|
this.brushClip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_brushclip")).append('rect');
|
|
7679
7776
|
this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer');
|
|
7680
7777
|
this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer');
|
|
7681
|
-
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer');
|
|
7778
|
+
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer').attr('clip-path', "url(#".concat(this.elementId, "_xAxisClip)")).append('g');
|
|
7682
7779
|
this.leftAxisLabel = this.svg.append('g').attr('class', 'left-axis-label-layer');
|
|
7683
7780
|
this.rightAxisLabel = this.svg.append('g').attr('class', 'right-axis-label-layer');
|
|
7684
7781
|
this.bottomAxisLabel = this.svg.append('g').attr('class', 'bottom-axis-label-layer');
|
|
7685
|
-
this.plotArea = this.svg.append('g').attr('class', 'plot-layer');
|
|
7686
|
-
this.areaLayer = this.svg.append('g').attr('class', 'area-layer');
|
|
7687
|
-
this.lineLayer = this.svg.append('g').attr('class', 'line-layer');
|
|
7688
|
-
this.barLayer = this.svg.append('g').attr('class', 'bar-layer');
|
|
7689
|
-
|
|
7690
|
-
this.
|
|
7691
|
-
this.
|
|
7782
|
+
this.plotArea = this.svg.append('g').attr('class', 'plot-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
|
|
7783
|
+
this.areaLayer = this.svg.append('g').attr('class', 'area-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
|
|
7784
|
+
this.lineLayer = this.svg.append('g').attr('class', 'line-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
|
|
7785
|
+
this.barLayer = this.svg.append('g').attr('class', 'bar-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g'); // this.barLayer.attr('clip-path', `url(#${this.elementId}_clip)`)
|
|
7786
|
+
|
|
7787
|
+
this.labelLayer = this.svg.append('g').attr('class', 'label-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
|
|
7788
|
+
this.symbolLayer = this.svg.append('g').attr('class', 'symbol-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
|
|
7789
|
+
this.refLineLayer = this.svg.append('g').attr('class', 'refline-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
|
|
7692
7790
|
this.trackingLineLayer = this.svg.append('g').attr('class', 'tracking-line-layer');
|
|
7693
7791
|
this.trackingLineLayer.append('line').attr('class', 'tracking-line');
|
|
7694
7792
|
this.tooltip = new WebsyDesigns.WebsyChartTooltip(this.svg);
|
|
@@ -7706,7 +7804,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7706
7804
|
}, {
|
|
7707
7805
|
key: "render",
|
|
7708
7806
|
value: function render(options) {
|
|
7709
|
-
var
|
|
7807
|
+
var _this45 = this;
|
|
7710
7808
|
|
|
7711
7809
|
/* global d3 options WebsyUtils */
|
|
7712
7810
|
if (typeof options !== 'undefined') {
|
|
@@ -7781,7 +7879,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7781
7879
|
this.options.data.series.map(function (s, i) {
|
|
7782
7880
|
return {
|
|
7783
7881
|
value: s.label || s.key,
|
|
7784
|
-
color: s.color ||
|
|
7882
|
+
color: s.color || _this45.options.colors[i % _this45.options.colors.length]
|
|
7785
7883
|
};
|
|
7786
7884
|
});
|
|
7787
7885
|
}
|
|
@@ -7980,46 +8078,123 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7980
8078
|
if (this.options.axis.hideBottom === true) {
|
|
7981
8079
|
this.options.margin.axisBottom = 0;
|
|
7982
8080
|
}
|
|
7983
|
-
} //
|
|
8081
|
+
} // At some point before this we need to add in logic to make space for any data point labels
|
|
8082
|
+
// Define the plot size
|
|
7984
8083
|
|
|
7985
8084
|
|
|
7986
8085
|
this.plotWidth = this.width - this.options.margin.legendLeft - this.options.margin.legendRight - this.options.margin.left - this.options.margin.right - this.options.margin.axisLeft - this.options.margin.axisRight;
|
|
7987
8086
|
this.plotHeight = this.height - this.options.margin.legendTop - this.options.margin.legendBottom - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom - this.options.margin.axisTop;
|
|
7988
8087
|
this.brushNeeded = false;
|
|
8088
|
+
var proposedBandWidth; // distance between x axis data points.
|
|
8089
|
+
|
|
8090
|
+
var maxBandWidthFits = false; // Check to see if all bars at the max allowed width will fit
|
|
8091
|
+
|
|
8092
|
+
this.bandPadding = 0;
|
|
8093
|
+
this.totalBandPadding = 0;
|
|
8094
|
+
this.brushBandPadding = 0;
|
|
8095
|
+
this.totalBrushBandPadding = 0;
|
|
8096
|
+
var noOfPoints = 0;
|
|
8097
|
+
var noOfGroups = 0;
|
|
8098
|
+
var plotable = 0;
|
|
8099
|
+
|
|
8100
|
+
if (this.options.maxBandWidth) {
|
|
8101
|
+
if (this.options.orientation === 'horizontal') {
|
|
8102
|
+
this.options.data.left.totalValueCount = this.options.data.left.data.reduce(function (a, b) {
|
|
8103
|
+
if (typeof b.valueCount === 'undefined') {
|
|
8104
|
+
return a + 1;
|
|
8105
|
+
}
|
|
7989
8106
|
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
8107
|
+
return a + b.valueCount;
|
|
8108
|
+
}, 0);
|
|
8109
|
+
|
|
8110
|
+
if (this.options.data.left.padding) {
|
|
8111
|
+
this.totalBandPadding = this.plotHeight * this.options.data.left.padding;
|
|
8112
|
+
this.bandPadding = this.totalBandPadding / this.options.data.left.data.length;
|
|
8113
|
+
this.totalBrushBandPadding = this.plotHeight * this.options.data.left.padding;
|
|
8114
|
+
this.brushBandPadding = this.totalBandPadding / this.options.data.left.data.length;
|
|
7994
8115
|
}
|
|
7995
8116
|
|
|
7996
|
-
|
|
7997
|
-
|
|
8117
|
+
plotable = this.plotHeight - this.totalBandPadding;
|
|
8118
|
+
noOfPoints = this.options.grouping === 'grouped' ? this.options.data.left.totalValueCount : this.options.data.left.data.length;
|
|
8119
|
+
noOfGroups = this.options.data.left.data.length;
|
|
8120
|
+
} else {
|
|
8121
|
+
this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce(function (a, b) {
|
|
8122
|
+
if (typeof b.valueCount === 'undefined') {
|
|
8123
|
+
return a + 1;
|
|
8124
|
+
}
|
|
7998
8125
|
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
} // some if to check if brushing is needed
|
|
8126
|
+
return a + b.valueCount;
|
|
8127
|
+
}, 0);
|
|
8002
8128
|
|
|
8129
|
+
if (this.options.data.bottom.padding) {
|
|
8130
|
+
this.totalBandPadding = this.plotWidth * this.options.data.bottom.padding;
|
|
8131
|
+
this.bandPadding = this.totalBandPadding / this.options.data.bottom.data.length;
|
|
8132
|
+
this.totalBrushBandPadding = this.plotWidth * this.options.data.bottom.padding;
|
|
8133
|
+
this.brushBandPadding = this.totalBandPadding / this.options.data.bottom.data.length;
|
|
8134
|
+
}
|
|
8003
8135
|
|
|
8004
|
-
|
|
8005
|
-
this.
|
|
8006
|
-
|
|
8136
|
+
plotable = this.plotWidth - this.totalBandPadding;
|
|
8137
|
+
noOfPoints = this.options.grouping === 'grouped' ? this.options.data.bottom.totalValueCount : this.options.data.bottom.data.length;
|
|
8138
|
+
noOfGroups = this.options.data.bottom.data.length;
|
|
8139
|
+
}
|
|
8140
|
+
|
|
8141
|
+
if (plotable / noOfPoints > this.options.maxBandWidth) {
|
|
8142
|
+
maxBandWidthFits = true;
|
|
8143
|
+
proposedBandWidth = this.options.maxBandWidth;
|
|
8007
8144
|
}
|
|
8008
|
-
} else {
|
|
8009
|
-
// some if to check if brushing is needed
|
|
8010
|
-
this.options.data.left.totalValueCount = this.options.data.left.data.reduce(function (a, b) {
|
|
8011
|
-
if (typeof b.valueCount === 'undefined') {
|
|
8012
|
-
return a + 1;
|
|
8013
|
-
}
|
|
8014
8145
|
|
|
8015
|
-
|
|
8016
|
-
|
|
8146
|
+
if (!maxBandWidthFits) {
|
|
8147
|
+
// Check to see if all bars at the min allowed width will fit
|
|
8148
|
+
if (plotable / noOfPoints < this.options.minBandWidth) {
|
|
8149
|
+
this.brushNeeded = true;
|
|
8150
|
+
proposedBandWidth = this.options.minBandWidth;
|
|
8017
8151
|
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8152
|
+
if (this.options.orientation === 'horizontal') {
|
|
8153
|
+
this.plotWidth -= this.options.brushHeight;
|
|
8154
|
+
} else {
|
|
8155
|
+
this.plotHeight -= this.options.brushHeight;
|
|
8156
|
+
}
|
|
8157
|
+
} else {
|
|
8158
|
+
proposedBandWidth = plotable / noOfPoints;
|
|
8159
|
+
}
|
|
8021
8160
|
}
|
|
8022
|
-
} //
|
|
8161
|
+
} // if (this.options.minBandWidth) {
|
|
8162
|
+
// this.widthForCalc = this.options.data.bottom.totalValueCount * this.options.minBandWidth
|
|
8163
|
+
// if (this.options.data.bottom.padding) {
|
|
8164
|
+
// this.widthForCalc += (this.options.minBandWidth * this.options.data.bottom.padding) * this.options.data.bottom.totalValueCount
|
|
8165
|
+
// this.widthForCalc += (this.options.data.bottom.data.length * this.options.groupPadding * 2)
|
|
8166
|
+
// }
|
|
8167
|
+
// }
|
|
8168
|
+
// if (this.options.orientation === 'vertical') {
|
|
8169
|
+
// this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
|
|
8170
|
+
// if (typeof b.valueCount === 'undefined') {
|
|
8171
|
+
// return a + 1
|
|
8172
|
+
// }
|
|
8173
|
+
// return a + b.valueCount
|
|
8174
|
+
// }, 0)
|
|
8175
|
+
// if (this.options.maxBandWidth) {
|
|
8176
|
+
// this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.totalValueCount) * this.options.maxBandWidth)
|
|
8177
|
+
// }
|
|
8178
|
+
// // some if to check if brushing is needed
|
|
8179
|
+
// if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
|
|
8180
|
+
// this.brushNeeded = true
|
|
8181
|
+
// this.plotHeight -= this.options.brushHeight
|
|
8182
|
+
// }
|
|
8183
|
+
// }
|
|
8184
|
+
// else {
|
|
8185
|
+
// // some if to check if brushing is needed
|
|
8186
|
+
// this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
|
|
8187
|
+
// if (typeof b.valueCount === 'undefined') {
|
|
8188
|
+
// return a + 1
|
|
8189
|
+
// }
|
|
8190
|
+
// return a + b.valueCount
|
|
8191
|
+
// }, 0)
|
|
8192
|
+
// if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
|
|
8193
|
+
// this.brushNeeded = true
|
|
8194
|
+
// this.plotWidth -= this.options.brushHeight
|
|
8195
|
+
// }
|
|
8196
|
+
// }
|
|
8197
|
+
// Translate the layers
|
|
8023
8198
|
|
|
8024
8199
|
|
|
8025
8200
|
this.leftAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")")).style('font-size', this.options.data.left && this.options.data.left.fontSize || this.options.fontSize);
|
|
@@ -8037,50 +8212,97 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8037
8212
|
this.refLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8038
8213
|
this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8039
8214
|
this.brushLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height, ")"));
|
|
8215
|
+
this.clip.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", 0)")).attr('width', this.plotWidth).attr('height', this.plotHeight + this.options.margin.top + this.options.margin.axisTop);
|
|
8216
|
+
this.xAxisClip.attr('transform', "translate(".concat(this.options.margin.left, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight, ")")).attr('width', this.plotWidth + this.options.margin.axisLeft).attr('height', longestBottomBounds.height + 10);
|
|
8040
8217
|
this.brushClip.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height, ")")).attr('width', this.plotWidth).attr('height', this.options.brushHeight);
|
|
8041
8218
|
this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8042
8219
|
var that = this;
|
|
8043
8220
|
this.eventLayer.attr('x', 0).attr('y', 0).attr('width', this.plotWidth).attr('height', this.plotHeight).attr('fill-opacity', '0'); // this.tooltip.transform(this.options.margin.left + this.options.margin.axisLeft, this.options.margin.top + this.options.margin.axisTop)
|
|
8044
8221
|
// Configure the bottom axis
|
|
8045
8222
|
|
|
8046
|
-
var bottomDomain = this.createDomain('bottom');
|
|
8047
|
-
|
|
8223
|
+
var bottomDomain = this.createDomain('bottom'); // let bottomBrushDomain = this.createDomain('bottom', true)
|
|
8224
|
+
|
|
8225
|
+
var bottomBrushDomain = this.createDomain('bottom');
|
|
8048
8226
|
var bottomRange = [0, this.plotWidth];
|
|
8227
|
+
var bottomBrushRange = [0, this.plotWidth];
|
|
8228
|
+
var leftRange = [this.plotHeight, 0];
|
|
8229
|
+
var leftBrushRange = [this.options.brushHeight, 0];
|
|
8230
|
+
|
|
8231
|
+
if (this.options.orientation === 'horizontal') {
|
|
8232
|
+
leftBrushRange = [this.plotHeight, 0];
|
|
8233
|
+
}
|
|
8234
|
+
|
|
8235
|
+
this.widthForCalc = proposedBandWidth * noOfPoints; // + totalPadding
|
|
8236
|
+
|
|
8049
8237
|
this.customBottomRange = [];
|
|
8238
|
+
this.customBottomDetailRange = [];
|
|
8239
|
+
this.customBottomBrushRange = [];
|
|
8240
|
+
this.customLeftRange = [];
|
|
8241
|
+
this.customLeftDetailRange = [];
|
|
8242
|
+
this.customLeftBrushRange = []; // if (this.options.allowUnevenBands === true) {
|
|
8243
|
+
// always allow uneven bands
|
|
8050
8244
|
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
})));
|
|
8058
|
-
}
|
|
8245
|
+
var customRangeSide = 'Bottom';
|
|
8246
|
+
var customRangeSideLC = 'bottom';
|
|
8247
|
+
|
|
8248
|
+
if (this.options.orientation === 'horizontal') {
|
|
8249
|
+
customRangeSide = 'Left';
|
|
8250
|
+
customRangeSideLC = 'left';
|
|
8059
8251
|
}
|
|
8060
8252
|
|
|
8061
|
-
this.options.data.
|
|
8062
|
-
|
|
8253
|
+
if (this.options.data[customRangeSideLC].data && this.options.data[customRangeSideLC].data[0] && (this.options.data[customRangeSideLC].data[0].valueCount || 1) && this.options.data[customRangeSideLC].scale === 'Ordinal') {
|
|
8254
|
+
var acc = 0;
|
|
8255
|
+
this["custom".concat(customRangeSide, "Range")] = [0].concat(_toConsumableArray(this.options.data[customRangeSideLC].data.map(function (d, index, arr) {
|
|
8256
|
+
var adjustment = _this45.bandPadding * index + _this45.bandPadding; // if (this.options.data.bottom.padding) {
|
|
8257
|
+
// adjustment = (this.widthForCalc * this.options.data.bottom.padding) / (arr.length * 2)
|
|
8258
|
+
// }
|
|
8063
8259
|
|
|
8064
|
-
|
|
8065
|
-
this.totalPadding = this.plotWidth * this.options.data.bottom.padding;
|
|
8066
|
-
var rangeLength = bottomDomain.length;
|
|
8260
|
+
var start = _this45.widthForCalc / noOfPoints * acc;
|
|
8067
8261
|
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8262
|
+
for (var i = 0; i < (d.valueCount || 1); i++) {
|
|
8263
|
+
var pos = i * proposedBandWidth;
|
|
8264
|
+
|
|
8265
|
+
_this45["custom".concat(customRangeSide, "DetailRange")].push(start + adjustment + pos);
|
|
8266
|
+
}
|
|
8267
|
+
|
|
8268
|
+
acc += _this45.options.grouping !== 'stacked' ? d.valueCount || 1 : 1;
|
|
8269
|
+
var end = _this45.widthForCalc / noOfPoints * acc; // this.customBottomBrushRange.push((end + adjustment) * (this.plotWidth / this.widthForCalc))
|
|
8071
8270
|
|
|
8072
|
-
|
|
8073
|
-
|
|
8271
|
+
return end + adjustment;
|
|
8272
|
+
})));
|
|
8273
|
+
acc = 0;
|
|
8274
|
+
this["custom".concat(customRangeSide, "BrushRange")] = [0].concat(_toConsumableArray(this.options.data[customRangeSideLC].data.map(function (d, index, arr) {
|
|
8275
|
+
var adjustment = _this45.brushBandPadding * index + _this45.brushBandPadding;
|
|
8276
|
+
acc += _this45.options.grouping !== 'stacked' ? d.valueCount || 1 : 1;
|
|
8277
|
+
return (_this45.options.orientation === 'vertical' ? _this45.plotWidth : _this45.plotHeight) / noOfPoints * acc;
|
|
8278
|
+
})));
|
|
8279
|
+
} // }
|
|
8280
|
+
|
|
8281
|
+
|
|
8282
|
+
var rangeLength = bottomDomain.length;
|
|
8283
|
+
this.options.data.bottomBrush = {};
|
|
8284
|
+
this.options.data.leftBrush = {};
|
|
8285
|
+
|
|
8286
|
+
if (this.options.orientation === 'vertical') {
|
|
8287
|
+
this.options.data.bottom.bandWidth = proposedBandWidth;
|
|
8288
|
+
this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints;
|
|
8289
|
+
} else {
|
|
8290
|
+
this.options.data.left.bandWidth = proposedBandWidth;
|
|
8291
|
+
this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints;
|
|
8074
8292
|
}
|
|
8075
8293
|
|
|
8076
|
-
|
|
8077
|
-
|
|
8294
|
+
this.brushBandPadding = this.totalBandPadding / noOfGroups;
|
|
8295
|
+
|
|
8296
|
+
if (this.options.orientation === 'vertical') {
|
|
8297
|
+
bottomRange = [0, this.widthForCalc + this.totalBandPadding];
|
|
8298
|
+
} else {
|
|
8299
|
+
leftRange = [this.widthForCalc + this.totalBandPadding, 0];
|
|
8078
8300
|
}
|
|
8079
8301
|
|
|
8080
|
-
this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || '
|
|
8302
|
+
this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Ordinal')]().domain(bottomDomain).range(bottomRange);
|
|
8081
8303
|
|
|
8082
8304
|
if (!this.brushInitialized) {
|
|
8083
|
-
this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || '
|
|
8305
|
+
this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Ordinal')]().domain(bottomBrushDomain).range(bottomBrushRange);
|
|
8084
8306
|
}
|
|
8085
8307
|
|
|
8086
8308
|
if (this.bottomAxis.nice) {// this.bottomAxis.nice()
|
|
@@ -8101,38 +8323,78 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8101
8323
|
brushLength = this.options.brushHeight;
|
|
8102
8324
|
brushThickness = this.plotHeight;
|
|
8103
8325
|
} else {
|
|
8104
|
-
if (
|
|
8105
|
-
brushEnd = this.plotWidth * (this.plotWidth / this.
|
|
8326
|
+
if (this.brushNeeded) {
|
|
8327
|
+
brushEnd = this.plotWidth * (this.plotWidth / (this.widthForCalc + this.totalBandPadding));
|
|
8106
8328
|
}
|
|
8107
8329
|
}
|
|
8108
8330
|
|
|
8109
|
-
this.brush = d3[brushMethod]().extent([[0, 0], [brushLength, brushThickness]]).on('brush end', this.brushed);
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
//
|
|
8331
|
+
this.brush = d3[brushMethod]().extent([[0, 0], [brushLength, brushThickness]]).on('brush end', this.brushed); // const brushResizePath = d => {
|
|
8332
|
+
// let e = +(d.type === 'e')
|
|
8333
|
+
// let x = e ? 1 : -1
|
|
8334
|
+
// let y = this.options.brushHeight
|
|
8335
|
+
// return (
|
|
8336
|
+
// 'M' +
|
|
8337
|
+
// 0.5 * x +
|
|
8338
|
+
// ',' +
|
|
8339
|
+
// y +
|
|
8340
|
+
// 'A6,6 0 0 ' +
|
|
8341
|
+
// e +
|
|
8342
|
+
// ' ' +
|
|
8343
|
+
// 6.5 * x +
|
|
8344
|
+
// ',' +
|
|
8345
|
+
// (y + 6) +
|
|
8346
|
+
// 'V' +
|
|
8347
|
+
// (2 * y - 6) +
|
|
8348
|
+
// 'A6,6 0 0 ' +
|
|
8349
|
+
// e +
|
|
8350
|
+
// ' ' +
|
|
8351
|
+
// 0.5 * x +
|
|
8352
|
+
// ',' +
|
|
8353
|
+
// 2 * y +
|
|
8354
|
+
// 'Z' +
|
|
8355
|
+
// 'M' +
|
|
8356
|
+
// 2.5 * x +
|
|
8357
|
+
// ',' +
|
|
8358
|
+
// (y + 8) +
|
|
8359
|
+
// 'V' +
|
|
8360
|
+
// (2 * y - 8) +
|
|
8361
|
+
// 'M' +
|
|
8362
|
+
// 4.5 * x +
|
|
8363
|
+
// ',' +
|
|
8364
|
+
// (y + 8) +
|
|
8365
|
+
// 'V' +
|
|
8366
|
+
// (2 * y - 8)
|
|
8367
|
+
// )
|
|
8368
|
+
// }
|
|
8369
|
+
// this.brushHandle = this.brushLayer
|
|
8370
|
+
// .select('.brush')
|
|
8371
|
+
// .selectAll('.handle--custom')
|
|
8372
|
+
// .remove()
|
|
8373
|
+
// this.brushHandle = this.brushLayer
|
|
8374
|
+
// .select('.brush')
|
|
8375
|
+
// .selectAll('.handle--custom')
|
|
8376
|
+
// .data([{ type: 'w' }, { type: 'e' }])
|
|
8377
|
+
// .enter()
|
|
8378
|
+
// .append('path')
|
|
8379
|
+
// .attr('class', 'handle--custom')
|
|
8380
|
+
// .attr('stroke', 'transparent')
|
|
8381
|
+
// .attr('fill', 'transparent')
|
|
8382
|
+
// .attr('cursor', 'ew-resize')
|
|
8383
|
+
// .attr('d', brushResizePath)
|
|
8384
|
+
// BRUSH END
|
|
8385
|
+
// this.brushLayer.selectAll('.handle').remove()
|
|
8125
8386
|
|
|
8126
8387
|
if (this.brushNeeded) {
|
|
8127
8388
|
if (!this.brushInitialized) {
|
|
8128
8389
|
this.brushLayer.style('visibility', 'visible');
|
|
8129
8390
|
this.brushInitialized = true;
|
|
8130
8391
|
this.brushLayer.select('.brush').call(this.brush).call(this.brush.move, [0, brushEnd]);
|
|
8392
|
+
} else {
|
|
8393
|
+
this.brushLayer.style('visibility', 'visible');
|
|
8131
8394
|
}
|
|
8132
8395
|
} else {
|
|
8133
8396
|
this.brushLayer.style('visibility', 'hidden'); // this.brushLayer.selectAll().remove()
|
|
8134
|
-
|
|
8135
|
-
this.brushArea.selectAll('*').remove();
|
|
8397
|
+
// this.brushArea.selectAll('*').remove()
|
|
8136
8398
|
}
|
|
8137
8399
|
|
|
8138
8400
|
if (this.options.margin.axisBottom > 0) {
|
|
@@ -8190,7 +8452,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8190
8452
|
|
|
8191
8453
|
if (this.options.data.bottom.formatter) {
|
|
8192
8454
|
this.bAxisFunc.tickFormat(function (d) {
|
|
8193
|
-
return
|
|
8455
|
+
return _this45.options.data.bottom.formatter(d);
|
|
8194
8456
|
});
|
|
8195
8457
|
}
|
|
8196
8458
|
|
|
@@ -8202,7 +8464,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8202
8464
|
|
|
8203
8465
|
if (this.customBottomRange.length > 0) {
|
|
8204
8466
|
this.bottomAxisLayer.selectAll('g').attr('transform', function (d, i) {
|
|
8205
|
-
return "translate(".concat(
|
|
8467
|
+
return "translate(".concat(_this45.customBottomRange[i] + (_this45.customBottomRange[i + 1] - _this45.customBottomRange[i]) / 2, ", 0)");
|
|
8206
8468
|
});
|
|
8207
8469
|
}
|
|
8208
8470
|
} // Configure the left axis
|
|
@@ -8211,8 +8473,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8211
8473
|
var leftDomain = this.createDomain('left');
|
|
8212
8474
|
var leftBrushDomain = this.createDomain('left', true);
|
|
8213
8475
|
var rightDomain = this.createDomain('right');
|
|
8214
|
-
this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range(
|
|
8215
|
-
this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range(
|
|
8476
|
+
this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range(leftRange);
|
|
8477
|
+
this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range(leftBrushRange);
|
|
8216
8478
|
|
|
8217
8479
|
if (this.leftAxis.padding && this.options.data.left.padding) {
|
|
8218
8480
|
this.leftAxis.padding(this.options.data.left.padding || 0);
|
|
@@ -8224,12 +8486,18 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8224
8486
|
|
|
8225
8487
|
if (this.options.margin.axisLeft > 0) {
|
|
8226
8488
|
this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
8227
|
-
if (
|
|
8228
|
-
d =
|
|
8489
|
+
if (_this45.options.data.left.formatter) {
|
|
8490
|
+
d = _this45.options.data.left.formatter(d);
|
|
8229
8491
|
}
|
|
8230
8492
|
|
|
8231
8493
|
return d;
|
|
8232
8494
|
}));
|
|
8495
|
+
|
|
8496
|
+
if (this.customLeftRange.length > 0) {
|
|
8497
|
+
this.leftAxisLayer.selectAll('g').attr('transform', function (d, i) {
|
|
8498
|
+
return "translate(0, ".concat(_this45.customLeftRange[i] + (_this45.customLeftRange[i + 1] - _this45.customLeftRange[i]) / 2, ")");
|
|
8499
|
+
});
|
|
8500
|
+
}
|
|
8233
8501
|
}
|
|
8234
8502
|
|
|
8235
8503
|
if (this.options.data.left && this.options.data.left.showTitle === true) {
|
|
@@ -8260,8 +8528,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8260
8528
|
|
|
8261
8529
|
if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
|
|
8262
8530
|
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.right.ticks || 5).tickFormat(function (d) {
|
|
8263
|
-
if (
|
|
8264
|
-
d =
|
|
8531
|
+
if (_this45.options.data.right.formatter) {
|
|
8532
|
+
d = _this45.options.data.right.formatter(d);
|
|
8265
8533
|
}
|
|
8266
8534
|
|
|
8267
8535
|
return d;
|
|
@@ -8292,7 +8560,11 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8292
8560
|
for (var key in this.renderedKeys) {
|
|
8293
8561
|
if (newKeys.indexOf(key) === -1) {
|
|
8294
8562
|
// remove the components
|
|
8295
|
-
this[
|
|
8563
|
+
// this[`remove${this.renderedKeys[key]}`](key)
|
|
8564
|
+
this.removeline(key);
|
|
8565
|
+
this.removebar(key);
|
|
8566
|
+
this.removesymbol(key);
|
|
8567
|
+
this.removelabel(key);
|
|
8296
8568
|
}
|
|
8297
8569
|
}
|
|
8298
8570
|
|
|
@@ -8303,48 +8575,57 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8303
8575
|
}, {
|
|
8304
8576
|
key: "renderComponents",
|
|
8305
8577
|
value: function renderComponents() {
|
|
8306
|
-
var
|
|
8578
|
+
var _this46 = this;
|
|
8307
8579
|
|
|
8308
8580
|
// Draw the series data
|
|
8309
8581
|
this.renderedKeys = {};
|
|
8310
8582
|
this.options.data.series.forEach(function (series, index) {
|
|
8311
8583
|
if (!series.key) {
|
|
8312
|
-
series.key =
|
|
8584
|
+
series.key = _this46.createIdentity();
|
|
8313
8585
|
}
|
|
8314
8586
|
|
|
8315
8587
|
if (!series.color) {
|
|
8316
|
-
series.color =
|
|
8588
|
+
series.color = _this46.options.colors[index % _this46.options.colors.length];
|
|
8317
8589
|
}
|
|
8318
8590
|
|
|
8319
|
-
|
|
8591
|
+
_this46["render".concat(series.type || 'bar')](series, index);
|
|
8320
8592
|
|
|
8321
|
-
|
|
8593
|
+
_this46.renderLabels(series, index);
|
|
8322
8594
|
|
|
8323
|
-
|
|
8595
|
+
_this46.renderedKeys[series.key] = series.type;
|
|
8324
8596
|
});
|
|
8325
8597
|
this.refLineLayer.selectAll('.reference-line').remove();
|
|
8326
8598
|
this.refLineLayer.selectAll('.reference-line-label').remove();
|
|
8327
8599
|
|
|
8328
8600
|
if (this.options.refLines && this.options.refLines.length > 0) {
|
|
8329
8601
|
this.options.refLines.forEach(function (l) {
|
|
8330
|
-
return
|
|
8602
|
+
return _this46.renderRefLine(l);
|
|
8331
8603
|
});
|
|
8332
8604
|
}
|
|
8333
8605
|
}
|
|
8334
8606
|
}, {
|
|
8335
8607
|
key: "renderarea",
|
|
8336
8608
|
value: function renderarea(series, index) {
|
|
8337
|
-
var
|
|
8609
|
+
var _this47 = this;
|
|
8338
8610
|
|
|
8339
8611
|
/* global d3 series index */
|
|
8340
8612
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
8341
8613
|
return d3.area().x(function (d) {
|
|
8342
|
-
return
|
|
8614
|
+
// return this[`${xAxis}Axis`](this.parseX(d.x.value))
|
|
8615
|
+
var xIndex = _this47[xAxis + 'Axis'].domain().indexOf(d.x.value);
|
|
8616
|
+
|
|
8617
|
+
var xPos = _this47["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
|
|
8618
|
+
|
|
8619
|
+
if (_this47["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
|
|
8620
|
+
xPos = xPos + (_this47["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
|
|
8621
|
+
}
|
|
8622
|
+
|
|
8623
|
+
return xPos;
|
|
8343
8624
|
}).y0(function (d) {
|
|
8344
|
-
return
|
|
8625
|
+
return _this47["".concat(yAxis, "Axis")](0);
|
|
8345
8626
|
}).y1(function (d) {
|
|
8346
|
-
return
|
|
8347
|
-
}).curve(d3[curveStyle ||
|
|
8627
|
+
return _this47["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8628
|
+
}).curve(d3[curveStyle || _this47.options.curveStyle]);
|
|
8348
8629
|
};
|
|
8349
8630
|
|
|
8350
8631
|
var xAxis = 'bottom';
|
|
@@ -8362,23 +8643,27 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8362
8643
|
areas // .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8363
8644
|
// .attr('id', `line_${series.key}`)
|
|
8364
8645
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8365
|
-
|
|
8366
|
-
|
|
8646
|
+
.attr('fill', function (d) {
|
|
8647
|
+
return d[0].y.color || series.color;
|
|
8648
|
+
}) // .attr('stroke', 'transparent')
|
|
8367
8649
|
.transition(this.transition).attr('d', function (d) {
|
|
8368
8650
|
return drawArea(xAxis, yAxis, series.curveStyle)(d);
|
|
8369
8651
|
}); // Enter
|
|
8370
8652
|
|
|
8371
8653
|
areas.enter().append('path').attr('d', function (d) {
|
|
8372
8654
|
return drawArea(xAxis, yAxis, series.curveStyle)(d);
|
|
8373
|
-
}).attr('class', "area_".concat(series.key)).attr('id', "area_".concat(series.key)).attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis
|
|
8374
|
-
.
|
|
8655
|
+
}).attr('class', "area_".concat(series.key)).attr('id', "area_".concat(series.key)) // .attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2) + ',0)')
|
|
8656
|
+
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8657
|
+
.attr('fill', function (d) {
|
|
8658
|
+
return d[0].y.color || series.color;
|
|
8659
|
+
}) // .style('fill-opacity', 0)
|
|
8375
8660
|
.attr('stroke', 'transparent') // .transition(this.transition)
|
|
8376
|
-
.style('fill-opacity', series.opacity || 0.
|
|
8661
|
+
.style('fill-opacity', series.opacity || 0.3);
|
|
8377
8662
|
}
|
|
8378
8663
|
}, {
|
|
8379
8664
|
key: "renderbar",
|
|
8380
8665
|
value: function renderbar(series, index) {
|
|
8381
|
-
var
|
|
8666
|
+
var _this48 = this;
|
|
8382
8667
|
|
|
8383
8668
|
/* global series index d3 */
|
|
8384
8669
|
var xAxis = 'bottom';
|
|
@@ -8390,16 +8675,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8390
8675
|
if (this.options.orientation === 'horizontal') {
|
|
8391
8676
|
xAxis = 'left';
|
|
8392
8677
|
yAxis = 'bottom';
|
|
8393
|
-
}
|
|
8394
|
-
// barWidth = barWidth / this.options.data.series.length - 4
|
|
8395
|
-
// }
|
|
8396
|
-
|
|
8678
|
+
}
|
|
8397
8679
|
|
|
8398
|
-
function getBarHeight(d, i,
|
|
8680
|
+
function getBarHeight(d, i, yAxis, xAxis) {
|
|
8399
8681
|
var output;
|
|
8400
8682
|
|
|
8401
8683
|
if (this.options.orientation === 'horizontal') {
|
|
8402
|
-
output = this.options.data[xAxis.
|
|
8684
|
+
output = Math.max(1, this.options.data[xAxis].bandWidth - (xAxis.indexOf('Brush') !== -1 ? 2 : this.options.groupPadding * 2));
|
|
8403
8685
|
} else {
|
|
8404
8686
|
var x = getBarX.call(this, d, i, xAxis);
|
|
8405
8687
|
|
|
@@ -8421,9 +8703,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8421
8703
|
var output;
|
|
8422
8704
|
|
|
8423
8705
|
if (this.options.orientation === 'horizontal') {
|
|
8424
|
-
|
|
8425
|
-
acummulativeY[d.y.index] += width;
|
|
8426
|
-
output = width;
|
|
8706
|
+
output = this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
|
|
8427
8707
|
} else {
|
|
8428
8708
|
var x = getBarX.call(this, d, i, xAxis);
|
|
8429
8709
|
|
|
@@ -8431,7 +8711,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8431
8711
|
return null;
|
|
8432
8712
|
}
|
|
8433
8713
|
|
|
8434
|
-
output = Math.max(1, this.options.data[xAxis.
|
|
8714
|
+
output = Math.max(1, this.options.data[xAxis].bandWidth - (xAxis.indexOf('Brush') !== -1 ? 2 : this.options.groupPadding * 2));
|
|
8435
8715
|
}
|
|
8436
8716
|
|
|
8437
8717
|
if (isNaN(output)) {
|
|
@@ -8442,46 +8722,50 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8442
8722
|
}
|
|
8443
8723
|
|
|
8444
8724
|
function getBarX(d, i, xAxis) {
|
|
8445
|
-
// let barWidth = this.plotWidth / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
8446
|
-
// if (this.options.data[xAxis.replace('Brush', '')].padding) {
|
|
8447
|
-
// barWidth = barWidth - (barWidth * this.options.data[xAxis.replace('Brush', '')].padding)
|
|
8448
|
-
// }
|
|
8449
|
-
// let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
8450
8725
|
var output;
|
|
8451
8726
|
|
|
8452
8727
|
if (this.options.orientation === 'horizontal') {
|
|
8453
8728
|
if (this.options.grouping === 'stacked') {
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
}
|
|
8729
|
+
// let h = getBarWidth.call(this, d, i, xAxis)
|
|
8730
|
+
// let adjustment = 0
|
|
8731
|
+
// if (d.y.accumulative && d.y.accumulative !== 0) {
|
|
8732
|
+
// adjustment = this[`${yAxis}Axis`](d.y.accumulative || 0)
|
|
8733
|
+
// }
|
|
8734
|
+
// output = this[`${yAxis}Axis`](0) + (adjustment * (d.y.value < 0 ? 1 : 0)) + (h * (d.y.value < 0 ? 1 : 0))
|
|
8735
|
+
var accH = getBarWidth.call(this, {
|
|
8736
|
+
x: d.x,
|
|
8737
|
+
y: {
|
|
8738
|
+
value: d.y.accumulative
|
|
8739
|
+
}
|
|
8740
|
+
}, i, xAxis); // let h = getBarWidth.call(this, d, i, xAxis)
|
|
8460
8741
|
|
|
8461
|
-
output =
|
|
8742
|
+
output = accH * (d.y.accumulative < 0 ? 0 : 1);
|
|
8462
8743
|
} else {
|
|
8463
|
-
var
|
|
8464
|
-
|
|
8465
|
-
output = this["".concat(yAxis, "Axis")](0) + _h * (d.y.value < 0 ? 1 : 0);
|
|
8744
|
+
var h = getBarWidth.call(this, d, i, xAxis);
|
|
8745
|
+
output = this["".concat(yAxis, "Axis")](0) + h * (d.y.value < 0 ? 1 : 0);
|
|
8466
8746
|
}
|
|
8467
8747
|
} else {
|
|
8468
8748
|
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
|
|
8469
|
-
|
|
8470
|
-
|
|
8749
|
+
// let adjustment = this[`custom${xAxis.toInitialCaps()}Range`][i] + (i * this.options.data[xAxis].bandWidth)
|
|
8471
8750
|
if (this.options.grouping === 'grouped') {
|
|
8472
8751
|
var xIndex = 0;
|
|
8473
8752
|
|
|
8474
8753
|
if (this.processedX[d.x.value]) {
|
|
8475
8754
|
xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel));
|
|
8476
|
-
}
|
|
8477
|
-
|
|
8478
|
-
|
|
8755
|
+
} // let barAdjustment =
|
|
8756
|
+
// (this.options.data[xAxis].bandWidth * xIndex) +
|
|
8757
|
+
// (xIndex * this.options.groupPadding * 2) + this.options.groupPadding +
|
|
8758
|
+
// (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
8759
|
+
// let barAdjustment =
|
|
8479
8760
|
// (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
|
|
8480
8761
|
// this.options.groupPadding
|
|
8481
8762
|
// // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
8482
8763
|
|
|
8483
|
-
|
|
8484
|
-
|
|
8764
|
+
|
|
8765
|
+
var barAdjustment = this.options.data[xAxis].bandWidth * xIndex + (xAxis.indexOf('Brush') !== -1 ? this.brushBandPadding : this.bandPadding) / 2 + (xAxis.indexOf('Brush') !== -1 ? 1 : this.options.groupPadding);
|
|
8766
|
+
|
|
8767
|
+
if (this["custom".concat(xAxis.toInitialCaps(), "Range")].length > 0) {
|
|
8768
|
+
output = this["custom".concat(xAxis.toInitialCaps(), "Range")][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment; // output = this[`custom${xAxis.toInitialCaps().replace('Brush', '')}DetailRange`][this[xAxis + 'Axis'].domain().indexOf(d.x.value)]
|
|
8485
8769
|
} else {
|
|
8486
8770
|
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
|
|
8487
8771
|
}
|
|
@@ -8492,12 +8776,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8492
8776
|
|
|
8493
8777
|
if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
|
|
8494
8778
|
this.processedX[d.x.value].push(d.y.tooltipLabel);
|
|
8495
|
-
}
|
|
8779
|
+
} // console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
|
|
8496
8780
|
|
|
8497
|
-
console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output);
|
|
8498
8781
|
} else {
|
|
8499
|
-
|
|
8500
|
-
|
|
8782
|
+
var _barAdjustment = (xAxis.indexOf('Brush') !== -1 ? this.brushBandPadding : this.bandPadding) / 2 + (xAxis.indexOf('Brush') !== -1 ? 1 : this.options.groupPadding);
|
|
8783
|
+
|
|
8784
|
+
output = this["custom".concat(xAxis.toInitialCaps(), "Range")][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + _barAdjustment;
|
|
8501
8785
|
}
|
|
8502
8786
|
}
|
|
8503
8787
|
|
|
@@ -8508,23 +8792,30 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8508
8792
|
return output;
|
|
8509
8793
|
}
|
|
8510
8794
|
|
|
8511
|
-
function getBarY(d, i,
|
|
8512
|
-
// let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
8513
|
-
// let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
8795
|
+
function getBarY(d, i, yAxis, xAxis) {
|
|
8514
8796
|
var output;
|
|
8515
8797
|
|
|
8516
8798
|
if (this.options.orientation === 'horizontal') {
|
|
8517
8799
|
if (this.options.grouping !== 'grouped') {
|
|
8518
|
-
|
|
8800
|
+
var barAdjustment = (xAxis.indexOf('Brush') !== -1 ? this.brushBandPadding : this.bandPadding) / 2 + (xAxis.indexOf('Brush') !== -1 ? 1 : this.options.groupPadding);
|
|
8801
|
+
output = this["custom".concat(xAxis.toInitialCaps(), "Range")][this[xAxis + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment;
|
|
8519
8802
|
} else {
|
|
8520
8803
|
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * this.options.data[xAxis.replace('Brush', '')].barWidth;
|
|
8521
8804
|
}
|
|
8522
8805
|
} else {
|
|
8523
8806
|
if (this.options.grouping === 'stacked') {
|
|
8524
|
-
|
|
8807
|
+
var accH = getBarHeight.call(this, {
|
|
8808
|
+
x: d.x,
|
|
8809
|
+
y: {
|
|
8810
|
+
value: d.y.accumulative
|
|
8811
|
+
}
|
|
8812
|
+
}, i, yAxis, xAxis);
|
|
8813
|
+
var h = getBarHeight.call(this, d, i, yAxis, xAxis);
|
|
8814
|
+
output = this["".concat(yAxis, "Axis")](0) - (accH + h) * (d.y.accumulative < 0 ? 0 : 1);
|
|
8525
8815
|
} else {
|
|
8526
|
-
var
|
|
8527
|
-
|
|
8816
|
+
var _h = getBarHeight.call(this, d, i, yAxis, xAxis);
|
|
8817
|
+
|
|
8818
|
+
output = this["".concat(yAxis, "Axis")](0) - _h * (d.y.value < 0 ? 0 : 1);
|
|
8528
8819
|
}
|
|
8529
8820
|
}
|
|
8530
8821
|
|
|
@@ -8537,25 +8828,25 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8537
8828
|
|
|
8538
8829
|
bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8539
8830
|
bars.attr('width', function (d, i) {
|
|
8540
|
-
return Math.abs(getBarWidth.call(
|
|
8831
|
+
return Math.abs(getBarWidth.call(_this48, d, i, xAxis));
|
|
8541
8832
|
}).attr('height', function (d, i) {
|
|
8542
|
-
return getBarHeight.call(
|
|
8833
|
+
return getBarHeight.call(_this48, d, i, yAxis, xAxis);
|
|
8543
8834
|
}).attr('x', function (d, i) {
|
|
8544
|
-
return getBarX.call(
|
|
8835
|
+
return getBarX.call(_this48, d, i, xAxis);
|
|
8545
8836
|
}).attr('y', function (d, i) {
|
|
8546
|
-
return getBarY.call(
|
|
8837
|
+
return getBarY.call(_this48, d, i, yAxis, xAxis);
|
|
8547
8838
|
}) // .transition(this.transition)
|
|
8548
8839
|
.attr('fill', function (d) {
|
|
8549
8840
|
return d.y.color || d.color || series.color;
|
|
8550
8841
|
});
|
|
8551
8842
|
bars.enter().append('rect').attr('width', function (d, i) {
|
|
8552
|
-
return Math.abs(getBarWidth.call(
|
|
8843
|
+
return Math.abs(getBarWidth.call(_this48, d, i, xAxis));
|
|
8553
8844
|
}).attr('height', function (d, i) {
|
|
8554
|
-
return getBarHeight.call(
|
|
8845
|
+
return getBarHeight.call(_this48, d, i, yAxis, xAxis);
|
|
8555
8846
|
}).attr('x', function (d, i) {
|
|
8556
|
-
return getBarX.call(
|
|
8847
|
+
return getBarX.call(_this48, d, i, xAxis);
|
|
8557
8848
|
}).attr('y', function (d, i) {
|
|
8558
|
-
return getBarY.call(
|
|
8849
|
+
return getBarY.call(_this48, d, i, yAxis, xAxis);
|
|
8559
8850
|
}) // .transition(this.transition)
|
|
8560
8851
|
.attr('fill', function (d) {
|
|
8561
8852
|
return d.y.color || d.color || series.color;
|
|
@@ -8567,25 +8858,25 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8567
8858
|
this.brushBarsInitialized[series.key] = true;
|
|
8568
8859
|
brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8569
8860
|
brushBars.attr('width', function (d, i) {
|
|
8570
|
-
return Math.abs(getBarWidth.call(
|
|
8861
|
+
return Math.abs(getBarWidth.call(_this48, d, i, "".concat(xAxis, "Brush")));
|
|
8571
8862
|
}).attr('height', function (d, i) {
|
|
8572
|
-
return getBarHeight.call(
|
|
8863
|
+
return getBarHeight.call(_this48, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8573
8864
|
}).attr('x', function (d, i) {
|
|
8574
|
-
return getBarX.call(
|
|
8865
|
+
return getBarX.call(_this48, d, i, "".concat(xAxis, "Brush"));
|
|
8575
8866
|
}).attr('y', function (d, i) {
|
|
8576
|
-
return getBarY.call(
|
|
8867
|
+
return getBarY.call(_this48, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8577
8868
|
}) // .transition(this.transition)
|
|
8578
8869
|
.attr('fill', function (d) {
|
|
8579
8870
|
return d.y.color || d.color || series.color;
|
|
8580
8871
|
});
|
|
8581
8872
|
brushBars.enter().append('rect').attr('width', function (d, i) {
|
|
8582
|
-
return Math.abs(getBarWidth.call(
|
|
8873
|
+
return Math.abs(getBarWidth.call(_this48, d, i, "".concat(xAxis, "Brush")));
|
|
8583
8874
|
}).attr('height', function (d, i) {
|
|
8584
|
-
return getBarHeight.call(
|
|
8875
|
+
return getBarHeight.call(_this48, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8585
8876
|
}).attr('x', function (d, i) {
|
|
8586
|
-
return getBarX.call(
|
|
8877
|
+
return getBarX.call(_this48, d, i, "".concat(xAxis, "Brush"));
|
|
8587
8878
|
}).attr('y', function (d, i) {
|
|
8588
|
-
return getBarY.call(
|
|
8879
|
+
return getBarY.call(_this48, d, i, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8589
8880
|
}) // .transition(this.transition)
|
|
8590
8881
|
.attr('fill', function (d) {
|
|
8591
8882
|
return d.y.color || d.color || series.color;
|
|
@@ -8603,16 +8894,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8603
8894
|
}, {
|
|
8604
8895
|
key: "renderLabels",
|
|
8605
8896
|
value: function renderLabels(series, index) {
|
|
8606
|
-
var
|
|
8897
|
+
var _this49 = this;
|
|
8607
8898
|
|
|
8608
8899
|
/* global series index d3 WebsyDesigns */
|
|
8609
|
-
var xAxis = '
|
|
8610
|
-
var yAxis = '
|
|
8900
|
+
var xAxis = 'bottom';
|
|
8901
|
+
var yAxis = 'left';
|
|
8611
8902
|
var that = this;
|
|
8612
8903
|
|
|
8613
8904
|
if (this.options.orientation === 'horizontal') {
|
|
8614
|
-
xAxis = '
|
|
8615
|
-
yAxis = '
|
|
8905
|
+
xAxis = 'left';
|
|
8906
|
+
yAxis = 'bottom';
|
|
8616
8907
|
}
|
|
8617
8908
|
|
|
8618
8909
|
if (this.options.showLabels === true || series.showLabels === true) {
|
|
@@ -8622,15 +8913,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8622
8913
|
var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
|
|
8623
8914
|
labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
8624
8915
|
labels.attr('x', function (d) {
|
|
8625
|
-
return getLabelX.call(
|
|
8916
|
+
return getLabelX.call(_this49, d, series.labelPosition);
|
|
8626
8917
|
}).attr('y', function (d) {
|
|
8627
|
-
return getLabelY.call(
|
|
8918
|
+
return getLabelY.call(_this49, d, series.labelPosition);
|
|
8628
8919
|
}).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
|
|
8629
|
-
if (
|
|
8920
|
+
if (_this49.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8630
8921
|
return 'transparent';
|
|
8631
8922
|
}
|
|
8632
8923
|
|
|
8633
|
-
return
|
|
8924
|
+
return _this49.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8634
8925
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
|
|
8635
8926
|
return d.y.label || d.y.value;
|
|
8636
8927
|
}).each(function (d, i) {
|
|
@@ -8655,15 +8946,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8655
8946
|
}
|
|
8656
8947
|
});
|
|
8657
8948
|
labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', function (d) {
|
|
8658
|
-
return getLabelX.call(
|
|
8949
|
+
return getLabelX.call(_this49, d, series.labelPosition);
|
|
8659
8950
|
}).attr('y', function (d) {
|
|
8660
|
-
return getLabelY.call(
|
|
8951
|
+
return getLabelY.call(_this49, d, series.labelPosition);
|
|
8661
8952
|
}).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
|
|
8662
|
-
if (
|
|
8953
|
+
if (_this49.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8663
8954
|
return 'transparent';
|
|
8664
8955
|
}
|
|
8665
8956
|
|
|
8666
|
-
return
|
|
8957
|
+
return _this49.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8667
8958
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
|
|
8668
8959
|
return d.y.label || d.y.value;
|
|
8669
8960
|
}).each(function (d, i) {
|
|
@@ -8685,6 +8976,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8685
8976
|
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
8686
8977
|
this.setAttribute('y', +this.getAttribute('y') + 8);
|
|
8687
8978
|
}
|
|
8979
|
+
|
|
8980
|
+
if (series.labelPosition !== 'outside') {
|
|
8981
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color));
|
|
8982
|
+
}
|
|
8688
8983
|
}
|
|
8689
8984
|
});
|
|
8690
8985
|
}
|
|
@@ -8694,12 +8989,20 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8694
8989
|
|
|
8695
8990
|
if (this.options.orientation === 'horizontal') {
|
|
8696
8991
|
if (this.options.grouping === 'stacked') {
|
|
8697
|
-
return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1);
|
|
8992
|
+
return this[yAxis + 'Axis'](d.y.accumulative) + this[yAxis + 'Axis'](d.y.value) / (labelPosition === 'inside' ? 2 : 1);
|
|
8698
8993
|
} else {
|
|
8699
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4;
|
|
8994
|
+
return this[yAxis + 'Axis'](isNaN(d.y.value) ? 0 : d.y.value) + 4;
|
|
8700
8995
|
}
|
|
8701
8996
|
} else {
|
|
8702
|
-
return this[xAxis](this.parseX(d.x.value)) + this.options.data[xAxis.replace('Axis', '')].bandWidth / 2
|
|
8997
|
+
// return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
|
|
8998
|
+
var xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value);
|
|
8999
|
+
var xPos = this["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
|
|
9000
|
+
|
|
9001
|
+
if (this["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
|
|
9002
|
+
xPos = xPos + (this["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
|
|
9003
|
+
}
|
|
9004
|
+
|
|
9005
|
+
return xPos;
|
|
8703
9006
|
}
|
|
8704
9007
|
}
|
|
8705
9008
|
|
|
@@ -8707,12 +9010,21 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8707
9010
|
var labelPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inside';
|
|
8708
9011
|
|
|
8709
9012
|
if (this.options.orientation === 'horizontal') {
|
|
8710
|
-
|
|
9013
|
+
var xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value);
|
|
9014
|
+
var xPos = this["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
|
|
9015
|
+
|
|
9016
|
+
if (this["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
|
|
9017
|
+
xPos = xPos + (this["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
|
|
9018
|
+
}
|
|
9019
|
+
|
|
9020
|
+
return xPos;
|
|
8711
9021
|
} else {
|
|
8712
9022
|
if (this.options.grouping === 'stacked') {
|
|
8713
|
-
|
|
9023
|
+
var accH = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.accumulative));
|
|
9024
|
+
var h = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
|
|
9025
|
+
return this["".concat(yAxis, "Axis")](0) - (accH + h - (labelPosition === 'inside' ? h / 2 : 0)) * (d.y.accumulative < 0 ? 0 : 1); // return (this[`${yAxis}Axis`](0)) - (this[yAxis + 'Axis'](d.y.accumulative) - (this[yAxis + 'Axis'](d.y.value))) // / (labelPosition === 'inside' ? 2 : 1)))
|
|
8714
9026
|
} else {
|
|
8715
|
-
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize);
|
|
9027
|
+
return this[yAxis + 'Axis'](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize);
|
|
8716
9028
|
}
|
|
8717
9029
|
}
|
|
8718
9030
|
}
|
|
@@ -8720,25 +9032,34 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8720
9032
|
}, {
|
|
8721
9033
|
key: "renderline",
|
|
8722
9034
|
value: function renderline(series, index) {
|
|
8723
|
-
var
|
|
9035
|
+
var _this50 = this;
|
|
8724
9036
|
|
|
8725
9037
|
/* global series index d3 */
|
|
8726
9038
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
8727
9039
|
return d3.line().x(function (d) {
|
|
8728
|
-
if (
|
|
8729
|
-
return
|
|
9040
|
+
if (_this50.options.orientation === 'horizontal') {
|
|
9041
|
+
return _this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8730
9042
|
} else {
|
|
8731
|
-
var
|
|
8732
|
-
|
|
9043
|
+
var xIndex = _this50[xAxis + 'Axis'].domain().indexOf(d.x.value);
|
|
9044
|
+
|
|
9045
|
+
var xPos = _this50["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
|
|
9046
|
+
|
|
9047
|
+
if (_this50["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
|
|
9048
|
+
xPos = xPos + (_this50["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
|
|
9049
|
+
} // let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
9050
|
+
// return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
|
|
9051
|
+
|
|
9052
|
+
|
|
9053
|
+
return xPos;
|
|
8733
9054
|
}
|
|
8734
9055
|
}).y(function (d) {
|
|
8735
|
-
if (
|
|
8736
|
-
var adjustment =
|
|
8737
|
-
return
|
|
9056
|
+
if (_this50.options.orientation === 'horizontal') {
|
|
9057
|
+
var adjustment = _this50.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this50.options.data[xAxis].bandWidth / 2;
|
|
9058
|
+
return _this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment;
|
|
8738
9059
|
} else {
|
|
8739
|
-
return
|
|
9060
|
+
return _this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8740
9061
|
}
|
|
8741
|
-
}).curve(d3[curveStyle ||
|
|
9062
|
+
}).curve(d3[curveStyle || _this50.options.curveStyle]);
|
|
8742
9063
|
};
|
|
8743
9064
|
|
|
8744
9065
|
var xAxis = 'bottom';
|
|
@@ -8764,14 +9085,18 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8764
9085
|
|
|
8765
9086
|
lines.style('stroke-width', series.lineWidth || this.options.lineWidth) // .attr('id', `line_${series.key}`)
|
|
8766
9087
|
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8767
|
-
.attr('stroke',
|
|
9088
|
+
.attr('stroke', function (d) {
|
|
9089
|
+
return d[0].y.color || series.color;
|
|
9090
|
+
}).attr('fill', 'transparent').transition(this.transition).attr('d', function (d) {
|
|
8768
9091
|
return drawLine(xAxis, yAxis, series.curveStyle)(d);
|
|
8769
9092
|
}); // Enter
|
|
8770
9093
|
|
|
8771
9094
|
lines.enter().append('path').attr('d', function (d) {
|
|
8772
9095
|
return drawLine(xAxis, yAxis, series.curveStyle)(d);
|
|
8773
9096
|
}).attr('class', "line_".concat(series.key)).attr('id', "line_".concat(series.key)) // .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
8774
|
-
.style('stroke-width', series.lineWidth || this.options.lineWidth).attr('stroke',
|
|
9097
|
+
.style('stroke-width', series.lineWidth || this.options.lineWidth).attr('stroke', function (d) {
|
|
9098
|
+
return d[0].y.color || series.color;
|
|
9099
|
+
}).attr('fill', 'transparent') // .transition(this.transition)
|
|
8775
9100
|
.style('stroke-opacity', 1);
|
|
8776
9101
|
|
|
8777
9102
|
if (!this.brushLinesInitialized[series.key]) {
|
|
@@ -8831,18 +9156,31 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8831
9156
|
value: function removeline(key) {
|
|
8832
9157
|
/* global key d3 */
|
|
8833
9158
|
var lines = this.lineLayer.selectAll(".line_".concat(key)).transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
9159
|
+
var areas = this.areaLayer.selectAll(".area_".concat(key)).transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
9160
|
+
}
|
|
9161
|
+
}, {
|
|
9162
|
+
key: "removelabel",
|
|
9163
|
+
value: function removelabel(key) {
|
|
9164
|
+
/* global key d3 */
|
|
9165
|
+
var labels = this.labelLayer.selectAll(".label_".concat(key)).transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
9166
|
+
}
|
|
9167
|
+
}, {
|
|
9168
|
+
key: "removesymbol",
|
|
9169
|
+
value: function removesymbol(key) {
|
|
9170
|
+
/* global key d3 */
|
|
9171
|
+
var symbols = this.symbolLayer.selectAll(".symbol_".concat(key)).transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
8834
9172
|
}
|
|
8835
9173
|
}, {
|
|
8836
9174
|
key: "rendersymbol",
|
|
8837
9175
|
value: function rendersymbol(series, index) {
|
|
8838
|
-
var
|
|
9176
|
+
var _this51 = this;
|
|
8839
9177
|
|
|
8840
9178
|
/* global d3 series index series.key */
|
|
8841
9179
|
var drawSymbol = function drawSymbol(size) {
|
|
8842
9180
|
return d3.symbol() // .type(d => {
|
|
8843
9181
|
// return d3.symbols[0]
|
|
8844
9182
|
// })
|
|
8845
|
-
.size(size ||
|
|
9183
|
+
.size(size || _this51.options.symbolSize);
|
|
8846
9184
|
};
|
|
8847
9185
|
|
|
8848
9186
|
var xAxis = 'bottom';
|
|
@@ -8860,12 +9198,28 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8860
9198
|
symbols.attr('d', function (d) {
|
|
8861
9199
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
8862
9200
|
}).transition(this.transition).attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
8863
|
-
|
|
9201
|
+
// let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
|
|
9202
|
+
// if (this.options.orientation === 'horizontal') {
|
|
9203
|
+
// return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
|
|
9204
|
+
// }
|
|
9205
|
+
// else {
|
|
9206
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
9207
|
+
// }
|
|
9208
|
+
var xIndex = _this51[xAxis + 'Axis'].domain().indexOf(d.x.value);
|
|
9209
|
+
|
|
9210
|
+
var xPos = _this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
|
|
9211
|
+
|
|
9212
|
+
if (_this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
|
|
9213
|
+
xPos = xPos + (_this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
|
|
9214
|
+
}
|
|
9215
|
+
|
|
9216
|
+
var adjustment = _this51.options.data[xAxis].scale === 'Time' || _this51.options.data[xAxis].scale === 'Linear' ? 0 : _this51.options.data[xAxis].bandWidth / 2;
|
|
8864
9217
|
|
|
8865
|
-
if (
|
|
8866
|
-
return "translate(".concat(
|
|
9218
|
+
if (_this51.options.orientation === 'horizontal') {
|
|
9219
|
+
return "translate(".concat(_this51["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(xPos, ")");
|
|
8867
9220
|
} else {
|
|
8868
|
-
return
|
|
9221
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
9222
|
+
return "translate(".concat(xPos, ", ").concat(_this51["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
8869
9223
|
}
|
|
8870
9224
|
}); // Enter
|
|
8871
9225
|
|
|
@@ -8875,12 +9229,21 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8875
9229
|
.attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
8876
9230
|
return "symbol symbol_".concat(series.key);
|
|
8877
9231
|
}).attr('transform', function (d) {
|
|
8878
|
-
var
|
|
9232
|
+
var xIndex = _this51[xAxis + 'Axis'].domain().indexOf(d.x.value);
|
|
8879
9233
|
|
|
8880
|
-
|
|
8881
|
-
|
|
9234
|
+
var xPos = _this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
|
|
9235
|
+
|
|
9236
|
+
if (_this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
|
|
9237
|
+
xPos = xPos + (_this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
|
|
9238
|
+
}
|
|
9239
|
+
|
|
9240
|
+
var adjustment = _this51.options.data[xAxis].scale === 'Time' || _this51.options.data[xAxis].scale === 'Linear' ? 0 : _this51.options.data[xAxis].bandWidth / 2;
|
|
9241
|
+
|
|
9242
|
+
if (_this51.options.orientation === 'horizontal') {
|
|
9243
|
+
return "translate(".concat(_this51["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(xPos, ")");
|
|
8882
9244
|
} else {
|
|
8883
|
-
return
|
|
9245
|
+
// return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
|
|
9246
|
+
return "translate(".concat(xPos, ", ").concat(_this51["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
8884
9247
|
}
|
|
8885
9248
|
});
|
|
8886
9249
|
}
|
|
@@ -9102,7 +9465,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
9102
9465
|
}, {
|
|
9103
9466
|
key: "resize",
|
|
9104
9467
|
value: function resize() {
|
|
9105
|
-
var
|
|
9468
|
+
var _this52 = this;
|
|
9106
9469
|
|
|
9107
9470
|
var el = document.getElementById(this.elementId);
|
|
9108
9471
|
|
|
@@ -9115,7 +9478,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
9115
9478
|
// }
|
|
9116
9479
|
var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
|
|
9117
9480
|
html += this._data.map(function (d, i) {
|
|
9118
|
-
return
|
|
9481
|
+
return _this52.getLegendItemHTML(d);
|
|
9119
9482
|
}).join('');
|
|
9120
9483
|
html += "\n <div>\n ";
|
|
9121
9484
|
el.innerHTML = html;
|
|
@@ -9287,7 +9650,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9287
9650
|
}, {
|
|
9288
9651
|
key: "render",
|
|
9289
9652
|
value: function render() {
|
|
9290
|
-
var
|
|
9653
|
+
var _this53 = this;
|
|
9291
9654
|
|
|
9292
9655
|
var mapEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
9293
9656
|
var legendEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
@@ -9296,7 +9659,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9296
9659
|
var legendData = this.options.data.polygons.map(function (s, i) {
|
|
9297
9660
|
return {
|
|
9298
9661
|
value: s.label || s.key,
|
|
9299
|
-
color: s.color ||
|
|
9662
|
+
color: s.color || _this53.options.colors[i % _this53.options.colors.length]
|
|
9300
9663
|
};
|
|
9301
9664
|
});
|
|
9302
9665
|
var longestValue = legendData.map(function (s) {
|
|
@@ -9360,7 +9723,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9360
9723
|
|
|
9361
9724
|
if (this.polygons) {
|
|
9362
9725
|
this.polygons.forEach(function (p) {
|
|
9363
|
-
return
|
|
9726
|
+
return _this53.map.removeLayer(p);
|
|
9364
9727
|
});
|
|
9365
9728
|
}
|
|
9366
9729
|
|
|
@@ -9418,18 +9781,18 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9418
9781
|
}
|
|
9419
9782
|
|
|
9420
9783
|
if (!p.options.color) {
|
|
9421
|
-
p.options.color =
|
|
9784
|
+
p.options.color = _this53.options.colors[i % _this53.options.colors.length];
|
|
9422
9785
|
}
|
|
9423
9786
|
|
|
9424
9787
|
var pol = L.polygon(p.data.map(function (c) {
|
|
9425
9788
|
return c.map(function (d) {
|
|
9426
9789
|
return [d.Latitude, d.Longitude];
|
|
9427
9790
|
});
|
|
9428
|
-
}), p.options).addTo(
|
|
9791
|
+
}), p.options).addTo(_this53.map);
|
|
9429
9792
|
|
|
9430
|
-
|
|
9793
|
+
_this53.polygons.push(pol);
|
|
9431
9794
|
|
|
9432
|
-
|
|
9795
|
+
_this53.map.fitBounds(pol.getBounds());
|
|
9433
9796
|
});
|
|
9434
9797
|
} // if (this.data.markers.length > 0) {
|
|
9435
9798
|
// el.classList.remove('hidden')
|