@websy/websy-designs 1.9.10 → 1.9.12

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.
@@ -2783,7 +2783,9 @@ class MultiForm {
2783
2783
  this.elementId = elementId
2784
2784
  const DEFAULTS = {
2785
2785
  addButton: `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 512 512"><line x1="256" y1="112" x2="256" y2="400" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="400" y1="256" x2="112" y2="256" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>`,
2786
- deleteButton: `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 512 512"><line x1="368" y1="368" x2="144" y2="144" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="368" y1="144" x2="144" y2="368" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>`
2786
+ deleteButton: `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 512 512"><line x1="368" y1="368" x2="144" y2="144" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="368" y1="144" x2="144" y2="368" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>`,
2787
+ allowAdd: true,
2788
+ allowDelete: true
2787
2789
  }
2788
2790
  this.options = Object.assign({}, DEFAULTS, options)
2789
2791
  this.formData = []
@@ -2848,7 +2850,9 @@ class MultiForm {
2848
2850
  deleteButtonEl.classList.remove('hidden')
2849
2851
  }
2850
2852
  // add new form
2851
- this.addEntry()
2853
+ if (this.options.allowAdd === true) {
2854
+ this.addEntry()
2855
+ }
2852
2856
  }
2853
2857
  if (event.target.classList.contains('websy-multi-form-delete')) {
2854
2858
  // delete form based on index
@@ -2884,25 +2888,33 @@ class MultiForm {
2884
2888
  <div id='${this.elementId}_${d.formId}_formContainer' class='websy-multi-form-form-container'>
2885
2889
  <div id='${this.elementId}_${d.formId}_form' class='websy-multi-form-form'>
2886
2890
  </div>
2891
+ `
2892
+ if (this.options.allowDelete === true) {
2893
+ html += `
2887
2894
  <button id='${this.elementId}_${d.formId}_deleteButton' data-formid='${d.formId}' data-rowid='${d.id}' class='websy-multi-form-delete'>
2888
2895
  ${this.options.deleteButton}
2889
- </button>
2896
+ </button>
2897
+ `
2898
+ }
2899
+ html += `
2890
2900
  </div>
2891
2901
  `
2892
2902
  })
2893
2903
  let id = WebsyDesigns.Utils.createIdentity()
2894
- html += `
2895
- <div id='${this.elementId}_${id}_formContainer' class='websy-multi-form-form-container'>
2896
- <div id='${this.elementId}_${id}_form' class='websy-multi-form-form'>
2904
+ if (this.options.allowAdd === true) {
2905
+ html += `
2906
+ <div id='${this.elementId}_${id}_formContainer' class='websy-multi-form-form-container'>
2907
+ <div id='${this.elementId}_${id}_form' class='websy-multi-form-form'>
2908
+ </div>
2909
+ <button id='${this.elementId}_${id}_deleteButton' data-formid='${id}' class='hidden websy-multi-form-delete'>
2910
+ ${this.options.deleteButton}
2911
+ </button>
2912
+ <button id='${this.elementId}_${id}_addButton' data-formid='${id}' class='websy-multi-form-add'>
2913
+ ${this.options.addButton}
2914
+ </button>
2897
2915
  </div>
2898
- <button id='${this.elementId}_${id}_deleteButton' data-formid='${id}' class='hidden websy-multi-form-delete'>
2899
- ${this.options.deleteButton}
2900
- </button>
2901
- <button id='${this.elementId}_${id}_addButton' data-formid='${id}' class='websy-multi-form-add'>
2902
- ${this.options.addButton}
2903
- </button>
2904
- </div>
2905
- `
2916
+ `
2917
+ }
2906
2918
  el.innerHTML = html
2907
2919
  this.formData.forEach(d => {
2908
2920
  let formOptions = Object.assign({}, this.options)
@@ -2910,8 +2922,10 @@ class MultiForm {
2910
2922
  formObject.data = d
2911
2923
  this.forms.push(formObject)
2912
2924
  })
2913
- let formOptions = Object.assign({}, this.options)
2914
- this.forms.push(new WebsyDesigns.Form(`${this.elementId}_${id}_form`, formOptions))
2925
+ if (this.options.allowAdd === true) {
2926
+ let formOptions = Object.assign({}, this.options)
2927
+ this.forms.push(new WebsyDesigns.Form(`${this.elementId}_${id}_form`, formOptions))
2928
+ }
2915
2929
  }
2916
2930
  }
2917
2931
  validateForm () {
@@ -8700,6 +8714,7 @@ else {
8700
8714
  let rangeLength = bottomDomain.length
8701
8715
  this.options.data.bottomBrush = {}
8702
8716
  this.options.data.leftBrush = {}
8717
+ this.options.data.rightBrush = {}
8703
8718
  if (this.options.orientation === 'vertical') {
8704
8719
  this.options.data.bottom.bandWidth = proposedBandWidth
8705
8720
  this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints
@@ -8707,6 +8722,7 @@ else {
8707
8722
  else {
8708
8723
  this.options.data.left.bandWidth = proposedBandWidth
8709
8724
  this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints
8725
+ this.options.data.rightBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints
8710
8726
  }
8711
8727
  this.brushBandPadding = this.totalBandPadding / noOfGroups
8712
8728
  if (this.options.orientation === 'vertical') {
@@ -8910,7 +8926,8 @@ else {
8910
8926
  // Configure the left axis
8911
8927
  let leftDomain = this.createDomain('left')
8912
8928
  let leftBrushDomain = this.createDomain('left')
8913
- let rightDomain = this.createDomain('right')
8929
+ let rightDomain = this.createDomain('right')
8930
+ let rightBrushDomain = this.createDomain('right')
8914
8931
  this.leftAxis = d3[`scale${this.options.data.left.scale || 'Linear'}`]()
8915
8932
  .domain(leftDomain)
8916
8933
  .range(leftRange)
@@ -8983,6 +9000,9 @@ else {
8983
9000
  this.rightAxis = d3[`scale${this.options.data.right.scale || 'Linear'}`]()
8984
9001
  .domain(rightDomain)
8985
9002
  .range([this.plotHeight, 0])
9003
+ this.rightBrushAxis = d3[`scale${this.options.data.right.scale || 'Linear'}`]()
9004
+ .domain(rightBrushDomain)
9005
+ .range(leftBrushRange)
8986
9006
  if (this.rightAxis.nice) {
8987
9007
  this.rightAxis.nice()
8988
9008
  }
@@ -9573,10 +9593,10 @@ if (this.options.orientation === 'horizontal') {
9573
9593
  yAxis = 'bottom'
9574
9594
  }
9575
9595
  let xBrushAxis = 'bottomBrush'
9576
- let yBrushAxis = 'leftBrush'
9596
+ let yBrushAxis = series.axis === 'secondary' ? 'rightBrush' : 'leftBrush'
9577
9597
  if (this.options.orientation === 'horizontal') {
9578
9598
  xBrushAxis = 'leftBrush'
9579
- yBrushAxis = 'bottomBrush'
9599
+ yBrushAxis = 'bottomBrush'
9580
9600
  }
9581
9601
  let lines = this.lineLayer.selectAll(`.line_${series.key}`)
9582
9602
  .data([series.data])
@@ -10471,11 +10491,11 @@ class WebsyKPI {
10471
10491
  const DEFAULTS = {
10472
10492
  tooltip: {},
10473
10493
  label: {},
10474
- value: {},
10475
- subValue: {}
10494
+ value: {}
10476
10495
  }
10477
10496
  this.elementId = elementId
10478
10497
  this.options = Object.assign({}, DEFAULTS, options)
10498
+ this.render()
10479
10499
  }
10480
10500
  render (options) {
10481
10501
  this.options = Object.assign({}, this.options, options)
@@ -10485,7 +10505,7 @@ class WebsyKPI {
10485
10505
  if (!this.options.value.classes) {
10486
10506
  this.options.value.classes = []
10487
10507
  }
10488
- if (!this.options.subValue.classes) {
10508
+ if (this.options.subValue && !this.options.subValue.classes) {
10489
10509
  this.options.subValue.classes = []
10490
10510
  }
10491
10511
  if (!this.options.tooltip.classes) {
@@ -2742,7 +2742,9 @@ var MultiForm = /*#__PURE__*/function () {
2742
2742
  this.elementId = elementId;
2743
2743
  var DEFAULTS = {
2744
2744
  addButton: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"40\" height=\"40\" viewBox=\"0 0 512 512\"><line x1=\"256\" y1=\"112\" x2=\"256\" y2=\"400\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"400\" y1=\"256\" x2=\"112\" y2=\"256\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>",
2745
- deleteButton: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"40\" height=\"40\" viewBox=\"0 0 512 512\"><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>"
2745
+ deleteButton: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"40\" height=\"40\" viewBox=\"0 0 512 512\"><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>",
2746
+ allowAdd: true,
2747
+ allowDelete: true
2746
2748
  };
2747
2749
  this.options = _extends({}, DEFAULTS, options);
2748
2750
  this.formData = [];
@@ -2808,7 +2810,9 @@ var MultiForm = /*#__PURE__*/function () {
2808
2810
  deleteButtonEl.classList.remove('hidden');
2809
2811
  }
2810
2812
  // add new form
2811
- this.addEntry();
2813
+ if (this.options.allowAdd === true) {
2814
+ this.addEntry();
2815
+ }
2812
2816
  }
2813
2817
  if (event.target.classList.contains('websy-multi-form-delete')) {
2814
2818
  // delete form based on index
@@ -2843,10 +2847,16 @@ var MultiForm = /*#__PURE__*/function () {
2843
2847
  var html = '';
2844
2848
  this.formData.forEach(function (d) {
2845
2849
  d.formId = WebsyDesigns.Utils.createIdentity();
2846
- html += "\n <div id='".concat(_this21.elementId, "_").concat(d.formId, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(_this21.elementId, "_").concat(d.formId, "_form' class='websy-multi-form-form'>\n </div>\n <button id='").concat(_this21.elementId, "_").concat(d.formId, "_deleteButton' data-formid='").concat(d.formId, "' data-rowid='").concat(d.id, "' class='websy-multi-form-delete'>\n ").concat(_this21.options.deleteButton, "\n </button> \n </div>\n ");
2850
+ html += "\n <div id='".concat(_this21.elementId, "_").concat(d.formId, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(_this21.elementId, "_").concat(d.formId, "_form' class='websy-multi-form-form'>\n </div>\n ");
2851
+ if (_this21.options.allowDelete === true) {
2852
+ html += "\n <button id='".concat(_this21.elementId, "_").concat(d.formId, "_deleteButton' data-formid='").concat(d.formId, "' data-rowid='").concat(d.id, "' class='websy-multi-form-delete'>\n ").concat(_this21.options.deleteButton, "\n </button>\n ");
2853
+ }
2854
+ html += "\n </div>\n ";
2847
2855
  });
2848
2856
  var id = WebsyDesigns.Utils.createIdentity();
2849
- html += "\n <div id='".concat(this.elementId, "_").concat(id, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(this.elementId, "_").concat(id, "_form' class='websy-multi-form-form'>\n </div>\n <button id='").concat(this.elementId, "_").concat(id, "_deleteButton' data-formid='").concat(id, "' class='hidden websy-multi-form-delete'>\n ").concat(this.options.deleteButton, "\n </button> \n <button id='").concat(this.elementId, "_").concat(id, "_addButton' data-formid='").concat(id, "' class='websy-multi-form-add'>\n ").concat(this.options.addButton, "\n </button> \n </div>\n ");
2857
+ if (this.options.allowAdd === true) {
2858
+ html += "\n <div id='".concat(this.elementId, "_").concat(id, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(this.elementId, "_").concat(id, "_form' class='websy-multi-form-form'>\n </div>\n <button id='").concat(this.elementId, "_").concat(id, "_deleteButton' data-formid='").concat(id, "' class='hidden websy-multi-form-delete'>\n ").concat(this.options.deleteButton, "\n </button> \n <button id='").concat(this.elementId, "_").concat(id, "_addButton' data-formid='").concat(id, "' class='websy-multi-form-add'>\n ").concat(this.options.addButton, "\n </button> \n </div>\n ");
2859
+ }
2850
2860
  el.innerHTML = html;
2851
2861
  this.formData.forEach(function (d) {
2852
2862
  var formOptions = _extends({}, _this21.options);
@@ -2854,8 +2864,10 @@ var MultiForm = /*#__PURE__*/function () {
2854
2864
  formObject.data = d;
2855
2865
  _this21.forms.push(formObject);
2856
2866
  });
2857
- var formOptions = _extends({}, this.options);
2858
- this.forms.push(new WebsyDesigns.Form("".concat(this.elementId, "_").concat(id, "_form"), formOptions));
2867
+ if (this.options.allowAdd === true) {
2868
+ var formOptions = _extends({}, this.options);
2869
+ this.forms.push(new WebsyDesigns.Form("".concat(this.elementId, "_").concat(id, "_form"), formOptions));
2870
+ }
2859
2871
  }
2860
2872
  }
2861
2873
  }, {
@@ -8311,12 +8323,14 @@ var WebsyChart = /*#__PURE__*/function () {
8311
8323
  var rangeLength = bottomDomain.length;
8312
8324
  this.options.data.bottomBrush = {};
8313
8325
  this.options.data.leftBrush = {};
8326
+ this.options.data.rightBrush = {};
8314
8327
  if (this.options.orientation === 'vertical') {
8315
8328
  this.options.data.bottom.bandWidth = proposedBandWidth;
8316
8329
  this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints;
8317
8330
  } else {
8318
8331
  this.options.data.left.bandWidth = proposedBandWidth;
8319
8332
  this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints;
8333
+ this.options.data.rightBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints;
8320
8334
  }
8321
8335
  this.brushBandPadding = this.totalBandPadding / noOfGroups;
8322
8336
  if (this.options.orientation === 'vertical') {
@@ -8493,6 +8507,7 @@ var WebsyChart = /*#__PURE__*/function () {
8493
8507
  var leftDomain = this.createDomain('left');
8494
8508
  var leftBrushDomain = this.createDomain('left');
8495
8509
  var rightDomain = this.createDomain('right');
8510
+ var rightBrushDomain = this.createDomain('right');
8496
8511
  this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range(leftRange);
8497
8512
  this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range(leftBrushRange);
8498
8513
  if (this.leftAxis.padding && this.options.data.left.padding) {
@@ -8532,6 +8547,7 @@ var WebsyChart = /*#__PURE__*/function () {
8532
8547
  // Configure the right axis
8533
8548
  if (rightDomain.length > 0) {
8534
8549
  this.rightAxis = d3["scale".concat(this.options.data.right.scale || 'Linear')]().domain(rightDomain).range([this.plotHeight, 0]);
8550
+ this.rightBrushAxis = d3["scale".concat(this.options.data.right.scale || 'Linear')]().domain(rightBrushDomain).range(leftBrushRange);
8535
8551
  if (this.rightAxis.nice) {
8536
8552
  this.rightAxis.nice();
8537
8553
  }
@@ -9075,7 +9091,7 @@ var WebsyChart = /*#__PURE__*/function () {
9075
9091
  yAxis = 'bottom';
9076
9092
  }
9077
9093
  var xBrushAxis = 'bottomBrush';
9078
- var yBrushAxis = 'leftBrush';
9094
+ var yBrushAxis = series.axis === 'secondary' ? 'rightBrush' : 'leftBrush';
9079
9095
  if (this.options.orientation === 'horizontal') {
9080
9096
  xBrushAxis = 'leftBrush';
9081
9097
  yBrushAxis = 'bottomBrush';
@@ -9920,11 +9936,11 @@ var WebsyKPI = /*#__PURE__*/function () {
9920
9936
  var DEFAULTS = {
9921
9937
  tooltip: {},
9922
9938
  label: {},
9923
- value: {},
9924
- subValue: {}
9939
+ value: {}
9925
9940
  };
9926
9941
  this.elementId = elementId;
9927
9942
  this.options = _extends({}, DEFAULTS, options);
9943
+ this.render();
9928
9944
  }
9929
9945
  _createClass(WebsyKPI, [{
9930
9946
  key: "render",
@@ -9936,7 +9952,7 @@ var WebsyKPI = /*#__PURE__*/function () {
9936
9952
  if (!this.options.value.classes) {
9937
9953
  this.options.value.classes = [];
9938
9954
  }
9939
- if (!this.options.subValue.classes) {
9955
+ if (this.options.subValue && !this.options.subValue.classes) {
9940
9956
  this.options.subValue.classes = [];
9941
9957
  }
9942
9958
  if (!this.options.tooltip.classes) {