@websy/websy-designs 1.5.1 → 1.6.0

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.
@@ -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 _this11 = this;
2282
+ var _this12 = this;
2259
2283
 
2260
2284
  return new Promise(function (resolve, reject) {
2261
- if (_this11.options.useRecaptcha === true) {
2262
- if (_this11.recaptchaValue) {
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
- _this11.apiService.add('google/checkrecaptcha', {
2266
- grecaptcharesponse: _this11.recaptchaValue
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(_this11.elementId, "_recaptcha"), {
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 _this12 = this;
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(_this12.elementId, "_input_").concat(c.field, "_component"), c.options);
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 _this13 = this;
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(_this13.elementId, "_recaptcha"), {
2377
+ grecaptcha.render("".concat(_this14.elementId, "_recaptcha"), {
2354
2378
  sitekey: ENVIRONMENT.RECAPTCHA_KEY,
2355
- callback: _this13.validateRecaptcha.bind(_this13)
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 _this14 = this;
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(_this14.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
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(_this14.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 ");
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(_this14.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 ");
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 (_this14.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
2395
- _this14.recaptchaReady();
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 _this15 = this;
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 (_this15.options.url) {
2432
- var _this15$apiService;
2476
+ if (_this16.options.url) {
2477
+ var _this16$apiService;
2433
2478
 
2434
- var params = [_this15.options.url];
2479
+ var params = [_this16.options.url];
2435
2480
 
2436
- if (_this15.options.mode === 'update') {
2437
- params.push(_this15.options.id);
2481
+ if (_this16.options.mode === 'update') {
2482
+ params.push(_this16.options.id);
2438
2483
  }
2439
2484
 
2440
2485
  params.push(data);
2441
2486
 
2442
- (_this15$apiService = _this15.apiService)[_this15.options.mode].apply(_this15$apiService, params).then(function (result) {
2443
- if (_this15.options.clearAfterSave === true) {
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
- _this15.options.onSuccess.call(_this15, result);
2495
+ _this16.options.onSuccess.call(_this16, result);
2451
2496
  }, function (err) {
2452
2497
  console.log('Error submitting form data:', err);
2453
2498
 
2454
- _this15.options.onError.call(_this15, err);
2499
+ _this16.options.onError.call(_this16, err);
2455
2500
  });
2456
- } else if (_this15.options.submitFn) {
2457
- _this15.options.submitFn(data, function () {
2458
- if (_this15.options.clearAfterSave === true) {
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 _this16 = this;
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
- _this16.options.fields.forEach(function (f) {
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(_this16.elementId, "_input_").concat(f.field));
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 _this17 = this;
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[_this17.options.searchProp].toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
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 _this18 = this;
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 (_this18.options.onChangePageSize) {
3042
- _this18.options.onChangePageSize(selectedItem.value);
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 _this19 = this;
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(_this19.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
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 _this20 = this;
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 (_this20.options.targetId) {
3146
- var el = document.getElementById(_this20.options.targetId);
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 (_this20.options.pdfOptions) {
3154
- pdfData.options = _extends({}, _this20.options.pdfOptions);
3207
+ if (_this21.options.pdfOptions) {
3208
+ pdfData.options = _extends({}, _this21.options.pdfOptions);
3155
3209
  }
3156
3210
 
3157
- if (_this20.options.header) {
3158
- if (_this20.options.header.elementId) {
3159
- var headerEl = document.getElementById(_this20.options.header.elementId);
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 (_this20.options.header.css) {
3165
- pdfData.options.headerCSS = _this20.options.header.css;
3218
+ if (_this21.options.header.css) {
3219
+ pdfData.options.headerCSS = _this21.options.header.css;
3166
3220
  }
3167
3221
  }
3168
- } else if (_this20.options.header.html) {
3169
- pdfData.header = _this20.options.header.html;
3222
+ } else if (_this21.options.header.html) {
3223
+ pdfData.header = _this21.options.header.html;
3170
3224
 
3171
- if (_this20.options.header.css) {
3172
- pdfData.options.headerCSS = _this20.options.header.css;
3225
+ if (_this21.options.header.css) {
3226
+ pdfData.options.headerCSS = _this21.options.header.css;
3173
3227
  }
3174
3228
  } else {
3175
- pdfData.header = _this20.options.header;
3229
+ pdfData.header = _this21.options.header;
3176
3230
  }
3177
3231
  }
3178
3232
 
3179
- if (_this20.options.footer) {
3180
- if (_this20.options.footer.elementId) {
3181
- var footerEl = document.getElementById(_this20.options.footer.elementId);
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 (_this20.options.footer.css) {
3187
- pdfData.options.footerCSS = _this20.options.footer.css;
3240
+ if (_this21.options.footer.css) {
3241
+ pdfData.options.footerCSS = _this21.options.footer.css;
3188
3242
  }
3189
3243
  }
3190
3244
  } else {
3191
- pdfData.footer = _this20.options.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
- _this20.service.add('', pdfData, {
3254
+ _this21.service.add('', pdfData, {
3201
3255
  responseType: 'blob'
3202
3256
  }).then(function (response) {
3203
- _this20.loader.hide();
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 (_this20.options.directDownload === true) {
3264
+ if (_this21.options.directDownload === true) {
3211
3265
  var fileName;
3212
3266
 
3213
- if (typeof _this20.options.fileName === 'function') {
3214
- fileName = _this20.options.fileName() || 'Export';
3267
+ if (typeof _this21.options.fileName === 'function') {
3268
+ fileName = _this21.options.fileName() || 'Export';
3215
3269
  } else {
3216
- fileName = _this20.options.fileName || 'Export';
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(_this20.options.buttonText, "</button>\n </a>\n </div>\n ");
3276
+ msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this21.options.buttonText, "</button>\n </a>\n </div>\n ");
3223
3277
 
3224
- _this20.popup.show({
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 _this21 = this;
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 _this21.render();
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 _this22 = this;
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
- _this22.options.template = templateString;
3743
+ _this23.options.template = templateString;
3690
3744
 
3691
- _this22.render();
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 _this23 = this;
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 || _this23.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
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], _this23.buildHTML(items, 0, withoutFor, [].concat(_toConsumableArray(locator), ["".concat(startIndex + ix, ":").concat(c)])));
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 = _this23.flattenObject(row);
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 _this24 = this;
4027
+ var _this25 = this;
3974
4028
 
3975
4029
  if (this.options.entity) {
3976
4030
  this.apiService.get(this.options.entity).then(function (results) {
3977
- _this24.rows = results.rows;
4031
+ _this25.rows = results.rows;
3978
4032
 
3979
- _this24.resize();
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 _this25 = this;
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
- _this25.groups[group] = {
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 _this26 = this;
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 _this26.currentParams.items[p];
4203
+ delete _this27.currentParams.items[p];
4150
4204
  });
4151
4205
  path = this.buildUrlPath(this.currentParams.items);
4152
4206
  }
@@ -4510,12 +4564,12 @@ var WebsyRouter = /*#__PURE__*/function () {
4510
4564
  }, {
4511
4565
  key: "showComponents",
4512
4566
  value: function showComponents(view) {
4513
- var _this27 = this;
4567
+ var _this28 = this;
4514
4568
 
4515
4569
  if (this.options.views && this.options.views[view] && this.options.views[view].components) {
4516
4570
  this.options.views[view].components.forEach(function (c) {
4517
4571
  if (typeof c.instance === 'undefined') {
4518
- _this27.prepComponent(c.elementId, c.options);
4572
+ _this28.prepComponent(c.elementId, c.options);
4519
4573
 
4520
4574
  c.instance = new c.Component(c.elementId, c.options);
4521
4575
  } else if (c.instance.render) {
@@ -4894,7 +4948,7 @@ var Switch = /*#__PURE__*/function () {
4894
4948
 
4895
4949
  var WebsyTemplate = /*#__PURE__*/function () {
4896
4950
  function WebsyTemplate(elementId, options) {
4897
- var _this28 = this;
4951
+ var _this29 = this;
4898
4952
 
4899
4953
  _classCallCheck(this, WebsyTemplate);
4900
4954
 
@@ -4920,9 +4974,9 @@ var WebsyTemplate = /*#__PURE__*/function () {
4920
4974
 
4921
4975
  if (_typeof(options.template) === 'object' && options.template.url) {
4922
4976
  this.templateService.get(options.template.url).then(function (templateString) {
4923
- _this28.options.template = templateString;
4977
+ _this29.options.template = templateString;
4924
4978
 
4925
- _this28.render();
4979
+ _this29.render();
4926
4980
  });
4927
4981
  } else {
4928
4982
  this.render();
@@ -4932,7 +4986,7 @@ var WebsyTemplate = /*#__PURE__*/function () {
4932
4986
  _createClass(WebsyTemplate, [{
4933
4987
  key: "buildHTML",
4934
4988
  value: function buildHTML() {
4935
- var _this29 = this;
4989
+ var _this30 = this;
4936
4990
 
4937
4991
  var html = "";
4938
4992
 
@@ -4994,14 +5048,14 @@ var WebsyTemplate = /*#__PURE__*/function () {
4994
5048
  }
4995
5049
 
4996
5050
  if (polarity === true) {
4997
- if (typeof _this29.options.data[parts[0]] !== 'undefined' && _this29.options.data[parts[0]] === parts[1]) {
5051
+ if (typeof _this30.options.data[parts[0]] !== 'undefined' && _this30.options.data[parts[0]] === parts[1]) {
4998
5052
  // remove the <if> tags
4999
5053
  removeAll = false;
5000
5054
  } else if (parts[0] === parts[1]) {
5001
5055
  removeAll = false;
5002
5056
  }
5003
5057
  } else if (polarity === false) {
5004
- if (typeof _this29.options.data[parts[0]] !== 'undefined' && _this29.options.data[parts[0]] !== parts[1]) {
5058
+ if (typeof _this30.options.data[parts[0]] !== 'undefined' && _this30.options.data[parts[0]] !== parts[1]) {
5005
5059
  // remove the <if> tags
5006
5060
  removeAll = false;
5007
5061
  }
@@ -5294,7 +5348,7 @@ var WebsyUtils = {
5294
5348
 
5295
5349
  var WebsyTable = /*#__PURE__*/function () {
5296
5350
  function WebsyTable(elementId, options) {
5297
- var _this30 = this;
5351
+ var _this31 = this;
5298
5352
 
5299
5353
  _classCallCheck(this, WebsyTable);
5300
5354
 
@@ -5332,8 +5386,8 @@ var WebsyTable = /*#__PURE__*/function () {
5332
5386
  allowClear: false,
5333
5387
  disableSearch: true,
5334
5388
  onItemSelected: function onItemSelected(selectedItem) {
5335
- if (_this30.options.onChangePageSize) {
5336
- _this30.options.onChangePageSize(selectedItem.value);
5389
+ if (_this31.options.onChangePageSize) {
5390
+ _this31.options.onChangePageSize(selectedItem.value);
5337
5391
  }
5338
5392
  }
5339
5393
  });
@@ -5354,7 +5408,7 @@ var WebsyTable = /*#__PURE__*/function () {
5354
5408
  _createClass(WebsyTable, [{
5355
5409
  key: "appendRows",
5356
5410
  value: function appendRows(data) {
5357
- var _this31 = this;
5411
+ var _this32 = this;
5358
5412
 
5359
5413
  this.hideError();
5360
5414
  var bodyHTML = '';
@@ -5362,15 +5416,15 @@ var WebsyTable = /*#__PURE__*/function () {
5362
5416
  if (data) {
5363
5417
  bodyHTML += data.map(function (r, rowIndex) {
5364
5418
  return '<tr>' + r.map(function (c, i) {
5365
- if (_this31.options.columns[i].show !== false) {
5419
+ if (_this32.options.columns[i].show !== false) {
5366
5420
  var style = '';
5367
5421
 
5368
5422
  if (c.style) {
5369
5423
  style += c.style;
5370
5424
  }
5371
5425
 
5372
- if (_this31.options.columns[i].width) {
5373
- style += "width: ".concat(_this31.options.columns[i].width, "; ");
5426
+ if (_this32.options.columns[i].width) {
5427
+ style += "width: ".concat(_this32.options.columns[i].width, "; ");
5374
5428
  }
5375
5429
 
5376
5430
  if (c.backgroundColor) {
@@ -5385,18 +5439,18 @@ var WebsyTable = /*#__PURE__*/function () {
5385
5439
  style += "color: ".concat(c.color, "; ");
5386
5440
  }
5387
5441
 
5388
- if (_this31.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5389
- return "\n <td \n data-row-index='".concat(_this31.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this31.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(_this31.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this31.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
5390
- } else if ((_this31.options.columns[i].showAsNavigatorLink === true || _this31.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5391
- return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this31.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this31.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this31.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this31.options.columns[i].linkText || c.value, "</td>\n ");
5442
+ if (_this32.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5443
+ 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 ");
5444
+ } else if ((_this32.options.columns[i].showAsNavigatorLink === true || _this32.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5445
+ 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
5446
  } else {
5393
5447
  var info = c.value;
5394
5448
 
5395
- if (_this31.options.columns[i].showAsImage === true) {
5449
+ if (_this32.options.columns[i].showAsImage === true) {
5396
5450
  c.value = "\n <img src='".concat(c.value, "'>\n ");
5397
5451
  }
5398
5452
 
5399
- return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this31.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this31.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 ");
5453
+ 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
5454
  }
5401
5455
  }
5402
5456
  }).join('') + '</tr>';
@@ -5568,7 +5622,7 @@ var WebsyTable = /*#__PURE__*/function () {
5568
5622
  }, {
5569
5623
  key: "render",
5570
5624
  value: function render(data) {
5571
- var _this32 = this;
5625
+ var _this33 = this;
5572
5626
 
5573
5627
  if (!this.options.columns) {
5574
5628
  return;
@@ -5603,7 +5657,7 @@ var WebsyTable = /*#__PURE__*/function () {
5603
5657
  style += "width: ".concat(c.width || 'auto', ";");
5604
5658
  }
5605
5659
 
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 ? _this32.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
5660
+ 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
5661
  }
5608
5662
  }).join('') + '</tr>';
5609
5663
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
@@ -5622,7 +5676,7 @@ var WebsyTable = /*#__PURE__*/function () {
5622
5676
 
5623
5677
  if (pagingEl) {
5624
5678
  var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
5625
- return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this32.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
5679
+ return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this33.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
5626
5680
  });
5627
5681
  var startIndex = 0;
5628
5682
 
@@ -5690,7 +5744,7 @@ var WebsyTable = /*#__PURE__*/function () {
5690
5744
 
5691
5745
  var WebsyTable2 = /*#__PURE__*/function () {
5692
5746
  function WebsyTable2(elementId, options) {
5693
- var _this33 = this;
5747
+ var _this34 = this;
5694
5748
 
5695
5749
  _classCallCheck(this, WebsyTable2);
5696
5750
 
@@ -5731,8 +5785,8 @@ var WebsyTable2 = /*#__PURE__*/function () {
5731
5785
  allowClear: false,
5732
5786
  disableSearch: true,
5733
5787
  onItemSelected: function onItemSelected(selectedItem) {
5734
- if (_this33.options.onChangePageSize) {
5735
- _this33.options.onChangePageSize(selectedItem.value);
5788
+ if (_this34.options.onChangePageSize) {
5789
+ _this34.options.onChangePageSize(selectedItem.value);
5736
5790
  }
5737
5791
  }
5738
5792
  });
@@ -5756,7 +5810,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5756
5810
  _createClass(WebsyTable2, [{
5757
5811
  key: "appendRows",
5758
5812
  value: function appendRows(data) {
5759
- var _this34 = this;
5813
+ var _this35 = this;
5760
5814
 
5761
5815
  this.hideError();
5762
5816
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
@@ -5765,15 +5819,15 @@ var WebsyTable2 = /*#__PURE__*/function () {
5765
5819
  if (data) {
5766
5820
  bodyHTML += data.map(function (r, rowIndex) {
5767
5821
  return '<tr>' + r.map(function (c, i) {
5768
- if (_this34.options.columns[i].show !== false) {
5769
- var style = "height: ".concat(_this34.options.cellSize, "px; line-height: ").concat(_this34.options.cellSize, "px;");
5822
+ if (_this35.options.columns[i].show !== false) {
5823
+ var style = "height: ".concat(_this35.options.cellSize, "px; line-height: ").concat(_this35.options.cellSize, "px;");
5770
5824
 
5771
5825
  if (c.style) {
5772
5826
  style += c.style;
5773
5827
  }
5774
5828
 
5775
- if (_this34.options.columns[i].width) {
5776
- style += "width: ".concat(_this34.options.columns[i].width, "; ");
5829
+ if (_this35.options.columns[i].width) {
5830
+ style += "width: ".concat(_this35.options.columns[i].width, "; ");
5777
5831
  }
5778
5832
 
5779
5833
  if (c.backgroundColor) {
@@ -5788,18 +5842,18 @@ var WebsyTable2 = /*#__PURE__*/function () {
5788
5842
  style += "color: ".concat(c.color, "; ");
5789
5843
  }
5790
5844
 
5791
- if (_this34.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5792
- return "\n <td \n data-row-index='".concat(_this34.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this34.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(_this34.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this34.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
5793
- } else if ((_this34.options.columns[i].showAsNavigatorLink === true || _this34.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5794
- return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this34.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this34.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this34.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this34.options.columns[i].linkText || c.value, "</td>\n ");
5845
+ if (_this35.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5846
+ 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 ");
5847
+ } else if ((_this35.options.columns[i].showAsNavigatorLink === true || _this35.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5848
+ 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
5849
  } else {
5796
5850
  var info = c.value;
5797
5851
 
5798
- if (_this34.options.columns[i].showAsImage === true) {
5852
+ if (_this35.options.columns[i].showAsImage === true) {
5799
5853
  c.value = "\n <img src='".concat(c.value, "'>\n ");
5800
5854
  }
5801
5855
 
5802
- return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this34.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this34.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 ");
5856
+ 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
5857
  }
5804
5858
  }
5805
5859
  }).join('') + '</tr>';
@@ -6062,7 +6116,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
6062
6116
  }, {
6063
6117
  key: "render",
6064
6118
  value: function render(data) {
6065
- var _this35 = this;
6119
+ var _this36 = this;
6066
6120
 
6067
6121
  if (!this.options.columns) {
6068
6122
  return;
@@ -6098,7 +6152,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
6098
6152
  style += "width: ".concat(c.width || 'auto', "; ");
6099
6153
  }
6100
6154
 
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 ? _this35.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
6155
+ 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
6156
  }
6103
6157
  }).join('') + '</tr>';
6104
6158
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
@@ -6109,7 +6163,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
6109
6163
  var dropdownHTML = "";
6110
6164
  this.options.columns.forEach(function (c, i) {
6111
6165
  if (c.searchable && c.searchField) {
6112
- dropdownHTML += "\n <div id=\"".concat(_this35.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
6166
+ dropdownHTML += "\n <div id=\"".concat(_this36.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
6113
6167
  }
6114
6168
  });
6115
6169
  dropdownEl.innerHTML = dropdownHTML;
@@ -6131,7 +6185,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
6131
6185
 
6132
6186
  if (pagingEl) {
6133
6187
  var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
6134
- return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this35.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
6188
+ return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this36.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
6135
6189
  });
6136
6190
  var startIndex = 0;
6137
6191
 
@@ -6222,7 +6276,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
6222
6276
  }, {
6223
6277
  key: "getColumnParameters",
6224
6278
  value: function getColumnParameters(values) {
6225
- var _this36 = this;
6279
+ var _this37 = this;
6226
6280
 
6227
6281
  var tableEl = document.getElementById("".concat(this.elementId, "_table"));
6228
6282
  tableEl.style.tableLayout = 'auto';
@@ -6230,10 +6284,10 @@ var WebsyTable2 = /*#__PURE__*/function () {
6230
6284
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
6231
6285
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
6232
6286
  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 ? _this36.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
6287
+ 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
6288
  }).join('') + '</tr>';
6235
6289
  bodyEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c) {
6236
- return "\n <td \n style='height: ".concat(_this36.options.cellSize, "px; line-height: ").concat(_this36.options.cellSize, "px; padding: 10px 5px;'\n >").concat(c.value || '&nbsp;', "</td>\n ");
6290
+ 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 || '&nbsp;', "</td>\n ");
6237
6291
  }).join('') + '</tr>'; // get height of the first data cell
6238
6292
 
6239
6293
  var cells = bodyEl.querySelectorAll("tr:first-of-type td");
@@ -6364,7 +6418,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6364
6418
  }, {
6365
6419
  key: "buildBodyHtml",
6366
6420
  value: function buildBodyHtml() {
6367
- var _this37 = this;
6421
+ var _this38 = this;
6368
6422
 
6369
6423
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6370
6424
  var useWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -6427,7 +6481,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6427
6481
  } // console.log('rowspan', cell.rowspan)
6428
6482
 
6429
6483
 
6430
- bodyHtml += "<td \n class='websy-table-cell ".concat(sizeIndex < _this37.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) {
6484
+ 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
6485
  // bodyHtml += `
6432
6486
  // style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
6433
6487
  // width='${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}'
@@ -6437,11 +6491,11 @@ var WebsyTable3 = /*#__PURE__*/function () {
6437
6491
  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
6492
 
6439
6493
  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(_this37.options.plusIcon, "</i>");
6494
+ 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
6495
  }
6442
6496
 
6443
6497
  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(_this37.options.minusIcon, "</i>");
6498
+ 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
6499
  }
6446
6500
 
6447
6501
  if (sizingColumns[sizeIndex].showAsLink === true && cell.value.trim() !== '') {
@@ -6466,7 +6520,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6466
6520
  }, {
6467
6521
  key: "buildHeaderHtml",
6468
6522
  value: function buildHeaderHtml() {
6469
- var _this38 = this;
6523
+ var _this39 = this;
6470
6524
 
6471
6525
  var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
6472
6526
 
@@ -6486,7 +6540,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6486
6540
  }
6487
6541
 
6488
6542
  this.options.columns.forEach(function (row, rowIndex) {
6489
- if (useWidths === false && rowIndex !== _this38.options.columns.length - 1) {
6543
+ if (useWidths === false && rowIndex !== _this39.options.columns.length - 1) {
6490
6544
  // if we're calculating the size we only want to render the last row of column headers
6491
6545
  return;
6492
6546
  }
@@ -6505,25 +6559,25 @@ var WebsyTable3 = /*#__PURE__*/function () {
6505
6559
  style += col.style;
6506
6560
  }
6507
6561
 
6508
- headerHtml += "<td \n class='websy-table-cell ".concat(colIndex < _this38.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) {
6562
+ 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
6563
  // headerHtml += `
6510
6564
  // style='width: ${col.width || col.actualWidth}px'
6511
6565
  // width='${col.width || col.actualWidth}'
6512
6566
  // `
6513
6567
  // }
6514
6568
 
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 ? _this38.buildSortIcon(col.sort, colIndex) : '').concat(col.searchable === true ? _this38.buildSearchIcon(col, colIndex) : '', "\n </div>\n </td>");
6569
+ 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
6570
  });
6517
6571
  headerHtml += "</tr>";
6518
6572
  });
6519
6573
  var dropdownEl = document.getElementById("".concat(this.elementId, "_dropdownContainer"));
6520
6574
  this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
6521
6575
  if (c.searchable && c.isExternalSearch === true) {
6522
- var testEl = document.getElementById("".concat(_this38.elementId, "_columnSearch_").concat(c.dimId || i));
6576
+ var testEl = document.getElementById("".concat(_this39.elementId, "_columnSearch_").concat(c.dimId || i));
6523
6577
 
6524
6578
  if (!testEl) {
6525
6579
  var newE = document.createElement('div');
6526
- newE.id = "".concat(_this38.elementId, "_columnSearch_").concat(c.dimId || i);
6580
+ newE.id = "".concat(_this39.elementId, "_columnSearch_").concat(c.dimId || i);
6527
6581
  newE.className = 'websy-modal-dropdown';
6528
6582
  dropdownEl.appendChild(newE);
6529
6583
  }
@@ -6546,7 +6600,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6546
6600
  }, {
6547
6601
  key: "buildTotalHtml",
6548
6602
  value: function buildTotalHtml() {
6549
- var _this39 = this;
6603
+ var _this40 = this;
6550
6604
 
6551
6605
  var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
6552
6606
 
@@ -6559,7 +6613,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6559
6613
  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
6614
 
6561
6615
  if (useWidths === true) {
6562
- totalHtml += "\n style='width: ".concat(_this39.options.columns[_this39.options.columns.length - 1][colIndex].width || _this39.options.columns[_this39.options.columns.length - 1][colIndex].actualWidth, "px'\n width='").concat(col.width || col.actualWidth, "'\n ");
6616
+ 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
6617
  }
6564
6618
 
6565
6619
  totalHtml += " \n >\n ".concat(col.value, "\n </td>");
@@ -6570,7 +6624,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6570
6624
  }, {
6571
6625
  key: "calculateSizes",
6572
6626
  value: function calculateSizes() {
6573
- var _this40 = this;
6627
+ var _this41 = this;
6574
6628
 
6575
6629
  var sample = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6576
6630
  var totalRowCount = arguments.length > 1 ? arguments[1] : undefined;
@@ -6619,32 +6673,32 @@ var WebsyTable3 = /*#__PURE__*/function () {
6619
6673
  rows.forEach(function (row, rowIndex) {
6620
6674
  Array.from(row.children).forEach(function (col, colIndex) {
6621
6675
  var colSize = col.getBoundingClientRect();
6622
- _this40.sizes.cellHeight = colSize.height;
6676
+ _this41.sizes.cellHeight = colSize.height;
6623
6677
 
6624
- if (_this40.options.columns[_this40.options.columns.length - 1][colIndex]) {
6625
- if (!_this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth) {
6626
- _this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth = 0;
6678
+ if (_this41.options.columns[_this41.options.columns.length - 1][colIndex]) {
6679
+ if (!_this41.options.columns[_this41.options.columns.length - 1][colIndex].actualWidth) {
6680
+ _this41.options.columns[_this41.options.columns.length - 1][colIndex].actualWidth = 0;
6627
6681
  }
6628
6682
 
6629
- _this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth = Math.min(Math.max(_this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth, colSize.width), maxWidth);
6630
- _this40.options.columns[_this40.options.columns.length - 1][colIndex].cellHeight = colSize.height;
6683
+ _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);
6684
+ _this41.options.columns[_this41.options.columns.length - 1][colIndex].cellHeight = colSize.height;
6631
6685
 
6632
- if (colIndex >= _this40.pinnedColumns) {
6633
- firstNonPinnedColumnWidth = _this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth;
6686
+ if (colIndex >= _this41.pinnedColumns) {
6687
+ firstNonPinnedColumnWidth = _this41.options.columns[_this41.options.columns.length - 1][colIndex].actualWidth;
6634
6688
  }
6635
6689
  }
6636
6690
  });
6637
6691
  });
6638
6692
  this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
6639
- if (colIndex < _this40.pinnedColumns) {
6640
- _this40.sizes.scrollableWidth -= col.actualWidth;
6693
+ if (colIndex < _this41.pinnedColumns) {
6694
+ _this41.sizes.scrollableWidth -= col.actualWidth;
6641
6695
  }
6642
6696
  });
6643
6697
  this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce(function (a, b) {
6644
6698
  return a + (b.width || b.actualWidth);
6645
6699
  }, 0);
6646
6700
  this.sizes.totalNonPinnedWidth = this.options.columns[this.options.columns.length - 1].filter(function (c, i) {
6647
- return i >= _this40.pinnedColumns;
6701
+ return i >= _this41.pinnedColumns;
6648
6702
  }).reduce(function (a, b) {
6649
6703
  return a + (b.width || b.actualWidth);
6650
6704
  }, 0);
@@ -6665,10 +6719,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6665
6719
  c.actualWidth += equalWidth; // }
6666
6720
  // }
6667
6721
 
6668
- _this40.sizes.totalWidth += c.width || c.actualWidth;
6722
+ _this41.sizes.totalWidth += c.width || c.actualWidth;
6669
6723
 
6670
- if (i < _this40.pinnedColumns) {
6671
- _this40.sizes.totalNonPinnedWidth += c.width || c.actualWidth;
6724
+ if (i < _this41.pinnedColumns) {
6725
+ _this41.sizes.totalNonPinnedWidth += c.width || c.actualWidth;
6672
6726
  } // equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
6673
6727
 
6674
6728
  });
@@ -6731,7 +6785,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6731
6785
  }, {
6732
6786
  key: "createSample",
6733
6787
  value: function createSample(data) {
6734
- var _this41 = this;
6788
+ var _this42 = this;
6735
6789
 
6736
6790
  var output = [];
6737
6791
  this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
@@ -6743,7 +6797,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6743
6797
  var longest = '';
6744
6798
 
6745
6799
  for (var i = 0; i < Math.min(data.length, 1000); i++) {
6746
- if (data[i].length === _this41.options.columns[_this41.options.columns.length - 1].length) {
6800
+ if (data[i].length === _this42.options.columns[_this42.options.columns.length - 1].length) {
6747
6801
  if (longest.length < data[i][colIndex].value.length) {
6748
6802
  longest = data[i][colIndex].value;
6749
6803
  }
@@ -7171,7 +7225,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
7171
7225
 
7172
7226
  var WebsyChart = /*#__PURE__*/function () {
7173
7227
  function WebsyChart(elementId, options) {
7174
- var _this42 = this;
7228
+ var _this43 = this;
7175
7229
 
7176
7230
  _classCallCheck(this, WebsyChart);
7177
7231
 
@@ -7208,6 +7262,7 @@ var WebsyChart = /*#__PURE__*/function () {
7208
7262
  tooltipWidth: 200,
7209
7263
  brushHeight: 50,
7210
7264
  minBandWidth: 30,
7265
+ maxBandWidth: 100,
7211
7266
  allowUnevenBands: true
7212
7267
  };
7213
7268
  this.elementId = elementId;
@@ -7230,7 +7285,7 @@ var WebsyChart = /*#__PURE__*/function () {
7230
7285
  var forBrush = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
7231
7286
  var xAxis = 'bottom';
7232
7287
 
7233
- if (_this42.options.orientation === 'horizontal') {
7288
+ if (_this43.options.orientation === 'horizontal') {
7234
7289
  xAxis = 'left';
7235
7290
  }
7236
7291
 
@@ -7241,39 +7296,37 @@ var WebsyChart = /*#__PURE__*/function () {
7241
7296
  xAxis += 'Axis';
7242
7297
  var output;
7243
7298
 
7244
- var width = _this42.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth;
7299
+ var width = _this43.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth; // if (this.customBottomRange) {
7245
7300
 
7246
- if (_this42.customBottomRange) {
7247
- for (var index = 0; index < _this42.customBottomRange.length; index++) {
7248
- if (input > _this42.customBottomRange[index]) {
7249
- if (_this42.customBottomRange[index + 1]) {
7250
- if (input < _this42.customBottomRange[index + 1]) {
7251
- output = index;
7252
- break;
7253
- }
7254
- } else {
7301
+
7302
+ for (var index = 0; index < _this43.customBottomRange.length; index++) {
7303
+ if (input > _this43.customBottomRange[index]) {
7304
+ if (_this43.customBottomRange[index + 1]) {
7305
+ if (input < _this43.customBottomRange[index + 1]) {
7255
7306
  output = index;
7256
7307
  break;
7257
7308
  }
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;
7309
+ } else {
7310
+ output = index;
7273
7311
  break;
7274
7312
  }
7275
7313
  }
7276
- }
7314
+ } // }
7315
+ // else {
7316
+ // let domain = [...this[xAxis].domain()]
7317
+ // if (this.options.orientation === 'horizontal') {
7318
+ // domain = domain.reverse()
7319
+ // }
7320
+ // for (let j = 0; j < domain.length; j++) {
7321
+ // let breakA = this[xAxis](domain[j]) - (width / 2)
7322
+ // let breakB = breakA + width
7323
+ // if (input > breakA && input <= breakB) {
7324
+ // output = j
7325
+ // break
7326
+ // }
7327
+ // }
7328
+ // }
7329
+
7277
7330
 
7278
7331
  return output;
7279
7332
  };
@@ -7282,64 +7335,97 @@ var WebsyChart = /*#__PURE__*/function () {
7282
7335
 
7283
7336
  this.brushed = function (event) {
7284
7337
  console.log('brushing', event);
7285
- that.brushedDomain = [];
7286
- var xAxis = 'bottom';
7287
- var xAxisCaps = 'Bottom';
7338
+ var newX = that.options.margin.left + that.options.margin.axisLeft + (1 - event.selection[0] / (that.plotWidth / (that.widthForCalc + that.totalBandPadding)));
7288
7339
 
7289
- if (that.options.orientation === 'horizontal') {
7290
- xAxis = 'left';
7291
- xAxisCaps = 'Left';
7340
+ if (that.plotArea) {
7341
+ that.plotArea.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
7292
7342
  }
7293
7343
 
7294
- if (!that["".concat(xAxis, "Axis")]) {
7295
- return;
7344
+ if (that.areaLayer) {
7345
+ that.areaLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
7296
7346
  }
7297
7347
 
7298
- if (!that["".concat(xAxis, "Axis")].invert) {
7299
- that["".concat(xAxis, "Axis")].invert = that.invertOverride;
7348
+ if (that.lineLayer) {
7349
+ that.lineLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
7300
7350
  }
7301
7351
 
7302
- var s = event.selection || that["".concat(xAxis, "Axis")].range();
7303
-
7304
- if (!event.selection || event.selection.length === 0) {
7305
- that.brushLayer.select('.brush').call(that.brush).call(that.brush.move, s);
7306
- return;
7352
+ if (that.barLayer) {
7353
+ that.barLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
7307
7354
  }
7308
7355
 
7309
- if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
7310
- that.brushedDomain = s.map(that["".concat(xAxis, "BrushAxis")].invert, that[["".concat(xAxis, "Axis")]]);
7311
- } else {
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());
7356
+ if (that.labelLayer) {
7357
+ that.labelLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
7358
+ }
7320
7359
 
7321
- for (var i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
7322
- // domain.push(that.xRange[i])
7323
- that.brushedDomain.push(domainValues[i]);
7324
- }
7325
- }
7360
+ if (that.symbolLayer) {
7361
+ that.symbolLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
7326
7362
  }
7327
7363
 
7328
- if (that.brushedDomain.length > 0) {
7329
- that["".concat(xAxis, "Axis")].domain(that.brushedDomain);
7330
- that["".concat(xAxis, "AxisLayer")].call(d3["axis".concat(xAxisCaps)](that["".concat(xAxis, "Axis")]));
7364
+ if (that.refLineLayer) {
7365
+ that.refLineLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop, ")"));
7331
7366
  }
7332
7367
 
7333
- if (that.leftAxis && that.bottomAxis) {
7334
- that.renderComponents();
7368
+ if (that.bottomAxisLayer) {
7369
+ that.bottomAxisLayer.attr('transform', "translate(".concat(newX, ", ").concat(that.options.margin.top + that.options.margin.axisTop + that.plotHeight, ")"));
7370
+ } // that.brushedDomain = []
7371
+ // let xAxis = 'bottom'
7372
+ // let xAxisCaps = 'Bottom'
7373
+ // if (that.options.orientation === 'horizontal') {
7374
+ // xAxis = 'left'
7375
+ // xAxisCaps = 'Left'
7376
+ // }
7377
+ // if (!that[`${xAxis}Axis`]) {
7378
+ // return
7379
+ // }
7380
+ // if (!that[`${xAxis}Axis`].invert) {
7381
+ // that[`${xAxis}Axis`].invert = that.invertOverride
7382
+ // }
7383
+ // let s = event.selection || that[`${xAxis}Axis`].range()
7384
+ // if (!event.selection || event.selection.length === 0) {
7385
+ // that.brushLayer
7386
+ // .select('.brush')
7387
+ // .call(that.brush)
7388
+ // .call(that.brush.move, s)
7389
+ // return
7390
+ // }
7391
+ // if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
7392
+ // that.brushedDomain = s.map(that[`${xAxis}BrushAxis`].invert, that[[`${xAxis}Axis`]])
7393
+ // }
7394
+ // else {
7395
+ // let startEndOrdinal = s.map((a, b) => that.bottomAxis.invert(a, b, true), that.bottomBrushAxis)
7396
+ // if (
7397
+ // startEndOrdinal &&
7398
+ // startEndOrdinal.length === 2 &&
7399
+ // typeof startEndOrdinal[0] !== 'undefined' &&
7400
+ // typeof startEndOrdinal[1] !== 'undefined'
7401
+ // ) {
7402
+ // let domain = []
7403
+ // let domainValues = [...that[`${xAxis}BrushAxis`].domain()]
7404
+ // for (let i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
7405
+ // // domain.push(that.xRange[i])
7406
+ // that.brushedDomain.push(domainValues[i])
7407
+ // }
7408
+ // }
7409
+ // }
7410
+ // if (that.brushedDomain.length > 0) {
7411
+ // that[`${xAxis}Axis`].domain(that.brushedDomain)
7412
+ // that[`${xAxis}AxisLayer`].call(
7413
+ // d3[`axis${xAxisCaps}`](that[`${xAxis}Axis`])
7414
+ // )
7415
+ // }
7416
+ // if (that.leftAxis && that.bottomAxis) {
7417
+ // that.renderComponents()
7418
+ // if (that.options.orientation === 'vertical') {
7419
+ // // that.bottomAxisLayer.call(that.bAxisFunc)
7420
+ // if (that.options.data.bottom.rotate) {
7421
+ // that.bottomAxisLayer.selectAll('text')
7422
+ // .attr('transform', `rotate(${((that.options.data.bottom && that.options.data.bottom.rotate) || 0)})`)
7423
+ // .style('text-anchor', `${((that.options.data.bottom && that.options.data.bottom.rotate) || 0) === 0 ? 'middle' : 'end'}`)
7424
+ // .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`)
7425
+ // }
7426
+ // }
7427
+ // }
7335
7428
 
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
7429
  };
7344
7430
 
7345
7431
  var el = document.getElementById(this.elementId);
@@ -7454,10 +7540,10 @@ var WebsyChart = /*#__PURE__*/function () {
7454
7540
  }, {
7455
7541
  key: "handleEventMouseMove",
7456
7542
  value: function handleEventMouseMove(event, d) {
7457
- var _this43 = this;
7543
+ var _this44 = this;
7458
7544
 
7459
7545
  var bisectDate = d3.bisector(function (d) {
7460
- return _this43.parseX(d.x.value);
7546
+ return _this44.parseX(d.x.value);
7461
7547
  }).left;
7462
7548
 
7463
7549
  if (this.options.showTrackingLine === true && d3.pointer(event)) {
@@ -7496,12 +7582,12 @@ var WebsyChart = /*#__PURE__*/function () {
7496
7582
  }
7497
7583
 
7498
7584
  this.options.data.series.forEach(function (s) {
7499
- if (_this43.options.data[xData].scale !== 'Time') {
7500
- if (_this43.customBottomRange && _this43.customBottomRange.length > 0) {
7501
- xPoint = _this43.customBottomRange[x0] + (_this43.customBottomRange[x0 + 1] - _this43.customBottomRange[x0]) / 2;
7502
- } else {
7503
- xPoint = _this43[xAxis](_this43.parseX(xLabel));
7504
- }
7585
+ if (_this44.options.data[xData].scale !== 'Time') {
7586
+ // if (this.customBottomRange && this.customBottomRange.length > 0) {
7587
+ xPoint = _this44.customBottomRange[x0] + (_this44.customBottomRange[x0 + 1] - _this44.customBottomRange[x0]) / 2; // }
7588
+ // else {
7589
+ // xPoint = this[xAxis](this.parseX(xLabel))
7590
+ // }
7505
7591
 
7506
7592
  s.data.forEach(function (d) {
7507
7593
  if (d.x.value === xLabel) {
@@ -7521,13 +7607,13 @@ var WebsyChart = /*#__PURE__*/function () {
7521
7607
  var pointA = s.data[index - 1];
7522
7608
  var pointB = s.data[index];
7523
7609
 
7524
- if (_this43.options.orientation === 'horizontal') {
7610
+ if (_this44.options.orientation === 'horizontal') {
7525
7611
  pointA = _toConsumableArray(s.data).reverse()[index - 1];
7526
7612
  pointB = _toConsumableArray(s.data).reverse()[index];
7527
7613
  }
7528
7614
 
7529
7615
  if (pointA && !pointB) {
7530
- xPoint = _this43[xAxis](_this43.parseX(pointA.x.value));
7616
+ xPoint = _this44[xAxis](_this44.parseX(pointA.x.value));
7531
7617
  tooltipTitle = pointA.x.value;
7532
7618
 
7533
7619
  if (!pointA.y.color) {
@@ -7537,12 +7623,12 @@ var WebsyChart = /*#__PURE__*/function () {
7537
7623
  tooltipData.push(pointA.y);
7538
7624
 
7539
7625
  if (typeof pointA.x.value.getTime !== 'undefined') {
7540
- tooltipTitle = d3.timeFormat(_this43.options.dateFormat || _this43.options.calculatedTimeFormatPattern)(pointA.x.value);
7626
+ tooltipTitle = d3.timeFormat(_this44.options.dateFormat || _this44.options.calculatedTimeFormatPattern)(pointA.x.value);
7541
7627
  }
7542
7628
  }
7543
7629
 
7544
7630
  if (pointB && !pointA) {
7545
- xPoint = _this43[xAxis](_this43.parseX(pointB.x.value));
7631
+ xPoint = _this44[xAxis](_this44.parseX(pointB.x.value));
7546
7632
  tooltipTitle = pointB.x.value;
7547
7633
 
7548
7634
  if (!pointB.y.color) {
@@ -7552,14 +7638,14 @@ var WebsyChart = /*#__PURE__*/function () {
7552
7638
  tooltipData.push(pointB.y);
7553
7639
 
7554
7640
  if (typeof pointB.x.value.getTime !== 'undefined') {
7555
- tooltipTitle = d3.timeFormat(_this43.options.dateFormat || _this43.options.calculatedTimeFormatPattern)(pointB.x.value);
7641
+ tooltipTitle = d3.timeFormat(_this44.options.dateFormat || _this44.options.calculatedTimeFormatPattern)(pointB.x.value);
7556
7642
  }
7557
7643
  }
7558
7644
 
7559
7645
  if (pointA && pointB) {
7560
- var d0 = _this43[xAxis](_this43.parseX(pointA.x.value));
7646
+ var d0 = _this44[xAxis](_this44.parseX(pointA.x.value));
7561
7647
 
7562
- var d1 = _this43[xAxis](_this43.parseX(pointB.x.value));
7648
+ var d1 = _this44[xAxis](_this44.parseX(pointB.x.value));
7563
7649
 
7564
7650
  var mid = Math.abs(d0 - d1) / 2;
7565
7651
 
@@ -7568,7 +7654,7 @@ var WebsyChart = /*#__PURE__*/function () {
7568
7654
  tooltipTitle = pointB.x.value;
7569
7655
 
7570
7656
  if (typeof pointB.x.value.getTime !== 'undefined') {
7571
- tooltipTitle = d3.timeFormat(_this43.options.dateFormat || _this43.options.calculatedTimeFormatPattern)(pointB.x.value);
7657
+ tooltipTitle = d3.timeFormat(_this44.options.dateFormat || _this44.options.calculatedTimeFormatPattern)(pointB.x.value);
7572
7658
  }
7573
7659
 
7574
7660
  if (!pointB.y.color) {
@@ -7581,7 +7667,7 @@ var WebsyChart = /*#__PURE__*/function () {
7581
7667
  tooltipTitle = pointA.x.value;
7582
7668
 
7583
7669
  if (typeof pointB.x.value.getTime !== 'undefined') {
7584
- tooltipTitle = d3.timeFormat(_this43.options.dateFormat || _this43.options.calculatedTimeFormatPattern)(pointB.x.value);
7670
+ tooltipTitle = d3.timeFormat(_this44.options.dateFormat || _this44.options.calculatedTimeFormatPattern)(pointB.x.value);
7585
7671
  }
7586
7672
 
7587
7673
  if (!pointA.y.color) {
@@ -7645,6 +7731,12 @@ var WebsyChart = /*#__PURE__*/function () {
7645
7731
  }
7646
7732
 
7647
7733
  this.tooltip.setHeight(this.plotHeight);
7734
+
7735
+ if (isNaN(posOptions.left)) {
7736
+ this.tooltip.hide();
7737
+ return;
7738
+ }
7739
+
7648
7740
  this.options.showTooltip && this.tooltip.show(tooltipTitle, tooltipHTML, posOptions); // }
7649
7741
  // else {
7650
7742
  // xPoint = x0
@@ -7675,20 +7767,22 @@ var WebsyChart = /*#__PURE__*/function () {
7675
7767
  /* global d3 WebsyDesigns */
7676
7768
  this.defs = this.svg.append('defs');
7677
7769
  this.clip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_clip")).append('rect');
7770
+ this.xAxisClip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_xAxisClip")).append('rect');
7678
7771
  this.brushClip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_brushclip")).append('rect');
7679
7772
  this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer');
7680
7773
  this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer');
7681
- this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer');
7774
+ this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer').attr('clip-path', "url(#".concat(this.elementId, "_xAxisClip)")).append('g');
7682
7775
  this.leftAxisLabel = this.svg.append('g').attr('class', 'left-axis-label-layer');
7683
7776
  this.rightAxisLabel = this.svg.append('g').attr('class', 'right-axis-label-layer');
7684
7777
  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
- this.labelLayer = this.svg.append('g').attr('class', 'label-layer');
7690
- this.symbolLayer = this.svg.append('g').attr('class', 'symbol-layer');
7691
- this.refLineLayer = this.svg.append('g').attr('class', 'refline-layer');
7778
+ this.plotArea = this.svg.append('g').attr('class', 'plot-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
7779
+ this.areaLayer = this.svg.append('g').attr('class', 'area-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
7780
+ this.lineLayer = this.svg.append('g').attr('class', 'line-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
7781
+ 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)`)
7782
+
7783
+ this.labelLayer = this.svg.append('g').attr('class', 'label-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
7784
+ this.symbolLayer = this.svg.append('g').attr('class', 'symbol-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
7785
+ this.refLineLayer = this.svg.append('g').attr('class', 'refline-layer').attr('clip-path', "url(#".concat(this.elementId, "_clip)")).append('g');
7692
7786
  this.trackingLineLayer = this.svg.append('g').attr('class', 'tracking-line-layer');
7693
7787
  this.trackingLineLayer.append('line').attr('class', 'tracking-line');
7694
7788
  this.tooltip = new WebsyDesigns.WebsyChartTooltip(this.svg);
@@ -7706,7 +7800,7 @@ var WebsyChart = /*#__PURE__*/function () {
7706
7800
  }, {
7707
7801
  key: "render",
7708
7802
  value: function render(options) {
7709
- var _this44 = this;
7803
+ var _this45 = this;
7710
7804
 
7711
7805
  /* global d3 options WebsyUtils */
7712
7806
  if (typeof options !== 'undefined') {
@@ -7781,7 +7875,7 @@ var WebsyChart = /*#__PURE__*/function () {
7781
7875
  this.options.data.series.map(function (s, i) {
7782
7876
  return {
7783
7877
  value: s.label || s.key,
7784
- color: s.color || _this44.options.colors[i % _this44.options.colors.length]
7878
+ color: s.color || _this45.options.colors[i % _this45.options.colors.length]
7785
7879
  };
7786
7880
  });
7787
7881
  }
@@ -7980,46 +8074,123 @@ var WebsyChart = /*#__PURE__*/function () {
7980
8074
  if (this.options.axis.hideBottom === true) {
7981
8075
  this.options.margin.axisBottom = 0;
7982
8076
  }
7983
- } // Define the plot size
8077
+ } // At some point before this we need to add in logic to make space for any data point labels
8078
+ // Define the plot size
7984
8079
 
7985
8080
 
7986
8081
  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
8082
  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
8083
  this.brushNeeded = false;
8084
+ var proposedBandWidth; // distance between x axis data points.
8085
+
8086
+ var maxBandWidthFits = false; // Check to see if all bars at the max allowed width will fit
8087
+
8088
+ this.bandPadding = 0;
8089
+ this.totalBandPadding = 0;
8090
+ this.brushBandPadding = 0;
8091
+ this.totalBrushBandPadding = 0;
8092
+ var noOfPoints = 0;
8093
+ var noOfGroups = 0;
8094
+ var plotable = 0;
8095
+
8096
+ if (this.options.maxBandWidth) {
8097
+ if (this.options.orientation === 'horizontal') {
8098
+ this.options.data.left.totalValueCount = this.options.data.left.data.reduce(function (a, b) {
8099
+ if (typeof b.valueCount === 'undefined') {
8100
+ return a + 1;
8101
+ }
7989
8102
 
7990
- if (this.options.orientation === 'vertical') {
7991
- this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce(function (a, b) {
7992
- if (typeof b.valueCount === 'undefined') {
7993
- return a + 1;
8103
+ return a + b.valueCount;
8104
+ }, 0);
8105
+
8106
+ if (this.options.data.left.padding) {
8107
+ this.totalBandPadding = this.plotHeight * this.options.data.left.padding;
8108
+ this.bandPadding = this.totalBandPadding / this.options.data.left.data.length;
8109
+ this.totalBrushBandPadding = this.plotHeight * this.options.data.left.padding;
8110
+ this.brushBandPadding = this.totalBandPadding / this.options.data.left.data.length;
7994
8111
  }
7995
8112
 
7996
- return a + b.valueCount;
7997
- }, 0);
8113
+ plotable = this.plotHeight - this.totalBandPadding;
8114
+ noOfPoints = this.options.grouping === 'grouped' ? this.options.data.left.totalValueCount : this.options.data.left.data.length;
8115
+ noOfGroups = this.options.data.left.data.length;
8116
+ } else {
8117
+ this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce(function (a, b) {
8118
+ if (typeof b.valueCount === 'undefined') {
8119
+ return a + 1;
8120
+ }
7998
8121
 
7999
- if (this.options.maxBandWidth) {
8000
- this.plotWidth = Math.min(this.plotWidth, this.options.data.bottom.totalValueCount * this.options.maxBandWidth);
8001
- } // some if to check if brushing is needed
8122
+ return a + b.valueCount;
8123
+ }, 0);
8002
8124
 
8125
+ if (this.options.data.bottom.padding) {
8126
+ this.totalBandPadding = this.plotWidth * this.options.data.bottom.padding;
8127
+ this.bandPadding = this.totalBandPadding / this.options.data.bottom.data.length;
8128
+ this.totalBrushBandPadding = this.plotWidth * this.options.data.bottom.padding;
8129
+ this.brushBandPadding = this.totalBandPadding / this.options.data.bottom.data.length;
8130
+ }
8003
8131
 
8004
- if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
8005
- this.brushNeeded = true;
8006
- this.plotHeight -= this.options.brushHeight;
8132
+ plotable = this.plotWidth - this.totalBandPadding;
8133
+ noOfPoints = this.options.grouping === 'grouped' ? this.options.data.bottom.totalValueCount : this.options.data.bottom.data.length;
8134
+ noOfGroups = this.options.data.bottom.data.length;
8007
8135
  }
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
8136
 
8015
- return a + b.valueCount;
8016
- }, 0);
8137
+ if (plotable / noOfPoints > this.options.maxBandWidth) {
8138
+ maxBandWidthFits = true;
8139
+ proposedBandWidth = this.options.maxBandWidth;
8140
+ }
8141
+
8142
+ if (!maxBandWidthFits) {
8143
+ // Check to see if all bars at the min allowed width will fit
8144
+ if (plotable / noOfPoints < this.options.minBandWidth) {
8145
+ this.brushNeeded = true;
8146
+ proposedBandWidth = this.options.minBandWidth;
8017
8147
 
8018
- if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
8019
- this.brushNeeded = true;
8020
- this.plotWidth -= this.options.brushHeight;
8148
+ if (this.options.orientation === 'horizontal') {
8149
+ this.plotWidth -= this.options.brushHeight;
8150
+ } else {
8151
+ this.plotHeight -= this.options.brushHeight;
8152
+ }
8153
+ } else {
8154
+ proposedBandWidth = plotable / noOfPoints;
8155
+ }
8021
8156
  }
8022
- } // Translate the layers
8157
+ } // if (this.options.minBandWidth) {
8158
+ // this.widthForCalc = this.options.data.bottom.totalValueCount * this.options.minBandWidth
8159
+ // if (this.options.data.bottom.padding) {
8160
+ // this.widthForCalc += (this.options.minBandWidth * this.options.data.bottom.padding) * this.options.data.bottom.totalValueCount
8161
+ // this.widthForCalc += (this.options.data.bottom.data.length * this.options.groupPadding * 2)
8162
+ // }
8163
+ // }
8164
+ // if (this.options.orientation === 'vertical') {
8165
+ // this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce((a, b) => {
8166
+ // if (typeof b.valueCount === 'undefined') {
8167
+ // return a + 1
8168
+ // }
8169
+ // return a + b.valueCount
8170
+ // }, 0)
8171
+ // if (this.options.maxBandWidth) {
8172
+ // this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.totalValueCount) * this.options.maxBandWidth)
8173
+ // }
8174
+ // // some if to check if brushing is needed
8175
+ // if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
8176
+ // this.brushNeeded = true
8177
+ // this.plotHeight -= this.options.brushHeight
8178
+ // }
8179
+ // }
8180
+ // else {
8181
+ // // some if to check if brushing is needed
8182
+ // this.options.data.left.totalValueCount = this.options.data.left.data.reduce((a, b) => {
8183
+ // if (typeof b.valueCount === 'undefined') {
8184
+ // return a + 1
8185
+ // }
8186
+ // return a + b.valueCount
8187
+ // }, 0)
8188
+ // if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
8189
+ // this.brushNeeded = true
8190
+ // this.plotWidth -= this.options.brushHeight
8191
+ // }
8192
+ // }
8193
+ // Translate the layers
8023
8194
 
8024
8195
 
8025
8196
  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 +8208,97 @@ var WebsyChart = /*#__PURE__*/function () {
8037
8208
  this.refLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
8038
8209
  this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
8039
8210
  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, ")"));
8211
+ this.clip.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")")).attr('width', this.plotWidth).attr('height', this.plotHeight);
8212
+ 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
8213
  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
8214
  this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
8042
8215
  var that = this;
8043
8216
  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
8217
  // Configure the bottom axis
8045
8218
 
8046
- var bottomDomain = this.createDomain('bottom');
8047
- var bottomBrushDomain = this.createDomain('bottom', true);
8219
+ var bottomDomain = this.createDomain('bottom'); // let bottomBrushDomain = this.createDomain('bottom', true)
8220
+
8221
+ var bottomBrushDomain = this.createDomain('bottom');
8048
8222
  var bottomRange = [0, this.plotWidth];
8223
+ var bottomBrushRange = [0, this.plotWidth];
8224
+ var leftRange = [this.plotHeight, 0];
8225
+ var leftBrushRange = [this.options.brushHeight, 0];
8226
+
8227
+ if (this.options.orientation === 'horizontal') {
8228
+ leftBrushRange = [this.plotHeight, 0];
8229
+ }
8230
+
8231
+ this.widthForCalc = proposedBandWidth * noOfPoints; // + totalPadding
8232
+
8049
8233
  this.customBottomRange = [];
8234
+ this.customBottomDetailRange = [];
8235
+ this.customBottomBrushRange = [];
8236
+ this.customLeftRange = [];
8237
+ this.customLeftDetailRange = [];
8238
+ this.customLeftBrushRange = []; // if (this.options.allowUnevenBands === true) {
8239
+ // always allow uneven bands
8050
8240
 
8051
- if (this.options.allowUnevenBands === true) {
8052
- if (this.options.data.bottom.data && this.options.data.bottom.data[0] && this.options.data.bottom.data[0].valueCount && this.options.data.bottom.scale === 'Ordinal') {
8053
- var acc = 0;
8054
- this.customBottomRange = [0].concat(_toConsumableArray(this.options.data.bottom.data.map(function (d) {
8055
- acc += d.valueCount;
8056
- return _this44.plotWidth / _this44.options.data.bottom.totalValueCount * acc;
8057
- })));
8058
- }
8241
+ var customRangeSide = 'Bottom';
8242
+ var customRangeSideLC = 'bottom';
8243
+
8244
+ if (this.options.orientation === 'horizontal') {
8245
+ customRangeSide = 'Left';
8246
+ customRangeSideLC = 'left';
8059
8247
  }
8060
8248
 
8061
- this.options.data.bottom.step = this.plotWidth / this.options.data.bottom.totalValueCount;
8062
- this.options.data.bottom.bandWidth = this.options.data.bottom.step;
8249
+ 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') {
8250
+ var acc = 0;
8251
+ this["custom".concat(customRangeSide, "Range")] = [0].concat(_toConsumableArray(this.options.data[customRangeSideLC].data.map(function (d, index, arr) {
8252
+ var adjustment = _this45.bandPadding * index + _this45.bandPadding; // if (this.options.data.bottom.padding) {
8253
+ // adjustment = (this.widthForCalc * this.options.data.bottom.padding) / (arr.length * 2)
8254
+ // }
8063
8255
 
8064
- if (this.options.data.bottom.padding) {
8065
- this.totalPadding = this.plotWidth * this.options.data.bottom.padding;
8066
- var rangeLength = bottomDomain.length;
8256
+ var start = _this45.widthForCalc / noOfPoints * acc;
8067
8257
 
8068
- if (this.customBottomRange.length > 0) {
8069
- rangeLength = this.customBottomRange.length;
8070
- }
8258
+ for (var i = 0; i < (d.valueCount || 1); i++) {
8259
+ var pos = i * proposedBandWidth;
8260
+
8261
+ _this45["custom".concat(customRangeSide, "DetailRange")].push(start + adjustment + pos);
8262
+ }
8071
8263
 
8072
- this.bandPadding = this.totalPadding / rangeLength / 2;
8073
- this.options.data.bottom.bandWidth = (this.plotWidth - this.totalPadding) / this.options.data.bottom.totalValueCount;
8264
+ acc += _this45.options.grouping !== 'stacked' ? d.valueCount || 1 : 1;
8265
+ var end = _this45.widthForCalc / noOfPoints * acc; // this.customBottomBrushRange.push((end + adjustment) * (this.plotWidth / this.widthForCalc))
8266
+
8267
+ return end + adjustment;
8268
+ })));
8269
+ acc = 0;
8270
+ this["custom".concat(customRangeSide, "BrushRange")] = [0].concat(_toConsumableArray(this.options.data[customRangeSideLC].data.map(function (d, index, arr) {
8271
+ var adjustment = _this45.brushBandPadding * index + _this45.brushBandPadding;
8272
+ acc += _this45.options.grouping !== 'stacked' ? d.valueCount || 1 : 1;
8273
+ return (_this45.options.orientation === 'vertical' ? _this45.plotWidth : _this45.plotHeight) / noOfPoints * acc;
8274
+ })));
8275
+ } // }
8276
+
8277
+
8278
+ var rangeLength = bottomDomain.length;
8279
+ this.options.data.bottomBrush = {};
8280
+ this.options.data.leftBrush = {};
8281
+
8282
+ if (this.options.orientation === 'vertical') {
8283
+ this.options.data.bottom.bandWidth = proposedBandWidth;
8284
+ this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints;
8285
+ } else {
8286
+ this.options.data.left.bandWidth = proposedBandWidth;
8287
+ this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints;
8074
8288
  }
8075
8289
 
8076
- if (this.options.grouping === 'grouped' && this.options.data.series.length > 1) {
8077
- this.options.data.bottom.bandWidth = this.options.data.bottom.bandWidth - this.options.groupPadding * 2;
8290
+ this.brushBandPadding = this.totalBandPadding / noOfGroups;
8291
+
8292
+ if (this.options.orientation === 'vertical') {
8293
+ bottomRange = [0, this.widthForCalc + this.totalBandPadding];
8294
+ } else {
8295
+ leftRange = [this.widthForCalc + this.totalBandPadding, 0];
8078
8296
  }
8079
8297
 
8080
- this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomDomain).range(bottomRange);
8298
+ this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Ordinal')]().domain(bottomDomain).range(bottomRange);
8081
8299
 
8082
8300
  if (!this.brushInitialized) {
8083
- this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomBrushDomain).range(bottomRange);
8301
+ this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Ordinal')]().domain(bottomBrushDomain).range(bottomBrushRange);
8084
8302
  }
8085
8303
 
8086
8304
  if (this.bottomAxis.nice) {// this.bottomAxis.nice()
@@ -8101,38 +8319,78 @@ var WebsyChart = /*#__PURE__*/function () {
8101
8319
  brushLength = this.options.brushHeight;
8102
8320
  brushThickness = this.plotHeight;
8103
8321
  } else {
8104
- if (brushLength / bottomDomain.length < this.options.minBandWidth) {
8105
- brushEnd = this.plotWidth * (this.plotWidth / this.options.minBandWidth / bottomDomain.length);
8322
+ if (this.brushNeeded) {
8323
+ brushEnd = this.plotWidth * (this.plotWidth / (this.widthForCalc + this.totalBandPadding));
8106
8324
  }
8107
8325
  }
8108
8326
 
8109
- this.brush = d3[brushMethod]().extent([[0, 0], [brushLength, brushThickness]]).on('brush end', this.brushed);
8110
-
8111
- var brushResizePath = function brushResizePath(d) {
8112
- var e = +(d.type === 'e');
8113
- var x = e ? 1 : -1;
8114
- var y = _this44.options.brushHeight;
8115
- return 'M' + 0.5 * x + ',' + y + 'A6,6 0 0 ' + e + ' ' + 6.5 * x + ',' + (y + 6) + 'V' + (2 * y - 6) + 'A6,6 0 0 ' + e + ' ' + 0.5 * x + ',' + 2 * y + 'Z' + 'M' + 2.5 * x + ',' + (y + 8) + 'V' + (2 * y - 8) + 'M' + 4.5 * x + ',' + (y + 8) + 'V' + (2 * y - 8);
8116
- };
8117
-
8118
- this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').remove();
8119
- this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').data([{
8120
- type: 'w'
8121
- }, {
8122
- type: 'e'
8123
- }]).enter().append('path').attr('class', 'handle--custom').attr('stroke', 'transparent').attr('fill', 'transparent').attr('cursor', 'ew-resize').attr('d', brushResizePath); // BRUSH END
8124
- // this.brushArea.selectAll('*').remove()
8327
+ this.brush = d3[brushMethod]().extent([[0, 0], [brushLength, brushThickness]]).on('brush end', this.brushed); // const brushResizePath = d => {
8328
+ // let e = +(d.type === 'e')
8329
+ // let x = e ? 1 : -1
8330
+ // let y = this.options.brushHeight
8331
+ // return (
8332
+ // 'M' +
8333
+ // 0.5 * x +
8334
+ // ',' +
8335
+ // y +
8336
+ // 'A6,6 0 0 ' +
8337
+ // e +
8338
+ // ' ' +
8339
+ // 6.5 * x +
8340
+ // ',' +
8341
+ // (y + 6) +
8342
+ // 'V' +
8343
+ // (2 * y - 6) +
8344
+ // 'A6,6 0 0 ' +
8345
+ // e +
8346
+ // ' ' +
8347
+ // 0.5 * x +
8348
+ // ',' +
8349
+ // 2 * y +
8350
+ // 'Z' +
8351
+ // 'M' +
8352
+ // 2.5 * x +
8353
+ // ',' +
8354
+ // (y + 8) +
8355
+ // 'V' +
8356
+ // (2 * y - 8) +
8357
+ // 'M' +
8358
+ // 4.5 * x +
8359
+ // ',' +
8360
+ // (y + 8) +
8361
+ // 'V' +
8362
+ // (2 * y - 8)
8363
+ // )
8364
+ // }
8365
+ // this.brushHandle = this.brushLayer
8366
+ // .select('.brush')
8367
+ // .selectAll('.handle--custom')
8368
+ // .remove()
8369
+ // this.brushHandle = this.brushLayer
8370
+ // .select('.brush')
8371
+ // .selectAll('.handle--custom')
8372
+ // .data([{ type: 'w' }, { type: 'e' }])
8373
+ // .enter()
8374
+ // .append('path')
8375
+ // .attr('class', 'handle--custom')
8376
+ // .attr('stroke', 'transparent')
8377
+ // .attr('fill', 'transparent')
8378
+ // .attr('cursor', 'ew-resize')
8379
+ // .attr('d', brushResizePath)
8380
+ // BRUSH END
8381
+ // this.brushLayer.selectAll('.handle').remove()
8125
8382
 
8126
8383
  if (this.brushNeeded) {
8127
8384
  if (!this.brushInitialized) {
8128
8385
  this.brushLayer.style('visibility', 'visible');
8129
8386
  this.brushInitialized = true;
8130
8387
  this.brushLayer.select('.brush').call(this.brush).call(this.brush.move, [0, brushEnd]);
8388
+ } else {
8389
+ this.brushLayer.style('visibility', 'visible');
8131
8390
  }
8132
8391
  } else {
8133
8392
  this.brushLayer.style('visibility', 'hidden'); // this.brushLayer.selectAll().remove()
8134
-
8135
- this.brushArea.selectAll('*').remove();
8393
+ // this.brushArea.selectAll('*').remove()
8136
8394
  }
8137
8395
 
8138
8396
  if (this.options.margin.axisBottom > 0) {
@@ -8190,7 +8448,7 @@ var WebsyChart = /*#__PURE__*/function () {
8190
8448
 
8191
8449
  if (this.options.data.bottom.formatter) {
8192
8450
  this.bAxisFunc.tickFormat(function (d) {
8193
- return _this44.options.data.bottom.formatter(d);
8451
+ return _this45.options.data.bottom.formatter(d);
8194
8452
  });
8195
8453
  }
8196
8454
 
@@ -8202,7 +8460,7 @@ var WebsyChart = /*#__PURE__*/function () {
8202
8460
 
8203
8461
  if (this.customBottomRange.length > 0) {
8204
8462
  this.bottomAxisLayer.selectAll('g').attr('transform', function (d, i) {
8205
- return "translate(".concat(_this44.customBottomRange[i] + (_this44.customBottomRange[i + 1] - _this44.customBottomRange[i]) / 2, ", 0)");
8463
+ return "translate(".concat(_this45.customBottomRange[i] + (_this45.customBottomRange[i + 1] - _this45.customBottomRange[i]) / 2, ", 0)");
8206
8464
  });
8207
8465
  }
8208
8466
  } // Configure the left axis
@@ -8211,8 +8469,8 @@ var WebsyChart = /*#__PURE__*/function () {
8211
8469
  var leftDomain = this.createDomain('left');
8212
8470
  var leftBrushDomain = this.createDomain('left', true);
8213
8471
  var rightDomain = this.createDomain('right');
8214
- this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range([this.plotHeight, 0]);
8215
- this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range([this.options.brushHeight, 0]);
8472
+ this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range(leftRange);
8473
+ this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range(leftBrushRange);
8216
8474
 
8217
8475
  if (this.leftAxis.padding && this.options.data.left.padding) {
8218
8476
  this.leftAxis.padding(this.options.data.left.padding || 0);
@@ -8224,8 +8482,8 @@ var WebsyChart = /*#__PURE__*/function () {
8224
8482
 
8225
8483
  if (this.options.margin.axisLeft > 0) {
8226
8484
  this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
8227
- if (_this44.options.data.left.formatter) {
8228
- d = _this44.options.data.left.formatter(d);
8485
+ if (_this45.options.data.left.formatter) {
8486
+ d = _this45.options.data.left.formatter(d);
8229
8487
  }
8230
8488
 
8231
8489
  return d;
@@ -8260,8 +8518,8 @@ var WebsyChart = /*#__PURE__*/function () {
8260
8518
 
8261
8519
  if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
8262
8520
  this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.right.ticks || 5).tickFormat(function (d) {
8263
- if (_this44.options.data.right.formatter) {
8264
- d = _this44.options.data.right.formatter(d);
8521
+ if (_this45.options.data.right.formatter) {
8522
+ d = _this45.options.data.right.formatter(d);
8265
8523
  }
8266
8524
 
8267
8525
  return d;
@@ -8303,48 +8561,57 @@ var WebsyChart = /*#__PURE__*/function () {
8303
8561
  }, {
8304
8562
  key: "renderComponents",
8305
8563
  value: function renderComponents() {
8306
- var _this45 = this;
8564
+ var _this46 = this;
8307
8565
 
8308
8566
  // Draw the series data
8309
8567
  this.renderedKeys = {};
8310
8568
  this.options.data.series.forEach(function (series, index) {
8311
8569
  if (!series.key) {
8312
- series.key = _this45.createIdentity();
8570
+ series.key = _this46.createIdentity();
8313
8571
  }
8314
8572
 
8315
8573
  if (!series.color) {
8316
- series.color = _this45.options.colors[index % _this45.options.colors.length];
8574
+ series.color = _this46.options.colors[index % _this46.options.colors.length];
8317
8575
  }
8318
8576
 
8319
- _this45["render".concat(series.type || 'bar')](series, index);
8577
+ _this46["render".concat(series.type || 'bar')](series, index);
8320
8578
 
8321
- _this45.renderLabels(series, index);
8579
+ _this46.renderLabels(series, index);
8322
8580
 
8323
- _this45.renderedKeys[series.key] = series.type;
8581
+ _this46.renderedKeys[series.key] = series.type;
8324
8582
  });
8325
8583
  this.refLineLayer.selectAll('.reference-line').remove();
8326
8584
  this.refLineLayer.selectAll('.reference-line-label').remove();
8327
8585
 
8328
8586
  if (this.options.refLines && this.options.refLines.length > 0) {
8329
8587
  this.options.refLines.forEach(function (l) {
8330
- return _this45.renderRefLine(l);
8588
+ return _this46.renderRefLine(l);
8331
8589
  });
8332
8590
  }
8333
8591
  }
8334
8592
  }, {
8335
8593
  key: "renderarea",
8336
8594
  value: function renderarea(series, index) {
8337
- var _this46 = this;
8595
+ var _this47 = this;
8338
8596
 
8339
8597
  /* global d3 series index */
8340
8598
  var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
8341
8599
  return d3.area().x(function (d) {
8342
- return _this46["".concat(xAxis, "Axis")](_this46.parseX(d.x.value));
8600
+ // return this[`${xAxis}Axis`](this.parseX(d.x.value))
8601
+ var xIndex = _this47[xAxis + 'Axis'].domain().indexOf(d.x.value);
8602
+
8603
+ var xPos = _this47["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
8604
+
8605
+ if (_this47["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
8606
+ xPos = xPos + (_this47["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
8607
+ }
8608
+
8609
+ return xPos;
8343
8610
  }).y0(function (d) {
8344
- return _this46["".concat(yAxis, "Axis")](0);
8611
+ return _this47["".concat(yAxis, "Axis")](0);
8345
8612
  }).y1(function (d) {
8346
- return _this46["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8347
- }).curve(d3[curveStyle || _this46.options.curveStyle]);
8613
+ return _this47["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8614
+ }).curve(d3[curveStyle || _this47.options.curveStyle]);
8348
8615
  };
8349
8616
 
8350
8617
  var xAxis = 'bottom';
@@ -8362,23 +8629,27 @@ var WebsyChart = /*#__PURE__*/function () {
8362
8629
  areas // .style('stroke-width', series.lineWidth || this.options.lineWidth)
8363
8630
  // .attr('id', `line_${series.key}`)
8364
8631
  // .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
8365
- // .attr('fill', series.colour)
8366
- // .attr('stroke', 'transparent')
8632
+ .attr('fill', function (d) {
8633
+ return d[0].y.color || series.color;
8634
+ }) // .attr('stroke', 'transparent')
8367
8635
  .transition(this.transition).attr('d', function (d) {
8368
8636
  return drawArea(xAxis, yAxis, series.curveStyle)(d);
8369
8637
  }); // Enter
8370
8638
 
8371
8639
  areas.enter().append('path').attr('d', function (d) {
8372
8640
  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.replace('Brush', '')].bandWidth / 2) + ',0)') // .style('stroke-width', series.lineWidth || this.options.lineWidth)
8374
- .attr('fill', series.color) // .style('fill-opacity', 0)
8641
+ }).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)')
8642
+ // .style('stroke-width', series.lineWidth || this.options.lineWidth)
8643
+ .attr('fill', function (d) {
8644
+ return d[0].y.color || series.color;
8645
+ }) // .style('fill-opacity', 0)
8375
8646
  .attr('stroke', 'transparent') // .transition(this.transition)
8376
- .style('fill-opacity', series.opacity || 0.5);
8647
+ .style('fill-opacity', series.opacity || 0.3);
8377
8648
  }
8378
8649
  }, {
8379
8650
  key: "renderbar",
8380
8651
  value: function renderbar(series, index) {
8381
- var _this47 = this;
8652
+ var _this48 = this;
8382
8653
 
8383
8654
  /* global series index d3 */
8384
8655
  var xAxis = 'bottom';
@@ -8390,16 +8661,13 @@ var WebsyChart = /*#__PURE__*/function () {
8390
8661
  if (this.options.orientation === 'horizontal') {
8391
8662
  xAxis = 'left';
8392
8663
  yAxis = 'bottom';
8393
- } // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
8394
- // barWidth = barWidth / this.options.data.series.length - 4
8395
- // }
8396
-
8664
+ }
8397
8665
 
8398
8666
  function getBarHeight(d, i, heightBounds, yAxis, xAxis) {
8399
8667
  var output;
8400
8668
 
8401
8669
  if (this.options.orientation === 'horizontal') {
8402
- output = this.options.data[xAxis.replace('Brush', '')].bandWidth;
8670
+ output = this.options.data[xAxis].bandWidth;
8403
8671
  } else {
8404
8672
  var x = getBarX.call(this, d, i, xAxis);
8405
8673
 
@@ -8431,7 +8699,7 @@ var WebsyChart = /*#__PURE__*/function () {
8431
8699
  return null;
8432
8700
  }
8433
8701
 
8434
- output = Math.max(1, this.options.data[xAxis.replace('Brush', '')].bandWidth);
8702
+ output = Math.max(1, this.options.data[xAxis].bandWidth - (xAxis.indexOf('Brush') !== -1 ? 2 : this.options.groupPadding * 2));
8435
8703
  }
8436
8704
 
8437
8705
  if (isNaN(output)) {
@@ -8442,11 +8710,6 @@ var WebsyChart = /*#__PURE__*/function () {
8442
8710
  }
8443
8711
 
8444
8712
  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
8713
  var output;
8451
8714
 
8452
8715
  if (this.options.orientation === 'horizontal') {
@@ -8466,22 +8729,26 @@ var WebsyChart = /*#__PURE__*/function () {
8466
8729
  }
8467
8730
  } else {
8468
8731
  // let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
8469
- var _adjustment = this.customBottomRange[i] + i * this.options.data[xAxis.replace('Brush', '')].bandWidth;
8470
-
8732
+ // let adjustment = this[`custom${xAxis.toInitialCaps()}Range`][i] + (i * this.options.data[xAxis].bandWidth)
8471
8733
  if (this.options.grouping === 'grouped') {
8472
8734
  var xIndex = 0;
8473
8735
 
8474
8736
  if (this.processedX[d.x.value]) {
8475
8737
  xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel));
8476
- }
8477
-
8478
- var barAdjustment = this.options.data[xAxis.replace('Brush', '')].bandWidth * xIndex + xIndex * this.options.groupPadding * 2 + this.options.groupPadding + (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1); // let barAdjustment =
8738
+ } // let barAdjustment =
8739
+ // (this.options.data[xAxis].bandWidth * xIndex) +
8740
+ // (xIndex * this.options.groupPadding * 2) + this.options.groupPadding +
8741
+ // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
8742
+ // let barAdjustment =
8479
8743
  // (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
8480
8744
  // this.options.groupPadding
8481
8745
  // // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
8482
8746
 
8483
- if (this.customBottomRange.length > 0) {
8484
- output = this.customBottomRange[this[xAxis.replace('Brush', '') + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment;
8747
+
8748
+ 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);
8749
+
8750
+ if (this["custom".concat(xAxis.toInitialCaps(), "Range")].length > 0) {
8751
+ 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
8752
  } else {
8486
8753
  output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
8487
8754
  }
@@ -8492,12 +8759,10 @@ var WebsyChart = /*#__PURE__*/function () {
8492
8759
 
8493
8760
  if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
8494
8761
  this.processedX[d.x.value].push(d.y.tooltipLabel);
8495
- }
8762
+ } // console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output)
8496
8763
 
8497
- console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output);
8498
8764
  } else {
8499
- // output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
8500
- output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)); // + (i * barWidth)
8765
+ output = this["custom".concat(xAxis.toInitialCaps(), "Range")][this[xAxis + 'Axis'].domain().indexOf(d.x.value)];
8501
8766
  }
8502
8767
  }
8503
8768
 
@@ -8509,8 +8774,6 @@ var WebsyChart = /*#__PURE__*/function () {
8509
8774
  }
8510
8775
 
8511
8776
  function getBarY(d, i, heightBounds, yAxis, xAxis) {
8512
- // let barWidth = this[`${xAxis}Axis`].bandwidth()
8513
- // let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
8514
8777
  var output;
8515
8778
 
8516
8779
  if (this.options.orientation === 'horizontal') {
@@ -8521,10 +8784,19 @@ var WebsyChart = /*#__PURE__*/function () {
8521
8784
  }
8522
8785
  } else {
8523
8786
  if (this.options.grouping === 'stacked') {
8524
- output = heightBounds - this["".concat(yAxis, "Axis")](d.y.accumulative);
8787
+ var accH = getBarHeight.call(this, {
8788
+ x: d.x,
8789
+ y: {
8790
+ value: d.y.accumulative
8791
+ }
8792
+ }, i, heightBounds, yAxis, xAxis);
8793
+ var h = getBarHeight.call(this, d, i, heightBounds, yAxis, xAxis); // output = heightBounds - this[`${yAxis}Axis`](d.y.accumulative)
8794
+
8795
+ output = this["".concat(yAxis, "Axis")](0) - (accH + h) * (d.y.accumulative < 0 ? 0 : 1);
8525
8796
  } else {
8526
- var h = getBarHeight.call(this, d, i, heightBounds, yAxis, xAxis);
8527
- output = this["".concat(yAxis, "Axis")](0) - h * (d.y.value < 0 ? 0 : 1);
8797
+ var _h2 = getBarHeight.call(this, d, i, heightBounds, yAxis, xAxis);
8798
+
8799
+ output = this["".concat(yAxis, "Axis")](0) - _h2 * (d.y.value < 0 ? 0 : 1);
8528
8800
  }
8529
8801
  }
8530
8802
 
@@ -8537,25 +8809,25 @@ var WebsyChart = /*#__PURE__*/function () {
8537
8809
 
8538
8810
  bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8539
8811
  bars.attr('width', function (d, i) {
8540
- return Math.abs(getBarWidth.call(_this47, d, i, xAxis));
8812
+ return Math.abs(getBarWidth.call(_this48, d, i, xAxis));
8541
8813
  }).attr('height', function (d, i) {
8542
- return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8814
+ return getBarHeight.call(_this48, d, i, _this48.plotHeight, yAxis, xAxis);
8543
8815
  }).attr('x', function (d, i) {
8544
- return getBarX.call(_this47, d, i, xAxis);
8816
+ return getBarX.call(_this48, d, i, xAxis);
8545
8817
  }).attr('y', function (d, i) {
8546
- return getBarY.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8818
+ return getBarY.call(_this48, d, i, _this48.plotHeight, yAxis, xAxis);
8547
8819
  }) // .transition(this.transition)
8548
8820
  .attr('fill', function (d) {
8549
8821
  return d.y.color || d.color || series.color;
8550
8822
  });
8551
8823
  bars.enter().append('rect').attr('width', function (d, i) {
8552
- return Math.abs(getBarWidth.call(_this47, d, i, xAxis));
8824
+ return Math.abs(getBarWidth.call(_this48, d, i, xAxis));
8553
8825
  }).attr('height', function (d, i) {
8554
- return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8826
+ return getBarHeight.call(_this48, d, i, _this48.plotHeight, yAxis, xAxis);
8555
8827
  }).attr('x', function (d, i) {
8556
- return getBarX.call(_this47, d, i, xAxis);
8828
+ return getBarX.call(_this48, d, i, xAxis);
8557
8829
  }).attr('y', function (d, i) {
8558
- return getBarY.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
8830
+ return getBarY.call(_this48, d, i, _this48.plotHeight, yAxis, xAxis);
8559
8831
  }) // .transition(this.transition)
8560
8832
  .attr('fill', function (d) {
8561
8833
  return d.y.color || d.color || series.color;
@@ -8567,25 +8839,25 @@ var WebsyChart = /*#__PURE__*/function () {
8567
8839
  this.brushBarsInitialized[series.key] = true;
8568
8840
  brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
8569
8841
  brushBars.attr('width', function (d, i) {
8570
- return Math.abs(getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush")));
8842
+ return Math.abs(getBarWidth.call(_this48, d, i, "".concat(xAxis, "Brush")));
8571
8843
  }).attr('height', function (d, i) {
8572
- return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8844
+ return getBarHeight.call(_this48, d, i, _this48.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8573
8845
  }).attr('x', function (d, i) {
8574
- return getBarX.call(_this47, d, i, "".concat(xAxis, "Brush"));
8846
+ return getBarX.call(_this48, d, i, "".concat(xAxis, "Brush"));
8575
8847
  }).attr('y', function (d, i) {
8576
- return getBarY.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8848
+ return getBarY.call(_this48, d, i, _this48.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8577
8849
  }) // .transition(this.transition)
8578
8850
  .attr('fill', function (d) {
8579
8851
  return d.y.color || d.color || series.color;
8580
8852
  });
8581
8853
  brushBars.enter().append('rect').attr('width', function (d, i) {
8582
- return Math.abs(getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush")));
8854
+ return Math.abs(getBarWidth.call(_this48, d, i, "".concat(xAxis, "Brush")));
8583
8855
  }).attr('height', function (d, i) {
8584
- return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8856
+ return getBarHeight.call(_this48, d, i, _this48.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8585
8857
  }).attr('x', function (d, i) {
8586
- return getBarX.call(_this47, d, i, "".concat(xAxis, "Brush"));
8858
+ return getBarX.call(_this48, d, i, "".concat(xAxis, "Brush"));
8587
8859
  }).attr('y', function (d, i) {
8588
- return getBarY.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8860
+ return getBarY.call(_this48, d, i, _this48.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
8589
8861
  }) // .transition(this.transition)
8590
8862
  .attr('fill', function (d) {
8591
8863
  return d.y.color || d.color || series.color;
@@ -8603,16 +8875,16 @@ var WebsyChart = /*#__PURE__*/function () {
8603
8875
  }, {
8604
8876
  key: "renderLabels",
8605
8877
  value: function renderLabels(series, index) {
8606
- var _this48 = this;
8878
+ var _this49 = this;
8607
8879
 
8608
8880
  /* global series index d3 WebsyDesigns */
8609
- var xAxis = 'bottomAxis';
8610
- var yAxis = 'leftAxis';
8881
+ var xAxis = 'bottom';
8882
+ var yAxis = 'left';
8611
8883
  var that = this;
8612
8884
 
8613
8885
  if (this.options.orientation === 'horizontal') {
8614
- xAxis = 'leftAxis';
8615
- yAxis = 'bottomAxis';
8886
+ xAxis = 'left';
8887
+ yAxis = 'bottom';
8616
8888
  }
8617
8889
 
8618
8890
  if (this.options.showLabels === true || series.showLabels === true) {
@@ -8622,15 +8894,15 @@ var WebsyChart = /*#__PURE__*/function () {
8622
8894
  var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
8623
8895
  labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
8624
8896
  labels.attr('x', function (d) {
8625
- return getLabelX.call(_this48, d, series.labelPosition);
8897
+ return getLabelX.call(_this49, d, series.labelPosition);
8626
8898
  }).attr('y', function (d) {
8627
- return getLabelY.call(_this48, d, series.labelPosition);
8899
+ return getLabelY.call(_this49, d, series.labelPosition);
8628
8900
  }).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
8629
- if (_this48.options.grouping === 'stacked' && d.y.value === 0) {
8901
+ if (_this49.options.grouping === 'stacked' && d.y.value === 0) {
8630
8902
  return 'transparent';
8631
8903
  }
8632
8904
 
8633
- return _this48.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8905
+ return _this49.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8634
8906
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
8635
8907
  return d.y.label || d.y.value;
8636
8908
  }).each(function (d, i) {
@@ -8655,15 +8927,15 @@ var WebsyChart = /*#__PURE__*/function () {
8655
8927
  }
8656
8928
  });
8657
8929
  labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', function (d) {
8658
- return getLabelX.call(_this48, d, series.labelPosition);
8930
+ return getLabelX.call(_this49, d, series.labelPosition);
8659
8931
  }).attr('y', function (d) {
8660
- return getLabelY.call(_this48, d, series.labelPosition);
8932
+ return getLabelY.call(_this49, d, series.labelPosition);
8661
8933
  }).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
8662
- if (_this48.options.grouping === 'stacked' && d.y.value === 0) {
8934
+ if (_this49.options.grouping === 'stacked' && d.y.value === 0) {
8663
8935
  return 'transparent';
8664
8936
  }
8665
8937
 
8666
- return _this48.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8938
+ return _this49.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
8667
8939
  }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
8668
8940
  return d.y.label || d.y.value;
8669
8941
  }).each(function (d, i) {
@@ -8685,6 +8957,10 @@ var WebsyChart = /*#__PURE__*/function () {
8685
8957
  if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
8686
8958
  this.setAttribute('y', +this.getAttribute('y') + 8);
8687
8959
  }
8960
+
8961
+ if (series.labelPosition !== 'outside') {
8962
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color));
8963
+ }
8688
8964
  }
8689
8965
  });
8690
8966
  }
@@ -8699,7 +8975,15 @@ var WebsyChart = /*#__PURE__*/function () {
8699
8975
  return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4;
8700
8976
  }
8701
8977
  } else {
8702
- return this[xAxis](this.parseX(d.x.value)) + this.options.data[xAxis.replace('Axis', '')].bandWidth / 2;
8978
+ // return this[xAxis](this.parseX(d.x.value)) + (this.options.data[xAxis.replace('Axis', '')].bandWidth / 2)
8979
+ var xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value);
8980
+ var xPos = this["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
8981
+
8982
+ if (this["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
8983
+ xPos = xPos + (this["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
8984
+ }
8985
+
8986
+ return xPos;
8703
8987
  }
8704
8988
  }
8705
8989
 
@@ -8707,12 +8991,14 @@ var WebsyChart = /*#__PURE__*/function () {
8707
8991
  var labelPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inside';
8708
8992
 
8709
8993
  if (this.options.orientation === 'horizontal') {
8710
- return this[xAxis](this.parseX(d.x.value)) + this.options.data[xAxis.replace('Axis', '')].bandWidth / 2;
8994
+ return this[xAxis + 'Axis'](this.parseX(d.x.value)) + this.options.data[xAxis].bandWidth / 2;
8711
8995
  } else {
8712
8996
  if (this.options.grouping === 'stacked') {
8713
- return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1);
8997
+ var accH = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.accumulative));
8998
+ var h = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
8999
+ 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
9000
  } else {
8715
- return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize);
9001
+ return this[yAxis + 'Axis'](isNaN(d.y.value) ? 0 : d.y.value) - (this.options.labelSize || this.options.fontSize);
8716
9002
  }
8717
9003
  }
8718
9004
  }
@@ -8720,25 +9006,34 @@ var WebsyChart = /*#__PURE__*/function () {
8720
9006
  }, {
8721
9007
  key: "renderline",
8722
9008
  value: function renderline(series, index) {
8723
- var _this49 = this;
9009
+ var _this50 = this;
8724
9010
 
8725
9011
  /* global series index d3 */
8726
9012
  var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
8727
9013
  return d3.line().x(function (d) {
8728
- if (_this49.options.orientation === 'horizontal') {
8729
- return _this49["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
9014
+ if (_this50.options.orientation === 'horizontal') {
9015
+ return _this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8730
9016
  } else {
8731
- var adjustment = _this49.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this49["".concat(xAxis, "Axis")].bandwidth() / 2;
8732
- return _this49["".concat(xAxis, "Axis")](_this49.parseX(d.x.value)) + adjustment;
9017
+ var xIndex = _this50[xAxis + 'Axis'].domain().indexOf(d.x.value);
9018
+
9019
+ var xPos = _this50["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
9020
+
9021
+ if (_this50["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
9022
+ xPos = xPos + (_this50["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
9023
+ } // let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis].bandWidth / 2
9024
+ // return this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment
9025
+
9026
+
9027
+ return xPos;
8733
9028
  }
8734
9029
  }).y(function (d) {
8735
- if (_this49.options.orientation === 'horizontal') {
8736
- var adjustment = _this49.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this49["".concat(xAxis, "Axis")].bandwidth() / 2;
8737
- return _this49["".concat(xAxis, "Axis")](_this49.parseX(d.x.value)) + adjustment;
9030
+ if (_this50.options.orientation === 'horizontal') {
9031
+ var adjustment = _this50.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this50.options.data[xAxis].bandWidth / 2;
9032
+ return _this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment;
8738
9033
  } else {
8739
- return _this49["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
9034
+ return _this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8740
9035
  }
8741
- }).curve(d3[curveStyle || _this49.options.curveStyle]);
9036
+ }).curve(d3[curveStyle || _this50.options.curveStyle]);
8742
9037
  };
8743
9038
 
8744
9039
  var xAxis = 'bottom';
@@ -8764,14 +9059,18 @@ var WebsyChart = /*#__PURE__*/function () {
8764
9059
 
8765
9060
  lines.style('stroke-width', series.lineWidth || this.options.lineWidth) // .attr('id', `line_${series.key}`)
8766
9061
  // .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
8767
- .attr('stroke', series.color).attr('fill', 'transparent').transition(this.transition).attr('d', function (d) {
9062
+ .attr('stroke', function (d) {
9063
+ return d[0].y.color || series.color;
9064
+ }).attr('fill', 'transparent').transition(this.transition).attr('d', function (d) {
8768
9065
  return drawLine(xAxis, yAxis, series.curveStyle)(d);
8769
9066
  }); // Enter
8770
9067
 
8771
9068
  lines.enter().append('path').attr('d', function (d) {
8772
9069
  return drawLine(xAxis, yAxis, series.curveStyle)(d);
8773
9070
  }).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', series.color).attr('fill', 'transparent') // .transition(this.transition)
9071
+ .style('stroke-width', series.lineWidth || this.options.lineWidth).attr('stroke', function (d) {
9072
+ return d[0].y.color || series.color;
9073
+ }).attr('fill', 'transparent') // .transition(this.transition)
8775
9074
  .style('stroke-opacity', 1);
8776
9075
 
8777
9076
  if (!this.brushLinesInitialized[series.key]) {
@@ -8835,14 +9134,14 @@ var WebsyChart = /*#__PURE__*/function () {
8835
9134
  }, {
8836
9135
  key: "rendersymbol",
8837
9136
  value: function rendersymbol(series, index) {
8838
- var _this50 = this;
9137
+ var _this51 = this;
8839
9138
 
8840
9139
  /* global d3 series index series.key */
8841
9140
  var drawSymbol = function drawSymbol(size) {
8842
9141
  return d3.symbol() // .type(d => {
8843
9142
  // return d3.symbols[0]
8844
9143
  // })
8845
- .size(size || _this50.options.symbolSize);
9144
+ .size(size || _this51.options.symbolSize);
8846
9145
  };
8847
9146
 
8848
9147
  var xAxis = 'bottom';
@@ -8860,12 +9159,28 @@ var WebsyChart = /*#__PURE__*/function () {
8860
9159
  symbols.attr('d', function (d) {
8861
9160
  return drawSymbol(d.y.size || series.symbolSize)(d);
8862
9161
  }).transition(this.transition).attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('transform', function (d) {
8863
- var adjustment = _this50.options.data[xAxis].scale === 'Time' || _this50.options.data[xAxis].scale === 'Linear' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
9162
+ // let adjustment = (this.options.data[xAxis].scale === 'Time' || this.options.data[xAxis].scale === 'Linear') ? 0 : this.options.data[xAxis].bandWidth / 2
9163
+ // if (this.options.orientation === 'horizontal') {
9164
+ // return `translate(${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)}, ${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment})`
9165
+ // }
9166
+ // else {
9167
+ // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
9168
+ // }
9169
+ var xIndex = _this51[xAxis + 'Axis'].domain().indexOf(d.x.value);
8864
9170
 
8865
- if (_this50.options.orientation === 'horizontal') {
8866
- return "translate(".concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ")");
9171
+ var xPos = _this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
9172
+
9173
+ if (_this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
9174
+ xPos = xPos + (_this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
9175
+ }
9176
+
9177
+ var adjustment = _this51.options.data[xAxis].scale === 'Time' || _this51.options.data[xAxis].scale === 'Linear' ? 0 : _this51.options.data[xAxis].bandWidth / 2;
9178
+
9179
+ if (_this51.options.orientation === 'horizontal') {
9180
+ return "translate(".concat(_this51["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(xPos, ")");
8867
9181
  } else {
8868
- return "translate(".concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ", ").concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
9182
+ // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
9183
+ return "translate(".concat(xPos, ", ").concat(_this51["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
8869
9184
  }
8870
9185
  }); // Enter
8871
9186
 
@@ -8875,12 +9190,21 @@ var WebsyChart = /*#__PURE__*/function () {
8875
9190
  .attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('class', function (d) {
8876
9191
  return "symbol symbol_".concat(series.key);
8877
9192
  }).attr('transform', function (d) {
8878
- var adjustment = _this50.options.data[xAxis].scale === 'Time' || _this50.options.data[xAxis].scale === 'Linear' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
9193
+ var xIndex = _this51[xAxis + 'Axis'].domain().indexOf(d.x.value);
9194
+
9195
+ var xPos = _this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex];
8879
9196
 
8880
- if (_this50.options.orientation === 'horizontal') {
8881
- return "translate(".concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ")");
9197
+ if (_this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1]) {
9198
+ xPos = xPos + (_this51["custom".concat(xAxis.toInitialCaps(), "Range")][xIndex + 1] - xPos) / 2;
9199
+ }
9200
+
9201
+ var adjustment = _this51.options.data[xAxis].scale === 'Time' || _this51.options.data[xAxis].scale === 'Linear' ? 0 : _this51.options.data[xAxis].bandWidth / 2;
9202
+
9203
+ if (_this51.options.orientation === 'horizontal') {
9204
+ return "translate(".concat(_this51["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(xPos, ")");
8882
9205
  } else {
8883
- return "translate(".concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ", ").concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
9206
+ // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
9207
+ return "translate(".concat(xPos, ", ").concat(_this51["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
8884
9208
  }
8885
9209
  });
8886
9210
  }
@@ -9102,7 +9426,7 @@ var WebsyLegend = /*#__PURE__*/function () {
9102
9426
  }, {
9103
9427
  key: "resize",
9104
9428
  value: function resize() {
9105
- var _this51 = this;
9429
+ var _this52 = this;
9106
9430
 
9107
9431
  var el = document.getElementById(this.elementId);
9108
9432
 
@@ -9115,7 +9439,7 @@ var WebsyLegend = /*#__PURE__*/function () {
9115
9439
  // }
9116
9440
  var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
9117
9441
  html += this._data.map(function (d, i) {
9118
- return _this51.getLegendItemHTML(d);
9442
+ return _this52.getLegendItemHTML(d);
9119
9443
  }).join('');
9120
9444
  html += "\n <div>\n ";
9121
9445
  el.innerHTML = html;
@@ -9287,7 +9611,7 @@ var WebsyMap = /*#__PURE__*/function () {
9287
9611
  }, {
9288
9612
  key: "render",
9289
9613
  value: function render() {
9290
- var _this52 = this;
9614
+ var _this53 = this;
9291
9615
 
9292
9616
  var mapEl = document.getElementById("".concat(this.elementId, "_map"));
9293
9617
  var legendEl = document.getElementById("".concat(this.elementId, "_map"));
@@ -9296,7 +9620,7 @@ var WebsyMap = /*#__PURE__*/function () {
9296
9620
  var legendData = this.options.data.polygons.map(function (s, i) {
9297
9621
  return {
9298
9622
  value: s.label || s.key,
9299
- color: s.color || _this52.options.colors[i % _this52.options.colors.length]
9623
+ color: s.color || _this53.options.colors[i % _this53.options.colors.length]
9300
9624
  };
9301
9625
  });
9302
9626
  var longestValue = legendData.map(function (s) {
@@ -9360,7 +9684,7 @@ var WebsyMap = /*#__PURE__*/function () {
9360
9684
 
9361
9685
  if (this.polygons) {
9362
9686
  this.polygons.forEach(function (p) {
9363
- return _this52.map.removeLayer(p);
9687
+ return _this53.map.removeLayer(p);
9364
9688
  });
9365
9689
  }
9366
9690
 
@@ -9418,18 +9742,18 @@ var WebsyMap = /*#__PURE__*/function () {
9418
9742
  }
9419
9743
 
9420
9744
  if (!p.options.color) {
9421
- p.options.color = _this52.options.colors[i % _this52.options.colors.length];
9745
+ p.options.color = _this53.options.colors[i % _this53.options.colors.length];
9422
9746
  }
9423
9747
 
9424
9748
  var pol = L.polygon(p.data.map(function (c) {
9425
9749
  return c.map(function (d) {
9426
9750
  return [d.Latitude, d.Longitude];
9427
9751
  });
9428
- }), p.options).addTo(_this52.map);
9752
+ }), p.options).addTo(_this53.map);
9429
9753
 
9430
- _this52.polygons.push(pol);
9754
+ _this53.polygons.push(pol);
9431
9755
 
9432
- _this52.map.fitBounds(pol.getBounds());
9756
+ _this53.map.fitBounds(pol.getBounds());
9433
9757
  });
9434
9758
  } // if (this.data.markers.length > 0) {
9435
9759
  // el.classList.remove('hidden')