@esfaenza/es-charts 13.3.3 → 13.3.4

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.
@@ -107,12 +107,12 @@ class Vertical2DChartData {
107
107
  /**
108
108
  * Costruttore
109
109
  *
110
- * @param {{ name: string; values: KeyValue[]; }[]} groups Gruppi di valori raggruppati per nome
111
- * @param {{ color: string }[]} colorInfos Lista dei colori da utilizzare. Vanno a sovrascrivere quelli di default di amcharts
110
+ * @param {{ name: string; values: KeyValue[];, uom: string }[]} groups Gruppi di valori raggruppati per nome
111
+ * @param {{ color: string }[]} colorinfos Lista dei colori da utilizzare. Vanno a sovrascrivere quelli di default di amcharts
112
112
  */
113
- constructor(groups = [], colorInfos) {
113
+ constructor(groups = [], colorinfos) {
114
114
  this.groups = groups;
115
- this.colorInfos = colorInfos;
115
+ this.colorinfos = colorinfos;
116
116
  }
117
117
  }
118
118
 
@@ -123,7 +123,7 @@ class VerticalChartData {
123
123
  /**
124
124
  * Costruttore
125
125
  *
126
- * @param {KeyValue[]} values Lista di Chiave-Valore che rappresentano ognuno una colonna
126
+ * @param {KeyValueColor[]} values Lista di Chiave-Valore-Colore che rappresentano ognuno una colonna
127
127
  */
128
128
  constructor(values = []) {
129
129
  this.values = values;
@@ -137,7 +137,7 @@ class VerticalStackedChartData {
137
137
  /**
138
138
  * Costruttore
139
139
  *
140
- * @param {{ name: string; values: KeyValue[]; }[]} groups Gruppi di valori raggruppati per nome
140
+ * @param {{ name: string; values: KeyValue[], uom: string }[]} groups Gruppi di valori raggruppati per nome
141
141
  */
142
142
  constructor(groups = []) {
143
143
  this.groups = groups;
@@ -261,10 +261,11 @@ class KeyValue {
261
261
  */
262
262
  class KeyValueColor {
263
263
  /** @ignore */
264
- constructor(k, v, c) {
264
+ constructor(k, v, c, t) {
265
265
  this.k = k;
266
266
  this.v = v;
267
267
  this.c = c;
268
+ this.t = t;
268
269
  }
269
270
  }
270
271
 
@@ -281,14 +282,18 @@ class LineSerie {
281
282
  * @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)
282
283
  * @param {string} uom Unità di misura da presentare nell'asse delle Y
283
284
  * @param {boolean} fill Override della proprietà **Fill** del grafico, specifico per ogni serie
285
+ * @param {boolean} stacked Override della proprietà **Stacked** del grafico, specifico per ogni serie
286
+ * @param {boolean} hidden Indica se la serie deve partire nascosta di default
284
287
  */
285
- constructor(name, values, interval, color, uom, fill) {
288
+ constructor(name, values, interval, color, uom, fill, stacked, hidden) {
286
289
  this.name = name;
287
290
  this.values = values;
288
291
  this.interval = interval;
289
292
  this.color = color;
290
293
  this.uom = uom;
291
294
  this.fill = fill;
295
+ this.stacked = stacked;
296
+ this.hidden = hidden;
292
297
  }
293
298
  }
294
299
 
@@ -1100,6 +1105,8 @@ class LineChartService {
1100
1105
  /** @ignore */
1101
1106
  this.OpacityOnSelected = 0.3;
1102
1107
  /** @ignore */
1108
+ this.OpacityOnFill = 0.75;
1109
+ /** @ignore */
1103
1110
  this.singleDataSet = false;
1104
1111
  //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
1105
1112
  //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
@@ -1214,14 +1221,8 @@ class LineChartService {
1214
1221
  let seriesToPush = [];
1215
1222
  let seriesColors = [];
1216
1223
  let defaultIndex = 0;
1217
- //-- Generazione di un unico dataset invece che N, per poter gestire un unico tooltip
1218
- if (this.singleDataSet) {
1219
- this.ChartInstance.data = this.generateSingleDataset(dataConverted);
1220
- ;
1221
- dateAxis.cursorTooltipEnabled = false;
1222
- }
1223
- //-- Fine generazione
1224
- dataConverted.series.forEach((s, index) => {
1224
+ // Ordinamento dei dati se serve
1225
+ dataConverted.series.forEach((s) => {
1225
1226
  if (s.values[0] && !(s.values[0].d instanceof Date)) {
1226
1227
  for (let v = 0; v < s.values.length; v++)
1227
1228
  s.values[v].d = new Date(s.values[v].d);
@@ -1238,11 +1239,20 @@ class LineChartService {
1238
1239
  }
1239
1240
  if (!correctOrder)
1240
1241
  s.values.sort((d1, d2) => d1.d.getTime() - d2.d.getTime());
1241
- let fill = s.fill != null && s.fill != undefined ? s.fill : (settings?.Fill ?? false);
1242
+ });
1243
+ // Generazione di un unico dataset invece che N, per poter gestire un unico tooltip
1244
+ if (this.singleDataSet) {
1245
+ this.ChartInstance.data = this.generateSingleDataset(dataConverted);
1246
+ ;
1247
+ dateAxis.cursorTooltipEnabled = false;
1248
+ }
1249
+ dataConverted.series.forEach((s, index) => {
1250
+ let stacked = s.stacked != null && s.stacked != undefined ? s.stacked : (settings?.Stacked ?? false);
1251
+ let fill = stacked || (s.fill != null && s.fill != undefined ? s.fill : (settings?.Fill ?? false));
1242
1252
  let series = settings?.Step ? new am4charts.StepLineSeries() : new am4charts.LineSeries();
1243
1253
  series.dataFields.valueY = "v" + (this.singleDataSet ? index : "");
1244
1254
  series.dataFields.dateX = "d";
1245
- series.dataFields.measureUnit = s.uom;
1255
+ series.measureUnit = s.uom;
1246
1256
  series.name = s.name;
1247
1257
  series.strokeWidth = settings?.StrokeSize ?? 1;
1248
1258
  series.connect = !gapsAllowed;
@@ -1251,8 +1261,9 @@ class LineChartService {
1251
1261
  series.tooltip.pointerOrientation = "vertical";
1252
1262
  series.tooltip.background.fillOpacity = 0.5;
1253
1263
  series.tooltip.label.padding(12, 12, 12, 12);
1254
- series.fillOpacity = fill ? 1 : 0.0001;
1255
- series.stacked = fill;
1264
+ series.fillOpacity = fill ? this.OpacityOnFill : 0.0001;
1265
+ series.stacked = stacked;
1266
+ series.hidden = s.hidden;
1256
1267
  //Dataset singolo, i dati sono registrati a livello di chart, creo il tooltip che permette di vederli tutti insieme
1257
1268
  //altrimenti assegno i dati della serie direttamente alla serie
1258
1269
  if (this.singleDataSet) {
@@ -1263,7 +1274,7 @@ class LineChartService {
1263
1274
  series.tooltip.hiddenState.transitionDuration = 0;
1264
1275
  //Utilizzo il mio dateService per la formattazione della data in modo che non debba mai gestire n formati fra n librerie... bellissimo
1265
1276
  series.dateFormatter.format = (source) => {
1266
- if (interval && finalInstant) {
1277
+ if (interval && finalInstant && ["hour", "minute", "second"].includes(interval.timeunit)) {
1267
1278
  let timepart = null;
1268
1279
  switch (interval.timeunit) {
1269
1280
  case "hour":
@@ -1280,12 +1291,12 @@ class LineChartService {
1280
1291
  return this.dateExts.adjustDateToFinalInstant(source, timepart, interval ? interval.timeunit == "second" : false);
1281
1292
  }
1282
1293
  else
1283
- return this.dateExts.getFormatted(source, false, interval ? interval.timeunit == "second" : false);
1294
+ return this.dateExts.getFormatted(source, interval ? ["day", "week", "month", "year"].includes(interval.timeunit) : false, interval ? interval.timeunit == "second" : false);
1284
1295
  };
1285
1296
  series.adapter.add("tooltipText", () => {
1286
1297
  var text = "[bold]{dateX.formatDate()}[/]\n";
1287
1298
  this.ChartInstance.series.each((item) => {
1288
- let uom = " [font-style: italic]" + series.dataFields.measureUnit || "" + "[/]";
1299
+ let uom = " [font-style: italic]" + series.measureUnit || "" + "[/]";
1289
1300
  text += "[" + item.stroke.hex + "]●[/] " + (item.name ? (item.name + ": ") : "") + "[bold]{" + item.dataFields.valueY + "}[/]" + uom + "\n";
1290
1301
  });
1291
1302
  return text;
@@ -1407,8 +1418,8 @@ class LineChartService {
1407
1418
  }
1408
1419
  /** @ignore */
1409
1420
  processOver(hoveredSeries) {
1410
- hoveredSeries.toFront();
1411
- let fill = hoveredSeries.stacked;
1421
+ hoveredSeries.zIndex = 999;
1422
+ let fill = hoveredSeries.fillOpacity == this.OpacityOnFill;
1412
1423
  hoveredSeries.segments.each((segment) => {
1413
1424
  segment.setState("hover");
1414
1425
  if (!fill)
@@ -1418,7 +1429,7 @@ class LineChartService {
1418
1429
  hoveredSeries.legendDataItem.marker.children.getIndex(1).fillOpacity = this.OpacityOnSelected;
1419
1430
  this.ChartInstance.series.each((series) => {
1420
1431
  if (series != hoveredSeries) {
1421
- let fill = series.stacked;
1432
+ let fill = series.fillOpacity == this.OpacityOnFill;
1422
1433
  series.segments.each((segment) => {
1423
1434
  segment.setState("dimmed");
1424
1435
  if (!fill)
@@ -1429,8 +1440,9 @@ class LineChartService {
1429
1440
  }
1430
1441
  /** @ignore */
1431
1442
  processOut() {
1432
- this.ChartInstance.series.each((series) => {
1433
- let fill = series.stacked;
1443
+ this.ChartInstance.series.each((series, i) => {
1444
+ series.zIndex = i;
1445
+ let fill = series.fillOpacity == this.OpacityOnFill;
1434
1446
  series.segments.each((segment) => {
1435
1447
  segment.setState("default");
1436
1448
  if (!fill)
@@ -1594,6 +1606,7 @@ class VerticalChartService {
1594
1606
  let ChartInstanceCasted = this.ChartInstance;
1595
1607
  let dataConverted = this.Adapter ? this.Adapter.adaptDataForVerticalChart(data) : data;
1596
1608
  ChartInstanceCasted.data = dataConverted.values;
1609
+ let noStrokes = dataConverted.values.some(t => !!t.c);
1597
1610
  if (settings.Legend) {
1598
1611
  ChartInstanceCasted.legend = new am4charts.Legend();
1599
1612
  ChartInstanceCasted.legend.position = settings?.LegendPosition ?? 'right';
@@ -1649,12 +1662,19 @@ class VerticalChartService {
1649
1662
  series.dataFields.valueY = "v";
1650
1663
  series.dataFields.categoryX = "k";
1651
1664
  series.name = "";
1652
- series.columns.template.tooltipText = "{categoryX}: [bold]{valueY}[/]";
1653
- series.columns.template.fillOpacity = .8;
1654
- series.columns.template.width = am4core.percent(settings.ColumnWidthPercentage ?? this.DefaultColumnWidthPercentage);
1655
1665
  let columnTemplate = series.columns.template;
1656
- columnTemplate.strokeWidth = 2;
1657
- columnTemplate.strokeOpacity = 1;
1666
+ columnTemplate.tooltipText = "{categoryX}: [bold]{valueY}[/] {t}";
1667
+ columnTemplate.fillOpacity = .8;
1668
+ columnTemplate.width = am4core.percent(settings.ColumnWidthPercentage ?? this.DefaultColumnWidthPercentage);
1669
+ if (noStrokes) {
1670
+ columnTemplate.strokeOpacity = 0;
1671
+ columnTemplate.strokeWidth = 0;
1672
+ columnTemplate.adapter.add("fill", (_, target) => am4core.color(target.dataItem.dataContext.c));
1673
+ }
1674
+ else {
1675
+ columnTemplate.strokeWidth = 2;
1676
+ columnTemplate.strokeOpacity = 1;
1677
+ }
1658
1678
  return this;
1659
1679
  }
1660
1680
  /** @ignore */
@@ -1763,8 +1783,8 @@ class Vertical2DChartService {
1763
1783
  dataConverted.push(obj);
1764
1784
  }
1765
1785
  ChartInstanceCasted.data = dataConverted;
1766
- if (dataPreConverted.colorInfos)
1767
- ChartInstanceCasted.colors.list = dataPreConverted.colorInfos.map(c => am4core.color(c.color));
1786
+ if (dataPreConverted.colorinfos)
1787
+ ChartInstanceCasted.colors.list = dataPreConverted.colorinfos.map(c => am4core.color(c.color));
1768
1788
  //Prendo la prima categoria e mi baso sulle proprietà per dfeinire le serie
1769
1789
  for (let prop in dataConverted[0])
1770
1790
  if (prop !== "key")
@@ -2271,7 +2291,7 @@ class EsLineChartComponent extends BaseChartComponent {
2271
2291
  * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
2272
2292
  */
2273
2293
  getSpecificPropertiesToCheck() {
2274
- return ["Data", "DataArray", "Step", "DataGroupBucketSize", "DataGroupingThreshold", "StrokeSize", "AllowGaps", "MergeDatasets", "FinalInstants", "Fill", "Min", "Max"];
2294
+ return ["Data", "DataArray", "Step", "DataGroupBucketSize", "DataGroupingThreshold", "StrokeSize", "Stacked", "AllowGaps", "MergeDatasets", "FinalInstants", "Fill", "Min", "Max"];
2275
2295
  }
2276
2296
  /**
2277
2297
  * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
@@ -2297,6 +2317,7 @@ class EsLineChartComponent extends BaseChartComponent {
2297
2317
  settingsCasted.Min = settingsCasted.Min != null ? settingsCasted.Min : this.Min;
2298
2318
  settingsCasted.Max = settingsCasted.Max != null ? settingsCasted.Max : this.Max;
2299
2319
  settingsCasted.Fill = settingsCasted.Fill != null ? settingsCasted.Fill : this.Fill;
2320
+ settingsCasted.Stacked = settingsCasted.Stacked != null ? settingsCasted.Stacked : this.Stacked;
2300
2321
  }
2301
2322
  /**
2302
2323
  * Effettua il rendering di questo grafico in base ai Settings
@@ -2309,7 +2330,7 @@ class EsLineChartComponent extends BaseChartComponent {
2309
2330
  }
2310
2331
  }
2311
2332
  EsLineChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsLineChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i3.DateService }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_LOCALE }, { token: ESC_THEME }], target: i0.ɵɵFactoryTarget.Component });
2312
- EsLineChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: EsLineChartComponent, selector: "es-line-chart", inputs: { Data: "Data", DataArray: "DataArray", Step: "Step", DataGroupBucketSize: "DataGroupBucketSize", DataGroupingThreshold: "DataGroupingThreshold", StrokeSize: "StrokeSize", AllowGaps: "AllowGaps", MergeDatasets: "MergeDatasets", FinalInstants: "FinalInstants", Min: "Min", Max: "Max", Fill: "Fill" }, usesInheritance: true, ngImport: i0, template: "<chart-pager *ngIf=\"isPaged\" (onPageChange)=\"changePage($event)\" [Items]=\"DataArray\" [Dtos]=\"DataDtos\" [StartIndex]=\"DataDtoStartIndex\"\r\n [BrowseDelayMs]=\"BrowseDelayMs\">\r\n <ng-template #header_inner let-headerItem>\r\n <ng-container *ngTemplateOutlet=\"header_tr; context : {$implicit: headerItem}\"></ng-container>\r\n </ng-template>\r\n</chart-pager>\r\n\r\n<ng-container *ngIf=\"loadingChart && loading_template\">\r\n <div style=\"width: 100%;\" [style.height]=\"isPaged ? 'calc(100% - 44px)' : '100%'\">\r\n <ng-container *ngTemplateOutlet=\"loading_template\"></ng-container>\r\n </div>\r\n</ng-container>\r\n\r\n<ng-container *ngIf=\"loadingChart && !loading_template\">\r\n <div class=\"esc-loading-overlay\" style=\"width: 100%;\" [style.height]=\"isPaged ? 'calc(100% - 44px)' : '100%'\">\r\n <p class=\"label\">Loading....</p>\r\n </div>\r\n</ng-container>\r\n\r\n<div [class.hide-block]=\"loadingChart\" id=\"{{name}}\" style=\"width: 100%;\" [style.height]=\"isPaged ? 'calc(100% - 44px)' : '100%'\"></div>", styles: [".esc-loading-overlay{background:#9999;text-transform:uppercase;font-size:30px;font-weight:700;color:#fff;text-align:center;font-family:monospace}.esc-loading-overlay .label{margin:0;padding-top:7%}.hide-block{display:none}\n"], components: [{ type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2333
+ EsLineChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: EsLineChartComponent, selector: "es-line-chart", inputs: { Data: "Data", DataArray: "DataArray", Step: "Step", DataGroupBucketSize: "DataGroupBucketSize", DataGroupingThreshold: "DataGroupingThreshold", StrokeSize: "StrokeSize", AllowGaps: "AllowGaps", MergeDatasets: "MergeDatasets", FinalInstants: "FinalInstants", Min: "Min", Max: "Max", Fill: "Fill", Stacked: "Stacked" }, usesInheritance: true, ngImport: i0, template: "<chart-pager *ngIf=\"isPaged\" (onPageChange)=\"changePage($event)\" [Items]=\"DataArray\" [Dtos]=\"DataDtos\" [StartIndex]=\"DataDtoStartIndex\"\r\n [BrowseDelayMs]=\"BrowseDelayMs\">\r\n <ng-template #header_inner let-headerItem>\r\n <ng-container *ngTemplateOutlet=\"header_tr; context : {$implicit: headerItem}\"></ng-container>\r\n </ng-template>\r\n</chart-pager>\r\n\r\n<ng-container *ngIf=\"loadingChart && loading_template\">\r\n <div style=\"width: 100%;\" [style.height]=\"isPaged ? 'calc(100% - 44px)' : '100%'\">\r\n <ng-container *ngTemplateOutlet=\"loading_template\"></ng-container>\r\n </div>\r\n</ng-container>\r\n\r\n<ng-container *ngIf=\"loadingChart && !loading_template\">\r\n <div class=\"esc-loading-overlay\" style=\"width: 100%;\" [style.height]=\"isPaged ? 'calc(100% - 44px)' : '100%'\">\r\n <p class=\"label\">Loading....</p>\r\n </div>\r\n</ng-container>\r\n\r\n<div [class.hide-block]=\"loadingChart\" id=\"{{name}}\" style=\"width: 100%;\" [style.height]=\"isPaged ? 'calc(100% - 44px)' : '100%'\"></div>", styles: [".esc-loading-overlay{background:#9999;text-transform:uppercase;font-size:30px;font-weight:700;color:#fff;text-align:center;font-family:monospace}.esc-loading-overlay .label{margin:0;padding-top:7%}.hide-block{display:none}\n"], components: [{ type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2313
2334
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsLineChartComponent, decorators: [{
2314
2335
  type: Component,
2315
2336
  args: [{ selector: 'es-line-chart', changeDetection: ChangeDetectionStrategy.OnPush, template: "<chart-pager *ngIf=\"isPaged\" (onPageChange)=\"changePage($event)\" [Items]=\"DataArray\" [Dtos]=\"DataDtos\" [StartIndex]=\"DataDtoStartIndex\"\r\n [BrowseDelayMs]=\"BrowseDelayMs\">\r\n <ng-template #header_inner let-headerItem>\r\n <ng-container *ngTemplateOutlet=\"header_tr; context : {$implicit: headerItem}\"></ng-container>\r\n </ng-template>\r\n</chart-pager>\r\n\r\n<ng-container *ngIf=\"loadingChart && loading_template\">\r\n <div style=\"width: 100%;\" [style.height]=\"isPaged ? 'calc(100% - 44px)' : '100%'\">\r\n <ng-container *ngTemplateOutlet=\"loading_template\"></ng-container>\r\n </div>\r\n</ng-container>\r\n\r\n<ng-container *ngIf=\"loadingChart && !loading_template\">\r\n <div class=\"esc-loading-overlay\" style=\"width: 100%;\" [style.height]=\"isPaged ? 'calc(100% - 44px)' : '100%'\">\r\n <p class=\"label\">Loading....</p>\r\n </div>\r\n</ng-container>\r\n\r\n<div [class.hide-block]=\"loadingChart\" id=\"{{name}}\" style=\"width: 100%;\" [style.height]=\"isPaged ? 'calc(100% - 44px)' : '100%'\"></div>", styles: [".esc-loading-overlay{background:#9999;text-transform:uppercase;font-size:30px;font-weight:700;color:#fff;text-align:center;font-family:monospace}.esc-loading-overlay .label{margin:0;padding-top:7%}.hide-block{display:none}\n"] }]
@@ -2352,6 +2373,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
2352
2373
  type: Input
2353
2374
  }], Fill: [{
2354
2375
  type: Input
2376
+ }], Stacked: [{
2377
+ type: Input
2355
2378
  }] } });
2356
2379
 
2357
2380
  /**