@websy/websy-designs 1.3.1 → 1.3.2

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.
@@ -737,8 +737,9 @@ class WebsyDatePicker {
737
737
  let rangeEnd
738
738
  if (this.options.mode === 'date') {
739
739
  d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
740
- d.setUTCHours(12, 0, 0, 0)
740
+ // d.setUTCHours(12, 0, 0, 0)
741
741
  d = d.getTime()
742
+ // console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
742
743
  rangeStart = this.selectedRangeDates[0].getTime()
743
744
  rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
744
745
  }
@@ -747,8 +748,10 @@ class WebsyDatePicker {
747
748
  rangeStart = this.selectedRangeDates[0]
748
749
  rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
749
750
  }
750
- else if (this.options.mode === 'monthyear') {
751
- d = new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i)
751
+ else if (this.options.mode === 'monthyear') {
752
+ d = this.floorDate(new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i))
753
+ d = d.getTime()
754
+ console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
752
755
  rangeStart = this.selectedRangeDates[0].getTime()
753
756
  rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
754
757
  }
@@ -7119,15 +7122,20 @@ if (this.options.showLabels === true || series.showLabels === true) {
7119
7122
  .text(d => d.y.label || d.y.value)
7120
7123
  .each(function (d, i) {
7121
7124
  if (that.options.orientation === 'horizontal') {
7122
- if (that.options.grouping === 'stacked') {
7125
+ if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
7123
7126
  this.setAttribute('text-anchor', 'middle')
7124
7127
  }
7125
7128
  else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
7126
7129
  this.setAttribute('text-anchor', 'end')
7127
- this.setAttribute('x', +(this.getAttribute('x')) - 8)
7130
+ this.setAttribute('x', +(this.getAttribute('x')) - 8)
7128
7131
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
7129
7132
  }
7130
- else {
7133
+ else if (series.labelPosition === 'outside') {
7134
+ this.setAttribute('text-anchor', 'start')
7135
+ this.setAttribute('x', +(this.getAttribute('x')) + 8)
7136
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
7137
+ }
7138
+ else {
7131
7139
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
7132
7140
  }
7133
7141
  }
@@ -7151,15 +7159,20 @@ if (this.options.showLabels === true || series.showLabels === true) {
7151
7159
  .text(d => d.y.label || d.y.value)
7152
7160
  .each(function (d, i) {
7153
7161
  if (that.options.orientation === 'horizontal') {
7154
- if (that.options.grouping === 'stacked') {
7162
+ if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
7155
7163
  this.setAttribute('text-anchor', 'middle')
7156
7164
  }
7157
7165
  else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
7158
7166
  this.setAttribute('text-anchor', 'end')
7159
- this.setAttribute('x', +(this.getAttribute('x')) - 8)
7167
+ this.setAttribute('x', +(this.getAttribute('x')) - 8)
7160
7168
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
7161
7169
  }
7162
- else {
7170
+ else if (series.labelPosition === 'outside') {
7171
+ this.setAttribute('text-anchor', 'start')
7172
+ this.setAttribute('x', +(this.getAttribute('x')) + 8)
7173
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
7174
+ }
7175
+ else {
7163
7176
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
7164
7177
  }
7165
7178
  }
@@ -7171,10 +7184,10 @@ if (this.options.showLabels === true || series.showLabels === true) {
7171
7184
  })
7172
7185
  }
7173
7186
 
7174
- function getLabelX (d) {
7187
+ function getLabelX (d, labelPosition = 'inside') {
7175
7188
  if (this.options.orientation === 'horizontal') {
7176
7189
  if (this.options.grouping === 'stacked') {
7177
- return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / 2)
7190
+ return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
7178
7191
  }
7179
7192
  else {
7180
7193
  return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4
@@ -7184,13 +7197,13 @@ function getLabelX (d) {
7184
7197
  return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
7185
7198
  }
7186
7199
  }
7187
- function getLabelY (d) {
7200
+ function getLabelY (d, labelPosition = 'inside') {
7188
7201
  if (this.options.orientation === 'horizontal') {
7189
7202
  return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
7190
7203
  }
7191
7204
  else {
7192
7205
  if (this.options.grouping === 'stacked') {
7193
- //
7206
+ return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
7194
7207
  }
7195
7208
  else {
7196
7209
  return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - 4
@@ -829,9 +829,10 @@ var WebsyDatePicker = /*#__PURE__*/function () {
829
829
  var rangeEnd = void 0;
830
830
 
831
831
  if (this.options.mode === 'date') {
832
- d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + _i * this.oneDay));
833
- d.setUTCHours(12, 0, 0, 0);
834
- d = d.getTime();
832
+ d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + _i * this.oneDay)); // d.setUTCHours(12, 0, 0, 0)
833
+
834
+ d = d.getTime(); // console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
835
+
835
836
  rangeStart = this.selectedRangeDates[0].getTime();
836
837
  rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime();
837
838
  } else if (this.options.mode === 'year') {
@@ -839,7 +840,9 @@ var WebsyDatePicker = /*#__PURE__*/function () {
839
840
  rangeStart = this.selectedRangeDates[0];
840
841
  rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1];
841
842
  } else if (this.options.mode === 'monthyear') {
842
- d = new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + _i);
843
+ d = this.floorDate(new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + _i));
844
+ d = d.getTime();
845
+ console.log('highlighting', this.selectedRangeDates[0].getTime(), d);
843
846
  rangeStart = this.selectedRangeDates[0].getTime();
844
847
  rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime();
845
848
  } else if (this.options.mode === 'hour') {
@@ -7825,12 +7828,16 @@ var WebsyChart = /*#__PURE__*/function () {
7825
7828
  return d.y.label || d.y.value;
7826
7829
  }).each(function (d, i) {
7827
7830
  if (that.options.orientation === 'horizontal') {
7828
- if (that.options.grouping === 'stacked') {
7831
+ if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
7829
7832
  this.setAttribute('text-anchor', 'middle');
7830
7833
  } else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
7831
7834
  this.setAttribute('text-anchor', 'end');
7832
7835
  this.setAttribute('x', +this.getAttribute('x') - 8);
7833
7836
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color));
7837
+ } else if (series.labelPosition === 'outside') {
7838
+ this.setAttribute('text-anchor', 'start');
7839
+ this.setAttribute('x', +this.getAttribute('x') + 8);
7840
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
7834
7841
  } else {
7835
7842
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
7836
7843
  }
@@ -7846,12 +7853,16 @@ var WebsyChart = /*#__PURE__*/function () {
7846
7853
  return d.y.label || d.y.value;
7847
7854
  }).each(function (d, i) {
7848
7855
  if (that.options.orientation === 'horizontal') {
7849
- if (that.options.grouping === 'stacked') {
7856
+ if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
7850
7857
  this.setAttribute('text-anchor', 'middle');
7851
7858
  } else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
7852
7859
  this.setAttribute('text-anchor', 'end');
7853
7860
  this.setAttribute('x', +this.getAttribute('x') - 8);
7854
7861
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color));
7862
+ } else if (series.labelPosition === 'outside') {
7863
+ this.setAttribute('text-anchor', 'start');
7864
+ this.setAttribute('x', +this.getAttribute('x') + 8);
7865
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
7855
7866
  } else {
7856
7867
  this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
7857
7868
  }
@@ -7864,9 +7875,11 @@ var WebsyChart = /*#__PURE__*/function () {
7864
7875
  }
7865
7876
 
7866
7877
  function getLabelX(d) {
7878
+ var labelPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inside';
7879
+
7867
7880
  if (this.options.orientation === 'horizontal') {
7868
7881
  if (this.options.grouping === 'stacked') {
7869
- return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / 2;
7882
+ return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1);
7870
7883
  } else {
7871
7884
  return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4;
7872
7885
  }
@@ -7876,10 +7889,13 @@ var WebsyChart = /*#__PURE__*/function () {
7876
7889
  }
7877
7890
 
7878
7891
  function getLabelY(d) {
7892
+ var labelPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inside';
7893
+
7879
7894
  if (this.options.orientation === 'horizontal') {
7880
7895
  return this[xAxis](this.parseX(d.x.value)) + this[xAxis].bandwidth() / 2;
7881
7896
  } else {
7882
- if (this.options.grouping === 'stacked') {//
7897
+ if (this.options.grouping === 'stacked') {
7898
+ return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1);
7883
7899
  } else {
7884
7900
  return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - 4;
7885
7901
  }