@esfaenza/es-charts 15.2.2 → 15.2.3

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