@esfaenza/es-charts 13.1.7 → 13.1.8

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.
@@ -223,13 +223,14 @@ class LegendPad {
223
223
  */
224
224
  class Limit {
225
225
  /** @ignore */
226
- constructor(upper, upperlabel, uppercolor, lower, lowerlabel, lowercolor) {
226
+ constructor(upper, upperlabel, uppercolor, lower, lowerlabel, lowercolor, fillColor = "") {
227
227
  this.upper = upper;
228
228
  this.upperlabel = upperlabel;
229
229
  this.uppercolor = uppercolor;
230
230
  this.lower = lower;
231
231
  this.lowerlabel = lowerlabel;
232
232
  this.lowercolor = lowercolor;
233
+ this.fillColor = fillColor;
233
234
  }
234
235
  }
235
236
 
@@ -1008,6 +1009,15 @@ class BaseChartComponent {
1008
1009
  if (this.logs)
1009
1010
  console.log("@esfaenza/es-charts: " + log);
1010
1011
  }
1012
+ /**
1013
+ * Imposta lo zoom dal **from** al **to**
1014
+ *
1015
+ * @param {Date} from Inizio dello zoom
1016
+ * @param {Date} to Fine dello zoom
1017
+ */
1018
+ setSelection(from, to) {
1019
+ this.ChartService.setSelection(from, to);
1020
+ }
1011
1021
  /**
1012
1022
  * @ignore
1013
1023
  */
@@ -1123,33 +1133,57 @@ class LineChartService {
1123
1133
  yAxis.min = settings.Min;
1124
1134
  if (settings.Max)
1125
1135
  yAxis.max = settings.Max;
1126
- if (dataConverted.limit) {
1127
- if (dataConverted.limit.upper != null && dataConverted.limit.upper != undefined) {
1128
- let range = yAxis.axisRanges.create();
1129
- range.value = dataConverted.limit.upper;
1130
- range.label.inside = true;
1131
- range.label.text = dataConverted.limit.upperlabel;
1132
- range.label.fill = range.grid.stroke;
1133
- range.label.verticalCenter = "bottom";
1134
- range.label.stroke = am4core.color(dataConverted.limit.uppercolor || "#F92200");
1135
- range.grid.stroke = am4core.color(dataConverted.limit.uppercolor || "#F92200");
1136
- range.grid.strokeWidth = 2;
1137
- range.grid.strokeOpacity = 1;
1138
- }
1139
- if (dataConverted.limit.lower != null && dataConverted.limit.lower != undefined) {
1140
- let range = yAxis.axisRanges.create();
1141
- range.value = dataConverted.limit.lower;
1142
- range.label.inside = true;
1143
- range.label.text = dataConverted.limit.lowerlabel;
1144
- range.label.fill = range.grid.stroke;
1145
- range.label.verticalCenter = "bottom";
1146
- range.label.stroke = am4core.color(dataConverted.limit.lowercolor || "#F92200");
1147
- range.grid.stroke = am4core.color(dataConverted.limit.lowercolor || "#F92200");
1148
- range.grid.strokeWidth = 2;
1149
- range.grid.strokeOpacity = 1;
1136
+ let limitNullOrUndef = dataConverted.limit == null || dataConverted.limit == undefined;
1137
+ let limits = limitNullOrUndef ? [] : !dataConverted.limit.length ? [dataConverted.limit] : dataConverted.limit;
1138
+ if (limits.length > 0) {
1139
+ for (let i = 0; i < limits.length; i++) {
1140
+ let limit = limits[i];
1141
+ if (limit.upper != null && limit.upper != undefined && limit.lower != null && limit.lower != undefined) {
1142
+ let range = yAxis.axisRanges.create();
1143
+ range.value = limit.lower;
1144
+ range.endValue = limit.upper;
1145
+ if (limit.fillColor) {
1146
+ range.contents.stroke = am4core.color(limit.fillColor);
1147
+ range.contents.fill = range.contents.stroke;
1148
+ }
1149
+ range.label.inside = true;
1150
+ range.label.text = limit.upperlabel;
1151
+ range.label.fill = range.grid.stroke;
1152
+ range.label.verticalCenter = "bottom";
1153
+ range.label.stroke = am4core.color(limit.uppercolor || "#F92200");
1154
+ range.grid.stroke = am4core.color(limit.uppercolor || "#F92200");
1155
+ range.grid.strokeWidth = 2;
1156
+ range.grid.strokeOpacity = 1;
1157
+ }
1158
+ else if ((limit.lower == null || limit.lower == undefined) && limit.upper != null && limit.upper != undefined) {
1159
+ let range = yAxis.axisRanges.create();
1160
+ range.value = limit.upper;
1161
+ range.label.inside = true;
1162
+ range.label.text = limit.upperlabel;
1163
+ range.label.fill = range.grid.stroke;
1164
+ range.label.verticalCenter = "bottom";
1165
+ range.label.stroke = am4core.color(limit.uppercolor || "#F92200");
1166
+ range.grid.stroke = am4core.color(limit.uppercolor || "#F92200");
1167
+ range.grid.strokeWidth = 2;
1168
+ range.grid.strokeOpacity = 1;
1169
+ }
1170
+ else if ((limit.upper == null || limit.upper == undefined) && limit.lower != null && limit.lower != undefined) {
1171
+ let range = yAxis.axisRanges.create();
1172
+ range.value = limit.lower;
1173
+ range.label.inside = true;
1174
+ range.label.text = limit.lowerlabel;
1175
+ range.label.fill = range.grid.stroke;
1176
+ range.label.verticalCenter = "bottom";
1177
+ range.label.stroke = am4core.color(limit.lowercolor || "#F92200");
1178
+ range.grid.stroke = am4core.color(limit.lowercolor || "#F92200");
1179
+ range.grid.strokeWidth = 2;
1180
+ range.grid.strokeOpacity = 1;
1181
+ }
1150
1182
  }
1151
1183
  }
1152
- let dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
1184
+ this.dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
1185
+ // Per comatibilità col codice scritto quando non era a livello globale, mi scoccia sostituire
1186
+ let dateAxis = this.dateAxis;
1153
1187
  if (settings.XAxisTitle) {
1154
1188
  dateAxis.title.text = settings.XAxisTitle;
1155
1189
  dateAxis.title.fontWeight = "bold";
@@ -1319,6 +1353,10 @@ class LineChartService {
1319
1353
  return this;
1320
1354
  }
1321
1355
  /** @ignore */
1356
+ setSelection(from, to) {
1357
+ this.dateAxis.zoomToDates(from, to, true, true);
1358
+ }
1359
+ /** @ignore */
1322
1360
  refreshData(data) {
1323
1361
  let dataConverted = this.Adapter ? this.Adapter.adaptDataForLineChart(data) : data;
1324
1362
  if (this.singleDataSet) {
@@ -1509,6 +1547,9 @@ class PieChartService {
1509
1547
  return this;
1510
1548
  }
1511
1549
  /** @ignore */
1550
+ setSelection(from, to) {
1551
+ }
1552
+ /** @ignore */
1512
1553
  refreshData(data) {
1513
1554
  //TODO:IMPL
1514
1555
  }
@@ -1617,6 +1658,9 @@ class VerticalChartService {
1617
1658
  return this;
1618
1659
  }
1619
1660
  /** @ignore */
1661
+ setSelection(from, to) {
1662
+ }
1663
+ /** @ignore */
1620
1664
  refreshData(data) {
1621
1665
  //TODO:IMPL
1622
1666
  }
@@ -1728,6 +1772,9 @@ class Vertical2DChartService {
1728
1772
  return this;
1729
1773
  }
1730
1774
  /** @ignore */
1775
+ setSelection(from, to) {
1776
+ }
1777
+ /** @ignore */
1731
1778
  refreshData(data) {
1732
1779
  //TODO:IMPL
1733
1780
  }
@@ -1882,6 +1929,9 @@ class VerticalStackedChartService {
1882
1929
  return this;
1883
1930
  }
1884
1931
  /** @ignore */
1932
+ setSelection(from, to) {
1933
+ }
1934
+ /** @ignore */
1885
1935
  refreshData(data) {
1886
1936
  //TODO:IMPL
1887
1937
  }
@@ -1993,6 +2043,9 @@ class AreaChartService {
1993
2043
  return this;
1994
2044
  }
1995
2045
  /** @ignore */
2046
+ setSelection(from, to) {
2047
+ }
2048
+ /** @ignore */
1996
2049
  refreshData(data) {
1997
2050
  //TODO:IMPL
1998
2051
  }