@esfaenza/es-charts 15.2.3 → 15.2.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.
@@ -1,11 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, EventEmitter, Component, ChangeDetectionStrategy, Input, Output, ContentChild, InjectionToken, Inject, PLATFORM_ID, NgModule, Directive } from '@angular/core';
2
+ import { Injectable, EventEmitter, Component, ChangeDetectionStrategy, Input, Output, ContentChild, InjectionToken, Inject, Directive, PLATFORM_ID, NgModule } from '@angular/core';
3
3
  import * as i5 from '@angular/common';
4
- import { CommonModule, isPlatformBrowser } from '@angular/common';
4
+ import { isPlatformBrowser, CommonModule } from '@angular/common';
5
5
  import * as am4core from '@amcharts/amcharts4/core';
6
6
  import * as am4charts from '@amcharts/amcharts4/charts';
7
- import * as i4 from '@esfaenza/extensions';
8
- import * as i4$1 from '@esfaenza/localizations';
7
+ import * as i3 from '@esfaenza/extensions';
8
+ import * as i4 from '@esfaenza/localizations';
9
9
 
10
10
  /**
11
11
  * Adapter Base da reimplementare per trasformare i dati da una libreria di grafici a questa per evitare di riscrivere tutto il codice di
@@ -459,621 +459,755 @@ const ESC_THEME = new InjectionToken('ESC_THEME');
459
459
  const ESC_LOGS = new InjectionToken('ESC_LOGS');
460
460
 
461
461
  /**
462
- * Classe il cui unico scopo è gestire il setup e rendering di un LineChart
462
+ * Classe di supporto al caricamento dinamico dei vari pezzi di amcharts che mi servono per il grafico (temi, locali, ecc...)
463
+ *
464
+ * Essenzialmente ogni volta che viene creato un grafico, questo acquisisce il tema e il locale applicato IN QUEL MOMENTO,
465
+ * questo significa che per creare due grafici con temi diversi bisogna fare:
466
+ *
467
+ * 1) Caricamento tema 1
468
+ *
469
+ * 2) Creazione grafico 1
470
+ *
471
+ * 3) Scaricamento tema 1
472
+ *
473
+ * 3) Caricamento tema 2
474
+ *
475
+ * 4) Creazione grafico 2
476
+ *
463
477
  */
464
- class LineChartService {
465
- /** @ignore */
466
- constructor(Adapter, dateExts) {
467
- this.Adapter = Adapter;
468
- this.dateExts = dateExts;
469
- /** @ignore */
470
- this.DataGroupBucketSize = 1500;
471
- /** @ignore */
472
- this.OpacityOnSelected = 0.3;
473
- /** @ignore */
474
- this.OpacityOnFill = 0.75;
475
- /** @ignore */
476
- this.singleDataSet = false;
477
- //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
478
- //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
479
- /** @ignore */
480
- this.executionTimers = {};
478
+ class ChartLoader {
479
+ /**
480
+ * @ignore
481
+ */
482
+ constructor(logs) {
483
+ this.logs = logs;
484
+ /**
485
+ * Indica se attualmente ho le animazioni caricate in modo da non ricaricarle inutilmente
486
+ */
487
+ this.AnimationsAreLoaded = false;
488
+ /**
489
+ * Indica l'ultimo tema caricato in modo da non ricaricarlo inutilmente qualora il prossimo grafico da creare richieda lo stesso tema
490
+ */
491
+ this.LastLoadedTheme = "";
492
+ /**
493
+ * Cache dei temi (moduli caricati dinamicamente)
494
+ */
495
+ this.themeCache = {};
496
+ /**
497
+ * Cache delle localizzazioni (moduli caricati dinamicamente)
498
+ */
499
+ this.localizationCache = {};
481
500
  }
482
501
  /**
483
- * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un LineChart
502
+ * Applica il tema con le animazioni all'istanza globale di amCharts
503
+ *
504
+ * @param {Object} chartsCore Istanza globale di amCharts
505
+ * @returns {Promise} Promise che identifica la fine del caricamento
484
506
  */
485
- graphicate(data, settings) {
486
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
487
- let dataConverted = this.Adapter ? this.Adapter.adaptDataForLineChart(data) : data;
488
- let threshold = (_a = settings.DataGroupingThreshold) !== null && _a !== void 0 ? _a : 3000;
489
- this.singleDataSet = (_b = settings.MergeDatasets) !== null && _b !== void 0 ? _b : false;
490
- let showTicks = settings.ShowTicks == null ? true : settings === null || settings === void 0 ? void 0 : settings.ShowTicks;
491
- let dataShouldBeGrouped = Math.max(...dataConverted.series.map(t => t.values.length)) > threshold;
492
- let showTimeline = settings.Timeline || dataShouldBeGrouped;
493
- let seriesWithInterval = dataConverted.series.some(t => t.interval);
494
- let interval = seriesWithInterval ? dataConverted.series.find(t => t.interval).interval : null;
495
- let gapsAllowed = (settings === null || settings === void 0 ? void 0 : settings.AllowGaps) == null ? seriesWithInterval : settings === null || settings === void 0 ? void 0 : settings.AllowGaps;
496
- let finalInstant = (_c = settings === null || settings === void 0 ? void 0 : settings.FinalInstants) !== null && _c !== void 0 ? _c : true;
497
- //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
498
- am4core.options.autoDispose = true;
499
- this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
500
- let ChartInstanceCasted = this.ChartInstance;
501
- let yAxis = ChartInstanceCasted.yAxes.push(new am4charts.ValueAxis());
502
- if (settings.YAxisTitle) {
503
- yAxis.title.text = settings.YAxisTitle;
504
- yAxis.title.fontWeight = "bold";
507
+ applyAnimations(chartsCore) {
508
+ if (!this.AnimationsAreLoaded) {
509
+ return this.importIfNeeded('themes', ChartThemes.animated).then(() => {
510
+ this.log("CORE: Applying theme " + ChartThemes.animated);
511
+ chartsCore.useTheme(this.themeCache[ChartThemes.animated]);
512
+ this.AnimationsAreLoaded = true;
513
+ });
505
514
  }
506
- if (settings.Min)
507
- yAxis.min = settings.Min;
508
- if (settings.Max)
509
- yAxis.max = settings.Max;
510
- let limitNullOrUndef = dataConverted.limit == null || dataConverted.limit == undefined;
511
- let limits = limitNullOrUndef ? [] : !dataConverted.limit.length ? [dataConverted.limit] : dataConverted.limit;
512
- if (limits.length > 0) {
513
- for (let i = 0; i < limits.length; i++) {
514
- let limit = limits[i];
515
- if (limit.upper != null && limit.upper != undefined && limit.lower != null && limit.lower != undefined) {
516
- let range = yAxis.axisRanges.create();
517
- range.value = limit.lower;
518
- range.endValue = limit.upper;
519
- if (limit.fillColor) {
520
- range.contents.stroke = am4core.color(limit.fillColor);
521
- range.contents.fill = range.contents.stroke;
522
- }
523
- range.label.inside = true;
524
- range.label.text = limit.upperlabel;
525
- range.label.fill = range.grid.stroke;
526
- range.label.verticalCenter = "bottom";
527
- range.label.stroke = am4core.color(limit.uppercolor || "#F92200");
528
- range.grid.stroke = am4core.color(limit.uppercolor || "#F92200");
529
- range.grid.strokeWidth = 2;
530
- range.grid.strokeOpacity = 1;
531
- }
532
- else if ((limit.lower == null || limit.lower == undefined) && limit.upper != null && limit.upper != undefined) {
533
- let range = yAxis.axisRanges.create();
534
- range.value = limit.upper;
535
- range.label.inside = true;
536
- range.label.text = limit.upperlabel;
537
- range.label.fill = range.grid.stroke;
538
- range.label.verticalCenter = "bottom";
539
- range.label.stroke = am4core.color(limit.uppercolor || "#F92200");
540
- range.grid.stroke = am4core.color(limit.uppercolor || "#F92200");
541
- range.grid.strokeWidth = 2;
542
- range.grid.strokeOpacity = 1;
543
- }
544
- else if ((limit.upper == null || limit.upper == undefined) && limit.lower != null && limit.lower != undefined) {
545
- let range = yAxis.axisRanges.create();
546
- range.value = limit.lower;
547
- range.label.inside = true;
548
- range.label.text = limit.lowerlabel;
549
- range.label.fill = range.grid.stroke;
550
- range.label.verticalCenter = "bottom";
551
- range.label.stroke = am4core.color(limit.lowercolor || "#F92200");
552
- range.grid.stroke = am4core.color(limit.lowercolor || "#F92200");
553
- range.grid.strokeWidth = 2;
554
- range.grid.strokeOpacity = 1;
555
- }
556
- }
515
+ else {
516
+ this.log("CORE: theme already applyed " + ChartThemes.animated);
517
+ return new Promise((resolve) => { resolve(true); });
557
518
  }
558
- this.dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
559
- // Per comatibilità col codice scritto quando non era a livello globale, mi scoccia sostituire
560
- let dateAxis = this.dateAxis;
561
- if (settings.XAxisTitle) {
562
- dateAxis.title.text = settings.XAxisTitle;
563
- dateAxis.title.fontWeight = "bold";
519
+ }
520
+ /**
521
+ * De-applica il tema con le animazioni dall'istanza globale di amCharts
522
+ *
523
+ * @param {Object} chartsCore Istanza globale di amCharts
524
+ * @returns {Promise} Promise che identifica la fine dello scarico
525
+ */
526
+ unapplyAnimations(chartsCore) {
527
+ if (this.AnimationsAreLoaded) {
528
+ this.log("CORE: Animations in use, unapplying theme " + ChartThemes.animated);
529
+ chartsCore.unuseTheme(this.themeCache[ChartThemes.animated]);
530
+ this.AnimationsAreLoaded = false;
564
531
  }
565
- if (showTicks) {
566
- dateAxis.renderer.ticks.template.disabled = false;
567
- dateAxis.renderer.ticks.template.strokeOpacity = 1;
568
- dateAxis.renderer.ticks.template.stroke = am4core.color("#495C43");
569
- dateAxis.renderer.ticks.template.strokeWidth = 2;
570
- dateAxis.renderer.ticks.template.length = 10;
571
- dateAxis.renderer.ticks.template.location = 0;
532
+ else
533
+ this.log("CORE: Animations already unused, no need to unapply them");
534
+ return new Promise((resolve) => { resolve(true); });
535
+ }
536
+ /**
537
+ * Applica il tema specificato all'istanza globale di amCharts
538
+ *
539
+ * @param {Object} chartsCore Istanza globale di amCharts
540
+ * @param {'spiritedaway' | 'moonrisekingdom' | 'frozen' | 'dark' | 'kelly' | 'material' | 'dataviz' | 'none'} theme Tema da applicare
541
+ * @returns {Promise} Promise che identifica la fine del caricamento
542
+ */
543
+ applyTheme(chartsCore, theme) {
544
+ // Ultimo tema applicato è lo stesso che mi è stato richiesto di applicare --> NO-OP
545
+ if (this.LastLoadedTheme == theme) {
546
+ this.log("CORE: theme already applied " + theme);
547
+ return new Promise((resolve) => { resolve(true); });
572
548
  }
573
- dateAxis.renderer.minGridDistance = (_d = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _d !== void 0 ? _d : 50;
574
- dateAxis.renderer.grid.template.location = 0;
575
- dateAxis.minZoomCount = 5;
576
- dateAxis.groupData = dataShouldBeGrouped;
577
- dateAxis.groupCount = (_e = settings.DataGroupBucketSize) !== null && _e !== void 0 ? _e : this.DataGroupBucketSize;
578
- //Se ho almeno una serie ad intervallo e i settings non mi impediscono esplicitamente di usare i gaps, visualizzo i dati col gap
579
- if (gapsAllowed) {
580
- if (!seriesWithInterval) {
581
- console.error("Per utilizzare la funzionalità dei gap è obbligatorio definire un intervallo nelle serie del grafico");
582
- return null;
583
- }
584
- dateAxis.baseInterval = { count: interval.count, timeUnit: interval.timeunit };
549
+ // Scarico il tema precedente a prescindere, ormai non mi serve più
550
+ this.unapplyPreviousTheme(chartsCore);
551
+ // Il tema è il none --> registro la cosa e basta, il tema precedente è stato rimosso subito qui sopra ^
552
+ if (theme == ChartThemes.none) {
553
+ this.LastLoadedTheme = ChartThemes.none;
554
+ return new Promise((resolve) => { resolve(true); });
585
555
  }
586
- if (showTimeline)
587
- ChartInstanceCasted.scrollbarX = new am4charts.XYChartScrollbar();
588
- let seriesToPush = [];
589
- let seriesColors = [];
590
- let defaultIndex = 0;
591
- // Ordinamento dei dati se serve
592
- dataConverted.series.forEach((s) => {
593
- if (s.values[0] && !(s.values[0].d instanceof Date)) {
594
- for (let v = 0; v < s.values.length; v++)
595
- s.values[v].d = new Date(s.values[v].d);
596
- }
597
- var correctOrder = true;
598
- var prevDate = null;
599
- for (let v = 0; v < s.values.length; v++) {
600
- if (!prevDate)
601
- prevDate = s.values[v].d;
602
- else if (s.values[v].d < prevDate) {
603
- correctOrder = false;
604
- break;
605
- }
606
- }
607
- if (!correctOrder)
608
- s.values.sort((d1, d2) => d1.d.getTime() - d2.d.getTime());
556
+ // Il tema è diverso dal precedente e non è il tema vuoto --> Importo il tema specificato se non presente in memoria e lo applico al grafico attuale
557
+ return this.importIfNeeded('themes', theme).then(() => {
558
+ this.log("CORE: Applying theme " + theme);
559
+ chartsCore.useTheme(this.themeCache[theme]);
560
+ this.LastLoadedTheme = theme;
609
561
  });
610
- // Generazione di un unico dataset invece che N, per poter gestire un unico tooltip
611
- if (this.singleDataSet) {
612
- this.ChartInstance.data = this.generateSingleDataset(dataConverted);
613
- ;
614
- dateAxis.cursorTooltipEnabled = false;
615
- }
616
- dataConverted.series.forEach((s, index) => {
617
- var _a, _b, _c, _d;
618
- let stacked = s.stacked != null && s.stacked != undefined ? s.stacked : ((_a = settings === null || settings === void 0 ? void 0 : settings.Stacked) !== null && _a !== void 0 ? _a : false);
619
- let fill = stacked || (s.fill != null && s.fill != undefined ? s.fill : ((_b = settings === null || settings === void 0 ? void 0 : settings.Fill) !== null && _b !== void 0 ? _b : false));
620
- let series = (settings === null || settings === void 0 ? void 0 : settings.Step) ? new am4charts.StepLineSeries() : new am4charts.LineSeries();
621
- series.dataFields.valueY = "v" + (this.singleDataSet ? index : "");
622
- series.dataFields.dateX = "d";
623
- series.measureUnit = s.uom;
624
- series.name = s.name;
625
- series.strokeWidth = (_c = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _c !== void 0 ? _c : 1;
626
- series.connect = !gapsAllowed;
627
- series.minBulletDistance = 10;
628
- series.tooltipText = this.singleDataSet ? "" : s.name ? "{name}: [bold]{valueY}[/]" : "[bold]{valueY}[/]";
629
- series.tooltip.pointerOrientation = "vertical";
630
- series.tooltip.background.fillOpacity = 0.5;
631
- series.tooltip.label.padding(12, 12, 12, 12);
632
- series.fillOpacity = fill ? this.OpacityOnFill : 0.0001;
633
- series.stacked = stacked;
634
- series.hidden = s.hidden;
635
- //Dataset singolo, i dati sono registrati a livello di chart, creo il tooltip che permette di vederli tutti insieme
636
- //altrimenti assegno i dati della serie direttamente alla serie
637
- if (this.singleDataSet) {
638
- series.tooltip.getFillFromObject = false;
639
- series.tooltip.background.fill = am4core.color("#eee");
640
- series.tooltip.label.fill = am4core.color("#00");
641
- series.tooltip.defaultState.transitionDuration = 0;
642
- series.tooltip.hiddenState.transitionDuration = 0;
643
- //Utilizzo il mio dateService per la formattazione della data in modo che non debba mai gestire n formati fra n librerie... bellissimo
644
- series.dateFormatter.format = (source) => {
645
- if (interval && finalInstant && ["hour", "minute", "second"].includes(interval.timeunit)) {
646
- let timepart = null;
647
- switch (interval.timeunit) {
648
- case "hour":
649
- timepart = 'day';
650
- break;
651
- case "minute":
652
- timepart = 'hour';
653
- break;
654
- case "second":
655
- timepart = 'minute';
656
- break;
657
- }
658
- if (timepart)
659
- return this.dateExts.adjustDateToFinalInstant(source, timepart, interval ? interval.timeunit == "second" : false);
660
- }
661
- else
662
- return this.dateExts.getFormatted(source, interval ? ["day", "week", "month", "year"].includes(interval.timeunit) : false, interval ? interval.timeunit == "second" : false);
663
- };
664
- series.adapter.add("tooltipText", () => {
665
- var text = "[bold]{dateX.formatDate()}[/]\n";
666
- this.ChartInstance.series.each((item) => {
667
- let uom = " [font-style: italic]" + series.measureUnit || "" + "[/]";
668
- text += "[" + item.stroke.hex + "]●[/] " + (item.name ? (item.name + ": ") : "") + "[bold]{" + item.dataFields.valueY + "}[/]" + uom + "\n";
669
- });
670
- return text;
671
- });
672
- }
673
- else
674
- series.data = s.values;
675
- let segment = series.segments.template;
676
- let hoverState = segment.states.create("hover");
677
- hoverState.properties.strokeWidth = ((_d = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _d !== void 0 ? _d : 1) + 1;
678
- let dimmed = segment.states.create("dimmed");
679
- dimmed.properties.stroke = am4core.color("#dadada");
680
- //Se la serie ha un colore, uso quello, altrimenti pesco dai colori di default andando in ordine
681
- if (s.color)
682
- seriesColors.push(am4core.color(s.color));
683
- else {
684
- seriesColors.push(ChartInstanceCasted.colors.list[defaultIndex % ChartInstanceCasted.colors.list.length]);
685
- defaultIndex++;
686
- }
687
- seriesToPush.push(series);
688
- });
689
- ChartInstanceCasted.colors.list = seriesColors;
690
- //Scrivo le serie nel grafico
691
- seriesToPush.forEach(s => {
692
- ChartInstanceCasted.series.push(s);
693
- if (showTimeline)
694
- ChartInstanceCasted.scrollbarX.series.push(s);
695
- });
696
- if (settings.Legend) {
697
- this.ChartInstance.legend = new am4charts.Legend();
698
- this.ChartInstance.legend.position = (_f = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _f !== void 0 ? _f : 'right';
699
- this.ChartInstance.legend.scrollable = true;
700
- this.ChartInstance.legend.itemContainers.template.tooltipText = "{name}";
701
- this.ChartInstance.legend.itemContainers.template.events.on("over", (event) => { this.processOver(event.target.dataItem.dataContext); });
702
- this.ChartInstance.legend.itemContainers.template.events.on("out", () => { this.processOut(); });
703
- if (settings.LegendPadding) {
704
- let template = this.ChartInstance.legend.itemContainers.template;
705
- template.paddingTop = (_g = settings.LegendPadding.top) !== null && _g !== void 0 ? _g : 0;
706
- template.paddingBottom = (_h = settings.LegendPadding.bottom) !== null && _h !== void 0 ? _h : 0;
707
- template.paddingLeft = (_j = settings.LegendPadding.left) !== null && _j !== void 0 ? _j : 0;
708
- template.paddingRight = (_k = settings.LegendPadding.right) !== null && _k !== void 0 ? _k : 0;
709
- }
710
- }
711
- this.ChartInstance.cursor = new am4charts.XYCursor();
712
- //Prove******************************************************************************************************************************
713
- // this.ChartInstance.cursor.events.on("cursorpositionchanged", (ev) => {
714
- // //var value = dateAxis.positionToDate(dateAxis.toAxisPosition(ev.target.xPosition));
715
- // var dt = dateAxis.series.values.find(t => t.dataItem.values.dateX);
716
- // if (dt && dt.dataItem) {
717
- // console.log(dt.dataItem.values);
718
- // // this.ChartInstance.tooltipText = dt;
719
- // }
720
- // else {
721
- // this.ChartInstance.tooltipText = "";
722
- // }
723
- // });
724
- //******************************************************************************************************************************
725
- this.ChartInstance.cursor.xAxis = dateAxis;
726
- this.ChartInstance.cursor.yAxis = yAxis;
727
- if (this.singleDataSet)
728
- this.ChartInstance.cursor.maxTooltipDistance = -1;
729
- //TODO: Cercare di capire perché è figlio di puttana......
730
- dateAxis.events.on("startchanged", t => this.emitSelectionChanged(t, settings));
731
- dateAxis.events.on("endchanged", t => this.emitSelectionChanged(t, settings));
732
- return this;
733
- }
734
- /** @ignore */
735
- setSelection(from, to) {
736
- this.dateAxis.zoomToDates(from, to, true, true);
737
562
  }
738
- /** @ignore */
739
- refreshData(data) {
740
- let dataConverted = this.Adapter ? this.Adapter.adaptDataForLineChart(data) : data;
741
- if (this.singleDataSet) {
742
- var data = this.generateSingleDataset(dataConverted);
743
- this.ChartInstance.addData(data);
563
+ /**
564
+ * De-applica il tema precedente dall'istanza globale di amCharts
565
+ *
566
+ * @param {Object} chartsCore Istanza globale di amCharts
567
+ */
568
+ unapplyPreviousTheme(chartsCore) {
569
+ if (!this.LastLoadedTheme || this.LastLoadedTheme == ChartThemes.none)
744
570
  return;
745
- }
746
- throw "Impossibile aggiornare i dati senza unire il dataset. Si prega di impostare [MergeDatasets] a true";
571
+ this.log("CORE: Unapplying previously used theme " + this.LastLoadedTheme);
572
+ chartsCore.unuseTheme(this.themeCache[this.LastLoadedTheme]);
747
573
  }
748
- /** Partendo da dati divisi per seriue genera un dataset unito con la data come chiave e i vari valori dopo */
749
- generateSingleDataset(data) {
750
- let dto = {};
751
- data.series.forEach((vs, index) => {
752
- for (let i = 0; i < vs.values.length; i++) {
753
- var dataitem = vs.values[i];
754
- var indexer = new Date(dataitem.d).valueOf();
755
- if (!dto[indexer])
756
- dto[indexer] = {};
757
- dto[indexer]['v' + index] = dataitem.v;
758
- }
574
+ /**
575
+ * Applica il locale specificato all'istanza specifica del grafico
576
+ *
577
+ * @param {amCharts.Chart} chart Istanza specifica del grafico a cui applicare il locale
578
+ * @param {string} locale Locale da applicare
579
+ * @returns {Promise} Promise che identifica la fine del caricamento
580
+ */
581
+ applyLocale(chart, locale) {
582
+ return this.importIfNeeded('lang', locale).then(() => {
583
+ this.log("Chart " + chart.htmlContainer.id + ": applying locale " + locale);
584
+ chart.language.locale = this.localizationCache[locale];
759
585
  });
760
- var dates = Object.keys(dto);
761
- var ret = [];
762
- for (let i = 0; i < dates.length; i++) {
763
- let values = dto[dates[i]];
764
- let item = { d: new Date(parseInt(dates[i])) };
765
- var vals = Object.keys(values);
766
- for (let ii = 0; ii < vals.length; ii++) {
767
- let series = vals[ii];
768
- let singleVal = values[series];
769
- item[series] = singleVal;
770
- }
771
- ret.push(item);
586
+ }
587
+ /**
588
+ * Permette di importare, se serve un dato tema o localizzazione
589
+ *
590
+ * @param {'lang' | 'themes'} what Oggetto da importare, se localizzazione o tema
591
+ * @param {string} item Chiave dell'oggetto da importare
592
+ *
593
+ * @returns {Promise} Promise che identifica la fine del caricamento
594
+ */
595
+ importIfNeeded(what, item) {
596
+ // Se sto cercando di caricare qualcosa di già caricato non faccio nulla
597
+ if (!(what == 'themes' && !this.themeCache[item]) && !(what == 'lang' && !this.localizationCache[item])) {
598
+ this.log("CORE: " + (what == 'lang' ? "Language " : "Theme ") + item + " already loaded");
599
+ return new Promise((resolve) => { resolve(true); });
772
600
  }
773
- return ret;
601
+ this.log("CORE: Loading " + (what == 'lang' ? "language " : "theme ") + item);
602
+ /*
603
+ * ****************************
604
+ * ******** ATTENZIONE ********
605
+ * ****************************
606
+ *
607
+ * Se stai vedendo questo codice di import e stai valutando di riscriverlo come:
608
+ *
609
+ * V V
610
+ * import(`@amcharts/amcharts4/${what}/${item}`).then(module => {
611
+ * if (what == 'themes') this.themeCache[item] = module.default;
612
+ * else if (what == 'lang') this.localizationCache[item] = module.default;
613
+ * });
614
+ *
615
+ * Sappi che è una pessima idea. Gli import sono valutati da webpack in compiletime per generare i chunk,
616
+ * mettere la navigazione agli import con la concatenazione viene preso malissimo ed essenzialmente dice a webpack
617
+ * di tirare su e bundlare l'intera node_modules. Divertente, no?
618
+ *
619
+ */
620
+ switch (what) {
621
+ case 'themes':
622
+ switch (item) {
623
+ case ChartThemes.spiritedaway:
624
+ return import('@amcharts/amcharts4/themes/spiritedaway').then(theme => this.themeCache[item] = theme.default);
625
+ case ChartThemes.moonrisekingdom:
626
+ return import('@amcharts/amcharts4/themes/moonrisekingdom').then(theme => this.themeCache[item] = theme.default);
627
+ case ChartThemes.frozen:
628
+ return import('@amcharts/amcharts4/themes/frozen').then(theme => this.themeCache[item] = theme.default);
629
+ case ChartThemes.dark:
630
+ return import('@amcharts/amcharts4/themes/dark').then(theme => this.themeCache[item] = theme.default);
631
+ case ChartThemes.kelly:
632
+ return import('@amcharts/amcharts4/themes/kelly').then(theme => this.themeCache[item] = theme.default);
633
+ case ChartThemes.material:
634
+ return import('@amcharts/amcharts4/themes/material').then(theme => this.themeCache[item] = theme.default);
635
+ case ChartThemes.dataviz:
636
+ return import('@amcharts/amcharts4/themes/dataviz').then(theme => this.themeCache[item] = theme.default);
637
+ case ChartThemes.animated:
638
+ return import('@amcharts/amcharts4/themes/animated').then(theme => this.themeCache[item] = theme.default);
639
+ }
640
+ break;
641
+ case 'lang':
642
+ switch (item) {
643
+ case 'it-IT':
644
+ return import('@amcharts/amcharts4/lang/it_IT').then(lang => this.localizationCache[item] = lang.default);
645
+ case 'en-US':
646
+ return import('@amcharts/amcharts4/lang/en_US').then(lang => this.localizationCache[item] = lang.default);
647
+ }
648
+ }
649
+ this.log("CORE: Loading Failed. " + (what == 'lang' ? "Language " : "Theme") + " not recognized: " + item);
650
+ return new Promise((resolve) => { resolve(true); });
774
651
  }
775
- /** @ignore */
776
- emitSelectionChanged(ev, settings) {
777
- if (settings.OnSelectionChangedCallback) {
778
- this.throttla("selchange", () => {
779
- var axis = ev.target;
780
- var start = new Date(axis.minZoomed);
781
- var end = new Date(axis.maxZoomed);
782
- var initial = axis.min == axis.minZoomed && axis.max == axis.maxZoomed;
783
- settings.OnSelectionChangedCallback({ from: start, to: end, initial: initial });
784
- }, 150);
652
+ /**
653
+ * @ignore
654
+ */
655
+ log(text) {
656
+ if (this.logs)
657
+ console.log("@esfaenza/es-charts: " + text);
658
+ }
659
+ }
660
+ ChartLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartLoader, deps: [{ token: ESC_LOGS }], target: i0.ɵɵFactoryTarget.Injectable });
661
+ ChartLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartLoader });
662
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartLoader, decorators: [{
663
+ type: Injectable
664
+ }], ctorParameters: function () {
665
+ return [{ type: undefined, decorators: [{
666
+ type: Inject,
667
+ args: [ESC_LOGS]
668
+ }] }];
669
+ } });
670
+
671
+ /**
672
+ * 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
673
+ */
674
+ class ChartDispatcher {
675
+ /**
676
+ * @ignore
677
+ */
678
+ constructor(logs) {
679
+ this.logs = logs;
680
+ /**
681
+ * Coda di inizializzazioni ancora da eseguire. Quando questa è vuota significa che nessuno sta creando grafici
682
+ */
683
+ this.Initializations = [];
684
+ /**
685
+ * Lista dei grafici inizializzati e attivi in un dato momento (viene registrata la proprietà **name**). Non è possibile registrare due grafici con lo stesso identificativo
686
+ */
687
+ this.InitializedGraphs = [];
688
+ }
689
+ /**
690
+ * Registra un grafico da visualizzare insieme alla propria funzione di creazione. Quest'ultima sarà differita fino a che tutti i grafici
691
+ * precedentemente registati non hanno finito la fase di inizializzazione
692
+ *
693
+ * @param {string} name Identificativo del grafico da registrare
694
+ * @param {Function} chartCreationFunction Funzione che fisicamente dovrà occuparsi della creazione del grafico
695
+ */
696
+ register(name, chartCreationFunction) {
697
+ if (this.InitializedGraphs.indexOf(name) != -1)
698
+ throw "Attempting to register a duplicate chart '" + name + "'. Make sure the 'name' properties of your charts are univoque";
699
+ this.log("DISPATCHER: Registering chart creation function execution for " + name);
700
+ this.Initializations.push({ name: name, function: chartCreationFunction });
701
+ if (this.Initializations.length == 1) {
702
+ this.log("DISPATCHER: Initial drain started");
703
+ this.drainInitQueues();
785
704
  }
786
705
  }
787
- /** @ignore */
788
- processOver(hoveredSeries) {
789
- hoveredSeries.zIndex = 999;
790
- let fill = hoveredSeries.fillOpacity == this.OpacityOnFill;
791
- hoveredSeries.segments.each((segment) => {
792
- segment.setState("hover");
793
- if (!fill)
794
- segment.fillSprite.fillOpacity = this.OpacityOnSelected;
795
- });
796
- if (!fill)
797
- hoveredSeries.legendDataItem.marker.children.getIndex(1).fillOpacity = this.OpacityOnSelected;
798
- this.ChartInstance.series.each((series) => {
799
- if (series != hoveredSeries) {
800
- let fill = series.fillOpacity == this.OpacityOnFill;
801
- series.segments.each((segment) => {
802
- segment.setState("dimmed");
803
- if (!fill)
804
- segment.fillSprite.fillOpacity = 0;
805
- });
806
- }
807
- });
706
+ /**
707
+ * Deregistra un grafico presente. Chiamata generalmente al dispose del grafico in questione quando non dev'essere più mostrato nella pagina corrente
708
+ *
709
+ * @param {string} name Identificativo del grafico da deregistrare
710
+ */
711
+ deregisterGraph(name) {
712
+ let index = this.InitializedGraphs.indexOf(name);
713
+ if (index == -1) {
714
+ //Questo succede quando si cerca di distruggere il grafico mentre sta venendo graficato
715
+ this.log("DISPATCHER: Registration missing for chart " + name + " it was probably destroyed during load");
716
+ return;
717
+ }
718
+ this.log("DISPATCHER: Chart deregistered " + name);
719
+ this.InitializedGraphs.splice(index, 1);
808
720
  }
809
- /** @ignore */
810
- processOut() {
811
- this.ChartInstance.series.each((series, i) => {
812
- series.zIndex = i;
813
- let fill = series.fillOpacity == this.OpacityOnFill;
814
- series.segments.each((segment) => {
815
- segment.setState("default");
816
- if (!fill)
817
- segment.fillSprite.fillOpacity = 0;
818
- });
819
- if (!fill)
820
- series.legendDataItem.marker.children.getIndex(1).fillOpacity = 0;
721
+ /**
722
+ * Metodo che esegue in maniera sequenziale le funzioni di inizializzazione dei grafici finché presenti
723
+ * in modo che nessun grafico possa essere inizializzato contemporaneamente ad un altro.
724
+ *
725
+ * Questo è il punto chiave che permette di avere per ogni grafico temi e locale differenti
726
+ */
727
+ drainInitQueues() {
728
+ let toExecute = this.Initializations[0];
729
+ this.log("DISPATCHER: Executing initialization function for chart " + toExecute.name);
730
+ toExecute.function().then(() => {
731
+ this.log("DISPATCHER: initialization for chart " + toExecute.name + " is done");
732
+ this.InitializedGraphs.push(toExecute.name);
733
+ this.Initializations.splice(0, 1);
734
+ if (this.Initializations.length >= 1) {
735
+ this.log("DISPATCHER: Found queued initializations. Continuing");
736
+ this.drainInitQueues();
737
+ }
738
+ else
739
+ this.log("DISPATCHER: queue is over, nothing more to do");
821
740
  });
822
741
  }
823
- /** @ignore */
824
- throttla(id, func, throttleTime) {
825
- //Se ho la funzione che vuole eseguire ripulisco quel timeout
826
- if (this.executionTimers[id])
827
- clearTimeout(this.executionTimers[id]);
828
- //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
829
- this.executionTimers[id] = setTimeout(() => { func(); this.executionTimers[id] = null; }, throttleTime);
742
+ /**
743
+ * @ignore
744
+ */
745
+ log(text) {
746
+ if (this.logs)
747
+ console.log("@esfaenza/es-charts: " + text);
830
748
  }
831
- }
749
+ }
750
+ ChartDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartDispatcher, deps: [{ token: ESC_LOGS }], target: i0.ɵɵFactoryTarget.Injectable });
751
+ ChartDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartDispatcher, providedIn: 'root' });
752
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartDispatcher, decorators: [{
753
+ type: Injectable,
754
+ args: [{ providedIn: 'root' }]
755
+ }], ctorParameters: function () {
756
+ return [{ type: undefined, decorators: [{
757
+ type: Inject,
758
+ args: [ESC_LOGS]
759
+ }] }];
760
+ } });
832
761
 
833
762
  /**
834
- * 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
763
+ * Componente Grafico Base che gestisce tutte le cose comuni dei vari grafici istanziabili, come la presenza o menu di una legenda,
764
+ * il tema utilizzato, il locale del singolo grafico, ecc ecc...
835
765
  */
836
- class ChartDispatcher {
766
+ class BaseChartComponent {
837
767
  /**
838
- * @ignore
768
+ * Costruttore
769
+ *
770
+ * @param {ElementRef} el Contenitore all'interno del cui viene creato il grafico. Utilizzato per estrapolarne la **ContainerHeight**
771
+ * @param {Object} platformId piattaforma Angular (browser, ecc...) per essere sicuri che amcharts venga attivato solo lato browser. Non utilizzando SSR nelle applicazioni che consumano questa libreria non è particolarmente significativo, ma non si sa mai
772
+ * @param {NgZone} zone NgZone di default per permettere di inizializzare il grafico all'infuori di Angular per avere qualche prestazione in più
773
+ * @param {ChartLoader} Charter Istanza del Loader che si occuperà di caricare in memoria tutto ciò che serve per il grafico attuale (temi, locale, animazioni, ecc...)
774
+ * @param {ChartDispatcher} Dispatcher Istanza del Dispatcher che si occupa di differire il caricamento dei grafici 1 dopo l'altro in modo che caricamenti pseudo paralleli incasinino tutto
775
+ * @param {boolean} logs Indica se effettuare log a console o meno, iniettato dalle classi specializzate dal token ESC_LOGS
776
+ * @param {boolean} animations Indica se per questo grafico devono essere attive o meno le animazioni. Impostazione generica presa dal token ESC_ANIMATIONS
777
+ * @param {string} locale Indica il locale specifico per questo grafico. Impostazione generica presa dal LocalizationService
778
+ * @param {string} theme Indica il tema specifico per questo grafico. Impostazione generica presa dal token ESC_THEME
839
779
  */
840
- constructor(logs) {
780
+ constructor(el, platformId, zone, Charter, Dispatcher, logs, animations, locale, theme) {
781
+ this.el = el;
782
+ this.platformId = platformId;
783
+ this.zone = zone;
784
+ this.Charter = Charter;
785
+ this.Dispatcher = Dispatcher;
841
786
  this.logs = logs;
787
+ this.animations = animations;
788
+ this.locale = locale;
789
+ this.theme = theme;
842
790
  /**
843
- * Coda di inizializzazioni ancora da eseguire. Quando questa è vuota significa che nessuno sta creando grafici
791
+ * Nome del grafico, fondamentale assegnarlo per permettere alla libreria di schedularne la creazione
844
792
  */
845
- this.Initializations = [];
793
+ this.name = "";
846
794
  /**
847
- * Lista dei grafici inizializzati e attivi in un dato momento (viene registrata la proprietà **name**). Non è possibile registrare due grafici con lo stesso identificativo
795
+ * Dopo aver navigato a un nuovo grafico verranno attesi questi millisecondi prima di richiedere i dati attraverso la **DataRetrieve**.
796
+ *
797
+ * Questo per evitare che l'utente cliccando velocemente "avanti" generi tonnellate di richieste inutili
848
798
  */
849
- this.InitializedGraphs = [];
799
+ this.BrowseDelayMs = 500;
800
+ /**
801
+ * Evento lanciato sulla selezione di un range di dati o dalla timeline o dal grafico. Valido per tutti i grafici che supportano serie basate sulle date
802
+ */
803
+ this.onSelectionChanged = new EventEmitter();
804
+ /**
805
+ * Evento lanciato dal click di una serie dalla Legenda, a patto che l'Input **HideSeriesOnLabelClick** sia impostato a false
806
+ */
807
+ this.onSeriesClicked = new EventEmitter();
808
+ /**
809
+ * Evento lanciato all'inizio del caricamento di una nuova pagina del grafico
810
+ */
811
+ this.onLoadStart = new EventEmitter();
812
+ /**
813
+ * Evento lanciato al termine del caricamento di una nuova pagina del grafico
814
+ */
815
+ this.onLoadEnd = new EventEmitter();
816
+ /**
817
+ * Evento lanciato al termine della creazione del grafico referenziando l'istanza nativa del grafico creato in modo da poter effettuare modifiche
818
+ * post inizializzazione lato applicativo
819
+ */
820
+ this.chartLoaded = new EventEmitter();
821
+ /**
822
+ * Serve a decidere se sarà presente l'interfaccia di paginazione
823
+ */
824
+ this.isPaged = false;
825
+ /**
826
+ * @ignore
827
+ */
828
+ this.initDone = false;
850
829
  }
851
830
  /**
852
- * Registra un grafico da visualizzare insieme alla propria funzione di creazione. Quest'ultima sarà differita fino a che tutti i grafici
853
- * precedentemente registati non hanno finito la fase di inizializzazione
831
+ * Metodo di inizializzazione post valorizzazione degli input, utilizzato per valorizzare correttamente le proprietà essenziali del grafico (Animazioni, Tema e Locale)
854
832
  *
855
- * @param {string} name Identificativo del grafico da registrare
856
- * @param {Function} chartCreationFunction Funzione che fisicamente dovrà occuparsi della creazione del grafico
833
+ * Viene data priorità ai Settings (HTML), priorità secondaria agli Input diretti (Lato HTML), priorità ultima alle impostazioni globali,
834
+ * impostate in fase di import del modulo assegnando valori ai token ESC_ANIMATIONS, ESC_THEME
857
835
  */
858
- register(name, chartCreationFunction) {
859
- if (this.InitializedGraphs.indexOf(name) != -1)
860
- throw "Attempting to register a duplicate chart '" + name + "'. Make sure the 'name' properties of your charts are univoque";
861
- this.log("DISPATCHER: Registering chart creation function execution for " + name);
862
- this.Initializations.push({ name: name, function: chartCreationFunction });
863
- if (this.Initializations.length == 1) {
864
- this.log("DISPATCHER: Initial drain started");
865
- this.drainInitQueues();
836
+ ngOnInit() {
837
+ var _a, _b, _c, _d, _e, _f;
838
+ // Qui servono solo le variabili da conoscere PRE-graficazione per il caricamento dei moduli lazy del grafico
839
+ this.Animations = ((_a = this.Settings) === null || _a === void 0 ? void 0 : _a.Animations) != null ? (_b = this.Settings) === null || _b === void 0 ? void 0 : _b.Animations : (this.Animations != null ? this.Animations : this.animations);
840
+ this.Theme = ((_c = this.Settings) === null || _c === void 0 ? void 0 : _c.Theme) != null ? (_d = this.Settings) === null || _d === void 0 ? void 0 : _d.Theme : (this.Theme != null ? this.Theme : this.theme);
841
+ this.Locale = ((_e = this.Settings) === null || _e === void 0 ? void 0 : _e.Locale) != null ? (_f = this.Settings) === null || _f === void 0 ? void 0 : _f.Locale : (this.Locale != null ? this.Locale : this.locale);
842
+ this.isPaged = (this.DataArray && this.DataArray.length > 0 && !this.Data) || (this.DataDtos && this.DataDtos.length > 0 && !!this.DataRetrieve);
843
+ this.log("Chart " + this.name + ": ngOnInit");
844
+ }
845
+ /**
846
+ * Implementazione utilizzata per controllare eventuali proprietà chiave del grafico e rigraficare tutto qualora si rivelasse necessario
847
+ *
848
+ * @param {SimpleChanges} changes Indicazione dei cambiamenti sulle proprietà del grafico. Vedere documentazione Angular in merito
849
+ */
850
+ ngOnChanges(changes) {
851
+ if (!this.initDone)
852
+ return;
853
+ this.log("Chart " + this.name + ": ngOnChanges");
854
+ let propsToCheck = ["Timeline", "Legend", "Settings", "Animations", "Theme", "Locale", ...this.getSpecificPropertiesToCheck()];
855
+ this.checkPropertiesAndRegraphicateAsNeeded(changes, propsToCheck);
856
+ }
857
+ /**
858
+ * Nel post inizializzazione, a patto che mi trovi in ambiente "browser", proseguo al caricamento del grafico sull'HTML
859
+ */
860
+ ngAfterViewInit() {
861
+ if (!this.name)
862
+ throw "a Unique name is mandatory to create a chart";
863
+ this.log("Chart " + this.name + ": ngAfterViewInit, graphicating chart outside Angular");
864
+ if (!this.isPaged)
865
+ this.dispatchLoadChart();
866
+ }
867
+ /**
868
+ * All'onDestroy scarico il grafico per liberare memoria
869
+ */
870
+ ngOnDestroy() {
871
+ if (this.Chart) {
872
+ this.log("Chart " + this.name + ": Unloading destroyed chart");
873
+ this.browserOnly(() => { this.Chart.dispose(); this.Dispatcher.deregisterGraph(this.name); });
866
874
  }
875
+ else
876
+ this.log("Chart " + this.name + ": Unloading uncreated chart component. It probably was a duplicated");
867
877
  }
868
878
  /**
869
- * Deregistra un grafico presente. Chiamata generalmente al dispose del grafico in questione quando non dev'essere più mostrato nella pagina corrente
879
+ * Registra il grafico attuale nel Dispatcher in modo che venga caricato appena possibile
880
+ */
881
+ dispatchLoadChart() {
882
+ this.browserOnly(() => {
883
+ this.Dispatcher.register(this.name, () => { return this.loadChart(); });
884
+ });
885
+ }
886
+ /**
887
+ * Il caricamento del grafico funziona nel seguente modo:
870
888
  *
871
- * @param {string} name Identificativo del grafico da deregistrare
889
+ * 1) Caricamento del tema e delle animazioni, qualora necessari
890
+ *
891
+ * 2) Caricamento delle impostazioni specifiche e integrazione con le impostazioni generiche
892
+ *
893
+ * 3) Graficazione
894
+ *
895
+ * 4) Caricamento del locale
872
896
  */
873
- deregisterGraph(name) {
874
- let index = this.InitializedGraphs.indexOf(name);
875
- if (index == -1) {
876
- //Questo succede quando si cerca di distruggere il grafico mentre sta venendo graficato
877
- this.log("DISPATCHER: Registration missing for chart " + name + " it was probably destroyed during load");
897
+ loadChart() {
898
+ this.log("Chart " + this.name + ": Start loading Modules if needed");
899
+ return Promise.all([
900
+ this.setupAmChartsThemes().then(() => {
901
+ this.log("Chart " + this.name + ": Graphicating after modules load");
902
+ var castedSettings = this.getCastedSettings();
903
+ this.fillSettings(castedSettings);
904
+ this.fillSpecificSettings(castedSettings);
905
+ this.ChartService = this.graphicate(castedSettings);
906
+ this.Chart = this.ChartService.ChartInstance;
907
+ if (!this.Chart)
908
+ this.log("Chart " + this.name + ": Could not create graph");
909
+ // Unico punto reale in cui viene utilizzato il locale, tehe
910
+ return this.Charter.applyLocale(this.Chart, this.Locale).then(() => { this.initDone = true; this.chartLoaded.emit(this); });
911
+ })
912
+ ]);
913
+ }
914
+ /**
915
+ * Riempimento delle impostazioni nella classe Settings. Si danno priorità ai valori già impostati nei Settings,
916
+ * integrando eventualmente con le proprietà del grafico
917
+ *
918
+ * @param {BaseSettings} settings Impostazioni base ricevute dalla specializzazione del grafico
919
+ */
920
+ fillSettings(settings) {
921
+ var _a;
922
+ // Merge degli Input con i Settings, dando priorità ai Settings
923
+ settings.Theme = settings.Theme ? settings.Theme : this.Theme;
924
+ settings.Locale = settings.Locale ? settings.Locale : this.Locale;
925
+ settings.Animations = settings.Animations != null ? settings.Animations : this.Animations;
926
+ settings.Legend = settings.Legend != null ? settings.Legend : this.Legend;
927
+ settings.Name = settings.Name ? settings.Name : this.name;
928
+ settings.Timeline = settings.Timeline != null ? settings.Timeline : this.Timeline;
929
+ settings.AdaptLabelSizeAndOrientation = settings.AdaptLabelSizeAndOrientation != null ? settings.AdaptLabelSizeAndOrientation : this.AdaptLabelSizeAndOrientation;
930
+ settings.XAxisTitle = settings.XAxisTitle ? settings.XAxisTitle : this.XTitle;
931
+ settings.YAxisTitle = settings.YAxisTitle ? settings.YAxisTitle : this.YTitle;
932
+ settings.LegendPosition = settings.LegendPosition ? settings.LegendPosition : this.LegendPosition;
933
+ settings.HideSeriesOnLabelClick = settings.HideSeriesOnLabelClick != null ? settings.HideSeriesOnLabelClick : this.HideSeriesOnLabelClick;
934
+ settings.MinGridDistance = settings.MinGridDistance != null ? settings.MinGridDistance : this.MinGridDistance;
935
+ settings.LegendPadding = settings.LegendPadding ? settings.LegendPadding : (_a = this.LegendPadding) !== null && _a !== void 0 ? _a : null;
936
+ settings.ContainerHeight = this.el.nativeElement.parentElement.offsetHeight;
937
+ settings.OnSeriesClickCallback = (series) => { this.onSeriesClicked.emit(series); };
938
+ settings.OnSelectionChangedCallback = (event) => { this.onSelectionChanged.emit({ from: event.from, to: event.to, initial: event.initial }); };
939
+ }
940
+ /**
941
+ * Controlla i cambiamenti avvenuti alle proprietà chiave e rieffettua la graficazione qualora necessario
942
+ *
943
+ * @param {SimpleChanges} changes Indicazione della modifiche avvenute nei vari Input
944
+ * @param {string[]} propsToCheck Lista degli Input da controllare per cui una modifica causa una rigraficazione
945
+ */
946
+ checkPropertiesAndRegraphicateAsNeeded(changes, propsToCheck) {
947
+ let toReGraphicate = false;
948
+ for (let i = 0; i < propsToCheck.length; i++)
949
+ toReGraphicate = toReGraphicate || (changes[propsToCheck[i]] && changes[propsToCheck[i]].currentValue);
950
+ if (toReGraphicate)
951
+ this.reloadChart();
952
+ }
953
+ /**
954
+ * Funzione che effettua un cambio di pagina per i grafici paginati. Qualora **data** fosse nullo significa che è iniziato un caricamento
955
+ * e anche lato applicativo il DataRetrieve dovrà considerare che l'assenza di valori non è altro che un'indicazione di inizio caricamento
956
+ *
957
+ * Il caricamento di qualsiasi pagina genererà comunque una primo evento con **data** nullo in modo da indicare l'inizio caricamento e
958
+ * in seconda istanza un altro evento in cui **data** sarà sempre valorizzato, o con il Dto da usare per recuperare i dati, o con i dati
959
+ * veri e propri già presenti nel **DataArray**
960
+ *
961
+ * I callback **onLoadStart** e **onLoadEnd** vengono sempre chiamati
962
+ *
963
+ * @param {{ data: LineChartData | PieChartData | Vertical2DChartData | VerticalChartData | any, index: number }} nd Indice del caricamento dati, con eventualmente già i dati se disponibili
964
+ */
965
+ changePage(nd) {
966
+ if (!nd.data) {
967
+ this.loadingChart = true;
968
+ // Serve per informare l'applicativo in listening sull'indice attualmente in visualizzazione.
969
+ // La mancanza di dati indica che non devono essere effettuate ricerche per ora
970
+ if (this.DataRetrieve)
971
+ this.DataRetrieve(null, nd.index);
972
+ this.onLoadStart.emit();
878
973
  return;
879
974
  }
880
- this.log("DISPATCHER: Chart deregistered " + name);
881
- this.InitializedGraphs.splice(index, 1);
975
+ if (this.DataRetrieve)
976
+ this.DataRetrieve(nd.data, nd.index).then(t => { this.changePageDataReceived(t); });
977
+ else
978
+ this.changePageDataReceived(nd.data);
882
979
  }
883
980
  /**
884
- * Metodo che esegue in maniera sequenziale le funzioni di inizializzazione dei grafici finché presenti
885
- * in modo che nessun grafico possa essere inizializzato contemporaneamente ad un altro.
981
+ * Al termine del caricamento dei dati di una pagina questo metodo viene chiamato per rigraficare la situazione con i nuovi dati
886
982
  *
887
- * Questo è il punto chiave che permette di avere per ogni grafico temi e locale differenti
983
+ * @param {LineChartData | PieChartData | Vertical2DChartData | VerticalChartData | any} data Dati del grafico
888
984
  */
889
- drainInitQueues() {
890
- let toExecute = this.Initializations[0];
891
- this.log("DISPATCHER: Executing initialization function for chart " + toExecute.name);
892
- toExecute.function().then(() => {
893
- this.log("DISPATCHER: initialization for chart " + toExecute.name + " is done");
894
- this.InitializedGraphs.push(toExecute.name);
895
- this.Initializations.splice(0, 1);
896
- if (this.Initializations.length >= 1) {
897
- this.log("DISPATCHER: Found queued initializations. Continuing");
898
- this.drainInitQueues();
899
- }
900
- else
901
- this.log("DISPATCHER: queue is over, nothing more to do");
902
- });
985
+ changePageDataReceived(data) {
986
+ this.loadingChart = false;
987
+ this.onLoadEnd.emit();
988
+ let firstBind = !this.Data;
989
+ this.Data = data;
990
+ if (!firstBind)
991
+ this.reloadChart();
992
+ else
993
+ this.dispatchLoadChart();
903
994
  }
904
995
  /**
905
- * @ignore
996
+ * Ricarica il grafico distruggendo il vecchio e ricreando il nuovo
997
+ *
998
+ * Le chiamate a questo metodo possono essere trasformate in chiamate al metodo **graphicate** della Service, se solo quel metodo fosse abbastanza intelligente per capire
999
+ * le differenze fra il grafico com'era prima e come deve diventare, in modo da non ricrearlo ma semplicemente modificare quello che già è disegnato
906
1000
  */
907
- log(text) {
908
- if (this.logs)
909
- console.log("@esfaenza/es-charts: " + text);
1001
+ reloadChart() {
1002
+ this.browserOnly(() => {
1003
+ if (!this.Chart.isDisposed())
1004
+ this.Chart.dispose();
1005
+ this.Dispatcher.deregisterGraph(this.name);
1006
+ });
1007
+ this.Dispatcher.register(this.name, () => { return this.loadChart(); });
910
1008
  }
911
- }
912
- ChartDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartDispatcher, deps: [{ token: ESC_LOGS }], target: i0.ɵɵFactoryTarget.Injectable });
913
- ChartDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartDispatcher, providedIn: 'root' });
914
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartDispatcher, decorators: [{
915
- type: Injectable,
916
- args: [{ providedIn: 'root' }]
917
- }], ctorParameters: function () {
918
- return [{ type: undefined, decorators: [{
919
- type: Inject,
920
- args: [ESC_LOGS]
921
- }] }];
922
- } });
923
-
924
- /**
925
- * Componente specifico per la graficazione di un grafico a Linea su un asse temporale
926
- */
927
- class EsLineChartComponent extends BaseChartComponent {
928
1009
  /**
929
- * @ignore
1010
+ * Permette di aggiungere un blocco di dati in maniera "live" ad un grafico
930
1011
  */
931
- constructor(el, ChartLoader, ChartDispatcher, adapter, dateService, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
932
- super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
933
- this.adapter = adapter;
934
- this.dateService = dateService;
1012
+ addData(chartData) {
1013
+ this.ChartService.refreshData(chartData);
935
1014
  }
1015
+ ;
936
1016
  /**
937
- * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
1017
+ * Funzione che si occupa di caricare i temi necessari per il grafico in oggetto. Prima applica il tema, poi, se serve, applica le animazioni
938
1018
  */
939
- getSpecificPropertiesToCheck() {
940
- return ["Data", "DataArray", "Step", "DataGroupBucketSize", "DataGroupingThreshold", "StrokeSize", "Stacked", "AllowGaps", "MergeDatasets", "FinalInstants", "Fill", "Min", "Max"];
1019
+ setupAmChartsThemes() {
1020
+ return Promise.all([
1021
+ this.Charter.applyTheme(am4core, this.Theme).then(() => {
1022
+ return this.Animations ? this.Charter.applyAnimations(am4core) : this.Charter.unapplyAnimations(am4core);
1023
+ })
1024
+ ]);
941
1025
  }
942
1026
  /**
943
- * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
944
- *
945
- * @returns {LineChartSettings} Settings castati al tipo giusto
1027
+ * @ignore
946
1028
  */
947
- getCastedSettings() {
948
- var _a;
949
- return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new LineChartSettings());
1029
+ log(log) {
1030
+ if (this.logs)
1031
+ console.log("@esfaenza/es-charts: " + log);
950
1032
  }
951
1033
  /**
952
- * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
1034
+ * Imposta lo zoom dal **from** al **to**
953
1035
  *
954
- * @param {LineChartSettings} settingsCasted Settings castati al tipo giusto
1036
+ * @param {Date} from Inizio dello zoom
1037
+ * @param {Date} to Fine dello zoom
955
1038
  */
956
- fillSpecificSettings(settingsCasted) {
957
- settingsCasted.Step = settingsCasted.Step != null ? settingsCasted.Step : this.Step;
958
- settingsCasted.DataGroupBucketSize = settingsCasted.DataGroupBucketSize != null ? settingsCasted.DataGroupBucketSize : this.DataGroupBucketSize;
959
- settingsCasted.StrokeSize = settingsCasted.StrokeSize != null ? settingsCasted.StrokeSize : this.StrokeSize;
960
- settingsCasted.DataGroupingThreshold = settingsCasted.DataGroupingThreshold != null ? settingsCasted.DataGroupingThreshold : this.DataGroupingThreshold;
961
- settingsCasted.AllowGaps = settingsCasted.AllowGaps != null ? settingsCasted.AllowGaps : this.AllowGaps;
962
- settingsCasted.MergeDatasets = settingsCasted.MergeDatasets != null ? settingsCasted.MergeDatasets : this.MergeDatasets;
963
- settingsCasted.FinalInstants = settingsCasted.FinalInstants != null ? settingsCasted.FinalInstants : this.FinalInstants;
964
- settingsCasted.Min = settingsCasted.Min != null ? settingsCasted.Min : this.Min;
965
- settingsCasted.Max = settingsCasted.Max != null ? settingsCasted.Max : this.Max;
966
- settingsCasted.Fill = settingsCasted.Fill != null ? settingsCasted.Fill : this.Fill;
967
- settingsCasted.Stacked = settingsCasted.Stacked != null ? settingsCasted.Stacked : this.Stacked;
1039
+ setSelection(from, to) {
1040
+ this.ChartService.setSelection(from, to);
968
1041
  }
969
1042
  /**
970
- * Effettua il rendering di questo grafico in base ai Settings
971
- *
972
- * @param {LineChartSettings} settingsCasted Impostazioni di graficazione
973
- * @returns {LineChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
1043
+ * @ignore
974
1044
  */
975
- graphicate(settingsCasted) {
976
- return new LineChartService(this.adapter, this.dateService).graphicate(this.Data, settingsCasted);
1045
+ browserOnly(f) {
1046
+ if (isPlatformBrowser(this.platformId)) {
1047
+ this.zone.runOutsideAngular(() => {
1048
+ f();
1049
+ });
1050
+ }
977
1051
  }
978
1052
  }
979
- EsLineChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsLineChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i4.DateService }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4$1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
980
- EsLineChartComponentcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
981
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsLineChartComponent, decorators: [{
982
- type: Component,
983
- 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:rgba(153,153,153,.6);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"] }]
984
- }], ctorParameters: function () {
985
- return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i4.DateService }, { type: i0.NgZone }, { type: Object, decorators: [{
986
- type: Inject,
987
- args: [PLATFORM_ID]
988
- }] }, { type: undefined, decorators: [{
989
- type: Inject,
990
- args: [ESC_LOGS]
991
- }] }, { type: undefined, decorators: [{
992
- type: Inject,
993
- args: [ESC_ANIMATIONS]
994
- }] }, { type: undefined, decorators: [{
995
- type: Inject,
996
- args: [ESC_THEME]
997
- }] }, { type: i4$1.LocalizationService }];
998
- }, propDecorators: { Data: [{
1053
+ BaseChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseChartComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
1054
+ BaseChartComponentdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: BaseChartComponent, inputs: { XTitle: "XTitle", YTitle: "YTitle", Settings: "Settings", Legend: "Legend", LegendPosition: "LegendPosition", Timeline: "Timeline", name: "name", Animations: "Animations", Theme: "Theme", Locale: "Locale", HideSeriesOnLabelClick: "HideSeriesOnLabelClick", MinGridDistance: "MinGridDistance", AdaptLabelSizeAndOrientation: "AdaptLabelSizeAndOrientation", LegendPadding: "LegendPadding", DataDtos: "DataDtos", DataDtoStartIndex: "DataDtoStartIndex", DataRetrieve: "DataRetrieve", BrowseDelayMs: "BrowseDelayMs" }, outputs: { onSelectionChanged: "onSelectionChanged", onSeriesClicked: "onSeriesClicked", onLoadStart: "onLoadStart", onLoadEnd: "onLoadEnd", chartLoaded: "chartLoaded" }, queries: [{ propertyName: "header_tr", first: true, predicate: ["header"], descendants: true }, { propertyName: "loading_template", first: true, predicate: ["loading"], descendants: true }], usesOnChanges: true, ngImport: i0 });
1055
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseChartComponent, decorators: [{
1056
+ type: Directive
1057
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: Object }, { type: i0.NgZone }, { type: ChartLoader }, { type: ChartDispatcher }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }]; }, propDecorators: { XTitle: [{
999
1058
  type: Input
1000
- }], DataArray: [{
1059
+ }], YTitle: [{
1001
1060
  type: Input
1002
- }], Step: [{
1061
+ }], Settings: [{
1003
1062
  type: Input
1004
- }], DataGroupBucketSize: [{
1063
+ }], Legend: [{
1005
1064
  type: Input
1006
- }], DataGroupingThreshold: [{
1065
+ }], LegendPosition: [{
1007
1066
  type: Input
1008
- }], StrokeSize: [{
1067
+ }], Timeline: [{
1009
1068
  type: Input
1010
- }], AllowGaps: [{
1069
+ }], name: [{
1011
1070
  type: Input
1012
- }], MergeDatasets: [{
1071
+ }], Animations: [{
1013
1072
  type: Input
1014
- }], FinalInstants: [{
1073
+ }], Theme: [{
1015
1074
  type: Input
1016
- }], Min: [{
1075
+ }], Locale: [{
1017
1076
  type: Input
1018
- }], Max: [{
1077
+ }], HideSeriesOnLabelClick: [{
1019
1078
  type: Input
1020
- }], Fill: [{
1079
+ }], MinGridDistance: [{
1021
1080
  type: Input
1022
- }], Stacked: [{
1081
+ }], AdaptLabelSizeAndOrientation: [{
1082
+ type: Input
1083
+ }], LegendPadding: [{
1084
+ type: Input
1085
+ }], DataDtos: [{
1086
+ type: Input
1087
+ }], DataDtoStartIndex: [{
1088
+ type: Input
1089
+ }], DataRetrieve: [{
1090
+ type: Input
1091
+ }], BrowseDelayMs: [{
1023
1092
  type: Input
1093
+ }], header_tr: [{
1094
+ type: ContentChild,
1095
+ args: ['header', { static: false }]
1096
+ }], loading_template: [{
1097
+ type: ContentChild,
1098
+ args: ['loading', { static: false }]
1099
+ }], onSelectionChanged: [{
1100
+ type: Output
1101
+ }], onSeriesClicked: [{
1102
+ type: Output
1103
+ }], onLoadStart: [{
1104
+ type: Output
1105
+ }], onLoadEnd: [{
1106
+ type: Output
1107
+ }], chartLoaded: [{
1108
+ type: Output
1024
1109
  }] } });
1025
1110
 
1026
1111
  /**
1027
- * Classe il cui unico scopo è gestire il setup e rendering di un AreaChart
1112
+ * Classe il cui unico scopo è gestire il setup e rendering di un LineChart
1028
1113
  */
1029
- class AreaChartService {
1114
+ class LineChartService {
1030
1115
  /** @ignore */
1031
- constructor(Adapter) {
1116
+ constructor(Adapter, dateExts) {
1032
1117
  this.Adapter = Adapter;
1118
+ this.dateExts = dateExts;
1119
+ /** @ignore */
1120
+ this.DataGroupBucketSize = 1500;
1121
+ /** @ignore */
1122
+ this.OpacityOnSelected = 0.3;
1123
+ /** @ignore */
1124
+ this.OpacityOnFill = 0.75;
1125
+ /** @ignore */
1126
+ this.singleDataSet = false;
1033
1127
  //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
1034
1128
  //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
1035
1129
  /** @ignore */
1036
1130
  this.executionTimers = {};
1037
1131
  }
1038
1132
  /**
1039
- * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un AreaChart
1133
+ * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un LineChart
1040
1134
  */
1041
1135
  graphicate(data, settings) {
1042
- var _a, _b, _c, _d, _e, _f;
1043
- if (settings.Timeline) {
1044
- console.error("Timeline not supported for area chart");
1045
- return null;
1046
- }
1047
- let dataConverted = this.Adapter ? this.Adapter.adaptDataForAreaChart(data) : data;
1136
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1137
+ let dataConverted = this.Adapter ? this.Adapter.adaptDataForLineChart(data) : data;
1138
+ let threshold = (_a = settings.DataGroupingThreshold) !== null && _a !== void 0 ? _a : 3000;
1139
+ this.singleDataSet = (_b = settings.MergeDatasets) !== null && _b !== void 0 ? _b : false;
1048
1140
  let showTicks = settings.ShowTicks == null ? true : settings === null || settings === void 0 ? void 0 : settings.ShowTicks;
1049
- let interval = dataConverted.interval;
1141
+ let dataShouldBeGrouped = Math.max(...dataConverted.series.map(t => t.values.length)) > threshold;
1142
+ let showTimeline = settings.Timeline || dataShouldBeGrouped;
1143
+ let seriesWithInterval = dataConverted.series.some(t => t.interval);
1144
+ let interval = seriesWithInterval ? dataConverted.series.find(t => t.interval).interval : null;
1145
+ let gapsAllowed = (settings === null || settings === void 0 ? void 0 : settings.AllowGaps) == null ? seriesWithInterval : settings === null || settings === void 0 ? void 0 : settings.AllowGaps;
1146
+ let finalInstant = (_c = settings === null || settings === void 0 ? void 0 : settings.FinalInstants) !== null && _c !== void 0 ? _c : true;
1050
1147
  //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
1051
1148
  am4core.options.autoDispose = true;
1052
1149
  this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1053
1150
  let ChartInstanceCasted = this.ChartInstance;
1054
- if (settings.Legend) {
1055
- ChartInstanceCasted.legend = new am4charts.Legend();
1056
- ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
1057
- ChartInstanceCasted.legend.itemContainers.template.tooltipText = "{category}";
1058
- if (settings.LegendPadding) {
1059
- let template = this.ChartInstance.legend.itemContainers.template;
1060
- template.paddingTop = (_b = settings.LegendPadding.top) !== null && _b !== void 0 ? _b : 0;
1061
- template.paddingBottom = (_c = settings.LegendPadding.bottom) !== null && _c !== void 0 ? _c : 0;
1062
- template.paddingLeft = (_d = settings.LegendPadding.left) !== null && _d !== void 0 ? _d : 0;
1063
- template.paddingRight = (_e = settings.LegendPadding.right) !== null && _e !== void 0 ? _e : 0;
1151
+ let yAxis = ChartInstanceCasted.yAxes.push(new am4charts.ValueAxis());
1152
+ if (settings.YAxisTitle) {
1153
+ yAxis.title.text = settings.YAxisTitle;
1154
+ yAxis.title.fontWeight = "bold";
1155
+ }
1156
+ if (settings.Min)
1157
+ yAxis.min = settings.Min;
1158
+ if (settings.Max)
1159
+ yAxis.max = settings.Max;
1160
+ let limitNullOrUndef = dataConverted.limit == null || dataConverted.limit == undefined;
1161
+ let limits = limitNullOrUndef ? [] : !dataConverted.limit.length ? [dataConverted.limit] : dataConverted.limit;
1162
+ if (limits.length > 0) {
1163
+ for (let i = 0; i < limits.length; i++) {
1164
+ let limit = limits[i];
1165
+ if (limit.upper != null && limit.upper != undefined && limit.lower != null && limit.lower != undefined) {
1166
+ let range = yAxis.axisRanges.create();
1167
+ range.value = limit.lower;
1168
+ range.endValue = limit.upper;
1169
+ if (limit.fillColor) {
1170
+ range.contents.stroke = am4core.color(limit.fillColor);
1171
+ range.contents.fill = range.contents.stroke;
1172
+ }
1173
+ range.label.inside = true;
1174
+ range.label.text = limit.upperlabel;
1175
+ range.label.fill = range.grid.stroke;
1176
+ range.label.verticalCenter = "bottom";
1177
+ range.label.stroke = am4core.color(limit.uppercolor || "#F92200");
1178
+ range.grid.stroke = am4core.color(limit.uppercolor || "#F92200");
1179
+ range.grid.strokeWidth = 2;
1180
+ range.grid.strokeOpacity = 1;
1181
+ }
1182
+ else if ((limit.lower == null || limit.lower == undefined) && limit.upper != null && limit.upper != undefined) {
1183
+ let range = yAxis.axisRanges.create();
1184
+ range.value = limit.upper;
1185
+ range.label.inside = true;
1186
+ range.label.text = limit.upperlabel;
1187
+ range.label.fill = range.grid.stroke;
1188
+ range.label.verticalCenter = "bottom";
1189
+ range.label.stroke = am4core.color(limit.uppercolor || "#F92200");
1190
+ range.grid.stroke = am4core.color(limit.uppercolor || "#F92200");
1191
+ range.grid.strokeWidth = 2;
1192
+ range.grid.strokeOpacity = 1;
1193
+ }
1194
+ else if ((limit.upper == null || limit.upper == undefined) && limit.lower != null && limit.lower != undefined) {
1195
+ let range = yAxis.axisRanges.create();
1196
+ range.value = limit.lower;
1197
+ range.label.inside = true;
1198
+ range.label.text = limit.lowerlabel;
1199
+ range.label.fill = range.grid.stroke;
1200
+ range.label.verticalCenter = "bottom";
1201
+ range.label.stroke = am4core.color(limit.lowercolor || "#F92200");
1202
+ range.grid.stroke = am4core.color(limit.lowercolor || "#F92200");
1203
+ range.grid.strokeWidth = 2;
1204
+ range.grid.strokeOpacity = 1;
1205
+ }
1064
1206
  }
1065
1207
  }
1066
- let yAxis = ChartInstanceCasted.yAxes.push(new am4charts.ValueAxis());
1067
- yAxis.tooltip.disabled = true;
1068
- if (settings.YAxisTitle) {
1069
- yAxis.title.text = settings.YAxisTitle;
1070
- yAxis.title.fontWeight = "bold";
1071
- }
1072
- yAxis.min = 0;
1073
- let dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
1074
- dateAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 50;
1075
- dateAxis.startLocation = 0.5;
1076
- dateAxis.endLocation = 0.5;
1208
+ this.dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
1209
+ // Per comatibilità col codice scritto quando non era a livello globale, mi scoccia sostituire
1210
+ let dateAxis = this.dateAxis;
1077
1211
  if (settings.XAxisTitle) {
1078
1212
  dateAxis.title.text = settings.XAxisTitle;
1079
1213
  dateAxis.title.fontWeight = "bold";
@@ -1086,40 +1220,207 @@ class AreaChartService {
1086
1220
  dateAxis.renderer.ticks.template.length = 10;
1087
1221
  dateAxis.renderer.ticks.template.location = 0;
1088
1222
  }
1089
- if (!!interval)
1223
+ dateAxis.renderer.minGridDistance = (_d = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _d !== void 0 ? _d : 50;
1224
+ dateAxis.renderer.grid.template.location = 0;
1225
+ dateAxis.minZoomCount = 5;
1226
+ dateAxis.groupData = dataShouldBeGrouped;
1227
+ dateAxis.groupCount = (_e = settings.DataGroupBucketSize) !== null && _e !== void 0 ? _e : this.DataGroupBucketSize;
1228
+ //Se ho almeno una serie ad intervallo e i settings non mi impediscono esplicitamente di usare i gaps, visualizzo i dati col gap
1229
+ if (gapsAllowed) {
1230
+ if (!seriesWithInterval) {
1231
+ console.error("Per utilizzare la funzionalità dei gap è obbligatorio definire un intervallo nelle serie del grafico");
1232
+ return null;
1233
+ }
1090
1234
  dateAxis.baseInterval = { count: interval.count, timeUnit: interval.timeunit };
1091
- // Unisco il dataset e tiro fuori i dati
1092
- let chartData = [];
1093
- let seriesToMakeCache = {};
1094
- let seriesToMake = [];
1095
- for (let i = 0; i < dataConverted.groups.length; i++) {
1096
- let group = dataConverted.groups[i];
1097
- let dataItem = { date: group.name };
1098
- for (let ii = 0; ii < group.values.length; ii++) {
1099
- let val = group.values[ii];
1100
- dataItem[val.k] = val.v;
1101
- if (!seriesToMakeCache[val.k]) {
1102
- seriesToMakeCache[val.k] = true;
1103
- seriesToMake.push(val.k);
1235
+ }
1236
+ if (showTimeline)
1237
+ ChartInstanceCasted.scrollbarX = new am4charts.XYChartScrollbar();
1238
+ let seriesToPush = [];
1239
+ let seriesColors = [];
1240
+ let defaultIndex = 0;
1241
+ // Ordinamento dei dati se serve
1242
+ dataConverted.series.forEach((s) => {
1243
+ if (s.values[0] && !(s.values[0].d instanceof Date)) {
1244
+ for (let v = 0; v < s.values.length; v++)
1245
+ s.values[v].d = new Date(s.values[v].d);
1246
+ }
1247
+ var correctOrder = true;
1248
+ var prevDate = null;
1249
+ for (let v = 0; v < s.values.length; v++) {
1250
+ if (!prevDate)
1251
+ prevDate = s.values[v].d;
1252
+ else if (s.values[v].d < prevDate) {
1253
+ correctOrder = false;
1254
+ break;
1104
1255
  }
1105
1256
  }
1106
- chartData.push(dataItem);
1257
+ if (!correctOrder)
1258
+ s.values.sort((d1, d2) => d1.d.getTime() - d2.d.getTime());
1259
+ });
1260
+ // Generazione di un unico dataset invece che N, per poter gestire un unico tooltip
1261
+ if (this.singleDataSet) {
1262
+ this.ChartInstance.data = this.generateSingleDataset(dataConverted);
1263
+ ;
1264
+ dateAxis.cursorTooltipEnabled = false;
1265
+ }
1266
+ dataConverted.series.forEach((s, index) => {
1267
+ var _a, _b, _c, _d;
1268
+ let stacked = s.stacked != null && s.stacked != undefined ? s.stacked : ((_a = settings === null || settings === void 0 ? void 0 : settings.Stacked) !== null && _a !== void 0 ? _a : false);
1269
+ let fill = stacked || (s.fill != null && s.fill != undefined ? s.fill : ((_b = settings === null || settings === void 0 ? void 0 : settings.Fill) !== null && _b !== void 0 ? _b : false));
1270
+ let series = (settings === null || settings === void 0 ? void 0 : settings.Step) ? new am4charts.StepLineSeries() : new am4charts.LineSeries();
1271
+ series.dataFields.valueY = "v" + (this.singleDataSet ? index : "");
1272
+ series.dataFields.dateX = "d";
1273
+ series.measureUnit = s.uom;
1274
+ series.name = s.name;
1275
+ series.strokeWidth = (_c = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _c !== void 0 ? _c : 1;
1276
+ series.connect = !gapsAllowed;
1277
+ series.minBulletDistance = 10;
1278
+ series.tooltipText = this.singleDataSet ? "" : s.name ? "{name}: [bold]{valueY}[/]" : "[bold]{valueY}[/]";
1279
+ series.tooltip.pointerOrientation = "vertical";
1280
+ series.tooltip.background.fillOpacity = 0.5;
1281
+ series.tooltip.label.padding(12, 12, 12, 12);
1282
+ series.fillOpacity = fill ? this.OpacityOnFill : 0.0001;
1283
+ series.stacked = stacked;
1284
+ series.hidden = s.hidden;
1285
+ //Dataset singolo, i dati sono registrati a livello di chart, creo il tooltip che permette di vederli tutti insieme
1286
+ //altrimenti assegno i dati della serie direttamente alla serie
1287
+ if (this.singleDataSet) {
1288
+ series.tooltip.getFillFromObject = false;
1289
+ series.tooltip.background.fill = am4core.color("#eee");
1290
+ series.tooltip.label.fill = am4core.color("#00");
1291
+ series.tooltip.defaultState.transitionDuration = 0;
1292
+ series.tooltip.hiddenState.transitionDuration = 0;
1293
+ //Utilizzo il mio dateService per la formattazione della data in modo che non debba mai gestire n formati fra n librerie... bellissimo
1294
+ series.dateFormatter.format = (source) => {
1295
+ if (interval && finalInstant && ["hour", "minute", "second"].includes(interval.timeunit)) {
1296
+ let timepart = null;
1297
+ switch (interval.timeunit) {
1298
+ case "hour":
1299
+ timepart = 'day';
1300
+ break;
1301
+ case "minute":
1302
+ timepart = 'hour';
1303
+ break;
1304
+ case "second":
1305
+ timepart = 'minute';
1306
+ break;
1307
+ }
1308
+ if (timepart)
1309
+ return this.dateExts.adjustDateToFinalInstant(source, timepart, interval ? interval.timeunit == "second" : false);
1310
+ }
1311
+ else
1312
+ return this.dateExts.getFormatted(source, interval ? ["day", "week", "month", "year"].includes(interval.timeunit) : false, interval ? interval.timeunit == "second" : false);
1313
+ };
1314
+ series.adapter.add("tooltipText", () => {
1315
+ var text = "[bold]{dateX.formatDate()}[/]\n";
1316
+ this.ChartInstance.series.each((item) => {
1317
+ let uom = " [font-style: italic]" + series.measureUnit || "" + "[/]";
1318
+ text += "[" + item.stroke.hex + "]●[/] " + (item.name ? (item.name + ": ") : "") + "[bold]{" + item.dataFields.valueY + "}[/]" + uom + "\n";
1319
+ });
1320
+ return text;
1321
+ });
1322
+ }
1323
+ else
1324
+ series.data = s.values;
1325
+ let segment = series.segments.template;
1326
+ let hoverState = segment.states.create("hover");
1327
+ hoverState.properties.strokeWidth = ((_d = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _d !== void 0 ? _d : 1) + 1;
1328
+ let dimmed = segment.states.create("dimmed");
1329
+ dimmed.properties.stroke = am4core.color("#dadada");
1330
+ //Se la serie ha un colore, uso quello, altrimenti pesco dai colori di default andando in ordine
1331
+ if (s.color)
1332
+ seriesColors.push(am4core.color(s.color));
1333
+ else {
1334
+ seriesColors.push(ChartInstanceCasted.colors.list[defaultIndex % ChartInstanceCasted.colors.list.length]);
1335
+ defaultIndex++;
1336
+ }
1337
+ seriesToPush.push(series);
1338
+ });
1339
+ ChartInstanceCasted.colors.list = seriesColors;
1340
+ //Scrivo le serie nel grafico
1341
+ seriesToPush.forEach(s => {
1342
+ ChartInstanceCasted.series.push(s);
1343
+ if (showTimeline)
1344
+ ChartInstanceCasted.scrollbarX.series.push(s);
1345
+ });
1346
+ if (settings.Legend) {
1347
+ this.ChartInstance.legend = new am4charts.Legend();
1348
+ this.ChartInstance.legend.position = (_f = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _f !== void 0 ? _f : 'right';
1349
+ this.ChartInstance.legend.scrollable = true;
1350
+ this.ChartInstance.legend.itemContainers.template.tooltipText = "{name}";
1351
+ this.ChartInstance.legend.itemContainers.template.events.on("over", (event) => { this.processOver(event.target.dataItem.dataContext); });
1352
+ this.ChartInstance.legend.itemContainers.template.events.on("out", () => { this.processOut(); });
1353
+ if (settings.LegendPadding) {
1354
+ let template = this.ChartInstance.legend.itemContainers.template;
1355
+ template.paddingTop = (_g = settings.LegendPadding.top) !== null && _g !== void 0 ? _g : 0;
1356
+ template.paddingBottom = (_h = settings.LegendPadding.bottom) !== null && _h !== void 0 ? _h : 0;
1357
+ template.paddingLeft = (_j = settings.LegendPadding.left) !== null && _j !== void 0 ? _j : 0;
1358
+ template.paddingRight = (_k = settings.LegendPadding.right) !== null && _k !== void 0 ? _k : 0;
1359
+ }
1360
+ }
1361
+ this.ChartInstance.cursor = new am4charts.XYCursor();
1362
+ //Prove******************************************************************************************************************************
1363
+ // this.ChartInstance.cursor.events.on("cursorpositionchanged", (ev) => {
1364
+ // //var value = dateAxis.positionToDate(dateAxis.toAxisPosition(ev.target.xPosition));
1365
+ // var dt = dateAxis.series.values.find(t => t.dataItem.values.dateX);
1366
+ // if (dt && dt.dataItem) {
1367
+ // console.log(dt.dataItem.values);
1368
+ // // this.ChartInstance.tooltipText = dt;
1369
+ // }
1370
+ // else {
1371
+ // this.ChartInstance.tooltipText = "";
1372
+ // }
1373
+ // });
1374
+ //******************************************************************************************************************************
1375
+ this.ChartInstance.cursor.xAxis = dateAxis;
1376
+ this.ChartInstance.cursor.yAxis = yAxis;
1377
+ if (this.singleDataSet)
1378
+ this.ChartInstance.cursor.maxTooltipDistance = -1;
1379
+ //TODO: Cercare di capire perché è figlio di puttana......
1380
+ dateAxis.events.on("startchanged", t => this.emitSelectionChanged(t, settings));
1381
+ dateAxis.events.on("endchanged", t => this.emitSelectionChanged(t, settings));
1382
+ return this;
1383
+ }
1384
+ /** @ignore */
1385
+ setSelection(from, to) {
1386
+ this.dateAxis.zoomToDates(from, to, true, true);
1387
+ }
1388
+ /** @ignore */
1389
+ refreshData(data) {
1390
+ let dataConverted = this.Adapter ? this.Adapter.adaptDataForLineChart(data) : data;
1391
+ if (this.singleDataSet) {
1392
+ var data = this.generateSingleDataset(dataConverted);
1393
+ this.ChartInstance.addData(data);
1394
+ return;
1395
+ }
1396
+ throw "Impossibile aggiornare i dati senza unire il dataset. Si prega di impostare [MergeDatasets] a true";
1397
+ }
1398
+ /** Partendo da dati divisi per seriue genera un dataset unito con la data come chiave e i vari valori dopo */
1399
+ generateSingleDataset(data) {
1400
+ let dto = {};
1401
+ data.series.forEach((vs, index) => {
1402
+ for (let i = 0; i < vs.values.length; i++) {
1403
+ var dataitem = vs.values[i];
1404
+ var indexer = new Date(dataitem.d).valueOf();
1405
+ if (!dto[indexer])
1406
+ dto[indexer] = {};
1407
+ dto[indexer]['v' + index] = dataitem.v;
1408
+ }
1409
+ });
1410
+ var dates = Object.keys(dto);
1411
+ var ret = [];
1412
+ for (let i = 0; i < dates.length; i++) {
1413
+ let values = dto[dates[i]];
1414
+ let item = { d: new Date(parseInt(dates[i])) };
1415
+ var vals = Object.keys(values);
1416
+ for (let ii = 0; ii < vals.length; ii++) {
1417
+ let series = vals[ii];
1418
+ let singleVal = values[series];
1419
+ item[series] = singleVal;
1420
+ }
1421
+ ret.push(item);
1107
1422
  }
1108
- ChartInstanceCasted.data = chartData;
1109
- //---------------------------------------------------------
1110
- seriesToMake.forEach(s => { this.createSeries(ChartInstanceCasted, s); });
1111
- ChartInstanceCasted.cursor = new am4charts.XYCursor();
1112
- ChartInstanceCasted.cursor.xAxis = dateAxis;
1113
- dateAxis.events.on("startchanged", t => this.emitSelectionChanged(t, settings));
1114
- dateAxis.events.on("endchanged", t => this.emitSelectionChanged(t, settings));
1115
- return this;
1116
- }
1117
- /** @ignore */
1118
- setSelection(from, to) {
1119
- }
1120
- /** @ignore */
1121
- refreshData(data) {
1122
- //TODO:IMPL
1423
+ return ret;
1123
1424
  }
1124
1425
  /** @ignore */
1125
1426
  emitSelectionChanged(ev, settings) {
@@ -1134,20 +1435,40 @@ class AreaChartService {
1134
1435
  }
1135
1436
  }
1136
1437
  /** @ignore */
1137
- createSeries(chart, name) {
1138
- let series = chart.series.push(new am4charts.LineSeries());
1139
- series.dataFields.dateX = "date";
1140
- series.name = name[0].toUpperCase() + name.slice(1);
1141
- series.dataFields.valueY = name;
1142
- series.tooltipText = "[#000]{valueY.value}[/]";
1143
- //series.tooltip.background.fill = am4core.color("#FFF");
1144
- series.tooltip.getStrokeFromObject = true;
1145
- series.tooltip.background.strokeWidth = 3;
1146
- series.tooltip.getFillFromObject = false;
1147
- series.fillOpacity = 0.6;
1148
- series.strokeWidth = 2;
1149
- series.stacked = true;
1150
- return series;
1438
+ processOver(hoveredSeries) {
1439
+ hoveredSeries.zIndex = 999;
1440
+ let fill = hoveredSeries.fillOpacity == this.OpacityOnFill;
1441
+ hoveredSeries.segments.each((segment) => {
1442
+ segment.setState("hover");
1443
+ if (!fill)
1444
+ segment.fillSprite.fillOpacity = this.OpacityOnSelected;
1445
+ });
1446
+ if (!fill)
1447
+ hoveredSeries.legendDataItem.marker.children.getIndex(1).fillOpacity = this.OpacityOnSelected;
1448
+ this.ChartInstance.series.each((series) => {
1449
+ if (series != hoveredSeries) {
1450
+ let fill = series.fillOpacity == this.OpacityOnFill;
1451
+ series.segments.each((segment) => {
1452
+ segment.setState("dimmed");
1453
+ if (!fill)
1454
+ segment.fillSprite.fillOpacity = 0;
1455
+ });
1456
+ }
1457
+ });
1458
+ }
1459
+ /** @ignore */
1460
+ processOut() {
1461
+ this.ChartInstance.series.each((series, i) => {
1462
+ series.zIndex = i;
1463
+ let fill = series.fillOpacity == this.OpacityOnFill;
1464
+ series.segments.each((segment) => {
1465
+ segment.setState("default");
1466
+ if (!fill)
1467
+ segment.fillSprite.fillOpacity = 0;
1468
+ });
1469
+ if (!fill)
1470
+ series.legendDataItem.marker.children.getIndex(1).fillOpacity = 0;
1471
+ });
1151
1472
  }
1152
1473
  /** @ignore */
1153
1474
  throttla(id, func, throttleTime) {
@@ -1159,74 +1480,6 @@ class AreaChartService {
1159
1480
  }
1160
1481
  }
1161
1482
 
1162
- /**
1163
- * Componente specifico per la graficazione di un grafico ad Area
1164
- */
1165
- class EsAreaChartComponent extends BaseChartComponent {
1166
- /**
1167
- * @ignore
1168
- */
1169
- constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
1170
- super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
1171
- this.adapter = adapter;
1172
- }
1173
- /**
1174
- * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
1175
- */
1176
- getSpecificPropertiesToCheck() {
1177
- return ["Data", "DataArray"];
1178
- }
1179
- /**
1180
- * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
1181
- *
1182
- * @returns {AreaChartSettings} Settings castati al tipo giusto
1183
- */
1184
- getCastedSettings() {
1185
- var _a;
1186
- return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new AreaChartSettings());
1187
- }
1188
- /**
1189
- * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
1190
- *
1191
- * @param {AreaChartSettings} settingsCasted Settings castati al tipo giusto
1192
- */
1193
- fillSpecificSettings(settingsCasted) {
1194
- }
1195
- /**
1196
- * Effettua il rendering di questo grafico in base ai Settings
1197
- *
1198
- * @param {AreaChartSettings} settingsCasted Impostazioni di graficazione
1199
- * @returns {AreaChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
1200
- */
1201
- graphicate(settingsCasted) {
1202
- return new AreaChartService(this.adapter).graphicate(this.Data, settingsCasted);
1203
- }
1204
- }
1205
- EsAreaChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsAreaChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4$1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
1206
- EsAreaChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsAreaChartComponent, selector: "es-area-chart", inputs: { Data: "Data", DataArray: "DataArray" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1207
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsAreaChartComponent, decorators: [{
1208
- type: Component,
1209
- args: [{ selector: 'es-area-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:rgba(153,153,153,.6);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"] }]
1210
- }], ctorParameters: function () {
1211
- return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
1212
- type: Inject,
1213
- args: [PLATFORM_ID]
1214
- }] }, { type: undefined, decorators: [{
1215
- type: Inject,
1216
- args: [ESC_LOGS]
1217
- }] }, { type: undefined, decorators: [{
1218
- type: Inject,
1219
- args: [ESC_ANIMATIONS]
1220
- }] }, { type: undefined, decorators: [{
1221
- type: Inject,
1222
- args: [ESC_THEME]
1223
- }] }, { type: i4$1.LocalizationService }];
1224
- }, propDecorators: { Data: [{
1225
- type: Input
1226
- }], DataArray: [{
1227
- type: Input
1228
- }] } });
1229
-
1230
1483
  /**
1231
1484
  * Classe il cui unico scopo è gestire il setup e rendering di un PieChart
1232
1485
  */
@@ -1311,134 +1564,43 @@ class PieChartService {
1311
1564
  if (settings.OnSeriesClickCallback) {
1312
1565
  let clickedSeries = ev.target.dataItem.dataContext.legendDataItem.name;
1313
1566
  settings.OnSeriesClickCallback(clickedSeries);
1314
- }
1315
- });
1316
- }
1317
- if (settings.LegendPadding) {
1318
- let template = this.ChartInstance.legend.itemContainers.template;
1319
- template.paddingTop = (_a = settings.LegendPadding.top) !== null && _a !== void 0 ? _a : 0;
1320
- template.paddingBottom = (_b = settings.LegendPadding.bottom) !== null && _b !== void 0 ? _b : 0;
1321
- template.paddingLeft = (_c = settings.LegendPadding.left) !== null && _c !== void 0 ? _c : 0;
1322
- template.paddingRight = (_d = settings.LegendPadding.right) !== null && _d !== void 0 ? _d : 0;
1323
- }
1324
- }
1325
- return this;
1326
- }
1327
- /** @ignore */
1328
- setSelection(from, to) {
1329
- }
1330
- /** @ignore */
1331
- refreshData(data) {
1332
- //TODO:IMPL
1333
- }
1334
- /** @ignore */
1335
- hideZeroes(ev) {
1336
- if (ev.target.dataItem && (ev.target.dataItem.values.value.percent == 0))
1337
- ev.target.hide();
1338
- else
1339
- ev.target.show();
1340
- }
1341
- }
1342
-
1343
- /**
1344
- * Componente specifico per la graficazione di un grafico a Torta
1345
- */
1346
- class EsPieChartComponent extends BaseChartComponent {
1347
- /**
1348
- * @ignore
1349
- */
1350
- constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
1351
- super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
1352
- this.adapter = adapter;
1353
- }
1354
- /**
1355
- * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
1356
- */
1357
- getSpecificPropertiesToCheck() {
1358
- return ["Data", "DataArray", "HideZeroes", "Mode3D", "LabelsWrap", "LabelsTruncate", "LabelsWidth", "LabelsVisible"];
1359
- }
1360
- /**
1361
- * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
1362
- *
1363
- * @returns {PieChartSettings} Settings castati al tipo giusto
1364
- */
1365
- getCastedSettings() {
1366
- var _a;
1367
- return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new PieChartSettings());
1368
- }
1369
- /**
1370
- * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
1371
- *
1372
- * @param {PieChartSettings} settingsCasted Settings castati al tipo giusto
1373
- */
1374
- fillSpecificSettings(settingsCasted) {
1375
- settingsCasted.HideZeroes = settingsCasted.HideZeroes != null ? settingsCasted.HideZeroes : this.HideZeroes;
1376
- settingsCasted.Mode3D = settingsCasted.Mode3D != null ? settingsCasted.Mode3D : this.Mode3D;
1377
- settingsCasted.DonutRadiusPercentage = settingsCasted.DonutRadiusPercentage != null ? settingsCasted.DonutRadiusPercentage : this.DonutRadiusPercentage;
1378
- settingsCasted.LabelsWrap = settingsCasted.LabelsWrap != null ? settingsCasted.LabelsWrap : this.LabelsWrap;
1379
- settingsCasted.LabelsTruncate = settingsCasted.LabelsTruncate != null ? settingsCasted.LabelsTruncate : this.LabelsTruncate;
1380
- settingsCasted.LabelsWidth = settingsCasted.LabelsWidth != null ? settingsCasted.LabelsWidth : this.LabelsWidth;
1381
- settingsCasted.LabelsVisible = settingsCasted.LabelsVisible != null ? settingsCasted.LabelsVisible : this.LabelsVisible;
1382
- }
1383
- /**
1384
- * Effettua il rendering di questo grafico in base ai Settings
1385
- *
1386
- * @param {PieChartSettings} settingsCasted Impostazioni di graficazione
1387
- * @returns {PieChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
1388
- */
1389
- graphicate(settingsCasted) {
1390
- return new PieChartService(this.adapter).graphicate(this.Data, settingsCasted);
1391
- }
1392
- }
1393
- EsPieChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsPieChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4$1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
1394
- EsPieChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsPieChartComponent, selector: "es-pie-chart", inputs: { Data: "Data", DataArray: "DataArray", HideZeroes: "HideZeroes", Mode3D: "Mode3D", DonutRadiusPercentage: "DonutRadiusPercentage", LabelsWrap: "LabelsWrap", LabelsTruncate: "LabelsTruncate", LabelsWidth: "LabelsWidth", LabelsVisible: "LabelsVisible" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1395
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsPieChartComponent, decorators: [{
1396
- type: Component,
1397
- args: [{ selector: 'es-pie-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:rgba(153,153,153,.6);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"] }]
1398
- }], ctorParameters: function () {
1399
- return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
1400
- type: Inject,
1401
- args: [PLATFORM_ID]
1402
- }] }, { type: undefined, decorators: [{
1403
- type: Inject,
1404
- args: [ESC_LOGS]
1405
- }] }, { type: undefined, decorators: [{
1406
- type: Inject,
1407
- args: [ESC_ANIMATIONS]
1408
- }] }, { type: undefined, decorators: [{
1409
- type: Inject,
1410
- args: [ESC_THEME]
1411
- }] }, { type: i4$1.LocalizationService }];
1412
- }, propDecorators: { Data: [{
1413
- type: Input
1414
- }], DataArray: [{
1415
- type: Input
1416
- }], HideZeroes: [{
1417
- type: Input
1418
- }], Mode3D: [{
1419
- type: Input
1420
- }], DonutRadiusPercentage: [{
1421
- type: Input
1422
- }], LabelsWrap: [{
1423
- type: Input
1424
- }], LabelsTruncate: [{
1425
- type: Input
1426
- }], LabelsWidth: [{
1427
- type: Input
1428
- }], LabelsVisible: [{
1429
- type: Input
1430
- }] } });
1567
+ }
1568
+ });
1569
+ }
1570
+ if (settings.LegendPadding) {
1571
+ let template = this.ChartInstance.legend.itemContainers.template;
1572
+ template.paddingTop = (_a = settings.LegendPadding.top) !== null && _a !== void 0 ? _a : 0;
1573
+ template.paddingBottom = (_b = settings.LegendPadding.bottom) !== null && _b !== void 0 ? _b : 0;
1574
+ template.paddingLeft = (_c = settings.LegendPadding.left) !== null && _c !== void 0 ? _c : 0;
1575
+ template.paddingRight = (_d = settings.LegendPadding.right) !== null && _d !== void 0 ? _d : 0;
1576
+ }
1577
+ }
1578
+ return this;
1579
+ }
1580
+ /** @ignore */
1581
+ setSelection(from, to) {
1582
+ }
1583
+ /** @ignore */
1584
+ refreshData(data) {
1585
+ //TODO:IMPL
1586
+ }
1587
+ /** @ignore */
1588
+ hideZeroes(ev) {
1589
+ if (ev.target.dataItem && (ev.target.dataItem.values.value.percent == 0))
1590
+ ev.target.hide();
1591
+ else
1592
+ ev.target.show();
1593
+ }
1594
+ }
1431
1595
 
1432
1596
  /**
1433
- * Classe il cui unico scopo è gestire il setup e rendering di un Vertical2DChart
1597
+ * Classe il cui unico scopo è gestire il setup e rendering di un VerticalChart
1434
1598
  */
1435
- class Vertical2DChartService {
1599
+ class VerticalChartService {
1436
1600
  /** @ignore */
1437
1601
  constructor(Adapter) {
1438
1602
  this.Adapter = Adapter;
1439
1603
  /** @ignore */
1440
- this.DefaultGroupPaddingPercentage = 5;
1441
- /** @ignore */
1442
1604
  this.dangerZone = 50;
1443
1605
  /** @ignore */
1444
1606
  this.LabelWidth = 150;
@@ -1450,10 +1612,10 @@ class Vertical2DChartService {
1450
1612
  this.DefaultColumnWidthPercentage = 85;
1451
1613
  }
1452
1614
  /**
1453
- * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un Vertical2DChart
1615
+ * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un VerticalChart
1454
1616
  */
1455
1617
  graphicate(data, settings) {
1456
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1618
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1457
1619
  if (settings.Timeline) {
1458
1620
  console.error("Timeline not supported for vertical chart");
1459
1621
  return null;
@@ -1462,6 +1624,9 @@ class Vertical2DChartService {
1462
1624
  am4core.options.autoDispose = true;
1463
1625
  this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1464
1626
  let ChartInstanceCasted = this.ChartInstance;
1627
+ let dataConverted = this.Adapter ? this.Adapter.adaptDataForVerticalChart(data) : data;
1628
+ ChartInstanceCasted.data = dataConverted.values;
1629
+ let noStrokes = dataConverted.values.some(t => !!t.c);
1465
1630
  if (settings.Legend) {
1466
1631
  ChartInstanceCasted.legend = new am4charts.Legend();
1467
1632
  ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
@@ -1484,15 +1649,12 @@ class Vertical2DChartService {
1484
1649
  categoryAxis.title.text = settings.XAxisTitle;
1485
1650
  categoryAxis.title.fontWeight = "bold";
1486
1651
  }
1487
- yAxis.min = 0;
1488
- categoryAxis.dataFields.category = 'key';
1489
- categoryAxis.renderer.cellStartLocation = am4core.percent((_f = settings.GroupPaddingPercentage) !== null && _f !== void 0 ? _f : this.DefaultGroupPaddingPercentage).value;
1490
- categoryAxis.renderer.cellEndLocation = am4core.percent(100 - ((_g = settings.GroupPaddingPercentage) !== null && _g !== void 0 ? _g : this.DefaultGroupPaddingPercentage)).value;
1652
+ categoryAxis.dataFields.category = "k";
1491
1653
  categoryAxis.renderer.grid.template.location = 0;
1492
- categoryAxis.renderer.minGridDistance = (_h = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _h !== void 0 ? _h : 30;
1654
+ categoryAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 30;
1493
1655
  let label = categoryAxis.renderer.labels.template;
1494
1656
  label.truncate = true;
1495
- label.maxWidth = (_j = settings.LabelWidth) !== null && _j !== void 0 ? _j : this.LabelWidth;
1657
+ label.maxWidth = (_g = settings.LabelWidth) !== null && _g !== void 0 ? _g : this.LabelWidth;
1496
1658
  label.tooltipText = "{category}";
1497
1659
  if ((settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) == null ? true : settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) {
1498
1660
  categoryAxis.events.on("sizechanged", (ev) => {
@@ -1516,24 +1678,24 @@ class Vertical2DChartService {
1516
1678
  }
1517
1679
  });
1518
1680
  }
1519
- let dataPreConverted = this.Adapter ? this.Adapter.adaptDataForVertical2DChart(data) : data;
1520
- let dataConverted = [];
1521
- for (let i = 0; i < dataPreConverted.groups.length; i++) {
1522
- let item = dataPreConverted.groups[i];
1523
- let obj = { key: item.name };
1524
- for (let p = 0; p < item.values.length; p++) {
1525
- let value = item.values[p];
1526
- obj[value.k] = value.v;
1527
- }
1528
- dataConverted.push(obj);
1681
+ // Create series
1682
+ let series = ChartInstanceCasted.series.push(new am4charts.ColumnSeries());
1683
+ series.dataFields.valueY = "v";
1684
+ series.dataFields.categoryX = "k";
1685
+ series.name = "";
1686
+ let columnTemplate = series.columns.template;
1687
+ columnTemplate.tooltipText = "{categoryX}: [bold]{valueY}[/] {t}";
1688
+ columnTemplate.fillOpacity = .8;
1689
+ columnTemplate.width = am4core.percent((_h = settings.ColumnWidthPercentage) !== null && _h !== void 0 ? _h : this.DefaultColumnWidthPercentage);
1690
+ if (noStrokes) {
1691
+ columnTemplate.strokeOpacity = 0;
1692
+ columnTemplate.strokeWidth = 0;
1693
+ columnTemplate.adapter.add("fill", (_, target) => am4core.color(target.dataItem.dataContext.c));
1694
+ }
1695
+ else {
1696
+ columnTemplate.strokeWidth = 2;
1697
+ columnTemplate.strokeOpacity = 1;
1529
1698
  }
1530
- ChartInstanceCasted.data = dataConverted;
1531
- if (dataPreConverted.colorinfos)
1532
- ChartInstanceCasted.colors.list = dataPreConverted.colorinfos.map(c => am4core.color(c.color));
1533
- //Prendo la prima categoria e mi baso sulle proprietà per dfeinire le serie
1534
- for (let prop in dataConverted[0])
1535
- if (prop !== "key")
1536
- this.createSeries(ChartInstanceCasted, settings, prop, prop);
1537
1699
  return this;
1538
1700
  }
1539
1701
  /** @ignore */
@@ -1543,150 +1705,18 @@ class Vertical2DChartService {
1543
1705
  refreshData(data) {
1544
1706
  //TODO:IMPL
1545
1707
  }
1546
- /** @ignore */
1547
- createSeries(chart, settings, value, name) {
1548
- var _a;
1549
- let series = chart.series.push(new am4charts.ColumnSeries());
1550
- series.dataFields.valueY = value;
1551
- series.dataFields.categoryX = 'key';
1552
- series.name = name;
1553
- series.columns.template.tooltipText = "{name} {categoryX}: [bold]{valueY}[/]";
1554
- series.columns.template.fillOpacity = .8;
1555
- series.columns.template.width = am4core.percent((_a = settings.ColumnWidthPercentage) !== null && _a !== void 0 ? _a : this.DefaultColumnWidthPercentage);
1556
- series.events.on("hidden", () => this.arrangeColumns);
1557
- series.events.on("shown", () => this.arrangeColumns);
1558
- return series;
1559
- }
1560
- /** @ignore */
1561
- arrangeColumns() {
1562
- let ChartInstanceCasted = this.ChartInstance;
1563
- let series = ChartInstanceCasted.series.getIndex(0);
1564
- let xAxis = ChartInstanceCasted.xAxes.getIndex(0);
1565
- let w = 1 - xAxis.renderer.cellStartLocation - (1 - xAxis.renderer.cellEndLocation);
1566
- if (series.dataItems.length > 1) {
1567
- let x0 = xAxis.getX(series.dataItems.getIndex(0), "categoryX");
1568
- let x1 = xAxis.getX(series.dataItems.getIndex(1), "categoryX");
1569
- let delta = ((x1 - x0) / ChartInstanceCasted.series.length) * w;
1570
- if (am4core.isNumber(delta)) {
1571
- let middle = ChartInstanceCasted.series.length / 2;
1572
- let newIndex = 0;
1573
- ChartInstanceCasted.series.each((series) => {
1574
- if (!series.isHidden && !series.isHiding) {
1575
- series.dummyData = newIndex;
1576
- newIndex++;
1577
- }
1578
- else {
1579
- series.dummyData = ChartInstanceCasted.series.indexOf(series);
1580
- }
1581
- });
1582
- let visibleCount = newIndex;
1583
- let newMiddle = visibleCount / 2;
1584
- ChartInstanceCasted.series.each((series) => {
1585
- let trueIndex = ChartInstanceCasted.series.indexOf(series);
1586
- let newIndex = series.dummyData;
1587
- let dx = (newIndex - trueIndex + middle - newMiddle) * delta;
1588
- series.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1589
- series.bulletsContainer.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1590
- });
1591
- }
1592
- }
1593
- }
1594
1708
  }
1595
1709
 
1596
1710
  /**
1597
- * Componente specifico per la graficazione di un grafico a Barre con due dimensioni
1598
- */
1599
- class EsVertical2DChartComponent extends BaseChartComponent {
1600
- /**
1601
- * @ignore
1602
- */
1603
- constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
1604
- super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
1605
- this.adapter = adapter;
1606
- }
1607
- /**
1608
- * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
1609
- */
1610
- getSpecificPropertiesToCheck() {
1611
- return ["Data", "DataArray"];
1612
- }
1613
- /**
1614
- * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
1615
- *
1616
- * @returns {Vertical2DChartSettings} Settings castati al tipo giusto
1617
- */
1618
- getCastedSettings() {
1619
- var _a;
1620
- return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new Vertical2DChartSettings());
1621
- }
1622
- /**
1623
- * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
1624
- *
1625
- * @param {Vertical2DChartSettings} settingsCasted Settings castati al tipo giusto
1626
- */
1627
- fillSpecificSettings(settingsCasted) {
1628
- settingsCasted.ColumnWidthPercentage = settingsCasted.ColumnWidthPercentage != null ? settingsCasted.ColumnWidthPercentage : this.ColumnWidthPercentage;
1629
- settingsCasted.GroupPaddingPercentage = settingsCasted.GroupPaddingPercentage != null ? settingsCasted.GroupPaddingPercentage : this.GroupPaddingPercentage;
1630
- settingsCasted.LabelWidth = settingsCasted.LabelWidth != null ? settingsCasted.LabelWidth : this.LabelWidth;
1631
- settingsCasted.LabelVerticalOrientationCutoffWidth = settingsCasted.LabelVerticalOrientationCutoffWidth != null ? settingsCasted.LabelVerticalOrientationCutoffWidth : this.LabelVerticalOrientationCutoffWidth;
1632
- settingsCasted.LabelRightWhenCompressed = settingsCasted.LabelRightWhenCompressed != null ? settingsCasted.LabelRightWhenCompressed : this.LabelRightWhenCompressed;
1633
- settingsCasted.LabelTopWhenCompressed = settingsCasted.LabelTopWhenCompressed != null ? settingsCasted.LabelTopWhenCompressed : this.LabelTopWhenCompressed;
1634
- }
1635
- /**
1636
- * Effettua il rendering di questo grafico in base ai Settings
1637
- *
1638
- * @param {Vertical2DChartSettings} settingsCasted Impostazioni di graficazione
1639
- * @returns {Vertical2DChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
1640
- */
1641
- graphicate(settingsCasted) {
1642
- return new Vertical2DChartService(this.adapter).graphicate(this.Data, settingsCasted);
1643
- }
1644
- }
1645
- EsVertical2DChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVertical2DChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4$1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
1646
- EsVertical2DChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsVertical2DChartComponent, selector: "es-vertical-2d-chart", inputs: { Data: "Data", DataArray: "DataArray", ColumnWidthPercentage: "ColumnWidthPercentage", GroupPaddingPercentage: "GroupPaddingPercentage", LabelWidth: "LabelWidth", LabelVerticalOrientationCutoffWidth: "LabelVerticalOrientationCutoffWidth", LabelRightWhenCompressed: "LabelRightWhenCompressed", LabelTopWhenCompressed: "LabelTopWhenCompressed" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1647
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVertical2DChartComponent, decorators: [{
1648
- type: Component,
1649
- args: [{ selector: 'es-vertical-2d-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:rgba(153,153,153,.6);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"] }]
1650
- }], ctorParameters: function () {
1651
- return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
1652
- type: Inject,
1653
- args: [PLATFORM_ID]
1654
- }] }, { type: undefined, decorators: [{
1655
- type: Inject,
1656
- args: [ESC_LOGS]
1657
- }] }, { type: undefined, decorators: [{
1658
- type: Inject,
1659
- args: [ESC_ANIMATIONS]
1660
- }] }, { type: undefined, decorators: [{
1661
- type: Inject,
1662
- args: [ESC_THEME]
1663
- }] }, { type: i4$1.LocalizationService }];
1664
- }, propDecorators: { Data: [{
1665
- type: Input
1666
- }], DataArray: [{
1667
- type: Input
1668
- }], ColumnWidthPercentage: [{
1669
- type: Input
1670
- }], GroupPaddingPercentage: [{
1671
- type: Input
1672
- }], LabelWidth: [{
1673
- type: Input
1674
- }], LabelVerticalOrientationCutoffWidth: [{
1675
- type: Input
1676
- }], LabelRightWhenCompressed: [{
1677
- type: Input
1678
- }], LabelTopWhenCompressed: [{
1679
- type: Input
1680
- }] } });
1681
-
1682
- /**
1683
- * Classe il cui unico scopo è gestire il setup e rendering di un VerticalChart
1711
+ * Classe il cui unico scopo è gestire il setup e rendering di un Vertical2DChart
1684
1712
  */
1685
- class VerticalChartService {
1713
+ class Vertical2DChartService {
1686
1714
  /** @ignore */
1687
1715
  constructor(Adapter) {
1688
1716
  this.Adapter = Adapter;
1689
1717
  /** @ignore */
1718
+ this.DefaultGroupPaddingPercentage = 5;
1719
+ /** @ignore */
1690
1720
  this.dangerZone = 50;
1691
1721
  /** @ignore */
1692
1722
  this.LabelWidth = 150;
@@ -1698,10 +1728,10 @@ class VerticalChartService {
1698
1728
  this.DefaultColumnWidthPercentage = 85;
1699
1729
  }
1700
1730
  /**
1701
- * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un VerticalChart
1731
+ * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un Vertical2DChart
1702
1732
  */
1703
1733
  graphicate(data, settings) {
1704
- var _a, _b, _c, _d, _e, _f, _g, _h;
1734
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1705
1735
  if (settings.Timeline) {
1706
1736
  console.error("Timeline not supported for vertical chart");
1707
1737
  return null;
@@ -1710,9 +1740,6 @@ class VerticalChartService {
1710
1740
  am4core.options.autoDispose = true;
1711
1741
  this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1712
1742
  let ChartInstanceCasted = this.ChartInstance;
1713
- let dataConverted = this.Adapter ? this.Adapter.adaptDataForVerticalChart(data) : data;
1714
- ChartInstanceCasted.data = dataConverted.values;
1715
- let noStrokes = dataConverted.values.some(t => !!t.c);
1716
1743
  if (settings.Legend) {
1717
1744
  ChartInstanceCasted.legend = new am4charts.Legend();
1718
1745
  ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
@@ -1735,12 +1762,15 @@ class VerticalChartService {
1735
1762
  categoryAxis.title.text = settings.XAxisTitle;
1736
1763
  categoryAxis.title.fontWeight = "bold";
1737
1764
  }
1738
- categoryAxis.dataFields.category = "k";
1765
+ yAxis.min = 0;
1766
+ categoryAxis.dataFields.category = 'key';
1767
+ categoryAxis.renderer.cellStartLocation = am4core.percent((_f = settings.GroupPaddingPercentage) !== null && _f !== void 0 ? _f : this.DefaultGroupPaddingPercentage).value;
1768
+ categoryAxis.renderer.cellEndLocation = am4core.percent(100 - ((_g = settings.GroupPaddingPercentage) !== null && _g !== void 0 ? _g : this.DefaultGroupPaddingPercentage)).value;
1739
1769
  categoryAxis.renderer.grid.template.location = 0;
1740
- categoryAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 30;
1770
+ categoryAxis.renderer.minGridDistance = (_h = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _h !== void 0 ? _h : 30;
1741
1771
  let label = categoryAxis.renderer.labels.template;
1742
1772
  label.truncate = true;
1743
- label.maxWidth = (_g = settings.LabelWidth) !== null && _g !== void 0 ? _g : this.LabelWidth;
1773
+ label.maxWidth = (_j = settings.LabelWidth) !== null && _j !== void 0 ? _j : this.LabelWidth;
1744
1774
  label.tooltipText = "{category}";
1745
1775
  if ((settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) == null ? true : settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) {
1746
1776
  categoryAxis.events.on("sizechanged", (ev) => {
@@ -1764,24 +1794,24 @@ class VerticalChartService {
1764
1794
  }
1765
1795
  });
1766
1796
  }
1767
- // Create series
1768
- let series = ChartInstanceCasted.series.push(new am4charts.ColumnSeries());
1769
- series.dataFields.valueY = "v";
1770
- series.dataFields.categoryX = "k";
1771
- series.name = "";
1772
- let columnTemplate = series.columns.template;
1773
- columnTemplate.tooltipText = "{categoryX}: [bold]{valueY}[/] {t}";
1774
- columnTemplate.fillOpacity = .8;
1775
- columnTemplate.width = am4core.percent((_h = settings.ColumnWidthPercentage) !== null && _h !== void 0 ? _h : this.DefaultColumnWidthPercentage);
1776
- if (noStrokes) {
1777
- columnTemplate.strokeOpacity = 0;
1778
- columnTemplate.strokeWidth = 0;
1779
- columnTemplate.adapter.add("fill", (_, target) => am4core.color(target.dataItem.dataContext.c));
1780
- }
1781
- else {
1782
- columnTemplate.strokeWidth = 2;
1783
- columnTemplate.strokeOpacity = 1;
1797
+ let dataPreConverted = this.Adapter ? this.Adapter.adaptDataForVertical2DChart(data) : data;
1798
+ let dataConverted = [];
1799
+ for (let i = 0; i < dataPreConverted.groups.length; i++) {
1800
+ let item = dataPreConverted.groups[i];
1801
+ let obj = { key: item.name };
1802
+ for (let p = 0; p < item.values.length; p++) {
1803
+ let value = item.values[p];
1804
+ obj[value.k] = value.v;
1805
+ }
1806
+ dataConverted.push(obj);
1784
1807
  }
1808
+ ChartInstanceCasted.data = dataConverted;
1809
+ if (dataPreConverted.colorinfos)
1810
+ ChartInstanceCasted.colors.list = dataPreConverted.colorinfos.map(c => am4core.color(c.color));
1811
+ //Prendo la prima categoria e mi baso sulle proprietà per dfeinire le serie
1812
+ for (let prop in dataConverted[0])
1813
+ if (prop !== "key")
1814
+ this.createSeries(ChartInstanceCasted, settings, prop, prop);
1785
1815
  return this;
1786
1816
  }
1787
1817
  /** @ignore */
@@ -1791,90 +1821,55 @@ class VerticalChartService {
1791
1821
  refreshData(data) {
1792
1822
  //TODO:IMPL
1793
1823
  }
1794
- }
1795
-
1796
- /**
1797
- * Componente specifico per la graficazione di un grafico a Barre
1798
- */
1799
- class EsVerticalChartComponent extends BaseChartComponent {
1800
- /**
1801
- * @ignore
1802
- */
1803
- constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
1804
- super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
1805
- this.adapter = adapter;
1806
- }
1807
- /**
1808
- * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
1809
- */
1810
- getSpecificPropertiesToCheck() {
1811
- return ["Data", "DataArray"];
1812
- }
1813
- /**
1814
- * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
1815
- *
1816
- * @returns {VerticalChartSettings} Settings castati al tipo giusto
1817
- */
1818
- getCastedSettings() {
1824
+ /** @ignore */
1825
+ createSeries(chart, settings, value, name) {
1819
1826
  var _a;
1820
- return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new VerticalChartSettings());
1821
- }
1822
- /**
1823
- * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
1824
- *
1825
- * @param {VerticalChartSettings} settingsCasted Settings castati al tipo giusto
1826
- */
1827
- fillSpecificSettings(settingsCasted) {
1828
- settingsCasted.ColumnWidthPercentage = settingsCasted.ColumnWidthPercentage != null ? settingsCasted.ColumnWidthPercentage : this.ColumnWidthPercentage;
1829
- settingsCasted.LabelWidth = settingsCasted.LabelWidth != null ? settingsCasted.LabelWidth : this.LabelWidth;
1830
- settingsCasted.LabelVerticalOrientationCutoffWidth = settingsCasted.LabelVerticalOrientationCutoffWidth != null ? settingsCasted.LabelVerticalOrientationCutoffWidth : this.LabelVerticalOrientationCutoffWidth;
1831
- settingsCasted.LabelRightWhenCompressed = settingsCasted.LabelRightWhenCompressed != null ? settingsCasted.LabelRightWhenCompressed : this.LabelRightWhenCompressed;
1832
- settingsCasted.LabelTopWhenCompressed = settingsCasted.LabelTopWhenCompressed != null ? settingsCasted.LabelTopWhenCompressed : this.LabelTopWhenCompressed;
1827
+ let series = chart.series.push(new am4charts.ColumnSeries());
1828
+ series.dataFields.valueY = value;
1829
+ series.dataFields.categoryX = 'key';
1830
+ series.name = name;
1831
+ series.columns.template.tooltipText = "{name} {categoryX}: [bold]{valueY}[/]";
1832
+ series.columns.template.fillOpacity = .8;
1833
+ series.columns.template.width = am4core.percent((_a = settings.ColumnWidthPercentage) !== null && _a !== void 0 ? _a : this.DefaultColumnWidthPercentage);
1834
+ series.events.on("hidden", () => this.arrangeColumns);
1835
+ series.events.on("shown", () => this.arrangeColumns);
1836
+ return series;
1833
1837
  }
1834
- /**
1835
- * Effettua il rendering di questo grafico in base ai Settings
1836
- *
1837
- * @param {VerticalChartSettings} settingsCasted Impostazioni di graficazione
1838
- * @returns {VerticalChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
1839
- */
1840
- graphicate(settingsCasted) {
1841
- return new VerticalChartService(this.adapter).graphicate(this.Data, settingsCasted);
1838
+ /** @ignore */
1839
+ arrangeColumns() {
1840
+ let ChartInstanceCasted = this.ChartInstance;
1841
+ let series = ChartInstanceCasted.series.getIndex(0);
1842
+ let xAxis = ChartInstanceCasted.xAxes.getIndex(0);
1843
+ let w = 1 - xAxis.renderer.cellStartLocation - (1 - xAxis.renderer.cellEndLocation);
1844
+ if (series.dataItems.length > 1) {
1845
+ let x0 = xAxis.getX(series.dataItems.getIndex(0), "categoryX");
1846
+ let x1 = xAxis.getX(series.dataItems.getIndex(1), "categoryX");
1847
+ let delta = ((x1 - x0) / ChartInstanceCasted.series.length) * w;
1848
+ if (am4core.isNumber(delta)) {
1849
+ let middle = ChartInstanceCasted.series.length / 2;
1850
+ let newIndex = 0;
1851
+ ChartInstanceCasted.series.each((series) => {
1852
+ if (!series.isHidden && !series.isHiding) {
1853
+ series.dummyData = newIndex;
1854
+ newIndex++;
1855
+ }
1856
+ else {
1857
+ series.dummyData = ChartInstanceCasted.series.indexOf(series);
1858
+ }
1859
+ });
1860
+ let visibleCount = newIndex;
1861
+ let newMiddle = visibleCount / 2;
1862
+ ChartInstanceCasted.series.each((series) => {
1863
+ let trueIndex = ChartInstanceCasted.series.indexOf(series);
1864
+ let newIndex = series.dummyData;
1865
+ let dx = (newIndex - trueIndex + middle - newMiddle) * delta;
1866
+ series.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1867
+ series.bulletsContainer.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1868
+ });
1869
+ }
1870
+ }
1842
1871
  }
1843
- }
1844
- EsVerticalChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVerticalChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4$1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
1845
- EsVerticalChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsVerticalChartComponent, selector: "es-vertical-chart", inputs: { Data: "Data", DataArray: "DataArray", ColumnWidthPercentage: "ColumnWidthPercentage", LabelWidth: "LabelWidth", LabelVerticalOrientationCutoffWidth: "LabelVerticalOrientationCutoffWidth", LabelRightWhenCompressed: "LabelRightWhenCompressed", LabelTopWhenCompressed: "LabelTopWhenCompressed" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1846
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVerticalChartComponent, decorators: [{
1847
- type: Component,
1848
- args: [{ selector: 'es-vertical-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:rgba(153,153,153,.6);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"] }]
1849
- }], ctorParameters: function () {
1850
- return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
1851
- type: Inject,
1852
- args: [PLATFORM_ID]
1853
- }] }, { type: undefined, decorators: [{
1854
- type: Inject,
1855
- args: [ESC_LOGS]
1856
- }] }, { type: undefined, decorators: [{
1857
- type: Inject,
1858
- args: [ESC_ANIMATIONS]
1859
- }] }, { type: undefined, decorators: [{
1860
- type: Inject,
1861
- args: [ESC_THEME]
1862
- }] }, { type: i4$1.LocalizationService }];
1863
- }, propDecorators: { Data: [{
1864
- type: Input
1865
- }], DataArray: [{
1866
- type: Input
1867
- }], ColumnWidthPercentage: [{
1868
- type: Input
1869
- }], LabelWidth: [{
1870
- type: Input
1871
- }], LabelVerticalOrientationCutoffWidth: [{
1872
- type: Input
1873
- }], LabelRightWhenCompressed: [{
1874
- type: Input
1875
- }], LabelTopWhenCompressed: [{
1876
- type: Input
1877
- }] } });
1872
+ }
1878
1873
 
1879
1874
  /**
1880
1875
  * Classe il cui unico scopo è gestire il setup e rendering di un VerticalStackedChart
@@ -2005,87 +2000,140 @@ class VerticalStackedChartService {
2005
2000
  }
2006
2001
 
2007
2002
  /**
2008
- * Componente specifico per la graficazione di un grafico a Barre in modalità Stacked (una serie sopra l'altra)
2003
+ * Classe il cui unico scopo è gestire il setup e rendering di un AreaChart
2009
2004
  */
2010
- class EsVerticalStackedChartComponent extends BaseChartComponent {
2011
- /**
2012
- * @ignore
2013
- */
2014
- constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
2015
- super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
2016
- this.adapter = adapter;
2005
+ class AreaChartService {
2006
+ /** @ignore */
2007
+ constructor(Adapter) {
2008
+ this.Adapter = Adapter;
2009
+ //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
2010
+ //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
2011
+ /** @ignore */
2012
+ this.executionTimers = {};
2017
2013
  }
2018
2014
  /**
2019
- * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
2015
+ * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un AreaChart
2020
2016
  */
2021
- getSpecificPropertiesToCheck() {
2022
- return ["Data", "DataArray"];
2017
+ graphicate(data, settings) {
2018
+ var _a, _b, _c, _d, _e, _f;
2019
+ if (settings.Timeline) {
2020
+ console.error("Timeline not supported for area chart");
2021
+ return null;
2022
+ }
2023
+ let dataConverted = this.Adapter ? this.Adapter.adaptDataForAreaChart(data) : data;
2024
+ let showTicks = settings.ShowTicks == null ? true : settings === null || settings === void 0 ? void 0 : settings.ShowTicks;
2025
+ let interval = dataConverted.interval;
2026
+ //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
2027
+ am4core.options.autoDispose = true;
2028
+ this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
2029
+ let ChartInstanceCasted = this.ChartInstance;
2030
+ if (settings.Legend) {
2031
+ ChartInstanceCasted.legend = new am4charts.Legend();
2032
+ ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
2033
+ ChartInstanceCasted.legend.itemContainers.template.tooltipText = "{category}";
2034
+ if (settings.LegendPadding) {
2035
+ let template = this.ChartInstance.legend.itemContainers.template;
2036
+ template.paddingTop = (_b = settings.LegendPadding.top) !== null && _b !== void 0 ? _b : 0;
2037
+ template.paddingBottom = (_c = settings.LegendPadding.bottom) !== null && _c !== void 0 ? _c : 0;
2038
+ template.paddingLeft = (_d = settings.LegendPadding.left) !== null && _d !== void 0 ? _d : 0;
2039
+ template.paddingRight = (_e = settings.LegendPadding.right) !== null && _e !== void 0 ? _e : 0;
2040
+ }
2041
+ }
2042
+ let yAxis = ChartInstanceCasted.yAxes.push(new am4charts.ValueAxis());
2043
+ yAxis.tooltip.disabled = true;
2044
+ if (settings.YAxisTitle) {
2045
+ yAxis.title.text = settings.YAxisTitle;
2046
+ yAxis.title.fontWeight = "bold";
2047
+ }
2048
+ yAxis.min = 0;
2049
+ let dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
2050
+ dateAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 50;
2051
+ dateAxis.startLocation = 0.5;
2052
+ dateAxis.endLocation = 0.5;
2053
+ if (settings.XAxisTitle) {
2054
+ dateAxis.title.text = settings.XAxisTitle;
2055
+ dateAxis.title.fontWeight = "bold";
2056
+ }
2057
+ if (showTicks) {
2058
+ dateAxis.renderer.ticks.template.disabled = false;
2059
+ dateAxis.renderer.ticks.template.strokeOpacity = 1;
2060
+ dateAxis.renderer.ticks.template.stroke = am4core.color("#495C43");
2061
+ dateAxis.renderer.ticks.template.strokeWidth = 2;
2062
+ dateAxis.renderer.ticks.template.length = 10;
2063
+ dateAxis.renderer.ticks.template.location = 0;
2064
+ }
2065
+ if (!!interval)
2066
+ dateAxis.baseInterval = { count: interval.count, timeUnit: interval.timeunit };
2067
+ // Unisco il dataset e tiro fuori i dati
2068
+ let chartData = [];
2069
+ let seriesToMakeCache = {};
2070
+ let seriesToMake = [];
2071
+ for (let i = 0; i < dataConverted.groups.length; i++) {
2072
+ let group = dataConverted.groups[i];
2073
+ let dataItem = { date: group.name };
2074
+ for (let ii = 0; ii < group.values.length; ii++) {
2075
+ let val = group.values[ii];
2076
+ dataItem[val.k] = val.v;
2077
+ if (!seriesToMakeCache[val.k]) {
2078
+ seriesToMakeCache[val.k] = true;
2079
+ seriesToMake.push(val.k);
2080
+ }
2081
+ }
2082
+ chartData.push(dataItem);
2083
+ }
2084
+ ChartInstanceCasted.data = chartData;
2085
+ //---------------------------------------------------------
2086
+ seriesToMake.forEach(s => { this.createSeries(ChartInstanceCasted, s); });
2087
+ ChartInstanceCasted.cursor = new am4charts.XYCursor();
2088
+ ChartInstanceCasted.cursor.xAxis = dateAxis;
2089
+ dateAxis.events.on("startchanged", t => this.emitSelectionChanged(t, settings));
2090
+ dateAxis.events.on("endchanged", t => this.emitSelectionChanged(t, settings));
2091
+ return this;
2023
2092
  }
2024
- /**
2025
- * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
2026
- *
2027
- * @returns {VerticalStackedChartSettings} Settings castati al tipo giusto
2028
- */
2029
- getCastedSettings() {
2030
- var _a;
2031
- return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new VerticalStackedChartSettings());
2093
+ /** @ignore */
2094
+ setSelection(from, to) {
2095
+ }
2096
+ /** @ignore */
2097
+ refreshData(data) {
2098
+ //TODO:IMPL
2099
+ }
2100
+ /** @ignore */
2101
+ emitSelectionChanged(ev, settings) {
2102
+ if (settings.OnSelectionChangedCallback) {
2103
+ this.throttla("selchange", () => {
2104
+ var axis = ev.target;
2105
+ var start = new Date(axis.minZoomed);
2106
+ var end = new Date(axis.maxZoomed);
2107
+ var initial = axis.min == axis.minZoomed && axis.max == axis.maxZoomed;
2108
+ settings.OnSelectionChangedCallback({ from: start, to: end, initial: initial });
2109
+ }, 150);
2110
+ }
2032
2111
  }
2033
- /**
2034
- * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
2035
- *
2036
- * @param {VerticalStackedChartSettings} settingsCasted Settings castati al tipo giusto
2037
- */
2038
- fillSpecificSettings(settingsCasted) {
2039
- settingsCasted.ColumnWidthPercentage = settingsCasted.ColumnWidthPercentage != null ? settingsCasted.ColumnWidthPercentage : this.ColumnWidthPercentage;
2040
- settingsCasted.LabelWidth = settingsCasted.LabelWidth != null ? settingsCasted.LabelWidth : this.LabelWidth;
2041
- settingsCasted.LabelVerticalOrientationCutoffWidth = settingsCasted.LabelVerticalOrientationCutoffWidth != null ? settingsCasted.LabelVerticalOrientationCutoffWidth : this.LabelVerticalOrientationCutoffWidth;
2042
- settingsCasted.LabelRightWhenCompressed = settingsCasted.LabelRightWhenCompressed != null ? settingsCasted.LabelRightWhenCompressed : this.LabelRightWhenCompressed;
2043
- settingsCasted.LabelTopWhenCompressed = settingsCasted.LabelTopWhenCompressed != null ? settingsCasted.LabelTopWhenCompressed : this.LabelTopWhenCompressed;
2112
+ /** @ignore */
2113
+ createSeries(chart, name) {
2114
+ let series = chart.series.push(new am4charts.LineSeries());
2115
+ series.dataFields.dateX = "date";
2116
+ series.name = name[0].toUpperCase() + name.slice(1);
2117
+ series.dataFields.valueY = name;
2118
+ series.tooltipText = "[#000]{valueY.value}[/]";
2119
+ //series.tooltip.background.fill = am4core.color("#FFF");
2120
+ series.tooltip.getStrokeFromObject = true;
2121
+ series.tooltip.background.strokeWidth = 3;
2122
+ series.tooltip.getFillFromObject = false;
2123
+ series.fillOpacity = 0.6;
2124
+ series.strokeWidth = 2;
2125
+ series.stacked = true;
2126
+ return series;
2044
2127
  }
2045
- /**
2046
- * Effettua il rendering di questo grafico in base ai Settings
2047
- *
2048
- * @param {VerticalStackedChartSettings} settingsCasted Impostazioni di graficazione
2049
- * @returns {VerticalStackedChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
2050
- */
2051
- graphicate(settingsCasted) {
2052
- return new VerticalStackedChartService(this.adapter).graphicate(this.Data, settingsCasted);
2128
+ /** @ignore */
2129
+ throttla(id, func, throttleTime) {
2130
+ //Se ho la funzione che vuole eseguire ripulisco quel timeout
2131
+ if (this.executionTimers[id])
2132
+ clearTimeout(this.executionTimers[id]);
2133
+ //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
2134
+ this.executionTimers[id] = setTimeout(() => { func(); this.executionTimers[id] = null; }, throttleTime);
2053
2135
  }
2054
- }
2055
- EsVerticalStackedChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVerticalStackedChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4$1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
2056
- EsVerticalStackedChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsVerticalStackedChartComponent, selector: "es-vertical-stacked-chart", inputs: { Data: "Data", DataArray: "DataArray", ColumnWidthPercentage: "ColumnWidthPercentage", LabelWidth: "LabelWidth", LabelVerticalOrientationCutoffWidth: "LabelVerticalOrientationCutoffWidth", LabelRightWhenCompressed: "LabelRightWhenCompressed", LabelTopWhenCompressed: "LabelTopWhenCompressed" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2057
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVerticalStackedChartComponent, decorators: [{
2058
- type: Component,
2059
- args: [{ selector: 'es-vertical-stacked-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:rgba(153,153,153,.6);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"] }]
2060
- }], ctorParameters: function () {
2061
- return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
2062
- type: Inject,
2063
- args: [PLATFORM_ID]
2064
- }] }, { type: undefined, decorators: [{
2065
- type: Inject,
2066
- args: [ESC_LOGS]
2067
- }] }, { type: undefined, decorators: [{
2068
- type: Inject,
2069
- args: [ESC_ANIMATIONS]
2070
- }] }, { type: undefined, decorators: [{
2071
- type: Inject,
2072
- args: [ESC_THEME]
2073
- }] }, { type: i4$1.LocalizationService }];
2074
- }, propDecorators: { Data: [{
2075
- type: Input
2076
- }], DataArray: [{
2077
- type: Input
2078
- }], ColumnWidthPercentage: [{
2079
- type: Input
2080
- }], LabelWidth: [{
2081
- type: Input
2082
- }], LabelVerticalOrientationCutoffWidth: [{
2083
- type: Input
2084
- }], LabelRightWhenCompressed: [{
2085
- type: Input
2086
- }], LabelTopWhenCompressed: [{
2087
- type: Input
2088
- }] } });
2136
+ }
2089
2137
 
2090
2138
  /**
2091
2139
  * Componente specifico per la graficazione di un qualsiasi tipo di grafico.
@@ -2160,13 +2208,13 @@ class EsChartComponent extends BaseChartComponent {
2160
2208
  }
2161
2209
  }
2162
2210
  }
2163
- EsChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: i4.DateService }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4$1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
2211
+ EsChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: i3.DateService }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
2164
2212
  EsChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsChartComponent, selector: "es-chart", inputs: { Type: "Type", Data: "Data", DataArray: "DataArray" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2165
2213
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsChartComponent, decorators: [{
2166
2214
  type: Component,
2167
2215
  args: [{ selector: 'es-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:rgba(153,153,153,.6);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"] }]
2168
2216
  }], ctorParameters: function () {
2169
- return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: i4.DateService }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
2217
+ return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: i3.DateService }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
2170
2218
  type: Inject,
2171
2219
  args: [PLATFORM_ID]
2172
2220
  }] }, { type: undefined, decorators: [{
@@ -2178,7 +2226,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2178
2226
  }] }, { type: undefined, decorators: [{
2179
2227
  type: Inject,
2180
2228
  args: [ESC_THEME]
2181
- }] }, { type: i4$1.LocalizationService }];
2229
+ }] }, { type: i4.LocalizationService }];
2182
2230
  }, propDecorators: { Type: [{
2183
2231
  type: Input
2184
2232
  }], Data: [{
@@ -2187,614 +2235,515 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2187
2235
  type: Input
2188
2236
  }] } });
2189
2237
 
2190
- /** Componenti esportati dal modulo */
2191
- const COMPONENTS = [
2192
- EsChartComponent,
2193
- EsLineChartComponent,
2194
- EsPieChartComponent,
2195
- EsVertical2DChartComponent,
2196
- EsVerticalChartComponent,
2197
- EsVerticalStackedChartComponent,
2198
- PageChartSelector,
2199
- EsAreaChartComponent
2200
- ];
2201
- class EsChartsModule {
2202
- static forRoot(config) {
2203
- return {
2204
- ngModule: EsChartsModule,
2205
- providers: [
2206
- { provide: ESC_ANIMATIONS, useValue: (config === null || config === void 0 ? void 0 : config.animations) == null || (config === null || config === void 0 ? void 0 : config.animations) == undefined ? true : config === null || config === void 0 ? void 0 : config.animations },
2207
- { provide: ESC_THEME, useValue: (config === null || config === void 0 ? void 0 : config.theme) || 'spiritedaway' },
2208
- { provide: ESC_LOGS, useValue: (config === null || config === void 0 ? void 0 : config.debugMode) || false },
2209
- { provide: BaseAdapter, useClass: (config === null || config === void 0 ? void 0 : config.adapter) || BaseAdapter }
2210
- ]
2211
- };
2212
- }
2213
- }
2214
- EsChartsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsChartsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2215
- EsChartsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: EsChartsModule, declarations: [EsChartComponent,
2216
- EsLineChartComponent,
2217
- EsPieChartComponent,
2218
- EsVertical2DChartComponent,
2219
- EsVerticalChartComponent,
2220
- EsVerticalStackedChartComponent,
2221
- PageChartSelector,
2222
- EsAreaChartComponent], imports: [CommonModule], exports: [EsChartComponent,
2223
- EsLineChartComponent,
2224
- EsPieChartComponent,
2225
- EsVertical2DChartComponent,
2226
- EsVerticalChartComponent,
2227
- EsVerticalStackedChartComponent,
2228
- PageChartSelector,
2229
- EsAreaChartComponent] });
2230
- EsChartsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsChartsModule, imports: [CommonModule] });
2231
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsChartsModule, decorators: [{
2232
- type: NgModule,
2233
- args: [{
2234
- imports: [CommonModule],
2235
- declarations: [...COMPONENTS],
2236
- exports: [...COMPONENTS]
2237
- }]
2238
- }] });
2239
-
2240
2238
  /**
2241
- * Classe di supporto al caricamento dinamico dei vari pezzi di amcharts che mi servono per il grafico (temi, locali, ecc...)
2242
- *
2243
- * Essenzialmente ogni volta che viene creato un grafico, questo acquisisce il tema e il locale applicato IN QUEL MOMENTO,
2244
- * questo significa che per creare due grafici con temi diversi bisogna fare:
2245
- *
2246
- * 1) Caricamento tema 1
2247
- *
2248
- * 2) Creazione grafico 1
2249
- *
2250
- * 3) Scaricamento tema 1
2251
- *
2252
- * 3) Caricamento tema 2
2253
- *
2254
- * 4) Creazione grafico 2
2255
- *
2239
+ * Componente specifico per la graficazione di un grafico ad Area
2256
2240
  */
2257
- class ChartLoader {
2241
+ class EsAreaChartComponent extends BaseChartComponent {
2258
2242
  /**
2259
2243
  * @ignore
2260
2244
  */
2261
- constructor(logs) {
2262
- this.logs = logs;
2263
- /**
2264
- * Indica se attualmente ho le animazioni caricate in modo da non ricaricarle inutilmente
2265
- */
2266
- this.AnimationsAreLoaded = false;
2267
- /**
2268
- * Indica l'ultimo tema caricato in modo da non ricaricarlo inutilmente qualora il prossimo grafico da creare richieda lo stesso tema
2269
- */
2270
- this.LastLoadedTheme = "";
2271
- /**
2272
- * Cache dei temi (moduli caricati dinamicamente)
2273
- */
2274
- this.themeCache = {};
2275
- /**
2276
- * Cache delle localizzazioni (moduli caricati dinamicamente)
2277
- */
2278
- this.localizationCache = {};
2245
+ constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
2246
+ super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
2247
+ this.adapter = adapter;
2279
2248
  }
2280
2249
  /**
2281
- * Applica il tema con le animazioni all'istanza globale di amCharts
2250
+ * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
2251
+ */
2252
+ getSpecificPropertiesToCheck() {
2253
+ return ["Data", "DataArray"];
2254
+ }
2255
+ /**
2256
+ * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
2282
2257
  *
2283
- * @param {Object} chartsCore Istanza globale di amCharts
2284
- * @returns {Promise} Promise che identifica la fine del caricamento
2258
+ * @returns {AreaChartSettings} Settings castati al tipo giusto
2285
2259
  */
2286
- applyAnimations(chartsCore) {
2287
- if (!this.AnimationsAreLoaded) {
2288
- return this.importIfNeeded('themes', ChartThemes.animated).then(() => {
2289
- this.log("CORE: Applying theme " + ChartThemes.animated);
2290
- chartsCore.useTheme(this.themeCache[ChartThemes.animated]);
2291
- this.AnimationsAreLoaded = true;
2292
- });
2293
- }
2294
- else {
2295
- this.log("CORE: theme already applyed " + ChartThemes.animated);
2296
- return new Promise((resolve) => { resolve(true); });
2297
- }
2260
+ getCastedSettings() {
2261
+ var _a;
2262
+ return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new AreaChartSettings());
2298
2263
  }
2299
2264
  /**
2300
- * De-applica il tema con le animazioni dall'istanza globale di amCharts
2265
+ * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
2301
2266
  *
2302
- * @param {Object} chartsCore Istanza globale di amCharts
2303
- * @returns {Promise} Promise che identifica la fine dello scarico
2267
+ * @param {AreaChartSettings} settingsCasted Settings castati al tipo giusto
2304
2268
  */
2305
- unapplyAnimations(chartsCore) {
2306
- if (this.AnimationsAreLoaded) {
2307
- this.log("CORE: Animations in use, unapplying theme " + ChartThemes.animated);
2308
- chartsCore.unuseTheme(this.themeCache[ChartThemes.animated]);
2309
- this.AnimationsAreLoaded = false;
2310
- }
2311
- else
2312
- this.log("CORE: Animations already unused, no need to unapply them");
2313
- return new Promise((resolve) => { resolve(true); });
2269
+ fillSpecificSettings(settingsCasted) {
2314
2270
  }
2315
2271
  /**
2316
- * Applica il tema specificato all'istanza globale di amCharts
2272
+ * Effettua il rendering di questo grafico in base ai Settings
2317
2273
  *
2318
- * @param {Object} chartsCore Istanza globale di amCharts
2319
- * @param {'spiritedaway' | 'moonrisekingdom' | 'frozen' | 'dark' | 'kelly' | 'material' | 'dataviz' | 'none'} theme Tema da applicare
2320
- * @returns {Promise} Promise che identifica la fine del caricamento
2274
+ * @param {AreaChartSettings} settingsCasted Impostazioni di graficazione
2275
+ * @returns {AreaChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
2321
2276
  */
2322
- applyTheme(chartsCore, theme) {
2323
- // Ultimo tema applicato è lo stesso che mi è stato richiesto di applicare --> NO-OP
2324
- if (this.LastLoadedTheme == theme) {
2325
- this.log("CORE: theme already applied " + theme);
2326
- return new Promise((resolve) => { resolve(true); });
2327
- }
2328
- // Scarico il tema precedente a prescindere, ormai non mi serve più
2329
- this.unapplyPreviousTheme(chartsCore);
2330
- // Il tema è il none --> registro la cosa e basta, il tema precedente è stato rimosso subito qui sopra ^
2331
- if (theme == ChartThemes.none) {
2332
- this.LastLoadedTheme = ChartThemes.none;
2333
- return new Promise((resolve) => { resolve(true); });
2334
- }
2335
- // Il tema è diverso dal precedente e non è il tema vuoto --> Importo il tema specificato se non presente in memoria e lo applico al grafico attuale
2336
- return this.importIfNeeded('themes', theme).then(() => {
2337
- this.log("CORE: Applying theme " + theme);
2338
- chartsCore.useTheme(this.themeCache[theme]);
2339
- this.LastLoadedTheme = theme;
2340
- });
2277
+ graphicate(settingsCasted) {
2278
+ return new AreaChartService(this.adapter).graphicate(this.Data, settingsCasted);
2279
+ }
2280
+ }
2281
+ EsAreaChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsAreaChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
2282
+ EsAreaChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsAreaChartComponent, selector: "es-area-chart", inputs: { Data: "Data", DataArray: "DataArray" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2283
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsAreaChartComponent, decorators: [{
2284
+ type: Component,
2285
+ args: [{ selector: 'es-area-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:rgba(153,153,153,.6);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"] }]
2286
+ }], ctorParameters: function () {
2287
+ return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
2288
+ type: Inject,
2289
+ args: [PLATFORM_ID]
2290
+ }] }, { type: undefined, decorators: [{
2291
+ type: Inject,
2292
+ args: [ESC_LOGS]
2293
+ }] }, { type: undefined, decorators: [{
2294
+ type: Inject,
2295
+ args: [ESC_ANIMATIONS]
2296
+ }] }, { type: undefined, decorators: [{
2297
+ type: Inject,
2298
+ args: [ESC_THEME]
2299
+ }] }, { type: i4.LocalizationService }];
2300
+ }, propDecorators: { Data: [{
2301
+ type: Input
2302
+ }], DataArray: [{
2303
+ type: Input
2304
+ }] } });
2305
+
2306
+ /**
2307
+ * Componente specifico per la graficazione di un grafico a Linea su un asse temporale
2308
+ */
2309
+ class EsLineChartComponent extends BaseChartComponent {
2310
+ /**
2311
+ * @ignore
2312
+ */
2313
+ constructor(el, ChartLoader, ChartDispatcher, adapter, dateService, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
2314
+ super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
2315
+ this.adapter = adapter;
2316
+ this.dateService = dateService;
2341
2317
  }
2342
2318
  /**
2343
- * De-applica il tema precedente dall'istanza globale di amCharts
2344
- *
2345
- * @param {Object} chartsCore Istanza globale di amCharts
2319
+ * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
2346
2320
  */
2347
- unapplyPreviousTheme(chartsCore) {
2348
- if (!this.LastLoadedTheme || this.LastLoadedTheme == ChartThemes.none)
2349
- return;
2350
- this.log("CORE: Unapplying previously used theme " + this.LastLoadedTheme);
2351
- chartsCore.unuseTheme(this.themeCache[this.LastLoadedTheme]);
2321
+ getSpecificPropertiesToCheck() {
2322
+ return ["Data", "DataArray", "Step", "DataGroupBucketSize", "DataGroupingThreshold", "StrokeSize", "Stacked", "AllowGaps", "MergeDatasets", "FinalInstants", "Fill", "Min", "Max"];
2352
2323
  }
2353
2324
  /**
2354
- * Applica il locale specificato all'istanza specifica del grafico
2325
+ * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
2355
2326
  *
2356
- * @param {amCharts.Chart} chart Istanza specifica del grafico a cui applicare il locale
2357
- * @param {string} locale Locale da applicare
2358
- * @returns {Promise} Promise che identifica la fine del caricamento
2327
+ * @returns {LineChartSettings} Settings castati al tipo giusto
2359
2328
  */
2360
- applyLocale(chart, locale) {
2361
- return this.importIfNeeded('lang', locale).then(() => {
2362
- this.log("Chart " + chart.htmlContainer.id + ": applying locale " + locale);
2363
- chart.language.locale = this.localizationCache[locale];
2364
- });
2329
+ getCastedSettings() {
2330
+ var _a;
2331
+ return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new LineChartSettings());
2365
2332
  }
2366
2333
  /**
2367
- * Permette di importare, se serve un dato tema o localizzazione
2368
- *
2369
- * @param {'lang' | 'themes'} what Oggetto da importare, se localizzazione o tema
2370
- * @param {string} item Chiave dell'oggetto da importare
2334
+ * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
2371
2335
  *
2372
- * @returns {Promise} Promise che identifica la fine del caricamento
2336
+ * @param {LineChartSettings} settingsCasted Settings castati al tipo giusto
2373
2337
  */
2374
- importIfNeeded(what, item) {
2375
- // Se sto cercando di caricare qualcosa di già caricato non faccio nulla
2376
- if (!(what == 'themes' && !this.themeCache[item]) && !(what == 'lang' && !this.localizationCache[item])) {
2377
- this.log("CORE: " + (what == 'lang' ? "Language " : "Theme ") + item + " already loaded");
2378
- return new Promise((resolve) => { resolve(true); });
2379
- }
2380
- this.log("CORE: Loading " + (what == 'lang' ? "language " : "theme ") + item);
2381
- /*
2382
- * ****************************
2383
- * ******** ATTENZIONE ********
2384
- * ****************************
2385
- *
2386
- * Se stai vedendo questo codice di import e stai valutando di riscriverlo come:
2387
- *
2388
- * V V
2389
- * import(`@amcharts/amcharts4/${what}/${item}`).then(module => {
2390
- * if (what == 'themes') this.themeCache[item] = module.default;
2391
- * else if (what == 'lang') this.localizationCache[item] = module.default;
2392
- * });
2393
- *
2394
- * Sappi che è una pessima idea. Gli import sono valutati da webpack in compiletime per generare i chunk,
2395
- * mettere la navigazione agli import con la concatenazione viene preso malissimo ed essenzialmente dice a webpack
2396
- * di tirare su e bundlare l'intera node_modules. Divertente, no?
2397
- *
2398
- */
2399
- switch (what) {
2400
- case 'themes':
2401
- switch (item) {
2402
- case ChartThemes.spiritedaway:
2403
- return import('@amcharts/amcharts4/themes/spiritedaway').then(theme => this.themeCache[item] = theme.default);
2404
- case ChartThemes.moonrisekingdom:
2405
- return import('@amcharts/amcharts4/themes/moonrisekingdom').then(theme => this.themeCache[item] = theme.default);
2406
- case ChartThemes.frozen:
2407
- return import('@amcharts/amcharts4/themes/frozen').then(theme => this.themeCache[item] = theme.default);
2408
- case ChartThemes.dark:
2409
- return import('@amcharts/amcharts4/themes/dark').then(theme => this.themeCache[item] = theme.default);
2410
- case ChartThemes.kelly:
2411
- return import('@amcharts/amcharts4/themes/kelly').then(theme => this.themeCache[item] = theme.default);
2412
- case ChartThemes.material:
2413
- return import('@amcharts/amcharts4/themes/material').then(theme => this.themeCache[item] = theme.default);
2414
- case ChartThemes.dataviz:
2415
- return import('@amcharts/amcharts4/themes/dataviz').then(theme => this.themeCache[item] = theme.default);
2416
- case ChartThemes.animated:
2417
- return import('@amcharts/amcharts4/themes/animated').then(theme => this.themeCache[item] = theme.default);
2418
- }
2419
- break;
2420
- case 'lang':
2421
- switch (item) {
2422
- case 'it-IT':
2423
- return import('@amcharts/amcharts4/lang/it_IT').then(lang => this.localizationCache[item] = lang.default);
2424
- case 'en-US':
2425
- return import('@amcharts/amcharts4/lang/en_US').then(lang => this.localizationCache[item] = lang.default);
2426
- }
2427
- }
2428
- this.log("CORE: Loading Failed. " + (what == 'lang' ? "Language " : "Theme") + " not recognized: " + item);
2429
- return new Promise((resolve) => { resolve(true); });
2338
+ fillSpecificSettings(settingsCasted) {
2339
+ settingsCasted.Step = settingsCasted.Step != null ? settingsCasted.Step : this.Step;
2340
+ settingsCasted.DataGroupBucketSize = settingsCasted.DataGroupBucketSize != null ? settingsCasted.DataGroupBucketSize : this.DataGroupBucketSize;
2341
+ settingsCasted.StrokeSize = settingsCasted.StrokeSize != null ? settingsCasted.StrokeSize : this.StrokeSize;
2342
+ settingsCasted.DataGroupingThreshold = settingsCasted.DataGroupingThreshold != null ? settingsCasted.DataGroupingThreshold : this.DataGroupingThreshold;
2343
+ settingsCasted.AllowGaps = settingsCasted.AllowGaps != null ? settingsCasted.AllowGaps : this.AllowGaps;
2344
+ settingsCasted.MergeDatasets = settingsCasted.MergeDatasets != null ? settingsCasted.MergeDatasets : this.MergeDatasets;
2345
+ settingsCasted.FinalInstants = settingsCasted.FinalInstants != null ? settingsCasted.FinalInstants : this.FinalInstants;
2346
+ settingsCasted.Min = settingsCasted.Min != null ? settingsCasted.Min : this.Min;
2347
+ settingsCasted.Max = settingsCasted.Max != null ? settingsCasted.Max : this.Max;
2348
+ settingsCasted.Fill = settingsCasted.Fill != null ? settingsCasted.Fill : this.Fill;
2349
+ settingsCasted.Stacked = settingsCasted.Stacked != null ? settingsCasted.Stacked : this.Stacked;
2430
2350
  }
2431
2351
  /**
2432
- * @ignore
2352
+ * Effettua il rendering di questo grafico in base ai Settings
2353
+ *
2354
+ * @param {LineChartSettings} settingsCasted Impostazioni di graficazione
2355
+ * @returns {LineChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
2433
2356
  */
2434
- log(text) {
2435
- if (this.logs)
2436
- console.log("@esfaenza/es-charts: " + text);
2357
+ graphicate(settingsCasted) {
2358
+ return new LineChartService(this.adapter, this.dateService).graphicate(this.Data, settingsCasted);
2437
2359
  }
2438
2360
  }
2439
- ChartLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartLoader, deps: [{ token: ESC_LOGS }], target: i0.ɵɵFactoryTarget.Injectable });
2440
- ChartLoaderprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartLoader, providedIn: EsChartsModule });
2441
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ChartLoader, decorators: [{
2442
- type: Injectable,
2443
- args: [{ providedIn: EsChartsModule }]
2361
+ EsLineChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", 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_THEME }, { token: i4.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
2362
+ EsLineChartComponentcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2363
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsLineChartComponent, decorators: [{
2364
+ type: Component,
2365
+ 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:rgba(153,153,153,.6);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"] }]
2444
2366
  }], ctorParameters: function () {
2445
- return [{ type: undefined, decorators: [{
2367
+ return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i3.DateService }, { type: i0.NgZone }, { type: Object, decorators: [{
2368
+ type: Inject,
2369
+ args: [PLATFORM_ID]
2370
+ }] }, { type: undefined, decorators: [{
2446
2371
  type: Inject,
2447
2372
  args: [ESC_LOGS]
2448
- }] }];
2449
- } });
2373
+ }] }, { type: undefined, decorators: [{
2374
+ type: Inject,
2375
+ args: [ESC_ANIMATIONS]
2376
+ }] }, { type: undefined, decorators: [{
2377
+ type: Inject,
2378
+ args: [ESC_THEME]
2379
+ }] }, { type: i4.LocalizationService }];
2380
+ }, propDecorators: { Data: [{
2381
+ type: Input
2382
+ }], DataArray: [{
2383
+ type: Input
2384
+ }], Step: [{
2385
+ type: Input
2386
+ }], DataGroupBucketSize: [{
2387
+ type: Input
2388
+ }], DataGroupingThreshold: [{
2389
+ type: Input
2390
+ }], StrokeSize: [{
2391
+ type: Input
2392
+ }], AllowGaps: [{
2393
+ type: Input
2394
+ }], MergeDatasets: [{
2395
+ type: Input
2396
+ }], FinalInstants: [{
2397
+ type: Input
2398
+ }], Min: [{
2399
+ type: Input
2400
+ }], Max: [{
2401
+ type: Input
2402
+ }], Fill: [{
2403
+ type: Input
2404
+ }], Stacked: [{
2405
+ type: Input
2406
+ }] } });
2450
2407
 
2451
2408
  /**
2452
- * Componente Grafico Base che gestisce tutte le cose comuni dei vari grafici istanziabili, come la presenza o menu di una legenda,
2453
- * il tema utilizzato, il locale del singolo grafico, ecc ecc...
2409
+ * Componente specifico per la graficazione di un grafico a Torta
2454
2410
  */
2455
- class BaseChartComponent {
2411
+ class EsPieChartComponent extends BaseChartComponent {
2456
2412
  /**
2457
- * Costruttore
2458
- *
2459
- * @param {ElementRef} el Contenitore all'interno del cui viene creato il grafico. Utilizzato per estrapolarne la **ContainerHeight**
2460
- * @param {Object} platformId piattaforma Angular (browser, ecc...) per essere sicuri che amcharts venga attivato solo lato browser. Non utilizzando SSR nelle applicazioni che consumano questa libreria non è particolarmente significativo, ma non si sa mai
2461
- * @param {NgZone} zone NgZone di default per permettere di inizializzare il grafico all'infuori di Angular per avere qualche prestazione in più
2462
- * @param {ChartLoader} Charter Istanza del Loader che si occuperà di caricare in memoria tutto ciò che serve per il grafico attuale (temi, locale, animazioni, ecc...)
2463
- * @param {ChartDispatcher} Dispatcher Istanza del Dispatcher che si occupa di differire il caricamento dei grafici 1 dopo l'altro in modo che caricamenti pseudo paralleli incasinino tutto
2464
- * @param {boolean} logs Indica se effettuare log a console o meno, iniettato dalle classi specializzate dal token ESC_LOGS
2465
- * @param {boolean} animations Indica se per questo grafico devono essere attive o meno le animazioni. Impostazione generica presa dal token ESC_ANIMATIONS
2466
- * @param {string} locale Indica il locale specifico per questo grafico. Impostazione generica presa dal LocalizationService
2467
- * @param {string} theme Indica il tema specifico per questo grafico. Impostazione generica presa dal token ESC_THEME
2413
+ * @ignore
2468
2414
  */
2469
- constructor(el, platformId, zone, Charter, Dispatcher, logs, animations, locale, theme) {
2470
- this.el = el;
2471
- this.platformId = platformId;
2472
- this.zone = zone;
2473
- this.Charter = Charter;
2474
- this.Dispatcher = Dispatcher;
2475
- this.logs = logs;
2476
- this.animations = animations;
2477
- this.locale = locale;
2478
- this.theme = theme;
2479
- /**
2480
- * Nome del grafico, fondamentale assegnarlo per permettere alla libreria di schedularne la creazione
2481
- */
2482
- this.name = "";
2483
- /**
2484
- * Dopo aver navigato a un nuovo grafico verranno attesi questi millisecondi prima di richiedere i dati attraverso la **DataRetrieve**.
2485
- *
2486
- * Questo per evitare che l'utente cliccando velocemente "avanti" generi tonnellate di richieste inutili
2487
- */
2488
- this.BrowseDelayMs = 500;
2489
- /**
2490
- * Evento lanciato sulla selezione di un range di dati o dalla timeline o dal grafico. Valido per tutti i grafici che supportano serie basate sulle date
2491
- */
2492
- this.onSelectionChanged = new EventEmitter();
2493
- /**
2494
- * Evento lanciato dal click di una serie dalla Legenda, a patto che l'Input **HideSeriesOnLabelClick** sia impostato a false
2495
- */
2496
- this.onSeriesClicked = new EventEmitter();
2497
- /**
2498
- * Evento lanciato all'inizio del caricamento di una nuova pagina del grafico
2499
- */
2500
- this.onLoadStart = new EventEmitter();
2501
- /**
2502
- * Evento lanciato al termine del caricamento di una nuova pagina del grafico
2503
- */
2504
- this.onLoadEnd = new EventEmitter();
2505
- /**
2506
- * Evento lanciato al termine della creazione del grafico referenziando l'istanza nativa del grafico creato in modo da poter effettuare modifiche
2507
- * post inizializzazione lato applicativo
2508
- */
2509
- this.chartLoaded = new EventEmitter();
2510
- /**
2511
- * Serve a decidere se sarà presente l'interfaccia di paginazione
2512
- */
2513
- this.isPaged = false;
2514
- /**
2515
- * @ignore
2516
- */
2517
- this.initDone = false;
2415
+ constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
2416
+ super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
2417
+ this.adapter = adapter;
2418
+ }
2419
+ /**
2420
+ * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
2421
+ */
2422
+ getSpecificPropertiesToCheck() {
2423
+ return ["Data", "DataArray", "HideZeroes", "Mode3D", "LabelsWrap", "LabelsTruncate", "LabelsWidth", "LabelsVisible"];
2424
+ }
2425
+ /**
2426
+ * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
2427
+ *
2428
+ * @returns {PieChartSettings} Settings castati al tipo giusto
2429
+ */
2430
+ getCastedSettings() {
2431
+ var _a;
2432
+ return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new PieChartSettings());
2518
2433
  }
2519
2434
  /**
2520
- * Metodo di inizializzazione post valorizzazione degli input, utilizzato per valorizzare correttamente le proprietà essenziali del grafico (Animazioni, Tema e Locale)
2435
+ * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
2521
2436
  *
2522
- * Viene data priorità ai Settings (HTML), priorità secondaria agli Input diretti (Lato HTML), priorità ultima alle impostazioni globali,
2523
- * impostate in fase di import del modulo assegnando valori ai token ESC_ANIMATIONS, ESC_THEME
2437
+ * @param {PieChartSettings} settingsCasted Settings castati al tipo giusto
2524
2438
  */
2525
- ngOnInit() {
2526
- var _a, _b, _c, _d, _e, _f;
2527
- // Qui servono solo le variabili da conoscere PRE-graficazione per il caricamento dei moduli lazy del grafico
2528
- this.Animations = ((_a = this.Settings) === null || _a === void 0 ? void 0 : _a.Animations) != null ? (_b = this.Settings) === null || _b === void 0 ? void 0 : _b.Animations : (this.Animations != null ? this.Animations : this.animations);
2529
- this.Theme = ((_c = this.Settings) === null || _c === void 0 ? void 0 : _c.Theme) != null ? (_d = this.Settings) === null || _d === void 0 ? void 0 : _d.Theme : (this.Theme != null ? this.Theme : this.theme);
2530
- this.Locale = ((_e = this.Settings) === null || _e === void 0 ? void 0 : _e.Locale) != null ? (_f = this.Settings) === null || _f === void 0 ? void 0 : _f.Locale : (this.Locale != null ? this.Locale : this.locale);
2531
- this.isPaged = (this.DataArray && this.DataArray.length > 0 && !this.Data) || (this.DataDtos && this.DataDtos.length > 0 && !!this.DataRetrieve);
2532
- this.log("Chart " + this.name + ": ngOnInit");
2439
+ fillSpecificSettings(settingsCasted) {
2440
+ settingsCasted.HideZeroes = settingsCasted.HideZeroes != null ? settingsCasted.HideZeroes : this.HideZeroes;
2441
+ settingsCasted.Mode3D = settingsCasted.Mode3D != null ? settingsCasted.Mode3D : this.Mode3D;
2442
+ settingsCasted.DonutRadiusPercentage = settingsCasted.DonutRadiusPercentage != null ? settingsCasted.DonutRadiusPercentage : this.DonutRadiusPercentage;
2443
+ settingsCasted.LabelsWrap = settingsCasted.LabelsWrap != null ? settingsCasted.LabelsWrap : this.LabelsWrap;
2444
+ settingsCasted.LabelsTruncate = settingsCasted.LabelsTruncate != null ? settingsCasted.LabelsTruncate : this.LabelsTruncate;
2445
+ settingsCasted.LabelsWidth = settingsCasted.LabelsWidth != null ? settingsCasted.LabelsWidth : this.LabelsWidth;
2446
+ settingsCasted.LabelsVisible = settingsCasted.LabelsVisible != null ? settingsCasted.LabelsVisible : this.LabelsVisible;
2533
2447
  }
2534
2448
  /**
2535
- * Implementazione utilizzata per controllare eventuali proprietà chiave del grafico e rigraficare tutto qualora si rivelasse necessario
2449
+ * Effettua il rendering di questo grafico in base ai Settings
2536
2450
  *
2537
- * @param {SimpleChanges} changes Indicazione dei cambiamenti sulle proprietà del grafico. Vedere documentazione Angular in merito
2451
+ * @param {PieChartSettings} settingsCasted Impostazioni di graficazione
2452
+ * @returns {PieChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
2538
2453
  */
2539
- ngOnChanges(changes) {
2540
- if (!this.initDone)
2541
- return;
2542
- this.log("Chart " + this.name + ": ngOnChanges");
2543
- let propsToCheck = ["Timeline", "Legend", "Settings", "Animations", "Theme", "Locale", ...this.getSpecificPropertiesToCheck()];
2544
- this.checkPropertiesAndRegraphicateAsNeeded(changes, propsToCheck);
2454
+ graphicate(settingsCasted) {
2455
+ return new PieChartService(this.adapter).graphicate(this.Data, settingsCasted);
2545
2456
  }
2457
+ }
2458
+ EsPieChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsPieChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
2459
+ EsPieChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsPieChartComponent, selector: "es-pie-chart", inputs: { Data: "Data", DataArray: "DataArray", HideZeroes: "HideZeroes", Mode3D: "Mode3D", DonutRadiusPercentage: "DonutRadiusPercentage", LabelsWrap: "LabelsWrap", LabelsTruncate: "LabelsTruncate", LabelsWidth: "LabelsWidth", LabelsVisible: "LabelsVisible" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2460
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsPieChartComponent, decorators: [{
2461
+ type: Component,
2462
+ args: [{ selector: 'es-pie-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:rgba(153,153,153,.6);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"] }]
2463
+ }], ctorParameters: function () {
2464
+ return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
2465
+ type: Inject,
2466
+ args: [PLATFORM_ID]
2467
+ }] }, { type: undefined, decorators: [{
2468
+ type: Inject,
2469
+ args: [ESC_LOGS]
2470
+ }] }, { type: undefined, decorators: [{
2471
+ type: Inject,
2472
+ args: [ESC_ANIMATIONS]
2473
+ }] }, { type: undefined, decorators: [{
2474
+ type: Inject,
2475
+ args: [ESC_THEME]
2476
+ }] }, { type: i4.LocalizationService }];
2477
+ }, propDecorators: { Data: [{
2478
+ type: Input
2479
+ }], DataArray: [{
2480
+ type: Input
2481
+ }], HideZeroes: [{
2482
+ type: Input
2483
+ }], Mode3D: [{
2484
+ type: Input
2485
+ }], DonutRadiusPercentage: [{
2486
+ type: Input
2487
+ }], LabelsWrap: [{
2488
+ type: Input
2489
+ }], LabelsTruncate: [{
2490
+ type: Input
2491
+ }], LabelsWidth: [{
2492
+ type: Input
2493
+ }], LabelsVisible: [{
2494
+ type: Input
2495
+ }] } });
2496
+
2497
+ /**
2498
+ * Componente specifico per la graficazione di un grafico a Barre con due dimensioni
2499
+ */
2500
+ class EsVertical2DChartComponent extends BaseChartComponent {
2546
2501
  /**
2547
- * Nel post inizializzazione, a patto che mi trovi in ambiente "browser", proseguo al caricamento del grafico sull'HTML
2502
+ * @ignore
2548
2503
  */
2549
- ngAfterViewInit() {
2550
- if (!this.name)
2551
- throw "a Unique name is mandatory to create a chart";
2552
- this.log("Chart " + this.name + ": ngAfterViewInit, graphicating chart outside Angular");
2553
- if (!this.isPaged)
2554
- this.dispatchLoadChart();
2504
+ constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
2505
+ super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
2506
+ this.adapter = adapter;
2555
2507
  }
2556
2508
  /**
2557
- * All'onDestroy scarico il grafico per liberare memoria
2509
+ * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
2558
2510
  */
2559
- ngOnDestroy() {
2560
- if (this.Chart) {
2561
- this.log("Chart " + this.name + ": Unloading destroyed chart");
2562
- this.browserOnly(() => { this.Chart.dispose(); this.Dispatcher.deregisterGraph(this.name); });
2563
- }
2564
- else
2565
- this.log("Chart " + this.name + ": Unloading uncreated chart component. It probably was a duplicated");
2511
+ getSpecificPropertiesToCheck() {
2512
+ return ["Data", "DataArray"];
2566
2513
  }
2567
2514
  /**
2568
- * Registra il grafico attuale nel Dispatcher in modo che venga caricato appena possibile
2515
+ * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
2516
+ *
2517
+ * @returns {Vertical2DChartSettings} Settings castati al tipo giusto
2569
2518
  */
2570
- dispatchLoadChart() {
2571
- this.browserOnly(() => {
2572
- this.Dispatcher.register(this.name, () => { return this.loadChart(); });
2573
- });
2519
+ getCastedSettings() {
2520
+ var _a;
2521
+ return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new Vertical2DChartSettings());
2574
2522
  }
2575
2523
  /**
2576
- * Il caricamento del grafico funziona nel seguente modo:
2577
- *
2578
- * 1) Caricamento del tema e delle animazioni, qualora necessari
2579
- *
2580
- * 2) Caricamento delle impostazioni specifiche e integrazione con le impostazioni generiche
2581
- *
2582
- * 3) Graficazione
2524
+ * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
2583
2525
  *
2584
- * 4) Caricamento del locale
2526
+ * @param {Vertical2DChartSettings} settingsCasted Settings castati al tipo giusto
2585
2527
  */
2586
- loadChart() {
2587
- this.log("Chart " + this.name + ": Start loading Modules if needed");
2588
- return Promise.all([
2589
- this.setupAmChartsThemes().then(() => {
2590
- this.log("Chart " + this.name + ": Graphicating after modules load");
2591
- var castedSettings = this.getCastedSettings();
2592
- this.fillSettings(castedSettings);
2593
- this.fillSpecificSettings(castedSettings);
2594
- this.ChartService = this.graphicate(castedSettings);
2595
- this.Chart = this.ChartService.ChartInstance;
2596
- if (!this.Chart)
2597
- this.log("Chart " + this.name + ": Could not create graph");
2598
- // Unico punto reale in cui viene utilizzato il locale, tehe
2599
- return this.Charter.applyLocale(this.Chart, this.Locale).then(() => { this.initDone = true; this.chartLoaded.emit(this); });
2600
- })
2601
- ]);
2528
+ fillSpecificSettings(settingsCasted) {
2529
+ settingsCasted.ColumnWidthPercentage = settingsCasted.ColumnWidthPercentage != null ? settingsCasted.ColumnWidthPercentage : this.ColumnWidthPercentage;
2530
+ settingsCasted.GroupPaddingPercentage = settingsCasted.GroupPaddingPercentage != null ? settingsCasted.GroupPaddingPercentage : this.GroupPaddingPercentage;
2531
+ settingsCasted.LabelWidth = settingsCasted.LabelWidth != null ? settingsCasted.LabelWidth : this.LabelWidth;
2532
+ settingsCasted.LabelVerticalOrientationCutoffWidth = settingsCasted.LabelVerticalOrientationCutoffWidth != null ? settingsCasted.LabelVerticalOrientationCutoffWidth : this.LabelVerticalOrientationCutoffWidth;
2533
+ settingsCasted.LabelRightWhenCompressed = settingsCasted.LabelRightWhenCompressed != null ? settingsCasted.LabelRightWhenCompressed : this.LabelRightWhenCompressed;
2534
+ settingsCasted.LabelTopWhenCompressed = settingsCasted.LabelTopWhenCompressed != null ? settingsCasted.LabelTopWhenCompressed : this.LabelTopWhenCompressed;
2602
2535
  }
2603
2536
  /**
2604
- * Riempimento delle impostazioni nella classe Settings. Si danno priorità ai valori già impostati nei Settings,
2605
- * integrando eventualmente con le proprietà del grafico
2537
+ * Effettua il rendering di questo grafico in base ai Settings
2606
2538
  *
2607
- * @param {BaseSettings} settings Impostazioni base ricevute dalla specializzazione del grafico
2539
+ * @param {Vertical2DChartSettings} settingsCasted Impostazioni di graficazione
2540
+ * @returns {Vertical2DChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
2608
2541
  */
2609
- fillSettings(settings) {
2610
- var _a;
2611
- // Merge degli Input con i Settings, dando priorità ai Settings
2612
- settings.Theme = settings.Theme ? settings.Theme : this.Theme;
2613
- settings.Locale = settings.Locale ? settings.Locale : this.Locale;
2614
- settings.Animations = settings.Animations != null ? settings.Animations : this.Animations;
2615
- settings.Legend = settings.Legend != null ? settings.Legend : this.Legend;
2616
- settings.Name = settings.Name ? settings.Name : this.name;
2617
- settings.Timeline = settings.Timeline != null ? settings.Timeline : this.Timeline;
2618
- settings.AdaptLabelSizeAndOrientation = settings.AdaptLabelSizeAndOrientation != null ? settings.AdaptLabelSizeAndOrientation : this.AdaptLabelSizeAndOrientation;
2619
- settings.XAxisTitle = settings.XAxisTitle ? settings.XAxisTitle : this.XTitle;
2620
- settings.YAxisTitle = settings.YAxisTitle ? settings.YAxisTitle : this.YTitle;
2621
- settings.LegendPosition = settings.LegendPosition ? settings.LegendPosition : this.LegendPosition;
2622
- settings.HideSeriesOnLabelClick = settings.HideSeriesOnLabelClick != null ? settings.HideSeriesOnLabelClick : this.HideSeriesOnLabelClick;
2623
- settings.MinGridDistance = settings.MinGridDistance != null ? settings.MinGridDistance : this.MinGridDistance;
2624
- settings.LegendPadding = settings.LegendPadding ? settings.LegendPadding : (_a = this.LegendPadding) !== null && _a !== void 0 ? _a : null;
2625
- settings.ContainerHeight = this.el.nativeElement.parentElement.offsetHeight;
2626
- settings.OnSeriesClickCallback = (series) => { this.onSeriesClicked.emit(series); };
2627
- settings.OnSelectionChangedCallback = (event) => { this.onSelectionChanged.emit({ from: event.from, to: event.to, initial: event.initial }); };
2542
+ graphicate(settingsCasted) {
2543
+ return new Vertical2DChartService(this.adapter).graphicate(this.Data, settingsCasted);
2628
2544
  }
2545
+ }
2546
+ EsVertical2DChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVertical2DChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
2547
+ EsVertical2DChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsVertical2DChartComponent, selector: "es-vertical-2d-chart", inputs: { Data: "Data", DataArray: "DataArray", ColumnWidthPercentage: "ColumnWidthPercentage", GroupPaddingPercentage: "GroupPaddingPercentage", LabelWidth: "LabelWidth", LabelVerticalOrientationCutoffWidth: "LabelVerticalOrientationCutoffWidth", LabelRightWhenCompressed: "LabelRightWhenCompressed", LabelTopWhenCompressed: "LabelTopWhenCompressed" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2548
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVertical2DChartComponent, decorators: [{
2549
+ type: Component,
2550
+ args: [{ selector: 'es-vertical-2d-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:rgba(153,153,153,.6);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"] }]
2551
+ }], ctorParameters: function () {
2552
+ return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
2553
+ type: Inject,
2554
+ args: [PLATFORM_ID]
2555
+ }] }, { type: undefined, decorators: [{
2556
+ type: Inject,
2557
+ args: [ESC_LOGS]
2558
+ }] }, { type: undefined, decorators: [{
2559
+ type: Inject,
2560
+ args: [ESC_ANIMATIONS]
2561
+ }] }, { type: undefined, decorators: [{
2562
+ type: Inject,
2563
+ args: [ESC_THEME]
2564
+ }] }, { type: i4.LocalizationService }];
2565
+ }, propDecorators: { Data: [{
2566
+ type: Input
2567
+ }], DataArray: [{
2568
+ type: Input
2569
+ }], ColumnWidthPercentage: [{
2570
+ type: Input
2571
+ }], GroupPaddingPercentage: [{
2572
+ type: Input
2573
+ }], LabelWidth: [{
2574
+ type: Input
2575
+ }], LabelVerticalOrientationCutoffWidth: [{
2576
+ type: Input
2577
+ }], LabelRightWhenCompressed: [{
2578
+ type: Input
2579
+ }], LabelTopWhenCompressed: [{
2580
+ type: Input
2581
+ }] } });
2582
+
2583
+ /**
2584
+ * Componente specifico per la graficazione di un grafico a Barre
2585
+ */
2586
+ class EsVerticalChartComponent extends BaseChartComponent {
2629
2587
  /**
2630
- * Controlla i cambiamenti avvenuti alle proprietà chiave e rieffettua la graficazione qualora necessario
2631
- *
2632
- * @param {SimpleChanges} changes Indicazione della modifiche avvenute nei vari Input
2633
- * @param {string[]} propsToCheck Lista degli Input da controllare per cui una modifica causa una rigraficazione
2588
+ * @ignore
2634
2589
  */
2635
- checkPropertiesAndRegraphicateAsNeeded(changes, propsToCheck) {
2636
- let toReGraphicate = false;
2637
- for (let i = 0; i < propsToCheck.length; i++)
2638
- toReGraphicate = toReGraphicate || (changes[propsToCheck[i]] && changes[propsToCheck[i]].currentValue);
2639
- if (toReGraphicate)
2640
- this.reloadChart();
2590
+ constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
2591
+ super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
2592
+ this.adapter = adapter;
2641
2593
  }
2642
2594
  /**
2643
- * Funzione che effettua un cambio di pagina per i grafici paginati. Qualora **data** fosse nullo significa che è iniziato un caricamento
2644
- * e anche lato applicativo il DataRetrieve dovrà considerare che l'assenza di valori non è altro che un'indicazione di inizio caricamento
2645
- *
2646
- * Il caricamento di qualsiasi pagina genererà comunque una primo evento con **data** nullo in modo da indicare l'inizio caricamento e
2647
- * in seconda istanza un altro evento in cui **data** sarà sempre valorizzato, o con il Dto da usare per recuperare i dati, o con i dati
2648
- * veri e propri già presenti nel **DataArray**
2649
- *
2650
- * I callback **onLoadStart** e **onLoadEnd** vengono sempre chiamati
2651
- *
2652
- * @param {{ data: LineChartData | PieChartData | Vertical2DChartData | VerticalChartData | any, index: number }} nd Indice del caricamento dati, con eventualmente già i dati se disponibili
2595
+ * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
2653
2596
  */
2654
- changePage(nd) {
2655
- if (!nd.data) {
2656
- this.loadingChart = true;
2657
- // Serve per informare l'applicativo in listening sull'indice attualmente in visualizzazione.
2658
- // La mancanza di dati indica che non devono essere effettuate ricerche per ora
2659
- if (this.DataRetrieve)
2660
- this.DataRetrieve(null, nd.index);
2661
- this.onLoadStart.emit();
2662
- return;
2663
- }
2664
- if (this.DataRetrieve)
2665
- this.DataRetrieve(nd.data, nd.index).then(t => { this.changePageDataReceived(t); });
2666
- else
2667
- this.changePageDataReceived(nd.data);
2597
+ getSpecificPropertiesToCheck() {
2598
+ return ["Data", "DataArray"];
2599
+ }
2600
+ /**
2601
+ * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
2602
+ *
2603
+ * @returns {VerticalChartSettings} Settings castati al tipo giusto
2604
+ */
2605
+ getCastedSettings() {
2606
+ var _a;
2607
+ return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new VerticalChartSettings());
2668
2608
  }
2669
2609
  /**
2670
- * Al termine del caricamento dei dati di una pagina questo metodo viene chiamato per rigraficare la situazione con i nuovi dati
2610
+ * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
2671
2611
  *
2672
- * @param {LineChartData | PieChartData | Vertical2DChartData | VerticalChartData | any} data Dati del grafico
2612
+ * @param {VerticalChartSettings} settingsCasted Settings castati al tipo giusto
2673
2613
  */
2674
- changePageDataReceived(data) {
2675
- this.loadingChart = false;
2676
- this.onLoadEnd.emit();
2677
- let firstBind = !this.Data;
2678
- this.Data = data;
2679
- if (!firstBind)
2680
- this.reloadChart();
2681
- else
2682
- this.dispatchLoadChart();
2614
+ fillSpecificSettings(settingsCasted) {
2615
+ settingsCasted.ColumnWidthPercentage = settingsCasted.ColumnWidthPercentage != null ? settingsCasted.ColumnWidthPercentage : this.ColumnWidthPercentage;
2616
+ settingsCasted.LabelWidth = settingsCasted.LabelWidth != null ? settingsCasted.LabelWidth : this.LabelWidth;
2617
+ settingsCasted.LabelVerticalOrientationCutoffWidth = settingsCasted.LabelVerticalOrientationCutoffWidth != null ? settingsCasted.LabelVerticalOrientationCutoffWidth : this.LabelVerticalOrientationCutoffWidth;
2618
+ settingsCasted.LabelRightWhenCompressed = settingsCasted.LabelRightWhenCompressed != null ? settingsCasted.LabelRightWhenCompressed : this.LabelRightWhenCompressed;
2619
+ settingsCasted.LabelTopWhenCompressed = settingsCasted.LabelTopWhenCompressed != null ? settingsCasted.LabelTopWhenCompressed : this.LabelTopWhenCompressed;
2683
2620
  }
2684
2621
  /**
2685
- * Ricarica il grafico distruggendo il vecchio e ricreando il nuovo
2622
+ * Effettua il rendering di questo grafico in base ai Settings
2686
2623
  *
2687
- * Le chiamate a questo metodo possono essere trasformate in chiamate al metodo **graphicate** della Service, se solo quel metodo fosse abbastanza intelligente per capire
2688
- * le differenze fra il grafico com'era prima e come deve diventare, in modo da non ricrearlo ma semplicemente modificare quello che già è disegnato
2624
+ * @param {VerticalChartSettings} settingsCasted Impostazioni di graficazione
2625
+ * @returns {VerticalChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
2689
2626
  */
2690
- reloadChart() {
2691
- this.browserOnly(() => {
2692
- if (!this.Chart.isDisposed())
2693
- this.Chart.dispose();
2694
- this.Dispatcher.deregisterGraph(this.name);
2695
- });
2696
- this.Dispatcher.register(this.name, () => { return this.loadChart(); });
2627
+ graphicate(settingsCasted) {
2628
+ return new VerticalChartService(this.adapter).graphicate(this.Data, settingsCasted);
2697
2629
  }
2630
+ }
2631
+ EsVerticalChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVerticalChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
2632
+ EsVerticalChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsVerticalChartComponent, selector: "es-vertical-chart", inputs: { Data: "Data", DataArray: "DataArray", ColumnWidthPercentage: "ColumnWidthPercentage", LabelWidth: "LabelWidth", LabelVerticalOrientationCutoffWidth: "LabelVerticalOrientationCutoffWidth", LabelRightWhenCompressed: "LabelRightWhenCompressed", LabelTopWhenCompressed: "LabelTopWhenCompressed" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2633
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVerticalChartComponent, decorators: [{
2634
+ type: Component,
2635
+ args: [{ selector: 'es-vertical-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:rgba(153,153,153,.6);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"] }]
2636
+ }], ctorParameters: function () {
2637
+ return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
2638
+ type: Inject,
2639
+ args: [PLATFORM_ID]
2640
+ }] }, { type: undefined, decorators: [{
2641
+ type: Inject,
2642
+ args: [ESC_LOGS]
2643
+ }] }, { type: undefined, decorators: [{
2644
+ type: Inject,
2645
+ args: [ESC_ANIMATIONS]
2646
+ }] }, { type: undefined, decorators: [{
2647
+ type: Inject,
2648
+ args: [ESC_THEME]
2649
+ }] }, { type: i4.LocalizationService }];
2650
+ }, propDecorators: { Data: [{
2651
+ type: Input
2652
+ }], DataArray: [{
2653
+ type: Input
2654
+ }], ColumnWidthPercentage: [{
2655
+ type: Input
2656
+ }], LabelWidth: [{
2657
+ type: Input
2658
+ }], LabelVerticalOrientationCutoffWidth: [{
2659
+ type: Input
2660
+ }], LabelRightWhenCompressed: [{
2661
+ type: Input
2662
+ }], LabelTopWhenCompressed: [{
2663
+ type: Input
2664
+ }] } });
2665
+
2666
+ /**
2667
+ * Componente specifico per la graficazione di un grafico a Barre in modalità Stacked (una serie sopra l'altra)
2668
+ */
2669
+ class EsVerticalStackedChartComponent extends BaseChartComponent {
2698
2670
  /**
2699
- * Permette di aggiungere un blocco di dati in maniera "live" ad un grafico
2671
+ * @ignore
2700
2672
  */
2701
- addData(chartData) {
2702
- this.ChartService.refreshData(chartData);
2673
+ constructor(el, ChartLoader, ChartDispatcher, adapter, zone, platformId, ESC_LOGS, ESC_ANIMATIONS, ESC_THEME, lc) {
2674
+ super(el, platformId, zone, ChartLoader, ChartDispatcher, ESC_LOGS, ESC_ANIMATIONS, lc.Locale, ESC_THEME);
2675
+ this.adapter = adapter;
2703
2676
  }
2704
- ;
2705
2677
  /**
2706
- * Funzione che si occupa di caricare i temi necessari per il grafico in oggetto. Prima applica il tema, poi, se serve, applica le animazioni
2678
+ * Ottiene le proprietà specifiche per questa tipologia di grafico per cui serve rigraficare
2707
2679
  */
2708
- setupAmChartsThemes() {
2709
- return Promise.all([
2710
- this.Charter.applyTheme(am4core, this.Theme).then(() => {
2711
- return this.Animations ? this.Charter.applyAnimations(am4core) : this.Charter.unapplyAnimations(am4core);
2712
- })
2713
- ]);
2680
+ getSpecificPropertiesToCheck() {
2681
+ return ["Data", "DataArray"];
2714
2682
  }
2715
2683
  /**
2716
- * @ignore
2684
+ * Ottiene i Settings (Ereditati dalla classe base, quindi del tipo generico **BaseSettings**) castati al tipo specifico per questo grafico
2685
+ *
2686
+ * @returns {VerticalStackedChartSettings} Settings castati al tipo giusto
2717
2687
  */
2718
- log(log) {
2719
- if (this.logs)
2720
- console.log("@esfaenza/es-charts: " + log);
2688
+ getCastedSettings() {
2689
+ var _a;
2690
+ return ((_a = this.Settings) !== null && _a !== void 0 ? _a : new VerticalStackedChartSettings());
2721
2691
  }
2722
2692
  /**
2723
- * Imposta lo zoom dal **from** al **to**
2693
+ * Integra i Settings base con tutti gli Input specifici di questo grafico, dando priorità ai Settings se definiti
2724
2694
  *
2725
- * @param {Date} from Inizio dello zoom
2726
- * @param {Date} to Fine dello zoom
2695
+ * @param {VerticalStackedChartSettings} settingsCasted Settings castati al tipo giusto
2727
2696
  */
2728
- setSelection(from, to) {
2729
- this.ChartService.setSelection(from, to);
2697
+ fillSpecificSettings(settingsCasted) {
2698
+ settingsCasted.ColumnWidthPercentage = settingsCasted.ColumnWidthPercentage != null ? settingsCasted.ColumnWidthPercentage : this.ColumnWidthPercentage;
2699
+ settingsCasted.LabelWidth = settingsCasted.LabelWidth != null ? settingsCasted.LabelWidth : this.LabelWidth;
2700
+ settingsCasted.LabelVerticalOrientationCutoffWidth = settingsCasted.LabelVerticalOrientationCutoffWidth != null ? settingsCasted.LabelVerticalOrientationCutoffWidth : this.LabelVerticalOrientationCutoffWidth;
2701
+ settingsCasted.LabelRightWhenCompressed = settingsCasted.LabelRightWhenCompressed != null ? settingsCasted.LabelRightWhenCompressed : this.LabelRightWhenCompressed;
2702
+ settingsCasted.LabelTopWhenCompressed = settingsCasted.LabelTopWhenCompressed != null ? settingsCasted.LabelTopWhenCompressed : this.LabelTopWhenCompressed;
2730
2703
  }
2731
2704
  /**
2732
- * @ignore
2705
+ * Effettua il rendering di questo grafico in base ai Settings
2706
+ *
2707
+ * @param {VerticalStackedChartSettings} settingsCasted Impostazioni di graficazione
2708
+ * @returns {VerticalStackedChartService} La service utilizzata per il rendering nello stato subito successivo al rendering effettuato
2733
2709
  */
2734
- browserOnly(f) {
2735
- if (isPlatformBrowser(this.platformId)) {
2736
- this.zone.runOutsideAngular(() => {
2737
- f();
2738
- });
2739
- }
2710
+ graphicate(settingsCasted) {
2711
+ return new VerticalStackedChartService(this.adapter).graphicate(this.Data, settingsCasted);
2740
2712
  }
2741
2713
  }
2742
- BaseChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseChartComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
2743
- BaseChartComponentdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: BaseChartComponent, inputs: { XTitle: "XTitle", YTitle: "YTitle", Settings: "Settings", Legend: "Legend", LegendPosition: "LegendPosition", Timeline: "Timeline", name: "name", Animations: "Animations", Theme: "Theme", Locale: "Locale", HideSeriesOnLabelClick: "HideSeriesOnLabelClick", MinGridDistance: "MinGridDistance", AdaptLabelSizeAndOrientation: "AdaptLabelSizeAndOrientation", LegendPadding: "LegendPadding", DataDtos: "DataDtos", DataDtoStartIndex: "DataDtoStartIndex", DataRetrieve: "DataRetrieve", BrowseDelayMs: "BrowseDelayMs" }, outputs: { onSelectionChanged: "onSelectionChanged", onSeriesClicked: "onSeriesClicked", onLoadStart: "onLoadStart", onLoadEnd: "onLoadEnd", chartLoaded: "chartLoaded" }, queries: [{ propertyName: "header_tr", first: true, predicate: ["header"], descendants: true }, { propertyName: "loading_template", first: true, predicate: ["loading"], descendants: true }], usesOnChanges: true, ngImport: i0 });
2744
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseChartComponent, decorators: [{
2745
- type: Directive
2746
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: Object }, { type: i0.NgZone }, { type: ChartLoader }, { type: ChartDispatcher }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }]; }, propDecorators: { XTitle: [{
2747
- type: Input
2748
- }], YTitle: [{
2749
- type: Input
2750
- }], Settings: [{
2751
- type: Input
2752
- }], Legend: [{
2753
- type: Input
2754
- }], LegendPosition: [{
2755
- type: Input
2756
- }], Timeline: [{
2757
- type: Input
2758
- }], name: [{
2759
- type: Input
2760
- }], Animations: [{
2761
- type: Input
2762
- }], Theme: [{
2763
- type: Input
2764
- }], Locale: [{
2765
- type: Input
2766
- }], HideSeriesOnLabelClick: [{
2767
- type: Input
2768
- }], MinGridDistance: [{
2714
+ EsVerticalStackedChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVerticalStackedChartComponent, deps: [{ token: i0.ElementRef }, { token: ChartLoader }, { token: ChartDispatcher }, { token: BaseAdapter }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: ESC_LOGS }, { token: ESC_ANIMATIONS }, { token: ESC_THEME }, { token: i4.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
2715
+ EsVerticalStackedChartComponentcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: EsVerticalStackedChartComponent, selector: "es-vertical-stacked-chart", inputs: { Data: "Data", DataArray: "DataArray", ColumnWidthPercentage: "ColumnWidthPercentage", LabelWidth: "LabelWidth", LabelVerticalOrientationCutoffWidth: "LabelVerticalOrientationCutoffWidth", LabelRightWhenCompressed: "LabelRightWhenCompressed", LabelTopWhenCompressed: "LabelTopWhenCompressed" }, 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:rgba(153,153,153,.6);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"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PageChartSelector, selector: "chart-pager", inputs: ["Items", "Dtos", "BrowseDelayMs", "StartIndex"], outputs: ["onPageChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2716
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsVerticalStackedChartComponent, decorators: [{
2717
+ type: Component,
2718
+ args: [{ selector: 'es-vertical-stacked-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:rgba(153,153,153,.6);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"] }]
2719
+ }], ctorParameters: function () {
2720
+ return [{ type: i0.ElementRef }, { type: ChartLoader }, { type: ChartDispatcher }, { type: BaseAdapter }, { type: i0.NgZone }, { type: Object, decorators: [{
2721
+ type: Inject,
2722
+ args: [PLATFORM_ID]
2723
+ }] }, { type: undefined, decorators: [{
2724
+ type: Inject,
2725
+ args: [ESC_LOGS]
2726
+ }] }, { type: undefined, decorators: [{
2727
+ type: Inject,
2728
+ args: [ESC_ANIMATIONS]
2729
+ }] }, { type: undefined, decorators: [{
2730
+ type: Inject,
2731
+ args: [ESC_THEME]
2732
+ }] }, { type: i4.LocalizationService }];
2733
+ }, propDecorators: { Data: [{
2769
2734
  type: Input
2770
- }], AdaptLabelSizeAndOrientation: [{
2735
+ }], DataArray: [{
2771
2736
  type: Input
2772
- }], LegendPadding: [{
2737
+ }], ColumnWidthPercentage: [{
2773
2738
  type: Input
2774
- }], DataDtos: [{
2739
+ }], LabelWidth: [{
2775
2740
  type: Input
2776
- }], DataDtoStartIndex: [{
2741
+ }], LabelVerticalOrientationCutoffWidth: [{
2777
2742
  type: Input
2778
- }], DataRetrieve: [{
2743
+ }], LabelRightWhenCompressed: [{
2779
2744
  type: Input
2780
- }], BrowseDelayMs: [{
2745
+ }], LabelTopWhenCompressed: [{
2781
2746
  type: Input
2782
- }], header_tr: [{
2783
- type: ContentChild,
2784
- args: ['header', { static: false }]
2785
- }], loading_template: [{
2786
- type: ContentChild,
2787
- args: ['loading', { static: false }]
2788
- }], onSelectionChanged: [{
2789
- type: Output
2790
- }], onSeriesClicked: [{
2791
- type: Output
2792
- }], onLoadStart: [{
2793
- type: Output
2794
- }], onLoadEnd: [{
2795
- type: Output
2796
- }], chartLoaded: [{
2797
- type: Output
2798
2747
  }] } });
2799
2748
 
2800
2749
  /**
@@ -2817,6 +2766,57 @@ class PagedChartData {
2817
2766
  }
2818
2767
  }
2819
2768
 
2769
+ /** Componenti esportati dal modulo */
2770
+ const COMPONENTS = [
2771
+ EsChartComponent,
2772
+ EsLineChartComponent,
2773
+ EsPieChartComponent,
2774
+ EsVertical2DChartComponent,
2775
+ EsVerticalChartComponent,
2776
+ EsVerticalStackedChartComponent,
2777
+ PageChartSelector,
2778
+ EsAreaChartComponent
2779
+ ];
2780
+ class EsChartsModule {
2781
+ static forRoot(config) {
2782
+ return {
2783
+ ngModule: EsChartsModule,
2784
+ providers: [
2785
+ ChartLoader,
2786
+ { provide: ESC_ANIMATIONS, useValue: (config === null || config === void 0 ? void 0 : config.animations) == null || (config === null || config === void 0 ? void 0 : config.animations) == undefined ? true : config === null || config === void 0 ? void 0 : config.animations },
2787
+ { provide: ESC_THEME, useValue: (config === null || config === void 0 ? void 0 : config.theme) || 'spiritedaway' },
2788
+ { provide: ESC_LOGS, useValue: (config === null || config === void 0 ? void 0 : config.debugMode) || false },
2789
+ { provide: BaseAdapter, useClass: (config === null || config === void 0 ? void 0 : config.adapter) || BaseAdapter }
2790
+ ]
2791
+ };
2792
+ }
2793
+ }
2794
+ EsChartsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsChartsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2795
+ EsChartsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: EsChartsModule, declarations: [EsChartComponent,
2796
+ EsLineChartComponent,
2797
+ EsPieChartComponent,
2798
+ EsVertical2DChartComponent,
2799
+ EsVerticalChartComponent,
2800
+ EsVerticalStackedChartComponent,
2801
+ PageChartSelector,
2802
+ EsAreaChartComponent], imports: [CommonModule], exports: [EsChartComponent,
2803
+ EsLineChartComponent,
2804
+ EsPieChartComponent,
2805
+ EsVertical2DChartComponent,
2806
+ EsVerticalChartComponent,
2807
+ EsVerticalStackedChartComponent,
2808
+ PageChartSelector,
2809
+ EsAreaChartComponent] });
2810
+ EsChartsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsChartsModule, imports: [CommonModule] });
2811
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: EsChartsModule, decorators: [{
2812
+ type: NgModule,
2813
+ args: [{
2814
+ imports: [CommonModule],
2815
+ declarations: [...COMPONENTS],
2816
+ exports: [...COMPONENTS]
2817
+ }]
2818
+ }] });
2819
+
2820
2820
  /*
2821
2821
  * Public API Surface of es-charts
2822
2822
  */