@esfaenza/es-charts 11.2.21 → 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 +362 -390
  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 -5
  6. package/esfaenza-es-charts.metadata.json +1 -1
  7. package/esm2015/esfaenza-es-charts.js +5 -6
  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 +3 -2
  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 +25 -25
  52. package/fesm2015/esfaenza-es-charts.js +351 -370
  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 +10 -4
  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} +3 -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 +24 -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 -358
  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
@@ -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...
@@ -1222,26 +1222,7 @@ class LineChartService {
1222
1222
  this.ChartInstance.addData(data);
1223
1223
  return;
1224
1224
  }
1225
- this.ChartInstance.series.each(s => {
1226
- var relativeSerie = dataConverted.series.find(t => t.name == s.name);
1227
- // Una serie del grafico è stata ggiornata, ordino i datapoint e li aggiungo
1228
- var correctOrder = true;
1229
- var prevDate = null;
1230
- for (let v = 0; v < relativeSerie.values.length; v++) {
1231
- if (!prevDate)
1232
- prevDate = relativeSerie.values[v].d;
1233
- else if (relativeSerie.values[v].d < prevDate) {
1234
- correctOrder = false;
1235
- break;
1236
- }
1237
- }
1238
- if (!correctOrder)
1239
- relativeSerie.values.sort((d1, d2) => d1.d.getTime() - d2.d.getTime());
1240
- for (let v = 0; v < relativeSerie.values.length; v++) {
1241
- let obj = relativeSerie.values[v];
1242
- s.addData({ date: obj.d, value: obj.v });
1243
- }
1244
- });
1225
+ throw "Impossibile aggiornare i dati senza unire il dataset. Si prega di impostare [MergeDatasets] a true";
1245
1226
  }
1246
1227
  /** Partendo da dati divisi per seriue genera un dataset unito con la data come chiave e i vari valori dopo */
1247
1228
  generateSingleDataset(data) {
@@ -1328,168 +1309,35 @@ class LineChartService {
1328
1309
  }
1329
1310
 
1330
1311
  /**
1331
- * 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
1332
1313
  */
1333
- class AreaChartService {
1314
+ class PieChartService {
1334
1315
  /** @ignore */
1335
1316
  constructor(Adapter) {
1336
1317
  this.Adapter = Adapter;
1337
- //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
1338
- //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
1339
1318
  /** @ignore */
1340
- this.executionTimers = {};
1319
+ this.ViewAbsoluteValues = true;
1341
1320
  }
1342
1321
  /**
1343
- * 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
1344
1323
  */
1345
1324
  graphicate(data, settings) {
1346
- var _a, _b, _c, _d, _e, _f;
1325
+ var _a, _b, _c, _d;
1347
1326
  if (settings.Timeline) {
1348
- console.error("Timeline not supported for area chart");
1327
+ console.error("Timeline not supported for pie chart");
1349
1328
  return null;
1350
1329
  }
1351
- let dataConverted = this.Adapter ? this.Adapter.adaptDataForAreaChart(data) : data;
1352
- let showTicks = settings.ShowTicks == null ? true : settings === null || settings === void 0 ? void 0 : settings.ShowTicks;
1353
- let interval = dataConverted.interval;
1354
1330
  //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
1355
1331
  am4core.options.autoDispose = true;
1356
- this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1357
- let ChartInstanceCasted = this.ChartInstance;
1358
- if (settings.Legend) {
1359
- ChartInstanceCasted.legend = new am4charts.Legend();
1360
- ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
1361
- ChartInstanceCasted.legend.itemContainers.template.tooltipText = "{category}";
1362
- if (settings.LegendPadding) {
1363
- let template = this.ChartInstance.legend.itemContainers.template;
1364
- template.paddingTop = (_b = settings.LegendPadding.top) !== null && _b !== void 0 ? _b : 0;
1365
- template.paddingBottom = (_c = settings.LegendPadding.bottom) !== null && _c !== void 0 ? _c : 0;
1366
- template.paddingLeft = (_d = settings.LegendPadding.left) !== null && _d !== void 0 ? _d : 0;
1367
- template.paddingRight = (_e = settings.LegendPadding.right) !== null && _e !== void 0 ? _e : 0;
1368
- }
1369
- }
1370
- let yAxis = ChartInstanceCasted.yAxes.push(new am4charts.ValueAxis());
1371
- yAxis.tooltip.disabled = true;
1372
- if (settings.YAxisTitle) {
1373
- yAxis.title.text = settings.YAxisTitle;
1374
- yAxis.title.fontWeight = "bold";
1375
- }
1376
- yAxis.min = 0;
1377
- let dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
1378
- dateAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 50;
1379
- dateAxis.startLocation = 0.5;
1380
- dateAxis.endLocation = 0.5;
1381
- if (settings.XAxisTitle) {
1382
- dateAxis.title.text = settings.XAxisTitle;
1383
- dateAxis.title.fontWeight = "bold";
1384
- }
1385
- if (showTicks) {
1386
- dateAxis.renderer.ticks.template.disabled = false;
1387
- dateAxis.renderer.ticks.template.strokeOpacity = 1;
1388
- dateAxis.renderer.ticks.template.stroke = am4core.color("#495C43");
1389
- dateAxis.renderer.ticks.template.strokeWidth = 2;
1390
- dateAxis.renderer.ticks.template.length = 10;
1391
- dateAxis.renderer.ticks.template.location = 0;
1392
- }
1393
- if (!!interval)
1394
- dateAxis.baseInterval = { count: interval.count, timeUnit: interval.timeunit };
1395
- // Unisco il dataset e tiro fuori i dati
1396
- let chartData = [];
1397
- let seriesToMakeCache = {};
1398
- let seriesToMake = [];
1399
- for (let i = 0; i < dataConverted.groups.length; i++) {
1400
- let group = dataConverted.groups[i];
1401
- let dataItem = { date: group.name };
1402
- for (let ii = 0; ii < group.values.length; ii++) {
1403
- let val = group.values[ii];
1404
- dataItem[val.k] = val.v;
1405
- if (!seriesToMakeCache[val.k]) {
1406
- seriesToMakeCache[val.k] = true;
1407
- seriesToMake.push(val.k);
1408
- }
1409
- }
1410
- chartData.push(dataItem);
1411
- }
1412
- ChartInstanceCasted.data = chartData;
1413
- //---------------------------------------------------------
1414
- seriesToMake.forEach(s => { this.createSeries(ChartInstanceCasted, s); });
1415
- ChartInstanceCasted.cursor = new am4charts.XYCursor();
1416
- ChartInstanceCasted.cursor.xAxis = dateAxis;
1417
- dateAxis.events.on("startchanged", t => this.emitSelectionChanged(t, settings));
1418
- dateAxis.events.on("endchanged", t => this.emitSelectionChanged(t, settings));
1419
- return this;
1420
- }
1421
- /** @ignore */
1422
- refreshData(data) {
1423
- //TODO:IMPL
1424
- }
1425
- /** @ignore */
1426
- emitSelectionChanged(ev, settings) {
1427
- if (settings.OnSelectionChangedCallback) {
1428
- this.throttla("selchange", () => {
1429
- var axis = ev.target;
1430
- var start = new Date(axis.minZoomed);
1431
- var end = new Date(axis.maxZoomed);
1432
- var initial = axis.min == axis.minZoomed && axis.max == axis.maxZoomed;
1433
- settings.OnSelectionChangedCallback({ from: start, to: end, initial: initial });
1434
- }, 150);
1435
- }
1436
- }
1437
- /** @ignore */
1438
- createSeries(chart, name) {
1439
- let series = chart.series.push(new am4charts.LineSeries());
1440
- series.dataFields.dateX = "date";
1441
- series.name = name[0].toUpperCase() + name.slice(1);
1442
- series.dataFields.valueY = name;
1443
- series.tooltipText = "[#000]{valueY.value}[/]";
1444
- //series.tooltip.background.fill = am4core.color("#FFF");
1445
- series.tooltip.getStrokeFromObject = true;
1446
- series.tooltip.background.strokeWidth = 3;
1447
- series.tooltip.getFillFromObject = false;
1448
- series.fillOpacity = 0.6;
1449
- series.strokeWidth = 2;
1450
- series.stacked = true;
1451
- return series;
1452
- }
1453
- /** @ignore */
1454
- throttla(id, func, throttleTime) {
1455
- //Se ho la funzione che vuole eseguire ripulisco quel timeout
1456
- if (this.executionTimers[id])
1457
- clearTimeout(this.executionTimers[id]);
1458
- //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
1459
- this.executionTimers[id] = setTimeout(() => { func(); this.executionTimers[id] = null; }, throttleTime);
1460
- }
1461
- }
1462
-
1463
- /**
1464
- * Classe il cui unico scopo è gestire il setup e rendering di un PieChart
1465
- */
1466
- class PieChartService {
1467
- /** @ignore */
1468
- constructor(Adapter) {
1469
- this.Adapter = Adapter;
1470
- /** @ignore */
1471
- this.ViewAbsoluteValues = true;
1472
- }
1473
- /**
1474
- * Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un PieChart
1475
- */
1476
- graphicate(data, settings) {
1477
- var _a, _b, _c, _d;
1478
- if (settings.Timeline) {
1479
- console.error("Timeline not supported for pie chart");
1480
- return null;
1481
- }
1482
- //Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
1483
- am4core.options.autoDispose = true;
1484
- this.ChartInstance = am4core.create(settings.Name, settings.Mode3D ? am4charts.PieChart3D : am4charts.PieChart);
1485
- this.ChartInstance.innerRadius = ((settings.DonutRadiusPercentage || 15) / 100) * settings.ContainerHeight;
1486
- let series = this.ChartInstance.series.push(settings.Mode3D ? new am4charts.PieSeries3D() : new am4charts.PieSeries());
1487
- series.dataFields.value = "v";
1488
- series.dataFields.category = "k";
1489
- //Il default sono valori percentuali
1490
- if (this.ViewAbsoluteValues) {
1491
- series.legendSettings.valueText = "{value}";
1492
- series.labels.template.text = "{category}: [bold]{value}[/]";
1332
+ this.ChartInstance = am4core.create(settings.Name, settings.Mode3D ? am4charts.PieChart3D : am4charts.PieChart);
1333
+ this.ChartInstance.innerRadius = ((settings.DonutRadiusPercentage || 15) / 100) * settings.ContainerHeight;
1334
+ let series = this.ChartInstance.series.push(settings.Mode3D ? new am4charts.PieSeries3D() : new am4charts.PieSeries());
1335
+ series.dataFields.value = "v";
1336
+ series.dataFields.category = "k";
1337
+ //Il default sono valori percentuali
1338
+ if (this.ViewAbsoluteValues) {
1339
+ series.legendSettings.valueText = "{value}";
1340
+ series.labels.template.text = "{category}: [bold]{value}[/]";
1493
1341
  }
1494
1342
  series.slices.template.stroke = am4core.color("#fff");
1495
1343
  series.slices.template.strokeOpacity = 1;
@@ -1571,15 +1419,13 @@ class PieChartService {
1571
1419
  }
1572
1420
 
1573
1421
  /**
1574
- * 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
1575
1423
  */
1576
- class Vertical2DChartService {
1424
+ class VerticalChartService {
1577
1425
  /** @ignore */
1578
1426
  constructor(Adapter) {
1579
1427
  this.Adapter = Adapter;
1580
1428
  /** @ignore */
1581
- this.DefaultGroupPaddingPercentage = 5;
1582
- /** @ignore */
1583
1429
  this.dangerZone = 50;
1584
1430
  /** @ignore */
1585
1431
  this.LabelWidth = 150;
@@ -1591,10 +1437,10 @@ class Vertical2DChartService {
1591
1437
  this.DefaultColumnWidthPercentage = 85;
1592
1438
  }
1593
1439
  /**
1594
- * 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
1595
1441
  */
1596
1442
  graphicate(data, settings) {
1597
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1443
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1598
1444
  if (settings.Timeline) {
1599
1445
  console.error("Timeline not supported for vertical chart");
1600
1446
  return null;
@@ -1603,6 +1449,8 @@ class Vertical2DChartService {
1603
1449
  am4core.options.autoDispose = true;
1604
1450
  this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1605
1451
  let ChartInstanceCasted = this.ChartInstance;
1452
+ let dataConverted = this.Adapter ? this.Adapter.adaptDataForVerticalChart(data) : data;
1453
+ ChartInstanceCasted.data = dataConverted.values;
1606
1454
  if (settings.Legend) {
1607
1455
  ChartInstanceCasted.legend = new am4charts.Legend();
1608
1456
  ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
@@ -1625,15 +1473,12 @@ class Vertical2DChartService {
1625
1473
  categoryAxis.title.text = settings.XAxisTitle;
1626
1474
  categoryAxis.title.fontWeight = "bold";
1627
1475
  }
1628
- yAxis.min = 0;
1629
- categoryAxis.dataFields.category = 'key';
1630
- categoryAxis.renderer.cellStartLocation = am4core.percent((_f = settings.GroupPaddingPercentage) !== null && _f !== void 0 ? _f : this.DefaultGroupPaddingPercentage).value;
1631
- categoryAxis.renderer.cellEndLocation = am4core.percent(100 - ((_g = settings.GroupPaddingPercentage) !== null && _g !== void 0 ? _g : this.DefaultGroupPaddingPercentage)).value;
1476
+ categoryAxis.dataFields.category = "k";
1632
1477
  categoryAxis.renderer.grid.template.location = 0;
1633
- 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;
1634
1479
  let label = categoryAxis.renderer.labels.template;
1635
1480
  label.truncate = true;
1636
- 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;
1637
1482
  label.tooltipText = "{category}";
1638
1483
  if ((settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) == null ? true : settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) {
1639
1484
  categoryAxis.events.on("sizechanged", (ev) => {
@@ -1657,88 +1502,35 @@ class Vertical2DChartService {
1657
1502
  }
1658
1503
  });
1659
1504
  }
1660
- let dataPreConverted = this.Adapter ? this.Adapter.adaptDataForVertical2DChart(data) : data;
1661
- let dataConverted = [];
1662
- for (let i = 0; i < dataPreConverted.groups.length; i++) {
1663
- let item = dataPreConverted.groups[i];
1664
- let obj = { key: item.name };
1665
- for (let p = 0; p < item.values.length; p++) {
1666
- let value = item.values[p];
1667
- obj[value.k] = value.v;
1668
- }
1669
- dataConverted.push(obj);
1670
- }
1671
- ChartInstanceCasted.data = dataConverted;
1672
- if (dataPreConverted.colorInfos)
1673
- ChartInstanceCasted.colors.list = dataPreConverted.colorInfos.map(c => am4core.color(c.color));
1674
- //Prendo la prima categoria e mi baso sulle proprietà per dfeinire le serie
1675
- for (let prop in dataConverted[0])
1676
- if (prop !== "key")
1677
- 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;
1678
1516
  return this;
1679
1517
  }
1680
1518
  /** @ignore */
1681
1519
  refreshData(data) {
1682
1520
  //TODO:IMPL
1683
1521
  }
1684
- /** @ignore */
1685
- createSeries(chart, settings, value, name) {
1686
- var _a;
1687
- let series = chart.series.push(new am4charts.ColumnSeries());
1688
- series.dataFields.valueY = value;
1689
- series.dataFields.categoryX = 'key';
1690
- series.name = name;
1691
- series.columns.template.tooltipText = "{name} {categoryX}: [bold]{valueY}[/]";
1692
- series.columns.template.fillOpacity = .8;
1693
- series.columns.template.width = am4core.percent((_a = settings.ColumnWidthPercentage) !== null && _a !== void 0 ? _a : this.DefaultColumnWidthPercentage);
1694
- series.events.on("hidden", () => this.arrangeColumns);
1695
- series.events.on("shown", () => this.arrangeColumns);
1696
- return series;
1697
- }
1698
- /** @ignore */
1699
- arrangeColumns() {
1700
- let ChartInstanceCasted = this.ChartInstance;
1701
- let series = ChartInstanceCasted.series.getIndex(0);
1702
- let xAxis = ChartInstanceCasted.xAxes.getIndex(0);
1703
- let w = 1 - xAxis.renderer.cellStartLocation - (1 - xAxis.renderer.cellEndLocation);
1704
- if (series.dataItems.length > 1) {
1705
- let x0 = xAxis.getX(series.dataItems.getIndex(0), "categoryX");
1706
- let x1 = xAxis.getX(series.dataItems.getIndex(1), "categoryX");
1707
- let delta = ((x1 - x0) / ChartInstanceCasted.series.length) * w;
1708
- if (am4core.isNumber(delta)) {
1709
- let middle = ChartInstanceCasted.series.length / 2;
1710
- let newIndex = 0;
1711
- ChartInstanceCasted.series.each((series) => {
1712
- if (!series.isHidden && !series.isHiding) {
1713
- series.dummyData = newIndex;
1714
- newIndex++;
1715
- }
1716
- else {
1717
- series.dummyData = ChartInstanceCasted.series.indexOf(series);
1718
- }
1719
- });
1720
- let visibleCount = newIndex;
1721
- let newMiddle = visibleCount / 2;
1722
- ChartInstanceCasted.series.each((series) => {
1723
- let trueIndex = ChartInstanceCasted.series.indexOf(series);
1724
- let newIndex = series.dummyData;
1725
- let dx = (newIndex - trueIndex + middle - newMiddle) * delta;
1726
- series.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1727
- series.bulletsContainer.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
1728
- });
1729
- }
1730
- }
1731
- }
1732
1522
  }
1733
1523
 
1734
1524
  /**
1735
- * 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
1736
1526
  */
1737
- class VerticalChartService {
1527
+ class Vertical2DChartService {
1738
1528
  /** @ignore */
1739
1529
  constructor(Adapter) {
1740
1530
  this.Adapter = Adapter;
1741
1531
  /** @ignore */
1532
+ this.DefaultGroupPaddingPercentage = 5;
1533
+ /** @ignore */
1742
1534
  this.dangerZone = 50;
1743
1535
  /** @ignore */
1744
1536
  this.LabelWidth = 150;
@@ -1750,10 +1542,10 @@ class VerticalChartService {
1750
1542
  this.DefaultColumnWidthPercentage = 85;
1751
1543
  }
1752
1544
  /**
1753
- * 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
1754
1546
  */
1755
1547
  graphicate(data, settings) {
1756
- var _a, _b, _c, _d, _e, _f, _g, _h;
1548
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1757
1549
  if (settings.Timeline) {
1758
1550
  console.error("Timeline not supported for vertical chart");
1759
1551
  return null;
@@ -1762,8 +1554,6 @@ class VerticalChartService {
1762
1554
  am4core.options.autoDispose = true;
1763
1555
  this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
1764
1556
  let ChartInstanceCasted = this.ChartInstance;
1765
- let dataConverted = this.Adapter ? this.Adapter.adaptDataForVerticalChart(data) : data;
1766
- ChartInstanceCasted.data = dataConverted.values;
1767
1557
  if (settings.Legend) {
1768
1558
  ChartInstanceCasted.legend = new am4charts.Legend();
1769
1559
  ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
@@ -1786,12 +1576,15 @@ class VerticalChartService {
1786
1576
  categoryAxis.title.text = settings.XAxisTitle;
1787
1577
  categoryAxis.title.fontWeight = "bold";
1788
1578
  }
1789
- 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;
1790
1583
  categoryAxis.renderer.grid.template.location = 0;
1791
- 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;
1792
1585
  let label = categoryAxis.renderer.labels.template;
1793
1586
  label.truncate = true;
1794
- 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;
1795
1588
  label.tooltipText = "{category}";
1796
1589
  if ((settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) == null ? true : settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) {
1797
1590
  categoryAxis.events.on("sizechanged", (ev) => {
@@ -1815,23 +1608,78 @@ class VerticalChartService {
1815
1608
  }
1816
1609
  });
1817
1610
  }
1818
- // Create series
1819
- let series = ChartInstanceCasted.series.push(new am4charts.ColumnSeries());
1820
- series.dataFields.valueY = "v";
1821
- series.dataFields.categoryX = "k";
1822
- series.name = "";
1823
- series.columns.template.tooltipText = "{categoryX}: [bold]{valueY}[/]";
1824
- series.columns.template.fillOpacity = .8;
1825
- series.columns.template.width = am4core.percent((_h = settings.ColumnWidthPercentage) !== null && _h !== void 0 ? _h : this.DefaultColumnWidthPercentage);
1826
- let columnTemplate = series.columns.template;
1827
- columnTemplate.strokeWidth = 2;
1828
- 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);
1829
1629
  return this;
1830
1630
  }
1831
1631
  /** @ignore */
1832
1632
  refreshData(data) {
1833
1633
  //TODO:IMPL
1834
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
+ }
1835
1683
  }
1836
1684
 
1837
1685
  /**
@@ -1959,6 +1807,139 @@ class VerticalStackedChartService {
1959
1807
  }
1960
1808
  }
1961
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
+
1962
1943
  /**
1963
1944
  * Componente specifico per la graficazione di un qualsiasi tipo di grafico.
1964
1945
  *
@@ -2682,5 +2663,5 @@ EsChartsModule.decorators = [
2682
2663
  * Generated bundle index. Do not edit.
2683
2664
  */
2684
2665
 
2685
- 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, BaseInterval as ɵa, ChartLoader as ɵb, ChartDispatcher as ɵc, ESC_LOCALE as ɵd, ESC_ANIMATIONS as ɵe, ESC_THEME as ɵf, ESC_LOGS as ɵg, BaseAdapter as ɵh, EsChartComponent as ɵi, EsLineChartComponent as ɵj, EsPieChartComponent as ɵk, EsVertical2DChartComponent as ɵl, EsVerticalChartComponent as ɵm, EsVerticalStackedChartComponent as ɵn, PageChartSelector as ɵo, EsAreaChartComponent as ɵp };
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 };
2686
2667
  //# sourceMappingURL=esfaenza-es-charts.js.map