@websy/websy-designs 1.9.11 → 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.
@@ -2584,7 +2584,9 @@ class MultiForm {
2584
2584
  this.elementId = elementId
2585
2585
  const DEFAULTS = {
2586
2586
  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>`,
2587
- 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>`
2587
+ 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>`,
2588
+ allowAdd: true,
2589
+ allowDelete: true
2588
2590
  }
2589
2591
  this.options = Object.assign({}, DEFAULTS, options)
2590
2592
  this.formData = []
@@ -2649,7 +2651,9 @@ class MultiForm {
2649
2651
  deleteButtonEl.classList.remove('hidden')
2650
2652
  }
2651
2653
  // add new form
2652
- this.addEntry()
2654
+ if (this.options.allowAdd === true) {
2655
+ this.addEntry()
2656
+ }
2653
2657
  }
2654
2658
  if (event.target.classList.contains('websy-multi-form-delete')) {
2655
2659
  // delete form based on index
@@ -2685,25 +2689,33 @@ class MultiForm {
2685
2689
  <div id='${this.elementId}_${d.formId}_formContainer' class='websy-multi-form-form-container'>
2686
2690
  <div id='${this.elementId}_${d.formId}_form' class='websy-multi-form-form'>
2687
2691
  </div>
2692
+ `
2693
+ if (this.options.allowDelete === true) {
2694
+ html += `
2688
2695
  <button id='${this.elementId}_${d.formId}_deleteButton' data-formid='${d.formId}' data-rowid='${d.id}' class='websy-multi-form-delete'>
2689
2696
  ${this.options.deleteButton}
2690
- </button>
2697
+ </button>
2698
+ `
2699
+ }
2700
+ html += `
2691
2701
  </div>
2692
2702
  `
2693
2703
  })
2694
2704
  let id = WebsyDesigns.Utils.createIdentity()
2695
- html += `
2696
- <div id='${this.elementId}_${id}_formContainer' class='websy-multi-form-form-container'>
2697
- <div id='${this.elementId}_${id}_form' class='websy-multi-form-form'>
2705
+ if (this.options.allowAdd === true) {
2706
+ html += `
2707
+ <div id='${this.elementId}_${id}_formContainer' class='websy-multi-form-form-container'>
2708
+ <div id='${this.elementId}_${id}_form' class='websy-multi-form-form'>
2709
+ </div>
2710
+ <button id='${this.elementId}_${id}_deleteButton' data-formid='${id}' class='hidden websy-multi-form-delete'>
2711
+ ${this.options.deleteButton}
2712
+ </button>
2713
+ <button id='${this.elementId}_${id}_addButton' data-formid='${id}' class='websy-multi-form-add'>
2714
+ ${this.options.addButton}
2715
+ </button>
2698
2716
  </div>
2699
- <button id='${this.elementId}_${id}_deleteButton' data-formid='${id}' class='hidden websy-multi-form-delete'>
2700
- ${this.options.deleteButton}
2701
- </button>
2702
- <button id='${this.elementId}_${id}_addButton' data-formid='${id}' class='websy-multi-form-add'>
2703
- ${this.options.addButton}
2704
- </button>
2705
- </div>
2706
- `
2717
+ `
2718
+ }
2707
2719
  el.innerHTML = html
2708
2720
  this.formData.forEach(d => {
2709
2721
  let formOptions = Object.assign({}, this.options)
@@ -2711,8 +2723,10 @@ class MultiForm {
2711
2723
  formObject.data = d
2712
2724
  this.forms.push(formObject)
2713
2725
  })
2714
- let formOptions = Object.assign({}, this.options)
2715
- this.forms.push(new WebsyDesigns.Form(`${this.elementId}_${id}_form`, formOptions))
2726
+ if (this.options.allowAdd === true) {
2727
+ let formOptions = Object.assign({}, this.options)
2728
+ this.forms.push(new WebsyDesigns.Form(`${this.elementId}_${id}_form`, formOptions))
2729
+ }
2716
2730
  }
2717
2731
  }
2718
2732
  validateForm () {
@@ -8284,6 +8298,7 @@ else {
8284
8298
  let rangeLength = bottomDomain.length
8285
8299
  this.options.data.bottomBrush = {}
8286
8300
  this.options.data.leftBrush = {}
8301
+ this.options.data.rightBrush = {}
8287
8302
  if (this.options.orientation === 'vertical') {
8288
8303
  this.options.data.bottom.bandWidth = proposedBandWidth
8289
8304
  this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints
@@ -8291,6 +8306,7 @@ else {
8291
8306
  else {
8292
8307
  this.options.data.left.bandWidth = proposedBandWidth
8293
8308
  this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints
8309
+ this.options.data.rightBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints
8294
8310
  }
8295
8311
  this.brushBandPadding = this.totalBandPadding / noOfGroups
8296
8312
  if (this.options.orientation === 'vertical') {
@@ -8494,7 +8510,8 @@ else {
8494
8510
  // Configure the left axis
8495
8511
  let leftDomain = this.createDomain('left')
8496
8512
  let leftBrushDomain = this.createDomain('left')
8497
- let rightDomain = this.createDomain('right')
8513
+ let rightDomain = this.createDomain('right')
8514
+ let rightBrushDomain = this.createDomain('right')
8498
8515
  this.leftAxis = d3[`scale${this.options.data.left.scale || 'Linear'}`]()
8499
8516
  .domain(leftDomain)
8500
8517
  .range(leftRange)
@@ -8567,6 +8584,9 @@ else {
8567
8584
  this.rightAxis = d3[`scale${this.options.data.right.scale || 'Linear'}`]()
8568
8585
  .domain(rightDomain)
8569
8586
  .range([this.plotHeight, 0])
8587
+ this.rightBrushAxis = d3[`scale${this.options.data.right.scale || 'Linear'}`]()
8588
+ .domain(rightBrushDomain)
8589
+ .range(leftBrushRange)
8570
8590
  if (this.rightAxis.nice) {
8571
8591
  this.rightAxis.nice()
8572
8592
  }
@@ -9157,10 +9177,10 @@ if (this.options.orientation === 'horizontal') {
9157
9177
  yAxis = 'bottom'
9158
9178
  }
9159
9179
  let xBrushAxis = 'bottomBrush'
9160
- let yBrushAxis = 'leftBrush'
9180
+ let yBrushAxis = series.axis === 'secondary' ? 'rightBrush' : 'leftBrush'
9161
9181
  if (this.options.orientation === 'horizontal') {
9162
9182
  xBrushAxis = 'leftBrush'
9163
- yBrushAxis = 'bottomBrush'
9183
+ yBrushAxis = 'bottomBrush'
9164
9184
  }
9165
9185
  let lines = this.lineLayer.selectAll(`.line_${series.key}`)
9166
9186
  .data([series.data])
@@ -2565,7 +2565,9 @@ var MultiForm = /*#__PURE__*/function () {
2565
2565
  this.elementId = elementId;
2566
2566
  var DEFAULTS = {
2567
2567
  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>",
2568
- 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>"
2568
+ 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>",
2569
+ allowAdd: true,
2570
+ allowDelete: true
2569
2571
  };
2570
2572
  this.options = _extends({}, DEFAULTS, options);
2571
2573
  this.formData = [];
@@ -2631,7 +2633,9 @@ var MultiForm = /*#__PURE__*/function () {
2631
2633
  deleteButtonEl.classList.remove('hidden');
2632
2634
  }
2633
2635
  // add new form
2634
- this.addEntry();
2636
+ if (this.options.allowAdd === true) {
2637
+ this.addEntry();
2638
+ }
2635
2639
  }
2636
2640
  if (event.target.classList.contains('websy-multi-form-delete')) {
2637
2641
  // delete form based on index
@@ -2666,10 +2670,16 @@ var MultiForm = /*#__PURE__*/function () {
2666
2670
  var html = '';
2667
2671
  this.formData.forEach(function (d) {
2668
2672
  d.formId = WebsyDesigns.Utils.createIdentity();
2669
- html += "\n <div id='".concat(_this19.elementId, "_").concat(d.formId, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(_this19.elementId, "_").concat(d.formId, "_form' class='websy-multi-form-form'>\n </div>\n <button id='").concat(_this19.elementId, "_").concat(d.formId, "_deleteButton' data-formid='").concat(d.formId, "' data-rowid='").concat(d.id, "' class='websy-multi-form-delete'>\n ").concat(_this19.options.deleteButton, "\n </button> \n </div>\n ");
2673
+ html += "\n <div id='".concat(_this19.elementId, "_").concat(d.formId, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(_this19.elementId, "_").concat(d.formId, "_form' class='websy-multi-form-form'>\n </div>\n ");
2674
+ if (_this19.options.allowDelete === true) {
2675
+ html += "\n <button id='".concat(_this19.elementId, "_").concat(d.formId, "_deleteButton' data-formid='").concat(d.formId, "' data-rowid='").concat(d.id, "' class='websy-multi-form-delete'>\n ").concat(_this19.options.deleteButton, "\n </button>\n ");
2676
+ }
2677
+ html += "\n </div>\n ";
2670
2678
  });
2671
2679
  var id = WebsyDesigns.Utils.createIdentity();
2672
- 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 ");
2680
+ if (this.options.allowAdd === true) {
2681
+ 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 ");
2682
+ }
2673
2683
  el.innerHTML = html;
2674
2684
  this.formData.forEach(function (d) {
2675
2685
  var formOptions = _extends({}, _this19.options);
@@ -2677,8 +2687,10 @@ var MultiForm = /*#__PURE__*/function () {
2677
2687
  formObject.data = d;
2678
2688
  _this19.forms.push(formObject);
2679
2689
  });
2680
- var formOptions = _extends({}, this.options);
2681
- this.forms.push(new WebsyDesigns.Form("".concat(this.elementId, "_").concat(id, "_form"), formOptions));
2690
+ if (this.options.allowAdd === true) {
2691
+ var formOptions = _extends({}, this.options);
2692
+ this.forms.push(new WebsyDesigns.Form("".concat(this.elementId, "_").concat(id, "_form"), formOptions));
2693
+ }
2682
2694
  }
2683
2695
  }
2684
2696
  }, {
@@ -7918,12 +7930,14 @@ var WebsyChart = /*#__PURE__*/function () {
7918
7930
  var rangeLength = bottomDomain.length;
7919
7931
  this.options.data.bottomBrush = {};
7920
7932
  this.options.data.leftBrush = {};
7933
+ this.options.data.rightBrush = {};
7921
7934
  if (this.options.orientation === 'vertical') {
7922
7935
  this.options.data.bottom.bandWidth = proposedBandWidth;
7923
7936
  this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints;
7924
7937
  } else {
7925
7938
  this.options.data.left.bandWidth = proposedBandWidth;
7926
7939
  this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints;
7940
+ this.options.data.rightBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints;
7927
7941
  }
7928
7942
  this.brushBandPadding = this.totalBandPadding / noOfGroups;
7929
7943
  if (this.options.orientation === 'vertical') {
@@ -8100,6 +8114,7 @@ var WebsyChart = /*#__PURE__*/function () {
8100
8114
  var leftDomain = this.createDomain('left');
8101
8115
  var leftBrushDomain = this.createDomain('left');
8102
8116
  var rightDomain = this.createDomain('right');
8117
+ var rightBrushDomain = this.createDomain('right');
8103
8118
  this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range(leftRange);
8104
8119
  this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range(leftBrushRange);
8105
8120
  if (this.leftAxis.padding && this.options.data.left.padding) {
@@ -8139,6 +8154,7 @@ var WebsyChart = /*#__PURE__*/function () {
8139
8154
  // Configure the right axis
8140
8155
  if (rightDomain.length > 0) {
8141
8156
  this.rightAxis = d3["scale".concat(this.options.data.right.scale || 'Linear')]().domain(rightDomain).range([this.plotHeight, 0]);
8157
+ this.rightBrushAxis = d3["scale".concat(this.options.data.right.scale || 'Linear')]().domain(rightBrushDomain).range(leftBrushRange);
8142
8158
  if (this.rightAxis.nice) {
8143
8159
  this.rightAxis.nice();
8144
8160
  }
@@ -8682,7 +8698,7 @@ var WebsyChart = /*#__PURE__*/function () {
8682
8698
  yAxis = 'bottom';
8683
8699
  }
8684
8700
  var xBrushAxis = 'bottomBrush';
8685
- var yBrushAxis = 'leftBrush';
8701
+ var yBrushAxis = series.axis === 'secondary' ? 'rightBrush' : 'leftBrush';
8686
8702
  if (this.options.orientation === 'horizontal') {
8687
8703
  xBrushAxis = 'leftBrush';
8688
8704
  yBrushAxis = 'bottomBrush';