@esfaenza/es-charts 12.2.8 → 12.2.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.
@@ -58,9 +58,11 @@ class LineChartData {
58
58
  * Costruttore
59
59
  *
60
60
  * @param {LineSerie[]} series Lista di serie da graficare
61
+ * @param {{upper: lower}}
61
62
  */
62
- constructor(series = []) {
63
+ constructor(series = [], limit) {
63
64
  this.series = series;
65
+ this.limit = limit;
64
66
  }
65
67
  }
66
68
 
@@ -212,6 +214,21 @@ class BaseInterval {
212
214
  class LegendPad {
213
215
  }
214
216
 
217
+ /**
218
+ * Modello che identifica un limite superiore - inferiore
219
+ */
220
+ class Limit {
221
+ /** @ignore */
222
+ constructor(upper, upperLabel, upperColor, lower, lowerLabel, lowerColor) {
223
+ this.upper = upper;
224
+ this.upperLabel = upperLabel;
225
+ this.upperColor = upperColor;
226
+ this.lower = lower;
227
+ this.lowerLabel = lowerLabel;
228
+ this.lowerColor = lowerColor;
229
+ }
230
+ }
231
+
215
232
  /**
216
233
  * Modello che identifica la coppia Data-Valore
217
234
  */
@@ -256,15 +273,17 @@ class LineSerie {
256
273
  * @param {string} name Nome della serie
257
274
  * @param {DateValue[]} values Valori della serie
258
275
  * @param {BaseInterval} interval Intervallo della serie. Viene utilizzato per gestire Gap e date in Istante Finale
259
- * @param {string} color Colore della serie, verrà usato sia per la lineaa base che eventualmente per il riempimento (in caso si utilizzi l'Input **Fill** nel grafico)
276
+ * @param {string} color Colore della serie, verrà usato sia per la linea base che eventualmente per il riempimento (in caso si utilizzi l'Input **Fill** nel grafico)
260
277
  * @param {string} uom Unità di misura da presentare nell'asse delle Y
278
+ * @param {boolean} fill Override della proprietà **Fill** del grafico, specifico per ogni serie
261
279
  */
262
- constructor(name, values, interval, color, uom) {
280
+ constructor(name, values, interval, color, uom, fill) {
263
281
  this.name = name;
264
282
  this.values = values;
265
283
  this.interval = interval;
266
284
  this.color = color;
267
285
  this.uom = uom;
286
+ this.fill = fill;
268
287
  }
269
288
  }
270
289
 
@@ -283,7 +302,7 @@ const ESC_THEME = new InjectionToken('ESC_THEME');
283
302
  /**
284
303
  * Token che identifica l'utilizzo o meno del sistema di Log per l'intera libreria
285
304
  */
286
- const ESC_LOGS = new InjectionToken('ESC_LOG');
305
+ const ESC_LOGS = new InjectionToken('ESC_LOGS');
287
306
 
288
307
  /**
289
308
  * Classe che si occupa del dispatch delle operazioni di rendering dei grafici utilizzando una coda per permettere ad ogni grafico di avere temi e localizzazione custom
@@ -630,13 +649,7 @@ class ChartLoader {
630
649
  if (this.logs)
631
650
  console.log("@esfaenza/es-charts: " + text);
632
651
  }
633
- }
634
- ChartLoader.decorators = [
635
- { type: Injectable }
636
- ];
637
- ChartLoader.ctorParameters = () => [
638
- { type: Boolean, decorators: [{ type: Inject, args: [ESC_LOGS,] }] }
639
- ];
652
+ }
640
653
 
641
654
  /**
642
655
  * Componente Grafico Base che gestisce tutte le cose comuni dei vari grafici istanziabili, come la presenza o menu di una legenda,
@@ -966,7 +979,7 @@ class LineChartService {
966
979
  * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un LineChart
967
980
  */
968
981
  graphicate(data, settings) {
969
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
982
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
970
983
  let dataConverted = this.Adapter ? this.Adapter.adaptDataForLineChart(data) : data;
971
984
  let threshold = (_a = settings.DataGroupingThreshold) !== null && _a !== void 0 ? _a : 3000;
972
985
  let singleDataSet = (_b = settings.MergeDatasets) !== null && _b !== void 0 ? _b : false;
@@ -977,7 +990,6 @@ class LineChartService {
977
990
  let interval = seriesWithInterval ? dataConverted.series.find(t => t.interval).interval : null;
978
991
  let gapsAllowed = (settings === null || settings === void 0 ? void 0 : settings.AllowGaps) == null ? seriesWithInterval : settings === null || settings === void 0 ? void 0 : settings.AllowGaps;
979
992
  let finalInstant = (_c = settings === null || settings === void 0 ? void 0 : settings.FinalInstants) !== null && _c !== void 0 ? _c : true;
980
- let fill = (_d = settings === null || settings === void 0 ? void 0 : settings.Fill) !== null && _d !== void 0 ? _d : false;
981
993
  //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
982
994
  am4core.options.autoDispose = true;
983
995
  this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
@@ -991,6 +1003,32 @@ class LineChartService {
991
1003
  yAxis.min = settings.Min;
992
1004
  if (settings.Max)
993
1005
  yAxis.max = settings.Max;
1006
+ if (dataConverted.limit) {
1007
+ if (dataConverted.limit.upper != null && dataConverted.limit.upper != undefined) {
1008
+ let range = yAxis.axisRanges.create();
1009
+ range.value = dataConverted.limit.upper;
1010
+ range.label.inside = true;
1011
+ range.label.text = dataConverted.limit.upperLabel;
1012
+ range.label.fill = range.grid.stroke;
1013
+ range.label.verticalCenter = "bottom";
1014
+ range.label.stroke = am4core.color(dataConverted.limit.upperColor || "#F92200");
1015
+ range.grid.stroke = am4core.color(dataConverted.limit.upperColor || "#F92200");
1016
+ range.grid.strokeWidth = 2;
1017
+ range.grid.strokeOpacity = 1;
1018
+ }
1019
+ if (dataConverted.limit.lower != null && dataConverted.limit.lower != undefined) {
1020
+ let range = yAxis.axisRanges.create();
1021
+ range.value = dataConverted.limit.lower;
1022
+ range.label.inside = true;
1023
+ range.label.text = dataConverted.limit.lowerLabel;
1024
+ range.label.fill = range.grid.stroke;
1025
+ range.label.verticalCenter = "bottom";
1026
+ range.label.stroke = am4core.color(dataConverted.limit.lowerColor || "#F92200");
1027
+ range.grid.stroke = am4core.color(dataConverted.limit.lowerColor || "#F92200");
1028
+ range.grid.strokeWidth = 2;
1029
+ range.grid.strokeOpacity = 1;
1030
+ }
1031
+ }
994
1032
  let dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
995
1033
  if (settings.XAxisTitle) {
996
1034
  dateAxis.title.text = settings.XAxisTitle;
@@ -1004,11 +1042,11 @@ class LineChartService {
1004
1042
  dateAxis.renderer.ticks.template.length = 10;
1005
1043
  dateAxis.renderer.ticks.template.location = 0;
1006
1044
  }
1007
- dateAxis.renderer.minGridDistance = (_e = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _e !== void 0 ? _e : 50;
1045
+ dateAxis.renderer.minGridDistance = (_d = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _d !== void 0 ? _d : 50;
1008
1046
  dateAxis.renderer.grid.template.location = 0;
1009
1047
  dateAxis.minZoomCount = 5;
1010
1048
  dateAxis.groupData = dataShouldBeGrouped;
1011
- dateAxis.groupCount = (_f = settings.DataGroupBucketSize) !== null && _f !== void 0 ? _f : this.DataGroupBucketSize;
1049
+ dateAxis.groupCount = (_e = settings.DataGroupBucketSize) !== null && _e !== void 0 ? _e : this.DataGroupBucketSize;
1012
1050
  //Se ho almeno una serie ad intervallo e i settings non mi impediscono esplicitamente di usare i gaps, visualizzo i dati col gap
1013
1051
  if (gapsAllowed) {
1014
1052
  if (!seriesWithInterval) {
@@ -1052,7 +1090,7 @@ class LineChartService {
1052
1090
  }
1053
1091
  //-- Fine generazione
1054
1092
  dataConverted.series.forEach((s, index) => {
1055
- var _a, _b;
1093
+ var _a, _b, _c;
1056
1094
  if (s.values[0] && !(s.values[0].d instanceof Date)) {
1057
1095
  for (let v = 0; v < s.values.length; v++)
1058
1096
  s.values[v].d = new Date(s.values[v].d);
@@ -1069,12 +1107,13 @@ class LineChartService {
1069
1107
  }
1070
1108
  if (!correctOrder)
1071
1109
  s.values.sort((d1, d2) => d1.d.getTime() - d2.d.getTime());
1110
+ let fill = s.fill != null && s.fill != undefined ? s.fill : ((_a = settings === null || settings === void 0 ? void 0 : settings.Fill) !== null && _a !== void 0 ? _a : false);
1072
1111
  let series = (settings === null || settings === void 0 ? void 0 : settings.Step) ? new am4charts.StepLineSeries() : new am4charts.LineSeries();
1073
1112
  series.dataFields.valueY = "v" + (singleDataSet ? index : "");
1074
1113
  series.dataFields.dateX = "d";
1075
1114
  series.dataFields.measureUnit = s.uom;
1076
1115
  series.name = s.name;
1077
- series.strokeWidth = (_a = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _a !== void 0 ? _a : 1;
1116
+ series.strokeWidth = (_b = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _b !== void 0 ? _b : 1;
1078
1117
  series.connect = !gapsAllowed;
1079
1118
  series.minBulletDistance = 10;
1080
1119
  series.tooltipText = singleDataSet ? "" : "{name}: [bold]{valueY}[/]";
@@ -1125,7 +1164,7 @@ class LineChartService {
1125
1164
  series.data = s.values;
1126
1165
  let segment = series.segments.template;
1127
1166
  let hoverState = segment.states.create("hover");
1128
- hoverState.properties.strokeWidth = ((_b = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _b !== void 0 ? _b : 1) + 1;
1167
+ hoverState.properties.strokeWidth = ((_c = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _c !== void 0 ? _c : 1) + 1;
1129
1168
  let dimmed = segment.states.create("dimmed");
1130
1169
  dimmed.properties.stroke = am4core.color("#dadada");
1131
1170
  //Se la serie ha un colore, uso quello, altrimenti pesco dai colori di default andando in ordine
@@ -1146,17 +1185,17 @@ class LineChartService {
1146
1185
  });
1147
1186
  if (settings.Legend) {
1148
1187
  this.ChartInstance.legend = new am4charts.Legend();
1149
- this.ChartInstance.legend.position = (_g = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _g !== void 0 ? _g : 'right';
1188
+ this.ChartInstance.legend.position = (_f = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _f !== void 0 ? _f : 'right';
1150
1189
  this.ChartInstance.legend.scrollable = true;
1151
1190
  this.ChartInstance.legend.itemContainers.template.tooltipText = "{name}";
1152
- this.ChartInstance.legend.itemContainers.template.events.on("over", (event) => { this.processOver(event.target.dataItem.dataContext, fill); });
1153
- this.ChartInstance.legend.itemContainers.template.events.on("out", (event) => { this.processOut(fill); });
1191
+ this.ChartInstance.legend.itemContainers.template.events.on("over", (event) => { this.processOver(event.target.dataItem.dataContext); });
1192
+ this.ChartInstance.legend.itemContainers.template.events.on("out", () => { this.processOut(); });
1154
1193
  if (settings.LegendPadding) {
1155
1194
  let template = this.ChartInstance.legend.itemContainers.template;
1156
- template.paddingTop = (_h = settings.LegendPadding.top) !== null && _h !== void 0 ? _h : 0;
1157
- template.paddingBottom = (_j = settings.LegendPadding.bottom) !== null && _j !== void 0 ? _j : 0;
1158
- template.paddingLeft = (_k = settings.LegendPadding.left) !== null && _k !== void 0 ? _k : 0;
1159
- template.paddingRight = (_l = settings.LegendPadding.right) !== null && _l !== void 0 ? _l : 0;
1195
+ template.paddingTop = (_g = settings.LegendPadding.top) !== null && _g !== void 0 ? _g : 0;
1196
+ template.paddingBottom = (_h = settings.LegendPadding.bottom) !== null && _h !== void 0 ? _h : 0;
1197
+ template.paddingLeft = (_j = settings.LegendPadding.left) !== null && _j !== void 0 ? _j : 0;
1198
+ template.paddingRight = (_k = settings.LegendPadding.right) !== null && _k !== void 0 ? _k : 0;
1160
1199
  }
1161
1200
  }
1162
1201
  this.ChartInstance.cursor = new am4charts.XYCursor();
@@ -1199,8 +1238,9 @@ class LineChartService {
1199
1238
  }
1200
1239
  }
1201
1240
  /** @ignore */
1202
- processOver(hoveredSeries, fill) {
1241
+ processOver(hoveredSeries) {
1203
1242
  hoveredSeries.toFront();
1243
+ let fill = hoveredSeries.stacked;
1204
1244
  hoveredSeries.segments.each((segment) => {
1205
1245
  segment.setState("hover");
1206
1246
  if (!fill)
@@ -1209,17 +1249,20 @@ class LineChartService {
1209
1249
  if (!fill)
1210
1250
  hoveredSeries.legendDataItem.marker.children.getIndex(1).fillOpacity = this.OpacityOnSelected;
1211
1251
  this.ChartInstance.series.each((series) => {
1212
- if (series != hoveredSeries)
1252
+ if (series != hoveredSeries) {
1253
+ let fill = series.stacked;
1213
1254
  series.segments.each((segment) => {
1214
1255
  segment.setState("dimmed");
1215
1256
  if (!fill)
1216
1257
  segment.fillSprite.fillOpacity = 0;
1217
1258
  });
1259
+ }
1218
1260
  });
1219
1261
  }
1220
1262
  /** @ignore */
1221
- processOut(fill) {
1263
+ processOut() {
1222
1264
  this.ChartInstance.series.each((series) => {
1265
+ let fill = series.stacked;
1223
1266
  series.segments.each((segment) => {
1224
1267
  segment.setState("default");
1225
1268
  if (!fill)
@@ -1978,10 +2021,9 @@ class EsAreaChartComponent extends BaseChartComponent {
1978
2021
  /**
1979
2022
  * @ignore
1980
2023
  */
1981
- constructor(el, ChartLoader, ChartDispatcher, adapter, dateService, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_LOCALE, ESC_THEME) {
2024
+ constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_LOCALE, ESC_THEME) {
1982
2025
  super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, ESC_LOCALE, ESC_THEME);
1983
2026
  this.adapter = adapter;
1984
- this.dateService = dateService;
1985
2027
  }
1986
2028
  /**
1987
2029
  * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
@@ -2028,7 +2070,6 @@ EsAreaChartComponent.ctorParameters = () => [
2028
2070
  { type: ChartLoader },
2029
2071
  { type: ChartDispatcher },
2030
2072
  { type: BaseAdapter },
2031
- { type: DateService },
2032
2073
  { type: NgZone },
2033
2074
  { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] },
2034
2075
  { type: Boolean, decorators: [{ type: Inject, args: [ESC_LOGS,] }] },
@@ -2572,7 +2613,9 @@ class EsChartsModule {
2572
2613
  { provide: ESC_ANIMATIONS, useValue: (config === null || config === void 0 ? void 0 : config.animations) == null ? true : config === null || config === void 0 ? void 0 : config.animations },
2573
2614
  { provide: ESC_THEME, useValue: (config === null || config === void 0 ? void 0 : config.theme) || 'spiritedaway' },
2574
2615
  { provide: ESC_LOGS, useValue: (config === null || config === void 0 ? void 0 : config.debugMode) == null ? false : config === null || config === void 0 ? void 0 : config.debugMode },
2575
- { provide: BaseAdapter, useClass: (config === null || config === void 0 ? void 0 : config.adapter) || BaseAdapter }
2616
+ { provide: BaseAdapter, useClass: (config === null || config === void 0 ? void 0 : config.adapter) || BaseAdapter },
2617
+ // Singleton cattiva by Ema. Verificare strade migliori
2618
+ { provide: ChartLoader, useValue: new ChartLoader((config === null || config === void 0 ? void 0 : config.debugMode) == null ? false : config === null || config === void 0 ? void 0 : config.debugMode) }
2576
2619
  ]
2577
2620
  };
2578
2621
  }
@@ -2581,7 +2624,7 @@ EsChartsModule.decorators = [
2581
2624
  { type: NgModule, args: [{
2582
2625
  imports: [CommonModule],
2583
2626
  declarations: [...COMPONENTS],
2584
- providers: [ChartLoader, ChartDispatcher],
2627
+ providers: [ChartDispatcher],
2585
2628
  exports: [...COMPONENTS]
2586
2629
  },] }
2587
2630
  ];
@@ -2594,5 +2637,5 @@ EsChartsModule.decorators = [
2594
2637
  * Generated bundle index. Do not edit.
2595
2638
  */
2596
2639
 
2597
- export { AreaChartData, AreaChartSettings, BaseAdapter, BaseInterval, BaseSettings, ChartThemes, DateValue, EsAreaChartComponent, EsChartComponent, EsChartsModule, EsLineChartComponent, EsPieChartComponent, EsVertical2DChartComponent, EsVerticalChartComponent, EsVerticalStackedChartComponent, KeyValue, KeyValueColor, LegendPad, LineChartData, LineChartSettings, LineSerie, PagedChartData, PieChartData, PieChartSettings, Vertical2DChartData, Vertical2DChartSettings, VerticalChartData, VerticalChartSettings, VerticalStackedChartData, VerticalStackedChartSettings, BaseInterval as ɵa, BaseChartComponent as ɵb, ChartLoader as ɵc, ChartDispatcher as ɵd, ESC_LOCALE as ɵe, ESC_ANIMATIONS as ɵf, ESC_THEME as ɵg, ESC_LOGS as ɵh, BaseAdapter as ɵi, EsChartComponent as ɵj, EsLineChartComponent as ɵk, EsPieChartComponent as ɵl, EsVertical2DChartComponent as ɵm, EsVerticalChartComponent as ɵn, EsVerticalStackedChartComponent as ɵo, PageChartSelector as ɵp, EsAreaChartComponent as ɵq };
2640
+ export { AreaChartData, AreaChartSettings, BaseAdapter, BaseInterval, BaseSettings, ChartThemes, DateValue, EsAreaChartComponent, EsChartComponent, EsChartsModule, EsLineChartComponent, EsPieChartComponent, EsVertical2DChartComponent, EsVerticalChartComponent, EsVerticalStackedChartComponent, KeyValue, KeyValueColor, LegendPad, Limit, LineChartData, LineChartSettings, LineSerie, PagedChartData, PieChartData, PieChartSettings, Vertical2DChartData, Vertical2DChartSettings, VerticalChartData, VerticalChartSettings, VerticalStackedChartData, VerticalStackedChartSettings, BaseInterval as ɵa, BaseChartComponent as ɵb, ChartLoader as ɵc, ChartDispatcher as ɵd, ESC_LOCALE as ɵe, ESC_ANIMATIONS as ɵf, ESC_THEME as ɵg, ESC_LOGS as ɵh, BaseAdapter as ɵi, EsChartComponent as ɵj, EsLineChartComponent as ɵk, EsPieChartComponent as ɵl, EsVertical2DChartComponent as ɵm, EsVerticalChartComponent as ɵn, EsVerticalStackedChartComponent as ɵo, PageChartSelector as ɵp, EsAreaChartComponent as ɵq };
2598
2641
  //# sourceMappingURL=esfaenza-es-charts.js.map