@esfaenza/es-charts 11.2.18 → 11.2.22

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.
Files changed (142) hide show
  1. package/bundles/esfaenza-es-charts.umd.js +419 -408
  2. package/bundles/esfaenza-es-charts.umd.js.map +1 -1
  3. package/bundles/esfaenza-es-charts.umd.min.js +1 -1
  4. package/bundles/esfaenza-es-charts.umd.min.js.map +1 -1
  5. package/esfaenza-es-charts.d.ts +4 -6
  6. package/esfaenza-es-charts.metadata.json +1 -1
  7. package/esm2015/esfaenza-es-charts.js +5 -7
  8. package/esm2015/lib/adapters/BaseAdapter.js +47 -0
  9. package/esm2015/lib/adapters/IBaseAdapter.js +2 -0
  10. package/esm2015/lib/components/base/base-chart.component.js +11 -3
  11. package/esm2015/lib/components/chart-pager/chart-pager.component.js +1 -1
  12. package/esm2015/lib/components/specializations/es-area-chart.component.js +6 -5
  13. package/esm2015/lib/components/specializations/es-chart.component.js +18 -5
  14. package/esm2015/lib/components/specializations/es-line-chart.component.js +6 -5
  15. package/esm2015/lib/components/specializations/es-pie-chart.component.js +6 -5
  16. package/esm2015/lib/components/specializations/es-vertical-2d-chart.component.js +6 -5
  17. package/esm2015/lib/components/specializations/es-vertical-chart.component.js +6 -5
  18. package/esm2015/lib/components/specializations/es-vertical-stacked-chart.component.js +6 -5
  19. package/esm2015/lib/es-charts.module.js +13 -5
  20. package/esm2015/lib/models/core/ChartDispatcher.js +88 -0
  21. package/esm2015/lib/models/core/ChartLoader.js +201 -0
  22. package/esm2015/lib/models/core/ChartThemes.js +61 -0
  23. package/esm2015/lib/models/data/AreaChartData.js +16 -0
  24. package/esm2015/lib/models/data/LineChartData.js +16 -0
  25. package/esm2015/lib/models/data/PagedChartData.js +20 -0
  26. package/esm2015/lib/models/data/PieChartData.js +14 -0
  27. package/esm2015/lib/models/data/Vertical2DChartData.js +16 -0
  28. package/esm2015/lib/models/data/VerticalChartData.js +14 -0
  29. package/esm2015/lib/models/data/VerticalStackedChartData.js +14 -0
  30. package/esm2015/lib/models/data/base/DateValue.js +11 -0
  31. package/esm2015/lib/models/data/base/KeyValue.js +11 -0
  32. package/esm2015/lib/models/data/base/KeyValueColor.js +12 -0
  33. package/esm2015/lib/models/data/base/Limit.js +15 -0
  34. package/esm2015/lib/models/data/base/LineSerie.js +24 -0
  35. package/esm2015/lib/models/settings/AreaChartSettings.js +11 -0
  36. package/esm2015/lib/models/settings/LineChartSettings.js +11 -0
  37. package/esm2015/lib/models/settings/PieChartSettings.js +7 -0
  38. package/esm2015/lib/models/settings/Vertical2DChartSettings.js +11 -0
  39. package/esm2015/lib/models/settings/VerticalChartSettings.js +11 -0
  40. package/esm2015/lib/models/settings/VerticalStackedChartSettings.js +11 -0
  41. package/esm2015/lib/models/settings/base/BaseInterval.js +6 -0
  42. package/esm2015/lib/models/settings/base/BaseSettings.js +6 -0
  43. package/esm2015/lib/models/settings/base/LegendPad.js +6 -0
  44. package/esm2015/lib/services/AreaChartService.js +135 -0
  45. package/esm2015/lib/services/LineChartService.js +339 -0
  46. package/esm2015/lib/services/PieChartService.js +112 -0
  47. package/esm2015/lib/services/Vertical2DChartService.js +163 -0
  48. package/esm2015/lib/services/VerticalChartService.js +105 -0
  49. package/esm2015/lib/services/VerticalStackedChartService.js +127 -0
  50. package/esm2015/lib/services/base/IBaseService.js +2 -0
  51. package/esm2015/public-api.js +26 -25
  52. package/fesm2015/esfaenza-es-charts.js +395 -375
  53. package/fesm2015/esfaenza-es-charts.js.map +1 -1
  54. package/lib/adapters/{classes/BaseAdapter.d.ts → BaseAdapter.d.ts} +6 -1
  55. package/lib/adapters/{classes/IBaseAdapter.d.ts → IBaseAdapter.d.ts} +6 -1
  56. package/lib/components/base/base-chart.component.d.ts +15 -5
  57. package/lib/components/chart-pager/chart-pager.component.d.ts +1 -1
  58. package/lib/components/specializations/es-area-chart.component.d.ts +6 -4
  59. package/lib/components/specializations/es-chart.component.d.ts +17 -5
  60. package/lib/components/specializations/es-line-chart.component.d.ts +6 -4
  61. package/lib/components/specializations/es-pie-chart.component.d.ts +6 -4
  62. package/lib/components/specializations/es-vertical-2d-chart.component.d.ts +6 -4
  63. package/lib/components/specializations/es-vertical-chart.component.d.ts +6 -4
  64. package/lib/components/specializations/es-vertical-stacked-chart.component.d.ts +6 -4
  65. package/lib/models/core/{classes/ChartDispatcher.d.ts → ChartDispatcher.d.ts} +0 -0
  66. package/lib/models/core/{classes/ChartLoader.d.ts → ChartLoader.d.ts} +0 -0
  67. package/lib/models/core/{classes/ChartThemes.d.ts → ChartThemes.d.ts} +0 -0
  68. package/lib/models/data/{classes/AreaChartData.d.ts → AreaChartData.d.ts} +1 -1
  69. package/lib/models/data/{classes/LineChartData.d.ts → LineChartData.d.ts} +0 -0
  70. package/lib/models/data/{classes/PagedChartData.d.ts → PagedChartData.d.ts} +0 -0
  71. package/lib/models/data/{classes/PieChartData.d.ts → PieChartData.d.ts} +0 -0
  72. package/lib/models/data/{classes/Vertical2DChartData.d.ts → Vertical2DChartData.d.ts} +0 -0
  73. package/lib/models/data/{classes/VerticalChartData.d.ts → VerticalChartData.d.ts} +0 -0
  74. package/lib/models/data/{classes/VerticalStackedChartData.d.ts → VerticalStackedChartData.d.ts} +0 -0
  75. package/lib/models/data/{classes/base → base}/DateValue.d.ts +0 -0
  76. package/lib/models/data/{classes/base → base}/KeyValue.d.ts +0 -0
  77. package/lib/models/data/{classes/base → base}/KeyValueColor.d.ts +0 -0
  78. package/lib/models/data/{classes/base → base}/Limit.d.ts +0 -0
  79. package/lib/models/data/{classes/base → base}/LineSerie.d.ts +1 -1
  80. package/lib/models/settings/{classes/AreaChartSettings.d.ts → AreaChartSettings.d.ts} +0 -0
  81. package/lib/models/settings/{classes/LineChartSettings.d.ts → LineChartSettings.d.ts} +0 -0
  82. package/lib/models/settings/{classes/PieChartSettings.d.ts → PieChartSettings.d.ts} +0 -0
  83. package/lib/models/settings/{classes/Vertical2DChartSettings.d.ts → Vertical2DChartSettings.d.ts} +0 -0
  84. package/lib/models/settings/{classes/VerticalChartSettings.d.ts → VerticalChartSettings.d.ts} +0 -0
  85. package/lib/models/settings/{classes/VerticalStackedChartSettings.d.ts → VerticalStackedChartSettings.d.ts} +0 -0
  86. package/lib/models/settings/{classes/base → base}/BaseInterval.d.ts +0 -0
  87. package/lib/models/settings/{classes/base → base}/BaseSettings.d.ts +1 -1
  88. package/lib/models/settings/{classes/base → base}/LegendPad.d.ts +0 -0
  89. package/lib/services/{classes/AreaChartService.d.ts → AreaChartService.d.ts} +3 -3
  90. package/lib/services/{classes/LineChartService.d.ts → LineChartService.d.ts} +7 -3
  91. package/lib/services/{classes/PieChartService.d.ts → PieChartService.d.ts} +3 -3
  92. package/lib/services/{classes/Vertical2DChartService.d.ts → Vertical2DChartService.d.ts} +3 -3
  93. package/lib/services/{classes/VerticalChartService.d.ts → VerticalChartService.d.ts} +3 -3
  94. package/lib/services/{classes/VerticalStackedChartService.d.ts → VerticalStackedChartService.d.ts} +3 -3
  95. package/lib/services/{classes/base → base}/IBaseService.d.ts +1 -1
  96. package/package.json +1 -1
  97. package/public-api.d.ts +25 -24
  98. package/esm2015/lib/adapters/classes/BaseAdapter.js +0 -47
  99. package/esm2015/lib/adapters/classes/IBaseAdapter.js +0 -2
  100. package/esm2015/lib/adapters/index.js +0 -3
  101. package/esm2015/lib/components/index.js +0 -9
  102. package/esm2015/lib/models/core/classes/ChartDispatcher.js +0 -88
  103. package/esm2015/lib/models/core/classes/ChartLoader.js +0 -201
  104. package/esm2015/lib/models/core/classes/ChartThemes.js +0 -61
  105. package/esm2015/lib/models/core/index.js +0 -4
  106. package/esm2015/lib/models/data/classes/AreaChartData.js +0 -16
  107. package/esm2015/lib/models/data/classes/LineChartData.js +0 -16
  108. package/esm2015/lib/models/data/classes/PagedChartData.js +0 -20
  109. package/esm2015/lib/models/data/classes/PieChartData.js +0 -14
  110. package/esm2015/lib/models/data/classes/Vertical2DChartData.js +0 -16
  111. package/esm2015/lib/models/data/classes/VerticalChartData.js +0 -14
  112. package/esm2015/lib/models/data/classes/VerticalStackedChartData.js +0 -14
  113. package/esm2015/lib/models/data/classes/base/DateValue.js +0 -11
  114. package/esm2015/lib/models/data/classes/base/KeyValue.js +0 -11
  115. package/esm2015/lib/models/data/classes/base/KeyValueColor.js +0 -12
  116. package/esm2015/lib/models/data/classes/base/Limit.js +0 -15
  117. package/esm2015/lib/models/data/classes/base/LineSerie.js +0 -24
  118. package/esm2015/lib/models/data/index.js +0 -13
  119. package/esm2015/lib/models/settings/classes/AreaChartSettings.js +0 -11
  120. package/esm2015/lib/models/settings/classes/LineChartSettings.js +0 -11
  121. package/esm2015/lib/models/settings/classes/PieChartSettings.js +0 -7
  122. package/esm2015/lib/models/settings/classes/Vertical2DChartSettings.js +0 -11
  123. package/esm2015/lib/models/settings/classes/VerticalChartSettings.js +0 -11
  124. package/esm2015/lib/models/settings/classes/VerticalStackedChartSettings.js +0 -11
  125. package/esm2015/lib/models/settings/classes/base/BaseInterval.js +0 -6
  126. package/esm2015/lib/models/settings/classes/base/BaseSettings.js +0 -6
  127. package/esm2015/lib/models/settings/classes/base/LegendPad.js +0 -6
  128. package/esm2015/lib/models/settings/index.js +0 -10
  129. package/esm2015/lib/services/classes/AreaChartService.js +0 -135
  130. package/esm2015/lib/services/classes/LineChartService.js +0 -326
  131. package/esm2015/lib/services/classes/PieChartService.js +0 -112
  132. package/esm2015/lib/services/classes/Vertical2DChartService.js +0 -163
  133. package/esm2015/lib/services/classes/VerticalChartService.js +0 -105
  134. package/esm2015/lib/services/classes/VerticalStackedChartService.js +0 -127
  135. package/esm2015/lib/services/classes/base/IBaseService.js +0 -2
  136. package/esm2015/lib/services/index.js +0 -8
  137. package/lib/adapters/index.d.ts +0 -2
  138. package/lib/components/index.d.ts +0 -8
  139. package/lib/models/core/index.d.ts +0 -3
  140. package/lib/models/data/index.d.ts +0 -12
  141. package/lib/models/settings/index.d.ts +0 -9
  142. package/lib/services/index.d.ts +0 -7
@@ -1,7 +1,7 @@
1
1
  import { Injectable, InjectionToken, Inject, EventEmitter, Directive, ElementRef, NgZone, Input, ContentChild, Output, Component, ChangeDetectionStrategy, PLATFORM_ID, NgModule } from '@angular/core';
2
- import { DateService } from '@esfaenza/extensions';
3
2
  import { isPlatformBrowser, CommonModule } from '@angular/common';
4
3
  import * as am4core from '@amcharts/amcharts4/core';
4
+ import { DateService } from '@esfaenza/extensions';
5
5
  import * as am4charts from '@amcharts/amcharts4/charts';
6
6
 
7
7
  /**
@@ -287,109 +287,6 @@ class LineSerie {
287
287
  }
288
288
  }
289
289
 
290
- /**
291
- * Token che identifica il Locale di default per tutti i grafici, può essere sovrascritto dalle impostazioni locali (Settings e Input)
292
- */
293
- const ESC_LOCALE = new InjectionToken('ESC_LOCALE');
294
- /**
295
- * Token che identifica il default per l'utilizzo o meno delle Animazioni per tutti i grafici, può essere sovrascritto dalle impostazioni locali (Settings e Input)
296
- */
297
- const ESC_ANIMATIONS = new InjectionToken('ESC_ANIMATIONS');
298
- /**
299
- * Token che identifica il Tema di default per tutti i grafici, può essere sovrascritto dalle impostazioni locali (Settings e Input)
300
- */
301
- const ESC_THEME = new InjectionToken('ESC_THEME');
302
- /**
303
- * Token che identifica l'utilizzo o meno del sistema di Log per l'intera libreria
304
- */
305
- const ESC_LOGS = new InjectionToken('ESC_LOGS');
306
-
307
- /**
308
- * Classe che si occupa del dispatch delle operazioni di rendering dei grafici utilizzando una coda per permettere ad ogni grafico di avere temi e localizzazione custom
309
- */
310
- class ChartDispatcher {
311
- /**
312
- * @ignore
313
- */
314
- constructor(logs) {
315
- this.logs = logs;
316
- /**
317
- * Coda di inizializzazioni ancora da eseguire. Quando questa è vuota significa che nessuno sta creando grafici
318
- */
319
- this.Initializations = [];
320
- /**
321
- * Lista dei grafici inizializzati e attivi in un dato momento (viene registrata la proprietà **name**). Non è possibile registrare due grafici con lo stesso identificativo
322
- */
323
- this.InitializedGraphs = [];
324
- }
325
- /**
326
- * Registra un grafico da visualizzare insieme alla propria funzione di creazione. Quest'ultima sarà differita fino a che tutti i grafici
327
- * precedentemente registati non hanno finito la fase di inizializzazione
328
- *
329
- * @param {string} name Identificativo del grafico da registrare
330
- * @param {Function} chartCreationFunction Funzione che fisicamente dovrà occuparsi della creazione del grafico
331
- */
332
- register(name, chartCreationFunction) {
333
- if (this.InitializedGraphs.indexOf(name) != -1)
334
- throw "Attempting to register a duplicate chart '" + name + "'. Make sure the 'name' properties of your charts are univoque";
335
- this.log("DISPATCHER: Registering chart creation function execution for " + name);
336
- this.Initializations.push({ name: name, function: chartCreationFunction });
337
- if (this.Initializations.length == 1) {
338
- this.log("DISPATCHER: Initial drain started");
339
- this.drainInitQueues();
340
- }
341
- }
342
- /**
343
- * Deregistra un grafico presente. Chiamata generalmente al dispose del grafico in questione quando non dev'essere più mostrato nella pagina corrente
344
- *
345
- * @param {string} name Identificativo del grafico da deregistrare
346
- */
347
- deregisterGraph(name) {
348
- let index = this.InitializedGraphs.indexOf(name);
349
- if (index == -1) {
350
- //Questo succede quando si cerca di distruggere il grafico mentre sta venendo graficato
351
- this.log("DISPATCHER: Registration missing for chart " + name + " it was probably destroyed during load");
352
- return;
353
- }
354
- this.log("DISPATCHER: Chart deregistered " + name);
355
- this.InitializedGraphs.splice(index, 1);
356
- }
357
- /**
358
- * Metodo che esegue in maniera sequenziale le funzioni di inizializzazione dei grafici finché presenti
359
- * in modo che nessun grafico possa essere inizializzato contemporaneamente ad un altro.
360
- *
361
- * Questo è il punto chiave che permette di avere per ogni grafico temi e locale differenti
362
- */
363
- drainInitQueues() {
364
- let toExecute = this.Initializations[0];
365
- this.log("DISPATCHER: Executing initialization function for chart " + toExecute.name);
366
- toExecute.function().then(() => {
367
- this.log("DISPATCHER: initialization for chart " + toExecute.name + " is done");
368
- this.InitializedGraphs.push(toExecute.name);
369
- this.Initializations.splice(0, 1);
370
- if (this.Initializations.length >= 1) {
371
- this.log("DISPATCHER: Found queued initializations. Continuing");
372
- this.drainInitQueues();
373
- }
374
- else
375
- this.log("DISPATCHER: queue is over, nothing more to do");
376
- });
377
- }
378
- /**
379
- * @ignore
380
- */
381
- log(text) {
382
- if (this.logs)
383
- console.log("@esfaenza/es-charts: " + text);
384
- }
385
- }
386
- ChartDispatcher.decorators = [
387
- { type: Injectable }
388
- ];
389
- ChartDispatcher.ctorParameters = () => [
390
- { type: Boolean, decorators: [{ type: Inject, args: [ESC_LOGS,] }] }
391
- ];
392
-
393
290
  /** @ignore */
394
291
  const _spiritedaway = 'spiritedaway';
395
292
  /** @ignore */
@@ -651,6 +548,109 @@ class ChartLoader {
651
548
  }
652
549
  }
653
550
 
551
+ /**
552
+ * Token che identifica il Locale di default per tutti i grafici, può essere sovrascritto dalle impostazioni locali (Settings e Input)
553
+ */
554
+ const ESC_LOCALE = new InjectionToken('ESC_LOCALE');
555
+ /**
556
+ * Token che identifica il default per l'utilizzo o meno delle Animazioni per tutti i grafici, può essere sovrascritto dalle impostazioni locali (Settings e Input)
557
+ */
558
+ const ESC_ANIMATIONS = new InjectionToken('ESC_ANIMATIONS');
559
+ /**
560
+ * Token che identifica il Tema di default per tutti i grafici, può essere sovrascritto dalle impostazioni locali (Settings e Input)
561
+ */
562
+ const ESC_THEME = new InjectionToken('ESC_THEME');
563
+ /**
564
+ * Token che identifica l'utilizzo o meno del sistema di Log per l'intera libreria
565
+ */
566
+ const ESC_LOGS = new InjectionToken('ESC_LOGS');
567
+
568
+ /**
569
+ * 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
570
+ */
571
+ class ChartDispatcher {
572
+ /**
573
+ * @ignore
574
+ */
575
+ constructor(logs) {
576
+ this.logs = logs;
577
+ /**
578
+ * Coda di inizializzazioni ancora da eseguire. Quando questa è vuota significa che nessuno sta creando grafici
579
+ */
580
+ this.Initializations = [];
581
+ /**
582
+ * Lista dei grafici inizializzati e attivi in un dato momento (viene registrata la proprietà **name**). Non è possibile registrare due grafici con lo stesso identificativo
583
+ */
584
+ this.InitializedGraphs = [];
585
+ }
586
+ /**
587
+ * Registra un grafico da visualizzare insieme alla propria funzione di creazione. Quest'ultima sarà differita fino a che tutti i grafici
588
+ * precedentemente registati non hanno finito la fase di inizializzazione
589
+ *
590
+ * @param {string} name Identificativo del grafico da registrare
591
+ * @param {Function} chartCreationFunction Funzione che fisicamente dovrà occuparsi della creazione del grafico
592
+ */
593
+ register(name, chartCreationFunction) {
594
+ if (this.InitializedGraphs.indexOf(name) != -1)
595
+ throw "Attempting to register a duplicate chart '" + name + "'. Make sure the 'name' properties of your charts are univoque";
596
+ this.log("DISPATCHER: Registering chart creation function execution for " + name);
597
+ this.Initializations.push({ name: name, function: chartCreationFunction });
598
+ if (this.Initializations.length == 1) {
599
+ this.log("DISPATCHER: Initial drain started");
600
+ this.drainInitQueues();
601
+ }
602
+ }
603
+ /**
604
+ * Deregistra un grafico presente. Chiamata generalmente al dispose del grafico in questione quando non dev'essere più mostrato nella pagina corrente
605
+ *
606
+ * @param {string} name Identificativo del grafico da deregistrare
607
+ */
608
+ deregisterGraph(name) {
609
+ let index = this.InitializedGraphs.indexOf(name);
610
+ if (index == -1) {
611
+ //Questo succede quando si cerca di distruggere il grafico mentre sta venendo graficato
612
+ this.log("DISPATCHER: Registration missing for chart " + name + " it was probably destroyed during load");
613
+ return;
614
+ }
615
+ this.log("DISPATCHER: Chart deregistered " + name);
616
+ this.InitializedGraphs.splice(index, 1);
617
+ }
618
+ /**
619
+ * Metodo che esegue in maniera sequenziale le funzioni di inizializzazione dei grafici finché presenti
620
+ * in modo che nessun grafico possa essere inizializzato contemporaneamente ad un altro.
621
+ *
622
+ * Questo è il punto chiave che permette di avere per ogni grafico temi e locale differenti
623
+ */
624
+ drainInitQueues() {
625
+ let toExecute = this.Initializations[0];
626
+ this.log("DISPATCHER: Executing initialization function for chart " + toExecute.name);
627
+ toExecute.function().then(() => {
628
+ this.log("DISPATCHER: initialization for chart " + toExecute.name + " is done");
629
+ this.InitializedGraphs.push(toExecute.name);
630
+ this.Initializations.splice(0, 1);
631
+ if (this.Initializations.length >= 1) {
632
+ this.log("DISPATCHER: Found queued initializations. Continuing");
633
+ this.drainInitQueues();
634
+ }
635
+ else
636
+ this.log("DISPATCHER: queue is over, nothing more to do");
637
+ });
638
+ }
639
+ /**
640
+ * @ignore
641
+ */
642
+ log(text) {
643
+ if (this.logs)
644
+ console.log("@esfaenza/es-charts: " + text);
645
+ }
646
+ }
647
+ ChartDispatcher.decorators = [
648
+ { type: Injectable }
649
+ ];
650
+ ChartDispatcher.ctorParameters = () => [
651
+ { type: Boolean, decorators: [{ type: Inject, args: [ESC_LOGS,] }] }
652
+ ];
653
+
654
654
  /**
655
655
  * Componente Grafico Base che gestisce tutte le cose comuni dei vari grafici istanziabili, come la presenza o menu di una legenda,
656
656
  * il tema utilizzato, il locale del singolo grafico, ecc ecc...
@@ -798,7 +798,7 @@ class BaseChartComponent {
798
798
  this.Chart = this.ChartService.ChartInstance;
799
799
  if (!this.Chart)
800
800
  this.log("Chart " + this.name + ": Could not create graph");
801
- return this.Charter.applyLocale(this.Chart, this.Locale).then(() => { this.initDone = true; this.chartLoaded.emit(this.Chart); });
801
+ return this.Charter.applyLocale(this.Chart, this.Locale).then(() => { this.initDone = true; this.chartLoaded.emit(this); });
802
802
  })
803
803
  ]);
804
804
  }
@@ -894,6 +894,13 @@ class BaseChartComponent {
894
894
  this.Chart.dispose(); this.Dispatcher.deregisterGraph(this.name); });
895
895
  this.Dispatcher.register(this.name, () => { return this.loadChart(); });
896
896
  }
897
+ /**
898
+ * Permette di aggiungere un blocco di dati in maniera "live" ad un grafico
899
+ */
900
+ addData(chartData) {
901
+ this.ChartService.refreshData(chartData);
902
+ }
903
+ ;
897
904
  /**
898
905
  * Funzione che si occupa di caricare i temi necessari per il grafico in oggetto. Prima applica il tema, poi, se serve, applica le animazioni
899
906
  */
@@ -976,6 +983,8 @@ class LineChartService {
976
983
  this.DataGroupBucketSize = 1500;
977
984
  /** @ignore */
978
985
  this.OpacityOnSelected = 0.3;
986
+ /** @ignore */
987
+ this.singleDataSet = false;
979
988
  //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
980
989
  //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
981
990
  /** @ignore */
@@ -988,7 +997,7 @@ class LineChartService {
988
997
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
989
998
  let dataConverted = this.Adapter ? this.Adapter.adaptDataForLineChart(data) : data;
990
999
  let threshold = (_a = settings.DataGroupingThreshold) !== null && _a !== void 0 ? _a : 3000;
991
- let singleDataSet = (_b = settings.MergeDatasets) !== null && _b !== void 0 ? _b : false;
1000
+ this.singleDataSet = (_b = settings.MergeDatasets) !== null && _b !== void 0 ? _b : false;
992
1001
  let showTicks = settings.ShowTicks == null ? true : settings === null || settings === void 0 ? void 0 : settings.ShowTicks;
993
1002
  let dataShouldBeGrouped = Math.max(...dataConverted.series.map(t => t.values.length)) > threshold;
994
1003
  let showTimeline = settings.Timeline || dataShouldBeGrouped;
@@ -1067,31 +1076,9 @@ class LineChartService {
1067
1076
  let seriesColors = [];
1068
1077
  let defaultIndex = 0;
1069
1078
  //-- Generazione di un unico dataset invece che N, per poter gestire un unico tooltip
1070
- if (singleDataSet) {
1071
- let dto = {};
1072
- dataConverted.series.forEach((vs, index) => {
1073
- for (let i = 0; i < vs.values.length; i++) {
1074
- var dataitem = vs.values[i];
1075
- var indexer = new Date(dataitem.d).valueOf();
1076
- if (!dto[indexer])
1077
- dto[indexer] = {};
1078
- dto[indexer]['v' + index] = dataitem.v;
1079
- }
1080
- });
1081
- var dates = Object.keys(dto);
1082
- let singleDS = [];
1083
- for (let i = 0; i < dates.length; i++) {
1084
- let values = dto[dates[i]];
1085
- let item = { d: new Date(parseInt(dates[i])) };
1086
- var vals = Object.keys(values);
1087
- for (let ii = 0; ii < vals.length; ii++) {
1088
- let series = vals[ii];
1089
- let singleVal = values[series];
1090
- item[series] = singleVal;
1091
- }
1092
- singleDS.push(item);
1093
- }
1094
- this.ChartInstance.data = singleDS;
1079
+ if (this.singleDataSet) {
1080
+ this.ChartInstance.data = this.generateSingleDataset(dataConverted);
1081
+ ;
1095
1082
  dateAxis.cursorTooltipEnabled = false;
1096
1083
  }
1097
1084
  //-- Fine generazione
@@ -1115,14 +1102,14 @@ class LineChartService {
1115
1102
  s.values.sort((d1, d2) => d1.d.getTime() - d2.d.getTime());
1116
1103
  let fill = s.fill != null && s.fill != undefined ? s.fill : ((_a = settings === null || settings === void 0 ? void 0 : settings.Fill) !== null && _a !== void 0 ? _a : false);
1117
1104
  let series = (settings === null || settings === void 0 ? void 0 : settings.Step) ? new am4charts.StepLineSeries() : new am4charts.LineSeries();
1118
- series.dataFields.valueY = "v" + (singleDataSet ? index : "");
1105
+ series.dataFields.valueY = "v" + (this.singleDataSet ? index : "");
1119
1106
  series.dataFields.dateX = "d";
1120
1107
  series.dataFields.measureUnit = s.uom;
1121
1108
  series.name = s.name;
1122
1109
  series.strokeWidth = (_b = settings === null || settings === void 0 ? void 0 : settings.StrokeSize) !== null && _b !== void 0 ? _b : 1;
1123
1110
  series.connect = !gapsAllowed;
1124
1111
  series.minBulletDistance = 10;
1125
- series.tooltipText = singleDataSet ? "" : "{name}: [bold]{valueY}[/]";
1112
+ series.tooltipText = this.singleDataSet ? "" : s.name ? "{name}: [bold]{valueY}[/]" : "[bold]{valueY}[/]";
1126
1113
  series.tooltip.pointerOrientation = "vertical";
1127
1114
  series.tooltip.background.fillOpacity = 0.5;
1128
1115
  series.tooltip.label.padding(12, 12, 12, 12);
@@ -1130,7 +1117,7 @@ class LineChartService {
1130
1117
  series.stacked = fill;
1131
1118
  //Dataset singolo, i dati sono registrati a livello di chart, creo il tooltip che permette di vederli tutti insieme
1132
1119
  //altrimenti assegno i dati della serie direttamente alla serie
1133
- if (singleDataSet) {
1120
+ if (this.singleDataSet) {
1134
1121
  series.tooltip.getFillFromObject = false;
1135
1122
  series.tooltip.background.fill = am4core.color("#eee");
1136
1123
  series.tooltip.label.fill = am4core.color("#00");
@@ -1161,7 +1148,7 @@ class LineChartService {
1161
1148
  var text = "[bold]{dateX.formatDate()}[/]\n";
1162
1149
  this.ChartInstance.series.each((item) => {
1163
1150
  let uom = " [font-style: italic]" + series.dataFields.measureUnit || "" + "[/]";
1164
- text += "[" + item.stroke.hex + "]●[/] " + item.name + ": [bold]{" + item.dataFields.valueY + "}[/]" + uom + "\n";
1151
+ text += "[" + item.stroke.hex + "]●[/] " + (item.name ? (item.name + ": ") : "") + "[bold]{" + item.dataFields.valueY + "}[/]" + uom + "\n";
1165
1152
  });
1166
1153
  return text;
1167
1154
  });
@@ -1220,7 +1207,7 @@ class LineChartService {
1220
1207
  //******************************************************************************************************************************
1221
1208
  this.ChartInstance.cursor.xAxis = dateAxis;
1222
1209
  this.ChartInstance.cursor.yAxis = yAxis;
1223
- if (singleDataSet)
1210
+ if (this.singleDataSet)
1224
1211
  this.ChartInstance.cursor.maxTooltipDistance = -1;
1225
1212
  //TODO: Cercare di capire perché è figlio di puttana......
1226
1213
  dateAxis.events.on("startchanged", t => this.emitSelectionChanged(t, settings));
@@ -1229,7 +1216,40 @@ class LineChartService {
1229
1216
  }
1230
1217
  /** @ignore */
1231
1218
  refreshData(data) {
1232
- //TODO:IMPL
1219
+ let dataConverted = this.Adapter ? this.Adapter.adaptDataForLineChart(data) : data;
1220
+ if (this.singleDataSet) {
1221
+ var data = this.generateSingleDataset(dataConverted);
1222
+ this.ChartInstance.addData(data);
1223
+ return;
1224
+ }
1225
+ throw "Impossibile aggiornare i dati senza unire il dataset. Si prega di impostare [MergeDatasets] a true";
1226
+ }
1227
+ /** Partendo da dati divisi per seriue genera un dataset unito con la data come chiave e i vari valori dopo */
1228
+ generateSingleDataset(data) {
1229
+ let dto = {};
1230
+ data.series.forEach((vs, index) => {
1231
+ for (let i = 0; i < vs.values.length; i++) {
1232
+ var dataitem = vs.values[i];
1233
+ var indexer = new Date(dataitem.d).valueOf();
1234
+ if (!dto[indexer])
1235
+ dto[indexer] = {};
1236
+ dto[indexer]['v' + index] = dataitem.v;
1237
+ }
1238
+ });
1239
+ var dates = Object.keys(dto);
1240
+ var ret = [];
1241
+ for (let i = 0; i < dates.length; i++) {
1242
+ let values = dto[dates[i]];
1243
+ let item = { d: new Date(parseInt(dates[i])) };
1244
+ var vals = Object.keys(values);
1245
+ for (let ii = 0; ii < vals.length; ii++) {
1246
+ let series = vals[ii];
1247
+ let singleVal = values[series];
1248
+ item[series] = singleVal;
1249
+ }
1250
+ ret.push(item);
1251
+ }
1252
+ return ret;
1233
1253
  }
1234
1254
  /** @ignore */
1235
1255
  emitSelectionChanged(ev, settings) {
@@ -1289,155 +1309,22 @@ class LineChartService {
1289
1309
  }
1290
1310
 
1291
1311
  /**
1292
- * Classe il cui unico scopo è gestire il setup e rendering di un AreaChart
1312
+ * Classe il cui unico scopo è gestire il setup e rendering di un PieChart
1293
1313
  */
1294
- class AreaChartService {
1314
+ class PieChartService {
1295
1315
  /** @ignore */
1296
1316
  constructor(Adapter) {
1297
1317
  this.Adapter = Adapter;
1298
- //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
1299
- //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
1300
1318
  /** @ignore */
1301
- this.executionTimers = {};
1319
+ this.ViewAbsoluteValues = true;
1302
1320
  }
1303
1321
  /**
1304
- * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un AreaChart
1322
+ * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un PieChart
1305
1323
  */
1306
1324
  graphicate(data, settings) {
1307
- var _a, _b, _c, _d, _e, _f;
1325
+ var _a, _b, _c, _d;
1308
1326
  if (settings.Timeline) {
1309
- console.error("Timeline not supported for area chart");
1310
- return null;
1311
- }
1312
- let dataConverted = this.Adapter ? this.Adapter.adaptDataForAreaChart(data) : data;
1313
- let showTicks = settings.ShowTicks == null ? true : settings === null || settings === void 0 ? void 0 : settings.ShowTicks;
1314
- let interval = dataConverted.interval;
1315
- //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
1316
- am4core.options.autoDispose = true;
1317
- this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1318
- let ChartInstanceCasted = this.ChartInstance;
1319
- if (settings.Legend) {
1320
- ChartInstanceCasted.legend = new am4charts.Legend();
1321
- ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
1322
- ChartInstanceCasted.legend.itemContainers.template.tooltipText = "{category}";
1323
- if (settings.LegendPadding) {
1324
- let template = this.ChartInstance.legend.itemContainers.template;
1325
- template.paddingTop = (_b = settings.LegendPadding.top) !== null && _b !== void 0 ? _b : 0;
1326
- template.paddingBottom = (_c = settings.LegendPadding.bottom) !== null && _c !== void 0 ? _c : 0;
1327
- template.paddingLeft = (_d = settings.LegendPadding.left) !== null && _d !== void 0 ? _d : 0;
1328
- template.paddingRight = (_e = settings.LegendPadding.right) !== null && _e !== void 0 ? _e : 0;
1329
- }
1330
- }
1331
- let yAxis = ChartInstanceCasted.yAxes.push(new am4charts.ValueAxis());
1332
- yAxis.tooltip.disabled = true;
1333
- if (settings.YAxisTitle) {
1334
- yAxis.title.text = settings.YAxisTitle;
1335
- yAxis.title.fontWeight = "bold";
1336
- }
1337
- yAxis.min = 0;
1338
- let dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
1339
- dateAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 50;
1340
- dateAxis.startLocation = 0.5;
1341
- dateAxis.endLocation = 0.5;
1342
- if (settings.XAxisTitle) {
1343
- dateAxis.title.text = settings.XAxisTitle;
1344
- dateAxis.title.fontWeight = "bold";
1345
- }
1346
- if (showTicks) {
1347
- dateAxis.renderer.ticks.template.disabled = false;
1348
- dateAxis.renderer.ticks.template.strokeOpacity = 1;
1349
- dateAxis.renderer.ticks.template.stroke = am4core.color("#495C43");
1350
- dateAxis.renderer.ticks.template.strokeWidth = 2;
1351
- dateAxis.renderer.ticks.template.length = 10;
1352
- dateAxis.renderer.ticks.template.location = 0;
1353
- }
1354
- if (!!interval)
1355
- dateAxis.baseInterval = { count: interval.count, timeUnit: interval.timeunit };
1356
- // Unisco il dataset e tiro fuori i dati
1357
- let chartData = [];
1358
- let seriesToMakeCache = {};
1359
- let seriesToMake = [];
1360
- for (let i = 0; i < dataConverted.groups.length; i++) {
1361
- let group = dataConverted.groups[i];
1362
- let dataItem = { date: group.name };
1363
- for (let ii = 0; ii < group.values.length; ii++) {
1364
- let val = group.values[ii];
1365
- dataItem[val.k] = val.v;
1366
- if (!seriesToMakeCache[val.k]) {
1367
- seriesToMakeCache[val.k] = true;
1368
- seriesToMake.push(val.k);
1369
- }
1370
- }
1371
- chartData.push(dataItem);
1372
- }
1373
- ChartInstanceCasted.data = chartData;
1374
- //---------------------------------------------------------
1375
- seriesToMake.forEach(s => { this.createSeries(ChartInstanceCasted, s); });
1376
- ChartInstanceCasted.cursor = new am4charts.XYCursor();
1377
- ChartInstanceCasted.cursor.xAxis = dateAxis;
1378
- dateAxis.events.on("startchanged", t => this.emitSelectionChanged(t, settings));
1379
- dateAxis.events.on("endchanged", t => this.emitSelectionChanged(t, settings));
1380
- return this;
1381
- }
1382
- /** @ignore */
1383
- refreshData(data) {
1384
- //TODO:IMPL
1385
- }
1386
- /** @ignore */
1387
- emitSelectionChanged(ev, settings) {
1388
- if (settings.OnSelectionChangedCallback) {
1389
- this.throttla("selchange", () => {
1390
- var axis = ev.target;
1391
- var start = new Date(axis.minZoomed);
1392
- var end = new Date(axis.maxZoomed);
1393
- var initial = axis.min == axis.minZoomed && axis.max == axis.maxZoomed;
1394
- settings.OnSelectionChangedCallback({ from: start, to: end, initial: initial });
1395
- }, 150);
1396
- }
1397
- }
1398
- /** @ignore */
1399
- createSeries(chart, name) {
1400
- let series = chart.series.push(new am4charts.LineSeries());
1401
- series.dataFields.dateX = "date";
1402
- series.name = name[0].toUpperCase() + name.slice(1);
1403
- series.dataFields.valueY = name;
1404
- series.tooltipText = "[#000]{valueY.value}[/]";
1405
- //series.tooltip.background.fill = am4core.color("#FFF");
1406
- series.tooltip.getStrokeFromObject = true;
1407
- series.tooltip.background.strokeWidth = 3;
1408
- series.tooltip.getFillFromObject = false;
1409
- series.fillOpacity = 0.6;
1410
- series.strokeWidth = 2;
1411
- series.stacked = true;
1412
- return series;
1413
- }
1414
- /** @ignore */
1415
- throttla(id, func, throttleTime) {
1416
- //Se ho la funzione che vuole eseguire ripulisco quel timeout
1417
- if (this.executionTimers[id])
1418
- clearTimeout(this.executionTimers[id]);
1419
- //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
1420
- this.executionTimers[id] = setTimeout(() => { func(); this.executionTimers[id] = null; }, throttleTime);
1421
- }
1422
- }
1423
-
1424
- /**
1425
- * Classe il cui unico scopo è gestire il setup e rendering di un PieChart
1426
- */
1427
- class PieChartService {
1428
- /** @ignore */
1429
- constructor(Adapter) {
1430
- this.Adapter = Adapter;
1431
- /** @ignore */
1432
- this.ViewAbsoluteValues = true;
1433
- }
1434
- /**
1435
- * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un PieChart
1436
- */
1437
- graphicate(data, settings) {
1438
- var _a, _b, _c, _d;
1439
- if (settings.Timeline) {
1440
- console.error("Timeline not supported for pie chart");
1327
+ console.error("Timeline not supported for pie chart");
1441
1328
  return null;
1442
1329
  }
1443
1330
  //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
@@ -1532,15 +1419,13 @@ class PieChartService {
1532
1419
  }
1533
1420
 
1534
1421
  /**
1535
- * Classe il cui unico scopo è gestire il setup e rendering di un Vertical2DChart
1422
+ * Classe il cui unico scopo è gestire il setup e rendering di un VerticalChart
1536
1423
  */
1537
- class Vertical2DChartService {
1424
+ class VerticalChartService {
1538
1425
  /** @ignore */
1539
1426
  constructor(Adapter) {
1540
1427
  this.Adapter = Adapter;
1541
1428
  /** @ignore */
1542
- this.DefaultGroupPaddingPercentage = 5;
1543
- /** @ignore */
1544
1429
  this.dangerZone = 50;
1545
1430
  /** @ignore */
1546
1431
  this.LabelWidth = 150;
@@ -1552,10 +1437,10 @@ class Vertical2DChartService {
1552
1437
  this.DefaultColumnWidthPercentage = 85;
1553
1438
  }
1554
1439
  /**
1555
- * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un Vertical2DChart
1440
+ * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un VerticalChart
1556
1441
  */
1557
1442
  graphicate(data, settings) {
1558
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1443
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1559
1444
  if (settings.Timeline) {
1560
1445
  console.error("Timeline not supported for vertical chart");
1561
1446
  return null;
@@ -1564,6 +1449,8 @@ class Vertical2DChartService {
1564
1449
  am4core.options.autoDispose = true;
1565
1450
  this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1566
1451
  let ChartInstanceCasted = this.ChartInstance;
1452
+ let dataConverted = this.Adapter ? this.Adapter.adaptDataForVerticalChart(data) : data;
1453
+ ChartInstanceCasted.data = dataConverted.values;
1567
1454
  if (settings.Legend) {
1568
1455
  ChartInstanceCasted.legend = new am4charts.Legend();
1569
1456
  ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
@@ -1586,15 +1473,12 @@ class Vertical2DChartService {
1586
1473
  categoryAxis.title.text = settings.XAxisTitle;
1587
1474
  categoryAxis.title.fontWeight = "bold";
1588
1475
  }
1589
- yAxis.min = 0;
1590
- categoryAxis.dataFields.category = 'key';
1591
- categoryAxis.renderer.cellStartLocation = am4core.percent((_f = settings.GroupPaddingPercentage) !== null && _f !== void 0 ? _f : this.DefaultGroupPaddingPercentage).value;
1592
- categoryAxis.renderer.cellEndLocation = am4core.percent(100 - ((_g = settings.GroupPaddingPercentage) !== null && _g !== void 0 ? _g : this.DefaultGroupPaddingPercentage)).value;
1476
+ categoryAxis.dataFields.category = "k";
1593
1477
  categoryAxis.renderer.grid.template.location = 0;
1594
- categoryAxis.renderer.minGridDistance = (_h = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _h !== void 0 ? _h : 30;
1478
+ categoryAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 30;
1595
1479
  let label = categoryAxis.renderer.labels.template;
1596
1480
  label.truncate = true;
1597
- label.maxWidth = (_j = settings.LabelWidth) !== null && _j !== void 0 ? _j : this.LabelWidth;
1481
+ label.maxWidth = (_g = settings.LabelWidth) !== null && _g !== void 0 ? _g : this.LabelWidth;
1598
1482
  label.tooltipText = "{category}";
1599
1483
  if ((settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) == null ? true : settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) {
1600
1484
  categoryAxis.events.on("sizechanged", (ev) => {
@@ -1618,88 +1502,35 @@ class Vertical2DChartService {
1618
1502
  }
1619
1503
  });
1620
1504
  }
1621
- let dataPreConverted = this.Adapter ? this.Adapter.adaptDataForVertical2DChart(data) : data;
1622
- let dataConverted = [];
1623
- for (let i = 0; i < dataPreConverted.groups.length; i++) {
1624
- let item = dataPreConverted.groups[i];
1625
- let obj = { key: item.name };
1626
- for (let p = 0; p < item.values.length; p++) {
1627
- let value = item.values[p];
1628
- obj[value.k] = value.v;
1629
- }
1630
- dataConverted.push(obj);
1631
- }
1632
- ChartInstanceCasted.data = dataConverted;
1633
- if (dataPreConverted.colorInfos)
1634
- ChartInstanceCasted.colors.list = dataPreConverted.colorInfos.map(c => am4core.color(c.color));
1635
- //Prendo la prima categoria e mi baso sulle proprietà per dfeinire le serie
1636
- for (let prop in dataConverted[0])
1637
- if (prop !== "key")
1638
- this.createSeries(ChartInstanceCasted, settings, prop, prop);
1505
+ // Create series
1506
+ let series = ChartInstanceCasted.series.push(new am4charts.ColumnSeries());
1507
+ series.dataFields.valueY = "v";
1508
+ series.dataFields.categoryX = "k";
1509
+ series.name = "";
1510
+ series.columns.template.tooltipText = "{categoryX}: [bold]{valueY}[/]";
1511
+ series.columns.template.fillOpacity = .8;
1512
+ series.columns.template.width = am4core.percent((_h = settings.ColumnWidthPercentage) !== null && _h !== void 0 ? _h : this.DefaultColumnWidthPercentage);
1513
+ let columnTemplate = series.columns.template;
1514
+ columnTemplate.strokeWidth = 2;
1515
+ columnTemplate.strokeOpacity = 1;
1639
1516
  return this;
1640
1517
  }
1641
1518
  /** @ignore */
1642
1519
  refreshData(data) {
1643
1520
  //TODO:IMPL
1644
1521
  }
1645
- /** @ignore */
1646
- createSeries(chart, settings, value, name) {
1647
- var _a;
1648
- let series = chart.series.push(new am4charts.ColumnSeries());
1649
- series.dataFields.valueY = value;
1650
- series.dataFields.categoryX = 'key';
1651
- series.name = name;
1652
- series.columns.template.tooltipText = "{name} {categoryX}: [bold]{valueY}[/]";
1653
- series.columns.template.fillOpacity = .8;
1654
- series.columns.template.width = am4core.percent((_a = settings.ColumnWidthPercentage) !== null && _a !== void 0 ? _a : this.DefaultColumnWidthPercentage);
1655
- series.events.on("hidden", () => this.arrangeColumns);
1656
- series.events.on("shown", () => this.arrangeColumns);
1657
- return series;
1658
- }
1659
- /** @ignore */
1660
- arrangeColumns() {
1661
- let ChartInstanceCasted = this.ChartInstance;
1662
- let series = ChartInstanceCasted.series.getIndex(0);
1663
- let xAxis = ChartInstanceCasted.xAxes.getIndex(0);
1664
- let w = 1 - xAxis.renderer.cellStartLocation - (1 - xAxis.renderer.cellEndLocation);
1665
- if (series.dataItems.length > 1) {
1666
- let x0 = xAxis.getX(series.dataItems.getIndex(0), "categoryX");
1667
- let x1 = xAxis.getX(series.dataItems.getIndex(1), "categoryX");
1668
- let delta = ((x1 - x0) / ChartInstanceCasted.series.length) * w;
1669
- if (am4core.isNumber(delta)) {
1670
- let middle = ChartInstanceCasted.series.length / 2;
1671
- let newIndex = 0;
1672
- ChartInstanceCasted.series.each((series) => {
1673
- if (!series.isHidden && !series.isHiding) {
1674
- series.dummyData = newIndex;
1675
- newIndex++;
1676
- }
1677
- else {
1678
- series.dummyData = ChartInstanceCasted.series.indexOf(series);
1679
- }
1680
- });
1681
- let visibleCount = newIndex;
1682
- let newMiddle = visibleCount / 2;
1683
- ChartInstanceCasted.series.each((series) => {
1684
- let trueIndex = ChartInstanceCasted.series.indexOf(series);
1685
- let newIndex = series.dummyData;
1686
- let dx = (newIndex - trueIndex + middle - newMiddle) * delta;
1687
- series.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1688
- series.bulletsContainer.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1689
- });
1690
- }
1691
- }
1692
- }
1693
1522
  }
1694
1523
 
1695
1524
  /**
1696
- * Classe il cui unico scopo è gestire il setup e rendering di un VerticalChart
1525
+ * Classe il cui unico scopo è gestire il setup e rendering di un Vertical2DChart
1697
1526
  */
1698
- class VerticalChartService {
1527
+ class Vertical2DChartService {
1699
1528
  /** @ignore */
1700
1529
  constructor(Adapter) {
1701
1530
  this.Adapter = Adapter;
1702
1531
  /** @ignore */
1532
+ this.DefaultGroupPaddingPercentage = 5;
1533
+ /** @ignore */
1703
1534
  this.dangerZone = 50;
1704
1535
  /** @ignore */
1705
1536
  this.LabelWidth = 150;
@@ -1711,10 +1542,10 @@ class VerticalChartService {
1711
1542
  this.DefaultColumnWidthPercentage = 85;
1712
1543
  }
1713
1544
  /**
1714
- * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un VerticalChart
1545
+ * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un Vertical2DChart
1715
1546
  */
1716
1547
  graphicate(data, settings) {
1717
- var _a, _b, _c, _d, _e, _f, _g, _h;
1548
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1718
1549
  if (settings.Timeline) {
1719
1550
  console.error("Timeline not supported for vertical chart");
1720
1551
  return null;
@@ -1723,8 +1554,6 @@ class VerticalChartService {
1723
1554
  am4core.options.autoDispose = true;
1724
1555
  this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1725
1556
  let ChartInstanceCasted = this.ChartInstance;
1726
- let dataConverted = this.Adapter ? this.Adapter.adaptDataForVerticalChart(data) : data;
1727
- ChartInstanceCasted.data = dataConverted.values;
1728
1557
  if (settings.Legend) {
1729
1558
  ChartInstanceCasted.legend = new am4charts.Legend();
1730
1559
  ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
@@ -1747,12 +1576,15 @@ class VerticalChartService {
1747
1576
  categoryAxis.title.text = settings.XAxisTitle;
1748
1577
  categoryAxis.title.fontWeight = "bold";
1749
1578
  }
1750
- categoryAxis.dataFields.category = "k";
1579
+ yAxis.min = 0;
1580
+ categoryAxis.dataFields.category = 'key';
1581
+ categoryAxis.renderer.cellStartLocation = am4core.percent((_f = settings.GroupPaddingPercentage) !== null && _f !== void 0 ? _f : this.DefaultGroupPaddingPercentage).value;
1582
+ categoryAxis.renderer.cellEndLocation = am4core.percent(100 - ((_g = settings.GroupPaddingPercentage) !== null && _g !== void 0 ? _g : this.DefaultGroupPaddingPercentage)).value;
1751
1583
  categoryAxis.renderer.grid.template.location = 0;
1752
- categoryAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 30;
1584
+ categoryAxis.renderer.minGridDistance = (_h = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _h !== void 0 ? _h : 30;
1753
1585
  let label = categoryAxis.renderer.labels.template;
1754
1586
  label.truncate = true;
1755
- label.maxWidth = (_g = settings.LabelWidth) !== null && _g !== void 0 ? _g : this.LabelWidth;
1587
+ label.maxWidth = (_j = settings.LabelWidth) !== null && _j !== void 0 ? _j : this.LabelWidth;
1756
1588
  label.tooltipText = "{category}";
1757
1589
  if ((settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) == null ? true : settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) {
1758
1590
  categoryAxis.events.on("sizechanged", (ev) => {
@@ -1776,23 +1608,78 @@ class VerticalChartService {
1776
1608
  }
1777
1609
  });
1778
1610
  }
1779
- // Create series
1780
- let series = ChartInstanceCasted.series.push(new am4charts.ColumnSeries());
1781
- series.dataFields.valueY = "v";
1782
- series.dataFields.categoryX = "k";
1783
- series.name = "";
1784
- series.columns.template.tooltipText = "{categoryX}: [bold]{valueY}[/]";
1785
- series.columns.template.fillOpacity = .8;
1786
- series.columns.template.width = am4core.percent((_h = settings.ColumnWidthPercentage) !== null && _h !== void 0 ? _h : this.DefaultColumnWidthPercentage);
1787
- let columnTemplate = series.columns.template;
1788
- columnTemplate.strokeWidth = 2;
1789
- columnTemplate.strokeOpacity = 1;
1611
+ let dataPreConverted = this.Adapter ? this.Adapter.adaptDataForVertical2DChart(data) : data;
1612
+ let dataConverted = [];
1613
+ for (let i = 0; i < dataPreConverted.groups.length; i++) {
1614
+ let item = dataPreConverted.groups[i];
1615
+ let obj = { key: item.name };
1616
+ for (let p = 0; p < item.values.length; p++) {
1617
+ let value = item.values[p];
1618
+ obj[value.k] = value.v;
1619
+ }
1620
+ dataConverted.push(obj);
1621
+ }
1622
+ ChartInstanceCasted.data = dataConverted;
1623
+ if (dataPreConverted.colorInfos)
1624
+ ChartInstanceCasted.colors.list = dataPreConverted.colorInfos.map(c => am4core.color(c.color));
1625
+ //Prendo la prima categoria e mi baso sulle proprietà per dfeinire le serie
1626
+ for (let prop in dataConverted[0])
1627
+ if (prop !== "key")
1628
+ this.createSeries(ChartInstanceCasted, settings, prop, prop);
1790
1629
  return this;
1791
1630
  }
1792
1631
  /** @ignore */
1793
1632
  refreshData(data) {
1794
1633
  //TODO:IMPL
1795
1634
  }
1635
+ /** @ignore */
1636
+ createSeries(chart, settings, value, name) {
1637
+ var _a;
1638
+ let series = chart.series.push(new am4charts.ColumnSeries());
1639
+ series.dataFields.valueY = value;
1640
+ series.dataFields.categoryX = 'key';
1641
+ series.name = name;
1642
+ series.columns.template.tooltipText = "{name} {categoryX}: [bold]{valueY}[/]";
1643
+ series.columns.template.fillOpacity = .8;
1644
+ series.columns.template.width = am4core.percent((_a = settings.ColumnWidthPercentage) !== null && _a !== void 0 ? _a : this.DefaultColumnWidthPercentage);
1645
+ series.events.on("hidden", () => this.arrangeColumns);
1646
+ series.events.on("shown", () => this.arrangeColumns);
1647
+ return series;
1648
+ }
1649
+ /** @ignore */
1650
+ arrangeColumns() {
1651
+ let ChartInstanceCasted = this.ChartInstance;
1652
+ let series = ChartInstanceCasted.series.getIndex(0);
1653
+ let xAxis = ChartInstanceCasted.xAxes.getIndex(0);
1654
+ let w = 1 - xAxis.renderer.cellStartLocation - (1 - xAxis.renderer.cellEndLocation);
1655
+ if (series.dataItems.length > 1) {
1656
+ let x0 = xAxis.getX(series.dataItems.getIndex(0), "categoryX");
1657
+ let x1 = xAxis.getX(series.dataItems.getIndex(1), "categoryX");
1658
+ let delta = ((x1 - x0) / ChartInstanceCasted.series.length) * w;
1659
+ if (am4core.isNumber(delta)) {
1660
+ let middle = ChartInstanceCasted.series.length / 2;
1661
+ let newIndex = 0;
1662
+ ChartInstanceCasted.series.each((series) => {
1663
+ if (!series.isHidden && !series.isHiding) {
1664
+ series.dummyData = newIndex;
1665
+ newIndex++;
1666
+ }
1667
+ else {
1668
+ series.dummyData = ChartInstanceCasted.series.indexOf(series);
1669
+ }
1670
+ });
1671
+ let visibleCount = newIndex;
1672
+ let newMiddle = visibleCount / 2;
1673
+ ChartInstanceCasted.series.each((series) => {
1674
+ let trueIndex = ChartInstanceCasted.series.indexOf(series);
1675
+ let newIndex = series.dummyData;
1676
+ let dx = (newIndex - trueIndex + middle - newMiddle) * delta;
1677
+ series.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1678
+ series.bulletsContainer.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1679
+ });
1680
+ }
1681
+ }
1682
+ }
1796
1683
  }
1797
1684
 
1798
1685
  /**
@@ -1920,6 +1807,139 @@ class VerticalStackedChartService {
1920
1807
  }
1921
1808
  }
1922
1809
 
1810
+ /**
1811
+ * Classe il cui unico scopo è gestire il setup e rendering di un AreaChart
1812
+ */
1813
+ class AreaChartService {
1814
+ /** @ignore */
1815
+ constructor(Adapter) {
1816
+ this.Adapter = Adapter;
1817
+ //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
1818
+ //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
1819
+ /** @ignore */
1820
+ this.executionTimers = {};
1821
+ }
1822
+ /**
1823
+ * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un AreaChart
1824
+ */
1825
+ graphicate(data, settings) {
1826
+ var _a, _b, _c, _d, _e, _f;
1827
+ if (settings.Timeline) {
1828
+ console.error("Timeline not supported for area chart");
1829
+ return null;
1830
+ }
1831
+ let dataConverted = this.Adapter ? this.Adapter.adaptDataForAreaChart(data) : data;
1832
+ let showTicks = settings.ShowTicks == null ? true : settings === null || settings === void 0 ? void 0 : settings.ShowTicks;
1833
+ let interval = dataConverted.interval;
1834
+ //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
1835
+ am4core.options.autoDispose = true;
1836
+ this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1837
+ let ChartInstanceCasted = this.ChartInstance;
1838
+ if (settings.Legend) {
1839
+ ChartInstanceCasted.legend = new am4charts.Legend();
1840
+ ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
1841
+ ChartInstanceCasted.legend.itemContainers.template.tooltipText = "{category}";
1842
+ if (settings.LegendPadding) {
1843
+ let template = this.ChartInstance.legend.itemContainers.template;
1844
+ template.paddingTop = (_b = settings.LegendPadding.top) !== null && _b !== void 0 ? _b : 0;
1845
+ template.paddingBottom = (_c = settings.LegendPadding.bottom) !== null && _c !== void 0 ? _c : 0;
1846
+ template.paddingLeft = (_d = settings.LegendPadding.left) !== null && _d !== void 0 ? _d : 0;
1847
+ template.paddingRight = (_e = settings.LegendPadding.right) !== null && _e !== void 0 ? _e : 0;
1848
+ }
1849
+ }
1850
+ let yAxis = ChartInstanceCasted.yAxes.push(new am4charts.ValueAxis());
1851
+ yAxis.tooltip.disabled = true;
1852
+ if (settings.YAxisTitle) {
1853
+ yAxis.title.text = settings.YAxisTitle;
1854
+ yAxis.title.fontWeight = "bold";
1855
+ }
1856
+ yAxis.min = 0;
1857
+ let dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
1858
+ dateAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 50;
1859
+ dateAxis.startLocation = 0.5;
1860
+ dateAxis.endLocation = 0.5;
1861
+ if (settings.XAxisTitle) {
1862
+ dateAxis.title.text = settings.XAxisTitle;
1863
+ dateAxis.title.fontWeight = "bold";
1864
+ }
1865
+ if (showTicks) {
1866
+ dateAxis.renderer.ticks.template.disabled = false;
1867
+ dateAxis.renderer.ticks.template.strokeOpacity = 1;
1868
+ dateAxis.renderer.ticks.template.stroke = am4core.color("#495C43");
1869
+ dateAxis.renderer.ticks.template.strokeWidth = 2;
1870
+ dateAxis.renderer.ticks.template.length = 10;
1871
+ dateAxis.renderer.ticks.template.location = 0;
1872
+ }
1873
+ if (!!interval)
1874
+ dateAxis.baseInterval = { count: interval.count, timeUnit: interval.timeunit };
1875
+ // Unisco il dataset e tiro fuori i dati
1876
+ let chartData = [];
1877
+ let seriesToMakeCache = {};
1878
+ let seriesToMake = [];
1879
+ for (let i = 0; i < dataConverted.groups.length; i++) {
1880
+ let group = dataConverted.groups[i];
1881
+ let dataItem = { date: group.name };
1882
+ for (let ii = 0; ii < group.values.length; ii++) {
1883
+ let val = group.values[ii];
1884
+ dataItem[val.k] = val.v;
1885
+ if (!seriesToMakeCache[val.k]) {
1886
+ seriesToMakeCache[val.k] = true;
1887
+ seriesToMake.push(val.k);
1888
+ }
1889
+ }
1890
+ chartData.push(dataItem);
1891
+ }
1892
+ ChartInstanceCasted.data = chartData;
1893
+ //---------------------------------------------------------
1894
+ seriesToMake.forEach(s => { this.createSeries(ChartInstanceCasted, s); });
1895
+ ChartInstanceCasted.cursor = new am4charts.XYCursor();
1896
+ ChartInstanceCasted.cursor.xAxis = dateAxis;
1897
+ dateAxis.events.on("startchanged", t => this.emitSelectionChanged(t, settings));
1898
+ dateAxis.events.on("endchanged", t => this.emitSelectionChanged(t, settings));
1899
+ return this;
1900
+ }
1901
+ /** @ignore */
1902
+ refreshData(data) {
1903
+ //TODO:IMPL
1904
+ }
1905
+ /** @ignore */
1906
+ emitSelectionChanged(ev, settings) {
1907
+ if (settings.OnSelectionChangedCallback) {
1908
+ this.throttla("selchange", () => {
1909
+ var axis = ev.target;
1910
+ var start = new Date(axis.minZoomed);
1911
+ var end = new Date(axis.maxZoomed);
1912
+ var initial = axis.min == axis.minZoomed && axis.max == axis.maxZoomed;
1913
+ settings.OnSelectionChangedCallback({ from: start, to: end, initial: initial });
1914
+ }, 150);
1915
+ }
1916
+ }
1917
+ /** @ignore */
1918
+ createSeries(chart, name) {
1919
+ let series = chart.series.push(new am4charts.LineSeries());
1920
+ series.dataFields.dateX = "date";
1921
+ series.name = name[0].toUpperCase() + name.slice(1);
1922
+ series.dataFields.valueY = name;
1923
+ series.tooltipText = "[#000]{valueY.value}[/]";
1924
+ //series.tooltip.background.fill = am4core.color("#FFF");
1925
+ series.tooltip.getStrokeFromObject = true;
1926
+ series.tooltip.background.strokeWidth = 3;
1927
+ series.tooltip.getFillFromObject = false;
1928
+ series.fillOpacity = 0.6;
1929
+ series.strokeWidth = 2;
1930
+ series.stacked = true;
1931
+ return series;
1932
+ }
1933
+ /** @ignore */
1934
+ throttla(id, func, throttleTime) {
1935
+ //Se ho la funzione che vuole eseguire ripulisco quel timeout
1936
+ if (this.executionTimers[id])
1937
+ clearTimeout(this.executionTimers[id]);
1938
+ //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
1939
+ this.executionTimers[id] = setTimeout(() => { func(); this.executionTimers[id] = null; }, throttleTime);
1940
+ }
1941
+ }
1942
+
1923
1943
  /**
1924
1944
  * Componente specifico per la graficazione di un qualsiasi tipo di grafico.
1925
1945
  *
@@ -2643,5 +2663,5 @@ EsChartsModule.decorators = [
2643
2663
  * Generated bundle index. Do not edit.
2644
2664
  */
2645
2665
 
2646
- export { AreaChartData, AreaChartSettings, BaseAdapter, BaseInterval, BaseSettings, ChartThemes, DateValue, EsAreaChartComponent, EsChartComponent, EsChartsModule, EsLineChartComponent, EsPieChartComponent, EsVertical2DChartComponent, EsVerticalChartComponent, EsVerticalStackedChartComponent, KeyValue, KeyValueColor, LegendPad, Limit, LineChartData, LineChartSettings, LineSerie, PagedChartData, PieChartData, PieChartSettings, Vertical2DChartData, Vertical2DChartSettings, VerticalChartData, VerticalChartSettings, VerticalStackedChartData, VerticalStackedChartSettings, BaseInterval as ɵa, BaseChartComponent as ɵb, ChartLoader as ɵc, ChartDispatcher as ɵd, ESC_LOCALE as ɵe, ESC_ANIMATIONS as ɵf, ESC_THEME as ɵg, ESC_LOGS as ɵh, BaseAdapter as ɵi, EsChartComponent as ɵj, EsLineChartComponent as ɵk, EsPieChartComponent as ɵl, EsVertical2DChartComponent as ɵm, EsVerticalChartComponent as ɵn, EsVerticalStackedChartComponent as ɵo, PageChartSelector as ɵp, EsAreaChartComponent as ɵq };
2666
+ export { AreaChartData, AreaChartSettings, BaseAdapter, BaseChartComponent, BaseInterval, BaseSettings, ChartThemes, DateValue, EsAreaChartComponent, EsChartComponent, EsChartsModule, EsLineChartComponent, EsPieChartComponent, EsVertical2DChartComponent, EsVerticalChartComponent, EsVerticalStackedChartComponent, KeyValue, KeyValueColor, LegendPad, Limit, LineChartData, LineChartSettings, LineSerie, PagedChartData, PieChartData, PieChartSettings, Vertical2DChartData, Vertical2DChartSettings, VerticalChartData, VerticalChartSettings, VerticalStackedChartData, VerticalStackedChartSettings, ChartLoader as ɵa, ChartDispatcher as ɵb, ESC_LOCALE as ɵc, ESC_ANIMATIONS as ɵd, ESC_THEME as ɵe, ESC_LOGS as ɵf, PageChartSelector as ɵg };
2647
2667
  //# sourceMappingURL=esfaenza-es-charts.js.map