@esfaenza/es-charts 11.2.21 → 11.2.24
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.
- package/bundles/esfaenza-es-charts.umd.js +435 -463
- package/bundles/esfaenza-es-charts.umd.js.map +1 -1
- package/bundles/esfaenza-es-charts.umd.min.js +1 -1
- package/bundles/esfaenza-es-charts.umd.min.js.map +1 -1
- package/esfaenza-es-charts.d.ts +3 -5
- package/esfaenza-es-charts.metadata.json +1 -1
- package/esm2015/esfaenza-es-charts.js +4 -6
- package/esm2015/lib/adapters/BaseAdapter.js +47 -0
- package/esm2015/lib/adapters/IBaseAdapter.js +2 -0
- package/esm2015/lib/components/base/base-chart.component.js +3 -2
- package/esm2015/lib/components/chart-pager/chart-pager.component.js +1 -1
- package/esm2015/lib/components/specializations/es-area-chart.component.js +6 -5
- package/esm2015/lib/components/specializations/es-chart.component.js +18 -5
- package/esm2015/lib/components/specializations/es-line-chart.component.js +6 -5
- package/esm2015/lib/components/specializations/es-pie-chart.component.js +6 -5
- package/esm2015/lib/components/specializations/es-vertical-2d-chart.component.js +6 -5
- package/esm2015/lib/components/specializations/es-vertical-chart.component.js +6 -5
- package/esm2015/lib/components/specializations/es-vertical-stacked-chart.component.js +6 -5
- package/esm2015/lib/es-charts.module.js +13 -5
- package/esm2015/lib/models/core/ChartDispatcher.js +88 -0
- package/esm2015/lib/models/core/ChartLoader.js +201 -0
- package/esm2015/lib/models/core/ChartThemes.js +61 -0
- package/esm2015/lib/models/data/AreaChartData.js +16 -0
- package/esm2015/lib/models/data/LineChartData.js +16 -0
- package/esm2015/lib/models/data/PagedChartData.js +20 -0
- package/esm2015/lib/models/data/PieChartData.js +14 -0
- package/esm2015/lib/models/data/Vertical2DChartData.js +16 -0
- package/esm2015/lib/models/data/VerticalChartData.js +14 -0
- package/esm2015/lib/models/data/VerticalStackedChartData.js +14 -0
- package/esm2015/lib/models/data/base/DateValue.js +11 -0
- package/esm2015/lib/models/data/base/KeyValue.js +11 -0
- package/esm2015/lib/models/data/base/KeyValueColor.js +12 -0
- package/esm2015/lib/models/data/base/Limit.js +15 -0
- package/esm2015/lib/models/data/base/LineSerie.js +24 -0
- package/esm2015/lib/models/settings/AreaChartSettings.js +11 -0
- package/esm2015/lib/models/settings/LineChartSettings.js +11 -0
- package/esm2015/lib/models/settings/PieChartSettings.js +7 -0
- package/esm2015/lib/models/settings/Vertical2DChartSettings.js +11 -0
- package/esm2015/lib/models/settings/VerticalChartSettings.js +11 -0
- package/esm2015/lib/models/settings/VerticalStackedChartSettings.js +11 -0
- package/esm2015/lib/models/settings/base/BaseInterval.js +6 -0
- package/esm2015/lib/models/settings/base/BaseSettings.js +6 -0
- package/esm2015/lib/models/settings/base/LegendPad.js +6 -0
- package/esm2015/lib/services/AreaChartService.js +135 -0
- package/esm2015/lib/services/LineChartService.js +339 -0
- package/esm2015/lib/services/PieChartService.js +112 -0
- package/esm2015/lib/services/Vertical2DChartService.js +163 -0
- package/esm2015/lib/services/VerticalChartService.js +105 -0
- package/esm2015/lib/services/VerticalStackedChartService.js +127 -0
- package/esm2015/lib/services/base/IBaseService.js +2 -0
- package/esm2015/public-api.js +26 -25
- package/fesm2015/esfaenza-es-charts.js +412 -431
- package/fesm2015/esfaenza-es-charts.js.map +1 -1
- package/lib/adapters/{classes/BaseAdapter.d.ts → BaseAdapter.d.ts} +6 -1
- package/lib/adapters/{classes/IBaseAdapter.d.ts → IBaseAdapter.d.ts} +6 -1
- package/lib/components/base/base-chart.component.d.ts +10 -4
- package/lib/components/chart-pager/chart-pager.component.d.ts +1 -1
- package/lib/components/specializations/es-area-chart.component.d.ts +6 -4
- package/lib/components/specializations/es-chart.component.d.ts +17 -5
- package/lib/components/specializations/es-line-chart.component.d.ts +6 -4
- package/lib/components/specializations/es-pie-chart.component.d.ts +6 -4
- package/lib/components/specializations/es-vertical-2d-chart.component.d.ts +6 -4
- package/lib/components/specializations/es-vertical-chart.component.d.ts +6 -4
- package/lib/components/specializations/es-vertical-stacked-chart.component.d.ts +6 -4
- package/lib/models/core/{classes/ChartDispatcher.d.ts → ChartDispatcher.d.ts} +0 -0
- package/lib/models/core/{classes/ChartLoader.d.ts → ChartLoader.d.ts} +0 -0
- package/lib/models/core/{classes/ChartThemes.d.ts → ChartThemes.d.ts} +0 -0
- package/lib/models/data/{classes/AreaChartData.d.ts → AreaChartData.d.ts} +1 -1
- package/lib/models/data/{classes/LineChartData.d.ts → LineChartData.d.ts} +0 -0
- package/lib/models/data/{classes/PagedChartData.d.ts → PagedChartData.d.ts} +0 -0
- package/lib/models/data/{classes/PieChartData.d.ts → PieChartData.d.ts} +0 -0
- package/lib/models/data/{classes/Vertical2DChartData.d.ts → Vertical2DChartData.d.ts} +0 -0
- package/lib/models/data/{classes/VerticalChartData.d.ts → VerticalChartData.d.ts} +0 -0
- package/lib/models/data/{classes/VerticalStackedChartData.d.ts → VerticalStackedChartData.d.ts} +0 -0
- package/lib/models/data/{classes/base → base}/DateValue.d.ts +0 -0
- package/lib/models/data/{classes/base → base}/KeyValue.d.ts +0 -0
- package/lib/models/data/{classes/base → base}/KeyValueColor.d.ts +0 -0
- package/lib/models/data/base/Limit.d.ts +13 -0
- package/lib/models/data/{classes/base → base}/LineSerie.d.ts +1 -1
- package/lib/models/settings/{classes/AreaChartSettings.d.ts → AreaChartSettings.d.ts} +0 -0
- package/lib/models/settings/{classes/LineChartSettings.d.ts → LineChartSettings.d.ts} +0 -0
- package/lib/models/settings/{classes/PieChartSettings.d.ts → PieChartSettings.d.ts} +0 -0
- package/lib/models/settings/{classes/Vertical2DChartSettings.d.ts → Vertical2DChartSettings.d.ts} +0 -0
- package/lib/models/settings/{classes/VerticalChartSettings.d.ts → VerticalChartSettings.d.ts} +0 -0
- package/lib/models/settings/{classes/VerticalStackedChartSettings.d.ts → VerticalStackedChartSettings.d.ts} +0 -0
- package/lib/models/settings/{classes/base → base}/BaseInterval.d.ts +0 -0
- package/lib/models/settings/{classes/base → base}/BaseSettings.d.ts +1 -1
- package/lib/models/settings/{classes/base → base}/LegendPad.d.ts +0 -0
- package/lib/services/{classes/AreaChartService.d.ts → AreaChartService.d.ts} +3 -3
- package/lib/services/{classes/LineChartService.d.ts → LineChartService.d.ts} +3 -3
- package/lib/services/{classes/PieChartService.d.ts → PieChartService.d.ts} +3 -3
- package/lib/services/{classes/Vertical2DChartService.d.ts → Vertical2DChartService.d.ts} +3 -3
- package/lib/services/{classes/VerticalChartService.d.ts → VerticalChartService.d.ts} +3 -3
- package/lib/services/{classes/VerticalStackedChartService.d.ts → VerticalStackedChartService.d.ts} +3 -3
- package/lib/services/{classes/base → base}/IBaseService.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +25 -24
- package/esm2015/lib/adapters/classes/BaseAdapter.js +0 -47
- package/esm2015/lib/adapters/classes/IBaseAdapter.js +0 -2
- package/esm2015/lib/adapters/index.js +0 -3
- package/esm2015/lib/components/index.js +0 -9
- package/esm2015/lib/models/core/classes/ChartDispatcher.js +0 -88
- package/esm2015/lib/models/core/classes/ChartLoader.js +0 -201
- package/esm2015/lib/models/core/classes/ChartThemes.js +0 -61
- package/esm2015/lib/models/core/index.js +0 -4
- package/esm2015/lib/models/data/classes/AreaChartData.js +0 -16
- package/esm2015/lib/models/data/classes/LineChartData.js +0 -16
- package/esm2015/lib/models/data/classes/PagedChartData.js +0 -20
- package/esm2015/lib/models/data/classes/PieChartData.js +0 -14
- package/esm2015/lib/models/data/classes/Vertical2DChartData.js +0 -16
- package/esm2015/lib/models/data/classes/VerticalChartData.js +0 -14
- package/esm2015/lib/models/data/classes/VerticalStackedChartData.js +0 -14
- package/esm2015/lib/models/data/classes/base/DateValue.js +0 -11
- package/esm2015/lib/models/data/classes/base/KeyValue.js +0 -11
- package/esm2015/lib/models/data/classes/base/KeyValueColor.js +0 -12
- package/esm2015/lib/models/data/classes/base/Limit.js +0 -15
- package/esm2015/lib/models/data/classes/base/LineSerie.js +0 -24
- package/esm2015/lib/models/data/index.js +0 -13
- package/esm2015/lib/models/settings/classes/AreaChartSettings.js +0 -11
- package/esm2015/lib/models/settings/classes/LineChartSettings.js +0 -11
- package/esm2015/lib/models/settings/classes/PieChartSettings.js +0 -7
- package/esm2015/lib/models/settings/classes/Vertical2DChartSettings.js +0 -11
- package/esm2015/lib/models/settings/classes/VerticalChartSettings.js +0 -11
- package/esm2015/lib/models/settings/classes/VerticalStackedChartSettings.js +0 -11
- package/esm2015/lib/models/settings/classes/base/BaseInterval.js +0 -6
- package/esm2015/lib/models/settings/classes/base/BaseSettings.js +0 -6
- package/esm2015/lib/models/settings/classes/base/LegendPad.js +0 -6
- package/esm2015/lib/models/settings/index.js +0 -10
- package/esm2015/lib/services/classes/AreaChartService.js +0 -135
- package/esm2015/lib/services/classes/LineChartService.js +0 -358
- package/esm2015/lib/services/classes/PieChartService.js +0 -112
- package/esm2015/lib/services/classes/Vertical2DChartService.js +0 -163
- package/esm2015/lib/services/classes/VerticalChartService.js +0 -105
- package/esm2015/lib/services/classes/VerticalStackedChartService.js +0 -127
- package/esm2015/lib/services/classes/base/IBaseService.js +0 -2
- package/esm2015/lib/services/index.js +0 -8
- package/lib/adapters/index.d.ts +0 -2
- package/lib/components/index.d.ts +0 -8
- package/lib/models/core/index.d.ts +0 -3
- package/lib/models/data/classes/base/Limit.d.ts +0 -13
- package/lib/models/data/index.d.ts +0 -12
- package/lib/models/settings/index.d.ts +0 -9
- package/lib/services/index.d.ts +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable,
|
|
1
|
+
import { Injectable, EventEmitter, Component, ChangeDetectionStrategy, Input, Output, ContentChild, InjectionToken, Inject, Directive, ElementRef, NgZone, PLATFORM_ID, NgModule } from '@angular/core';
|
|
2
2
|
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
|
3
3
|
import * as am4core from '@amcharts/amcharts4/core';
|
|
4
4
|
import { DateService } from '@esfaenza/extensions';
|
|
@@ -219,13 +219,13 @@ class LegendPad {
|
|
|
219
219
|
*/
|
|
220
220
|
class Limit {
|
|
221
221
|
/** @ignore */
|
|
222
|
-
constructor(upper,
|
|
222
|
+
constructor(upper, upperlabel, uppercolor, lower, lowerlabel, lowercolor) {
|
|
223
223
|
this.upper = upper;
|
|
224
|
-
this.
|
|
225
|
-
this.
|
|
224
|
+
this.upperlabel = upperlabel;
|
|
225
|
+
this.uppercolor = uppercolor;
|
|
226
226
|
this.lower = lower;
|
|
227
|
-
this.
|
|
228
|
-
this.
|
|
227
|
+
this.lowerlabel = lowerlabel;
|
|
228
|
+
this.lowercolor = lowercolor;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
@@ -288,107 +288,87 @@ class LineSerie {
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
/**
|
|
291
|
-
*
|
|
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
|
|
291
|
+
* Componente che si occupa della paginazione dei grafici qualora servisse
|
|
309
292
|
*/
|
|
310
|
-
class
|
|
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 = [];
|
|
293
|
+
class PageChartSelector {
|
|
294
|
+
constructor() {
|
|
320
295
|
/**
|
|
321
|
-
*
|
|
296
|
+
* Indica un cambio di pagina ed emette un oggetto con i dati attuali e l'indice attuale.
|
|
297
|
+
*
|
|
298
|
+
* Qualora la proprietà **data** fosse null indica un evento di "loading"
|
|
322
299
|
*/
|
|
323
|
-
this.
|
|
300
|
+
this.onPageChange = new EventEmitter();
|
|
324
301
|
}
|
|
325
302
|
/**
|
|
326
|
-
*
|
|
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
|
|
303
|
+
* @ignore
|
|
331
304
|
*/
|
|
332
|
-
|
|
333
|
-
if (this.
|
|
334
|
-
throw
|
|
335
|
-
|
|
336
|
-
this.
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
this.drainInitQueues();
|
|
340
|
-
}
|
|
305
|
+
ngOnChanges() {
|
|
306
|
+
if (!(this.Items || this.Dtos) || (this.Items || this.Dtos).length == 0)
|
|
307
|
+
throw new Error("Chart array cannot be empty!");
|
|
308
|
+
var idx = (this.StartIndex || 0);
|
|
309
|
+
this.currentindex = idx;
|
|
310
|
+
this.currentpage = idx + 1;
|
|
311
|
+
this.handlePageChange();
|
|
341
312
|
}
|
|
342
313
|
/**
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* @param {string} name Identificativo del grafico da deregistrare
|
|
314
|
+
* Gestisce un cambio pagina inviando al callback **onPageChange** i dati attuali (siano essi il Dto per il caricamento dati i
|
|
315
|
+
* o i dati già presenti) e l'indice di visualizzazione
|
|
346
316
|
*/
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
this.log("DISPATCHER: Chart deregistered " + name);
|
|
355
|
-
this.InitializedGraphs.splice(index, 1);
|
|
317
|
+
handlePageChange() {
|
|
318
|
+
this.finalIndex = this.currentpage - 1;
|
|
319
|
+
this.currentindex = this.currentpage - 1;
|
|
320
|
+
let data = this.Items && this.Items.length > 0 ? this.Items[this.finalIndex].data : this.Dtos[this.finalIndex];
|
|
321
|
+
this.onPageChange.emit({ data: data, index: this.finalIndex });
|
|
356
322
|
}
|
|
357
323
|
/**
|
|
358
|
-
*
|
|
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
|
|
324
|
+
* Visualizza il grafico successivo
|
|
362
325
|
*/
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
this.
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (this.
|
|
371
|
-
this.
|
|
372
|
-
this.drainInitQueues();
|
|
373
|
-
}
|
|
326
|
+
Next() {
|
|
327
|
+
// Per passare da page a index è sempre un -1
|
|
328
|
+
this.currentpage++;
|
|
329
|
+
this.onPageChange.emit({ data: null, index: this.currentpage - 1 });
|
|
330
|
+
// Delay pseudo-intelligente per click compulsivi.
|
|
331
|
+
// Se dopo questo delay sono andato avanti solo di 1 effettuo il callback altrimenti incremento l'indice
|
|
332
|
+
setTimeout(() => {
|
|
333
|
+
if (this.currentindex == this.currentpage - 2)
|
|
334
|
+
this.handlePageChange();
|
|
374
335
|
else
|
|
375
|
-
this.
|
|
376
|
-
});
|
|
336
|
+
this.currentindex++;
|
|
337
|
+
}, this.BrowseDelayMs);
|
|
377
338
|
}
|
|
378
339
|
/**
|
|
379
|
-
*
|
|
340
|
+
* Visualizza il grafico precedente
|
|
380
341
|
*/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
342
|
+
Previous() {
|
|
343
|
+
// Per passare da page a index è sempre un -1
|
|
344
|
+
this.currentpage--;
|
|
345
|
+
this.onPageChange.emit({ data: null, index: this.currentpage - 1 });
|
|
346
|
+
// Delay pseudo-intelligente per click compulsivi.
|
|
347
|
+
// Se dopo questo delay sono andato indietro solo di 1 effettuo il callback altrimenti decremento l'indice
|
|
348
|
+
setTimeout(() => {
|
|
349
|
+
if (this.currentindex == this.currentpage)
|
|
350
|
+
this.handlePageChange();
|
|
351
|
+
else
|
|
352
|
+
this.currentindex--;
|
|
353
|
+
}, this.BrowseDelayMs);
|
|
384
354
|
}
|
|
385
355
|
}
|
|
386
|
-
|
|
387
|
-
{ type:
|
|
356
|
+
PageChartSelector.decorators = [
|
|
357
|
+
{ type: Component, args: [{
|
|
358
|
+
selector: "chart-pager",
|
|
359
|
+
template: "<div *ngIf=\"(Items || Dtos) && (Items || Dtos).length > 0\" class=\"pcs-no-selection\">\r\n <div class=\"pcs-button pcs-backward\">\r\n <svg class=\"pcs-svg-header\">\r\n <g class=\"pcs-svg-button-container\" role=\"button\" (click)=\"currentpage != 1 && Previous(); $event.stopPropagation(); $event.preventDefault();\">\r\n <!--Pulsante e freccettina all'interno-->\r\n <g class=\"pcs-svg-button\" [style.cursor]=\"currentpage == 1 ? 'not-allowed' : 'pointer'\"><path d=\"M3,0 L53.027,0 a3,3 0 0 1 3,3 L56.027,36.817 a3,3 0 0 1 -3,3 L3,39.817 a3,3 0 0 1 -3,-3 L0,3 a3,3 0 0 1 3,-3 Z\"></path></g>\r\n <g class=\"pcs-svg-arrow pcs-svg-arrow-left\"><path d=\"M26,14H10l5.17-6.79A2,2,0,0,0,12,4.79l-7.62,10a2,2,0,0,0,0,2.42l7.62,10a2,2,0,0,0,3.18-2.42L10,18H26a2,2,0,0,0,0-4Z\"></path></g>\r\n </g>\r\n </svg>\r\n </div>\r\n <div class=\"pcs-infos\">\r\n <ng-container *ngIf=\"headerInner_tr\">\r\n <ng-container *ngTemplateOutlet=\"headerInner_tr; context : {$implicit: (Items || Dtos)[currentpage - 1]}\"></ng-container>\r\n </ng-container>\r\n </div>\r\n <div class=\"pcs-button pcs-forward\">\r\n <svg class=\"pcs-svg-header\">\r\n <g class=\"pcs-svg-button-container\" role=\"button\" (click)=\"(Items || Dtos).length != currentpage && Next(); $event.stopPropagation(); $event.preventDefault();\">\r\n <!--Pulsante e freccettina all'interno-->\r\n <g class=\"pcs-svg-button\" [style.cursor]=\"(Items || Dtos).length == currentpage ? 'not-allowed' : 'pointer'\"><path d=\"M3,0 L53.027,0 a3,3 0 0 1 3,3 L56.027,36.817 a3,3 0 0 1 -3,3 L3,39.817 a3,3 0 0 1 -3,-3 L0,3 a3,3 0 0 1 3,-3 Z\"></path></g>\r\n <g class=\"pcs-svg-arrow pcs-svg-arrow-right\"><path d=\"M26,14H10l5.17-6.79A2,2,0,0,0,12,4.79l-7.62,10a2,2,0,0,0,0,2.42l7.62,10a2,2,0,0,0,3.18-2.42L10,18H26a2,2,0,0,0,0-4Z\"></path></g>\r\n </g>\r\n </svg>\r\n </div>\r\n <div style=\"clear: both;\"></div>\r\n</div>",
|
|
360
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
361
|
+
styles: [".pcs-button{width:60px}.pcs-forward{float:right;text-align:end}.pcs-backward{float:left}.pcs-svg-header{width:57px;height:40px}.pcs-svg-button-container{outline:medium none currentcolor}.pcs-svg-arrow{pointer-events:none;fill:#555}.pcs-svg-arrow-right{transform:translate(44px,36px) rotate(180deg)}.pcs-svg-arrow-left{transform:translate(13px,4px)}.pcs-svg-button{fill:#d9d9d9;stroke:#fff;fill-opacity:1;stroke-opacity:1}.pcs-svg-button:hover{fill:#a3a3a3;cursor:pointer}.pcs-infos{width:calc(100% - 120px);height:44px;float:left}.pcs-no-selection{-webkit-user-select:none;-moz-user-select:none;-khtml-user-select:none;-ms-user-select:none}"]
|
|
362
|
+
},] }
|
|
388
363
|
];
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
]
|
|
364
|
+
PageChartSelector.propDecorators = {
|
|
365
|
+
Items: [{ type: Input }],
|
|
366
|
+
Dtos: [{ type: Input }],
|
|
367
|
+
BrowseDelayMs: [{ type: Input }],
|
|
368
|
+
StartIndex: [{ type: Input }],
|
|
369
|
+
onPageChange: [{ type: Output }],
|
|
370
|
+
headerInner_tr: [{ type: ContentChild, args: ['header_inner', { static: false },] }]
|
|
371
|
+
};
|
|
392
372
|
|
|
393
373
|
/** @ignore */
|
|
394
374
|
const _spiritedaway = 'spiritedaway';
|
|
@@ -651,6 +631,109 @@ class ChartLoader {
|
|
|
651
631
|
}
|
|
652
632
|
}
|
|
653
633
|
|
|
634
|
+
/**
|
|
635
|
+
* Token che identifica il Locale di default per tutti i grafici, può essere sovrascritto dalle impostazioni locali (Settings e Input)
|
|
636
|
+
*/
|
|
637
|
+
const ESC_LOCALE = new InjectionToken('ESC_LOCALE');
|
|
638
|
+
/**
|
|
639
|
+
* 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)
|
|
640
|
+
*/
|
|
641
|
+
const ESC_ANIMATIONS = new InjectionToken('ESC_ANIMATIONS');
|
|
642
|
+
/**
|
|
643
|
+
* Token che identifica il Tema di default per tutti i grafici, può essere sovrascritto dalle impostazioni locali (Settings e Input)
|
|
644
|
+
*/
|
|
645
|
+
const ESC_THEME = new InjectionToken('ESC_THEME');
|
|
646
|
+
/**
|
|
647
|
+
* Token che identifica l'utilizzo o meno del sistema di Log per l'intera libreria
|
|
648
|
+
*/
|
|
649
|
+
const ESC_LOGS = new InjectionToken('ESC_LOGS');
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* 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
|
|
653
|
+
*/
|
|
654
|
+
class ChartDispatcher {
|
|
655
|
+
/**
|
|
656
|
+
* @ignore
|
|
657
|
+
*/
|
|
658
|
+
constructor(logs) {
|
|
659
|
+
this.logs = logs;
|
|
660
|
+
/**
|
|
661
|
+
* Coda di inizializzazioni ancora da eseguire. Quando questa è vuota significa che nessuno sta creando grafici
|
|
662
|
+
*/
|
|
663
|
+
this.Initializations = [];
|
|
664
|
+
/**
|
|
665
|
+
* Lista dei grafici inizializzati e attivi in un dato momento (viene registrata la proprietà **name**). Non è possibile registrare due grafici con lo stesso identificativo
|
|
666
|
+
*/
|
|
667
|
+
this.InitializedGraphs = [];
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Registra un grafico da visualizzare insieme alla propria funzione di creazione. Quest'ultima sarà differita fino a che tutti i grafici
|
|
671
|
+
* precedentemente registati non hanno finito la fase di inizializzazione
|
|
672
|
+
*
|
|
673
|
+
* @param {string} name Identificativo del grafico da registrare
|
|
674
|
+
* @param {Function} chartCreationFunction Funzione che fisicamente dovrà occuparsi della creazione del grafico
|
|
675
|
+
*/
|
|
676
|
+
register(name, chartCreationFunction) {
|
|
677
|
+
if (this.InitializedGraphs.indexOf(name) != -1)
|
|
678
|
+
throw "Attempting to register a duplicate chart '" + name + "'. Make sure the 'name' properties of your charts are univoque";
|
|
679
|
+
this.log("DISPATCHER: Registering chart creation function execution for " + name);
|
|
680
|
+
this.Initializations.push({ name: name, function: chartCreationFunction });
|
|
681
|
+
if (this.Initializations.length == 1) {
|
|
682
|
+
this.log("DISPATCHER: Initial drain started");
|
|
683
|
+
this.drainInitQueues();
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Deregistra un grafico presente. Chiamata generalmente al dispose del grafico in questione quando non dev'essere più mostrato nella pagina corrente
|
|
688
|
+
*
|
|
689
|
+
* @param {string} name Identificativo del grafico da deregistrare
|
|
690
|
+
*/
|
|
691
|
+
deregisterGraph(name) {
|
|
692
|
+
let index = this.InitializedGraphs.indexOf(name);
|
|
693
|
+
if (index == -1) {
|
|
694
|
+
//Questo succede quando si cerca di distruggere il grafico mentre sta venendo graficato
|
|
695
|
+
this.log("DISPATCHER: Registration missing for chart " + name + " it was probably destroyed during load");
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
this.log("DISPATCHER: Chart deregistered " + name);
|
|
699
|
+
this.InitializedGraphs.splice(index, 1);
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Metodo che esegue in maniera sequenziale le funzioni di inizializzazione dei grafici finché presenti
|
|
703
|
+
* in modo che nessun grafico possa essere inizializzato contemporaneamente ad un altro.
|
|
704
|
+
*
|
|
705
|
+
* Questo è il punto chiave che permette di avere per ogni grafico temi e locale differenti
|
|
706
|
+
*/
|
|
707
|
+
drainInitQueues() {
|
|
708
|
+
let toExecute = this.Initializations[0];
|
|
709
|
+
this.log("DISPATCHER: Executing initialization function for chart " + toExecute.name);
|
|
710
|
+
toExecute.function().then(() => {
|
|
711
|
+
this.log("DISPATCHER: initialization for chart " + toExecute.name + " is done");
|
|
712
|
+
this.InitializedGraphs.push(toExecute.name);
|
|
713
|
+
this.Initializations.splice(0, 1);
|
|
714
|
+
if (this.Initializations.length >= 1) {
|
|
715
|
+
this.log("DISPATCHER: Found queued initializations. Continuing");
|
|
716
|
+
this.drainInitQueues();
|
|
717
|
+
}
|
|
718
|
+
else
|
|
719
|
+
this.log("DISPATCHER: queue is over, nothing more to do");
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* @ignore
|
|
724
|
+
*/
|
|
725
|
+
log(text) {
|
|
726
|
+
if (this.logs)
|
|
727
|
+
console.log("@esfaenza/es-charts: " + text);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
ChartDispatcher.decorators = [
|
|
731
|
+
{ type: Injectable }
|
|
732
|
+
];
|
|
733
|
+
ChartDispatcher.ctorParameters = () => [
|
|
734
|
+
{ type: Boolean, decorators: [{ type: Inject, args: [ESC_LOGS,] }] }
|
|
735
|
+
];
|
|
736
|
+
|
|
654
737
|
/**
|
|
655
738
|
* Componente Grafico Base che gestisce tutte le cose comuni dei vari grafici istanziabili, come la presenza o menu di una legenda,
|
|
656
739
|
* il tema utilizzato, il locale del singolo grafico, ecc ecc...
|
|
@@ -1023,11 +1106,11 @@ class LineChartService {
|
|
|
1023
1106
|
let range = yAxis.axisRanges.create();
|
|
1024
1107
|
range.value = dataConverted.limit.upper;
|
|
1025
1108
|
range.label.inside = true;
|
|
1026
|
-
range.label.text = dataConverted.limit.
|
|
1109
|
+
range.label.text = dataConverted.limit.upperlabel;
|
|
1027
1110
|
range.label.fill = range.grid.stroke;
|
|
1028
1111
|
range.label.verticalCenter = "bottom";
|
|
1029
|
-
range.label.stroke = am4core.color(dataConverted.limit.
|
|
1030
|
-
range.grid.stroke = am4core.color(dataConverted.limit.
|
|
1112
|
+
range.label.stroke = am4core.color(dataConverted.limit.uppercolor || "#F92200");
|
|
1113
|
+
range.grid.stroke = am4core.color(dataConverted.limit.uppercolor || "#F92200");
|
|
1031
1114
|
range.grid.strokeWidth = 2;
|
|
1032
1115
|
range.grid.strokeOpacity = 1;
|
|
1033
1116
|
}
|
|
@@ -1035,11 +1118,11 @@ class LineChartService {
|
|
|
1035
1118
|
let range = yAxis.axisRanges.create();
|
|
1036
1119
|
range.value = dataConverted.limit.lower;
|
|
1037
1120
|
range.label.inside = true;
|
|
1038
|
-
range.label.text = dataConverted.limit.
|
|
1121
|
+
range.label.text = dataConverted.limit.lowerlabel;
|
|
1039
1122
|
range.label.fill = range.grid.stroke;
|
|
1040
1123
|
range.label.verticalCenter = "bottom";
|
|
1041
|
-
range.label.stroke = am4core.color(dataConverted.limit.
|
|
1042
|
-
range.grid.stroke = am4core.color(dataConverted.limit.
|
|
1124
|
+
range.label.stroke = am4core.color(dataConverted.limit.lowercolor || "#F92200");
|
|
1125
|
+
range.grid.stroke = am4core.color(dataConverted.limit.lowercolor || "#F92200");
|
|
1043
1126
|
range.grid.strokeWidth = 2;
|
|
1044
1127
|
range.grid.strokeOpacity = 1;
|
|
1045
1128
|
}
|
|
@@ -1222,26 +1305,7 @@ class LineChartService {
|
|
|
1222
1305
|
this.ChartInstance.addData(data);
|
|
1223
1306
|
return;
|
|
1224
1307
|
}
|
|
1225
|
-
|
|
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
|
-
});
|
|
1308
|
+
throw "Impossibile aggiornare i dati senza unire il dataset. Si prega di impostare [MergeDatasets] a true";
|
|
1245
1309
|
}
|
|
1246
1310
|
/** Partendo da dati divisi per seriue genera un dataset unito con la data come chiave e i vari valori dopo */
|
|
1247
1311
|
generateSingleDataset(data) {
|
|
@@ -1327,139 +1391,6 @@ class LineChartService {
|
|
|
1327
1391
|
}
|
|
1328
1392
|
}
|
|
1329
1393
|
|
|
1330
|
-
/**
|
|
1331
|
-
* Classe il cui unico scopo è gestire il setup e rendering di un AreaChart
|
|
1332
|
-
*/
|
|
1333
|
-
class AreaChartService {
|
|
1334
|
-
/** @ignore */
|
|
1335
|
-
constructor(Adapter) {
|
|
1336
|
-
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
|
-
/** @ignore */
|
|
1340
|
-
this.executionTimers = {};
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un AreaChart
|
|
1344
|
-
*/
|
|
1345
|
-
graphicate(data, settings) {
|
|
1346
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1347
|
-
if (settings.Timeline) {
|
|
1348
|
-
console.error("Timeline not supported for area chart");
|
|
1349
|
-
return null;
|
|
1350
|
-
}
|
|
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
|
-
//Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
|
|
1355
|
-
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
1394
|
/**
|
|
1464
1395
|
* Classe il cui unico scopo è gestire il setup e rendering di un PieChart
|
|
1465
1396
|
*/
|
|
@@ -1571,15 +1502,13 @@ class PieChartService {
|
|
|
1571
1502
|
}
|
|
1572
1503
|
|
|
1573
1504
|
/**
|
|
1574
|
-
* Classe il cui unico scopo è gestire il setup e rendering di un
|
|
1505
|
+
* Classe il cui unico scopo è gestire il setup e rendering di un VerticalChart
|
|
1575
1506
|
*/
|
|
1576
|
-
class
|
|
1507
|
+
class VerticalChartService {
|
|
1577
1508
|
/** @ignore */
|
|
1578
1509
|
constructor(Adapter) {
|
|
1579
1510
|
this.Adapter = Adapter;
|
|
1580
1511
|
/** @ignore */
|
|
1581
|
-
this.DefaultGroupPaddingPercentage = 5;
|
|
1582
|
-
/** @ignore */
|
|
1583
1512
|
this.dangerZone = 50;
|
|
1584
1513
|
/** @ignore */
|
|
1585
1514
|
this.LabelWidth = 150;
|
|
@@ -1591,10 +1520,10 @@ class Vertical2DChartService {
|
|
|
1591
1520
|
this.DefaultColumnWidthPercentage = 85;
|
|
1592
1521
|
}
|
|
1593
1522
|
/**
|
|
1594
|
-
* Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un
|
|
1523
|
+
* Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un VerticalChart
|
|
1595
1524
|
*/
|
|
1596
1525
|
graphicate(data, settings) {
|
|
1597
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
1526
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1598
1527
|
if (settings.Timeline) {
|
|
1599
1528
|
console.error("Timeline not supported for vertical chart");
|
|
1600
1529
|
return null;
|
|
@@ -1603,6 +1532,8 @@ class Vertical2DChartService {
|
|
|
1603
1532
|
am4core.options.autoDispose = true;
|
|
1604
1533
|
this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
|
|
1605
1534
|
let ChartInstanceCasted = this.ChartInstance;
|
|
1535
|
+
let dataConverted = this.Adapter ? this.Adapter.adaptDataForVerticalChart(data) : data;
|
|
1536
|
+
ChartInstanceCasted.data = dataConverted.values;
|
|
1606
1537
|
if (settings.Legend) {
|
|
1607
1538
|
ChartInstanceCasted.legend = new am4charts.Legend();
|
|
1608
1539
|
ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
|
|
@@ -1625,15 +1556,12 @@ class Vertical2DChartService {
|
|
|
1625
1556
|
categoryAxis.title.text = settings.XAxisTitle;
|
|
1626
1557
|
categoryAxis.title.fontWeight = "bold";
|
|
1627
1558
|
}
|
|
1628
|
-
|
|
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;
|
|
1559
|
+
categoryAxis.dataFields.category = "k";
|
|
1632
1560
|
categoryAxis.renderer.grid.template.location = 0;
|
|
1633
|
-
categoryAxis.renderer.minGridDistance = (
|
|
1561
|
+
categoryAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 30;
|
|
1634
1562
|
let label = categoryAxis.renderer.labels.template;
|
|
1635
1563
|
label.truncate = true;
|
|
1636
|
-
label.maxWidth = (
|
|
1564
|
+
label.maxWidth = (_g = settings.LabelWidth) !== null && _g !== void 0 ? _g : this.LabelWidth;
|
|
1637
1565
|
label.tooltipText = "{category}";
|
|
1638
1566
|
if ((settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) == null ? true : settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) {
|
|
1639
1567
|
categoryAxis.events.on("sizechanged", (ev) => {
|
|
@@ -1657,88 +1585,35 @@ class Vertical2DChartService {
|
|
|
1657
1585
|
}
|
|
1658
1586
|
});
|
|
1659
1587
|
}
|
|
1660
|
-
|
|
1661
|
-
let
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
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);
|
|
1588
|
+
// Create series
|
|
1589
|
+
let series = ChartInstanceCasted.series.push(new am4charts.ColumnSeries());
|
|
1590
|
+
series.dataFields.valueY = "v";
|
|
1591
|
+
series.dataFields.categoryX = "k";
|
|
1592
|
+
series.name = "";
|
|
1593
|
+
series.columns.template.tooltipText = "{categoryX}: [bold]{valueY}[/]";
|
|
1594
|
+
series.columns.template.fillOpacity = .8;
|
|
1595
|
+
series.columns.template.width = am4core.percent((_h = settings.ColumnWidthPercentage) !== null && _h !== void 0 ? _h : this.DefaultColumnWidthPercentage);
|
|
1596
|
+
let columnTemplate = series.columns.template;
|
|
1597
|
+
columnTemplate.strokeWidth = 2;
|
|
1598
|
+
columnTemplate.strokeOpacity = 1;
|
|
1678
1599
|
return this;
|
|
1679
1600
|
}
|
|
1680
1601
|
/** @ignore */
|
|
1681
1602
|
refreshData(data) {
|
|
1682
1603
|
//TODO:IMPL
|
|
1683
1604
|
}
|
|
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
1605
|
}
|
|
1733
1606
|
|
|
1734
1607
|
/**
|
|
1735
|
-
* Classe il cui unico scopo è gestire il setup e rendering di un
|
|
1608
|
+
* Classe il cui unico scopo è gestire il setup e rendering di un Vertical2DChart
|
|
1736
1609
|
*/
|
|
1737
|
-
class
|
|
1610
|
+
class Vertical2DChartService {
|
|
1738
1611
|
/** @ignore */
|
|
1739
1612
|
constructor(Adapter) {
|
|
1740
1613
|
this.Adapter = Adapter;
|
|
1741
1614
|
/** @ignore */
|
|
1615
|
+
this.DefaultGroupPaddingPercentage = 5;
|
|
1616
|
+
/** @ignore */
|
|
1742
1617
|
this.dangerZone = 50;
|
|
1743
1618
|
/** @ignore */
|
|
1744
1619
|
this.LabelWidth = 150;
|
|
@@ -1750,10 +1625,10 @@ class VerticalChartService {
|
|
|
1750
1625
|
this.DefaultColumnWidthPercentage = 85;
|
|
1751
1626
|
}
|
|
1752
1627
|
/**
|
|
1753
|
-
* Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un
|
|
1628
|
+
* Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un Vertical2DChart
|
|
1754
1629
|
*/
|
|
1755
1630
|
graphicate(data, settings) {
|
|
1756
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1631
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1757
1632
|
if (settings.Timeline) {
|
|
1758
1633
|
console.error("Timeline not supported for vertical chart");
|
|
1759
1634
|
return null;
|
|
@@ -1762,8 +1637,6 @@ class VerticalChartService {
|
|
|
1762
1637
|
am4core.options.autoDispose = true;
|
|
1763
1638
|
this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
|
|
1764
1639
|
let ChartInstanceCasted = this.ChartInstance;
|
|
1765
|
-
let dataConverted = this.Adapter ? this.Adapter.adaptDataForVerticalChart(data) : data;
|
|
1766
|
-
ChartInstanceCasted.data = dataConverted.values;
|
|
1767
1640
|
if (settings.Legend) {
|
|
1768
1641
|
ChartInstanceCasted.legend = new am4charts.Legend();
|
|
1769
1642
|
ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
|
|
@@ -1786,12 +1659,15 @@ class VerticalChartService {
|
|
|
1786
1659
|
categoryAxis.title.text = settings.XAxisTitle;
|
|
1787
1660
|
categoryAxis.title.fontWeight = "bold";
|
|
1788
1661
|
}
|
|
1789
|
-
|
|
1662
|
+
yAxis.min = 0;
|
|
1663
|
+
categoryAxis.dataFields.category = 'key';
|
|
1664
|
+
categoryAxis.renderer.cellStartLocation = am4core.percent((_f = settings.GroupPaddingPercentage) !== null && _f !== void 0 ? _f : this.DefaultGroupPaddingPercentage).value;
|
|
1665
|
+
categoryAxis.renderer.cellEndLocation = am4core.percent(100 - ((_g = settings.GroupPaddingPercentage) !== null && _g !== void 0 ? _g : this.DefaultGroupPaddingPercentage)).value;
|
|
1790
1666
|
categoryAxis.renderer.grid.template.location = 0;
|
|
1791
|
-
categoryAxis.renderer.minGridDistance = (
|
|
1667
|
+
categoryAxis.renderer.minGridDistance = (_h = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _h !== void 0 ? _h : 30;
|
|
1792
1668
|
let label = categoryAxis.renderer.labels.template;
|
|
1793
1669
|
label.truncate = true;
|
|
1794
|
-
label.maxWidth = (
|
|
1670
|
+
label.maxWidth = (_j = settings.LabelWidth) !== null && _j !== void 0 ? _j : this.LabelWidth;
|
|
1795
1671
|
label.tooltipText = "{category}";
|
|
1796
1672
|
if ((settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) == null ? true : settings === null || settings === void 0 ? void 0 : settings.AdaptLabelSizeAndOrientation) {
|
|
1797
1673
|
categoryAxis.events.on("sizechanged", (ev) => {
|
|
@@ -1815,22 +1691,77 @@ class VerticalChartService {
|
|
|
1815
1691
|
}
|
|
1816
1692
|
});
|
|
1817
1693
|
}
|
|
1818
|
-
|
|
1819
|
-
let
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1694
|
+
let dataPreConverted = this.Adapter ? this.Adapter.adaptDataForVertical2DChart(data) : data;
|
|
1695
|
+
let dataConverted = [];
|
|
1696
|
+
for (let i = 0; i < dataPreConverted.groups.length; i++) {
|
|
1697
|
+
let item = dataPreConverted.groups[i];
|
|
1698
|
+
let obj = { key: item.name };
|
|
1699
|
+
for (let p = 0; p < item.values.length; p++) {
|
|
1700
|
+
let value = item.values[p];
|
|
1701
|
+
obj[value.k] = value.v;
|
|
1702
|
+
}
|
|
1703
|
+
dataConverted.push(obj);
|
|
1704
|
+
}
|
|
1705
|
+
ChartInstanceCasted.data = dataConverted;
|
|
1706
|
+
if (dataPreConverted.colorInfos)
|
|
1707
|
+
ChartInstanceCasted.colors.list = dataPreConverted.colorInfos.map(c => am4core.color(c.color));
|
|
1708
|
+
//Prendo la prima categoria e mi baso sulle proprietà per dfeinire le serie
|
|
1709
|
+
for (let prop in dataConverted[0])
|
|
1710
|
+
if (prop !== "key")
|
|
1711
|
+
this.createSeries(ChartInstanceCasted, settings, prop, prop);
|
|
1829
1712
|
return this;
|
|
1830
1713
|
}
|
|
1831
1714
|
/** @ignore */
|
|
1832
|
-
refreshData(data) {
|
|
1833
|
-
//TODO:IMPL
|
|
1715
|
+
refreshData(data) {
|
|
1716
|
+
//TODO:IMPL
|
|
1717
|
+
}
|
|
1718
|
+
/** @ignore */
|
|
1719
|
+
createSeries(chart, settings, value, name) {
|
|
1720
|
+
var _a;
|
|
1721
|
+
let series = chart.series.push(new am4charts.ColumnSeries());
|
|
1722
|
+
series.dataFields.valueY = value;
|
|
1723
|
+
series.dataFields.categoryX = 'key';
|
|
1724
|
+
series.name = name;
|
|
1725
|
+
series.columns.template.tooltipText = "{name} {categoryX}: [bold]{valueY}[/]";
|
|
1726
|
+
series.columns.template.fillOpacity = .8;
|
|
1727
|
+
series.columns.template.width = am4core.percent((_a = settings.ColumnWidthPercentage) !== null && _a !== void 0 ? _a : this.DefaultColumnWidthPercentage);
|
|
1728
|
+
series.events.on("hidden", () => this.arrangeColumns);
|
|
1729
|
+
series.events.on("shown", () => this.arrangeColumns);
|
|
1730
|
+
return series;
|
|
1731
|
+
}
|
|
1732
|
+
/** @ignore */
|
|
1733
|
+
arrangeColumns() {
|
|
1734
|
+
let ChartInstanceCasted = this.ChartInstance;
|
|
1735
|
+
let series = ChartInstanceCasted.series.getIndex(0);
|
|
1736
|
+
let xAxis = ChartInstanceCasted.xAxes.getIndex(0);
|
|
1737
|
+
let w = 1 - xAxis.renderer.cellStartLocation - (1 - xAxis.renderer.cellEndLocation);
|
|
1738
|
+
if (series.dataItems.length > 1) {
|
|
1739
|
+
let x0 = xAxis.getX(series.dataItems.getIndex(0), "categoryX");
|
|
1740
|
+
let x1 = xAxis.getX(series.dataItems.getIndex(1), "categoryX");
|
|
1741
|
+
let delta = ((x1 - x0) / ChartInstanceCasted.series.length) * w;
|
|
1742
|
+
if (am4core.isNumber(delta)) {
|
|
1743
|
+
let middle = ChartInstanceCasted.series.length / 2;
|
|
1744
|
+
let newIndex = 0;
|
|
1745
|
+
ChartInstanceCasted.series.each((series) => {
|
|
1746
|
+
if (!series.isHidden && !series.isHiding) {
|
|
1747
|
+
series.dummyData = newIndex;
|
|
1748
|
+
newIndex++;
|
|
1749
|
+
}
|
|
1750
|
+
else {
|
|
1751
|
+
series.dummyData = ChartInstanceCasted.series.indexOf(series);
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
let visibleCount = newIndex;
|
|
1755
|
+
let newMiddle = visibleCount / 2;
|
|
1756
|
+
ChartInstanceCasted.series.each((series) => {
|
|
1757
|
+
let trueIndex = ChartInstanceCasted.series.indexOf(series);
|
|
1758
|
+
let newIndex = series.dummyData;
|
|
1759
|
+
let dx = (newIndex - trueIndex + middle - newMiddle) * delta;
|
|
1760
|
+
series.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
|
|
1761
|
+
series.bulletsContainer.animate({ property: "dx", to: dx }, series.interpolationDuration, series.interpolationEasing);
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1834
1765
|
}
|
|
1835
1766
|
}
|
|
1836
1767
|
|
|
@@ -1959,6 +1890,139 @@ class VerticalStackedChartService {
|
|
|
1959
1890
|
}
|
|
1960
1891
|
}
|
|
1961
1892
|
|
|
1893
|
+
/**
|
|
1894
|
+
* Classe il cui unico scopo è gestire il setup e rendering di un AreaChart
|
|
1895
|
+
*/
|
|
1896
|
+
class AreaChartService {
|
|
1897
|
+
/** @ignore */
|
|
1898
|
+
constructor(Adapter) {
|
|
1899
|
+
this.Adapter = Adapter;
|
|
1900
|
+
//******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
|
|
1901
|
+
//TODO: spostarla in un metodo di utilità (esfaenza/extensions)
|
|
1902
|
+
/** @ignore */
|
|
1903
|
+
this.executionTimers = {};
|
|
1904
|
+
}
|
|
1905
|
+
/**
|
|
1906
|
+
* Metodo che data una coppia Dati - Impostazioni li utilizza per creare e visualizzare un AreaChart
|
|
1907
|
+
*/
|
|
1908
|
+
graphicate(data, settings) {
|
|
1909
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1910
|
+
if (settings.Timeline) {
|
|
1911
|
+
console.error("Timeline not supported for area chart");
|
|
1912
|
+
return null;
|
|
1913
|
+
}
|
|
1914
|
+
let dataConverted = this.Adapter ? this.Adapter.adaptDataForAreaChart(data) : data;
|
|
1915
|
+
let showTicks = settings.ShowTicks == null ? true : settings === null || settings === void 0 ? void 0 : settings.ShowTicks;
|
|
1916
|
+
let interval = dataConverted.interval;
|
|
1917
|
+
//Per evitare di dimenticarmeli e gestire comunque bene gli ngif ecc...
|
|
1918
|
+
am4core.options.autoDispose = true;
|
|
1919
|
+
this.ChartInstance = am4core.create(settings.Name, am4charts.XYChart);
|
|
1920
|
+
let ChartInstanceCasted = this.ChartInstance;
|
|
1921
|
+
if (settings.Legend) {
|
|
1922
|
+
ChartInstanceCasted.legend = new am4charts.Legend();
|
|
1923
|
+
ChartInstanceCasted.legend.position = (_a = settings === null || settings === void 0 ? void 0 : settings.LegendPosition) !== null && _a !== void 0 ? _a : 'right';
|
|
1924
|
+
ChartInstanceCasted.legend.itemContainers.template.tooltipText = "{category}";
|
|
1925
|
+
if (settings.LegendPadding) {
|
|
1926
|
+
let template = this.ChartInstance.legend.itemContainers.template;
|
|
1927
|
+
template.paddingTop = (_b = settings.LegendPadding.top) !== null && _b !== void 0 ? _b : 0;
|
|
1928
|
+
template.paddingBottom = (_c = settings.LegendPadding.bottom) !== null && _c !== void 0 ? _c : 0;
|
|
1929
|
+
template.paddingLeft = (_d = settings.LegendPadding.left) !== null && _d !== void 0 ? _d : 0;
|
|
1930
|
+
template.paddingRight = (_e = settings.LegendPadding.right) !== null && _e !== void 0 ? _e : 0;
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
let yAxis = ChartInstanceCasted.yAxes.push(new am4charts.ValueAxis());
|
|
1934
|
+
yAxis.tooltip.disabled = true;
|
|
1935
|
+
if (settings.YAxisTitle) {
|
|
1936
|
+
yAxis.title.text = settings.YAxisTitle;
|
|
1937
|
+
yAxis.title.fontWeight = "bold";
|
|
1938
|
+
}
|
|
1939
|
+
yAxis.min = 0;
|
|
1940
|
+
let dateAxis = ChartInstanceCasted.xAxes.push(new am4charts.DateAxis());
|
|
1941
|
+
dateAxis.renderer.minGridDistance = (_f = settings === null || settings === void 0 ? void 0 : settings.MinGridDistance) !== null && _f !== void 0 ? _f : 50;
|
|
1942
|
+
dateAxis.startLocation = 0.5;
|
|
1943
|
+
dateAxis.endLocation = 0.5;
|
|
1944
|
+
if (settings.XAxisTitle) {
|
|
1945
|
+
dateAxis.title.text = settings.XAxisTitle;
|
|
1946
|
+
dateAxis.title.fontWeight = "bold";
|
|
1947
|
+
}
|
|
1948
|
+
if (showTicks) {
|
|
1949
|
+
dateAxis.renderer.ticks.template.disabled = false;
|
|
1950
|
+
dateAxis.renderer.ticks.template.strokeOpacity = 1;
|
|
1951
|
+
dateAxis.renderer.ticks.template.stroke = am4core.color("#495C43");
|
|
1952
|
+
dateAxis.renderer.ticks.template.strokeWidth = 2;
|
|
1953
|
+
dateAxis.renderer.ticks.template.length = 10;
|
|
1954
|
+
dateAxis.renderer.ticks.template.location = 0;
|
|
1955
|
+
}
|
|
1956
|
+
if (!!interval)
|
|
1957
|
+
dateAxis.baseInterval = { count: interval.count, timeUnit: interval.timeunit };
|
|
1958
|
+
// Unisco il dataset e tiro fuori i dati
|
|
1959
|
+
let chartData = [];
|
|
1960
|
+
let seriesToMakeCache = {};
|
|
1961
|
+
let seriesToMake = [];
|
|
1962
|
+
for (let i = 0; i < dataConverted.groups.length; i++) {
|
|
1963
|
+
let group = dataConverted.groups[i];
|
|
1964
|
+
let dataItem = { date: group.name };
|
|
1965
|
+
for (let ii = 0; ii < group.values.length; ii++) {
|
|
1966
|
+
let val = group.values[ii];
|
|
1967
|
+
dataItem[val.k] = val.v;
|
|
1968
|
+
if (!seriesToMakeCache[val.k]) {
|
|
1969
|
+
seriesToMakeCache[val.k] = true;
|
|
1970
|
+
seriesToMake.push(val.k);
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
chartData.push(dataItem);
|
|
1974
|
+
}
|
|
1975
|
+
ChartInstanceCasted.data = chartData;
|
|
1976
|
+
//---------------------------------------------------------
|
|
1977
|
+
seriesToMake.forEach(s => { this.createSeries(ChartInstanceCasted, s); });
|
|
1978
|
+
ChartInstanceCasted.cursor = new am4charts.XYCursor();
|
|
1979
|
+
ChartInstanceCasted.cursor.xAxis = dateAxis;
|
|
1980
|
+
dateAxis.events.on("startchanged", t => this.emitSelectionChanged(t, settings));
|
|
1981
|
+
dateAxis.events.on("endchanged", t => this.emitSelectionChanged(t, settings));
|
|
1982
|
+
return this;
|
|
1983
|
+
}
|
|
1984
|
+
/** @ignore */
|
|
1985
|
+
refreshData(data) {
|
|
1986
|
+
//TODO:IMPL
|
|
1987
|
+
}
|
|
1988
|
+
/** @ignore */
|
|
1989
|
+
emitSelectionChanged(ev, settings) {
|
|
1990
|
+
if (settings.OnSelectionChangedCallback) {
|
|
1991
|
+
this.throttla("selchange", () => {
|
|
1992
|
+
var axis = ev.target;
|
|
1993
|
+
var start = new Date(axis.minZoomed);
|
|
1994
|
+
var end = new Date(axis.maxZoomed);
|
|
1995
|
+
var initial = axis.min == axis.minZoomed && axis.max == axis.maxZoomed;
|
|
1996
|
+
settings.OnSelectionChangedCallback({ from: start, to: end, initial: initial });
|
|
1997
|
+
}, 150);
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
/** @ignore */
|
|
2001
|
+
createSeries(chart, name) {
|
|
2002
|
+
let series = chart.series.push(new am4charts.LineSeries());
|
|
2003
|
+
series.dataFields.dateX = "date";
|
|
2004
|
+
series.name = name[0].toUpperCase() + name.slice(1);
|
|
2005
|
+
series.dataFields.valueY = name;
|
|
2006
|
+
series.tooltipText = "[#000]{valueY.value}[/]";
|
|
2007
|
+
//series.tooltip.background.fill = am4core.color("#FFF");
|
|
2008
|
+
series.tooltip.getStrokeFromObject = true;
|
|
2009
|
+
series.tooltip.background.strokeWidth = 3;
|
|
2010
|
+
series.tooltip.getFillFromObject = false;
|
|
2011
|
+
series.fillOpacity = 0.6;
|
|
2012
|
+
series.strokeWidth = 2;
|
|
2013
|
+
series.stacked = true;
|
|
2014
|
+
return series;
|
|
2015
|
+
}
|
|
2016
|
+
/** @ignore */
|
|
2017
|
+
throttla(id, func, throttleTime) {
|
|
2018
|
+
//Se ho la funzione che vuole eseguire ripulisco quel timeout
|
|
2019
|
+
if (this.executionTimers[id])
|
|
2020
|
+
clearTimeout(this.executionTimers[id]);
|
|
2021
|
+
//Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
|
|
2022
|
+
this.executionTimers[id] = setTimeout(() => { func(); this.executionTimers[id] = null; }, throttleTime);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
|
|
1962
2026
|
/**
|
|
1963
2027
|
* Componente specifico per la graficazione di un qualsiasi tipo di grafico.
|
|
1964
2028
|
*
|
|
@@ -2555,89 +2619,6 @@ class PagedChartData {
|
|
|
2555
2619
|
}
|
|
2556
2620
|
}
|
|
2557
2621
|
|
|
2558
|
-
/**
|
|
2559
|
-
* Componente che si occupa della paginazione dei grafici qualora servisse
|
|
2560
|
-
*/
|
|
2561
|
-
class PageChartSelector {
|
|
2562
|
-
constructor() {
|
|
2563
|
-
/**
|
|
2564
|
-
* Indica un cambio di pagina ed emette un oggetto con i dati attuali e l'indice attuale.
|
|
2565
|
-
*
|
|
2566
|
-
* Qualora la proprietà **data** fosse null indica un evento di "loading"
|
|
2567
|
-
*/
|
|
2568
|
-
this.onPageChange = new EventEmitter();
|
|
2569
|
-
}
|
|
2570
|
-
/**
|
|
2571
|
-
* @ignore
|
|
2572
|
-
*/
|
|
2573
|
-
ngOnChanges() {
|
|
2574
|
-
if (!(this.Items || this.Dtos) || (this.Items || this.Dtos).length == 0)
|
|
2575
|
-
throw new Error("Chart array cannot be empty!");
|
|
2576
|
-
var idx = (this.StartIndex || 0);
|
|
2577
|
-
this.currentindex = idx;
|
|
2578
|
-
this.currentpage = idx + 1;
|
|
2579
|
-
this.handlePageChange();
|
|
2580
|
-
}
|
|
2581
|
-
/**
|
|
2582
|
-
* Gestisce un cambio pagina inviando al callback **onPageChange** i dati attuali (siano essi il Dto per il caricamento dati i
|
|
2583
|
-
* o i dati già presenti) e l'indice di visualizzazione
|
|
2584
|
-
*/
|
|
2585
|
-
handlePageChange() {
|
|
2586
|
-
this.finalIndex = this.currentpage - 1;
|
|
2587
|
-
this.currentindex = this.currentpage - 1;
|
|
2588
|
-
let data = this.Items && this.Items.length > 0 ? this.Items[this.finalIndex].data : this.Dtos[this.finalIndex];
|
|
2589
|
-
this.onPageChange.emit({ data: data, index: this.finalIndex });
|
|
2590
|
-
}
|
|
2591
|
-
/**
|
|
2592
|
-
* Visualizza il grafico successivo
|
|
2593
|
-
*/
|
|
2594
|
-
Next() {
|
|
2595
|
-
// Per passare da page a index è sempre un -1
|
|
2596
|
-
this.currentpage++;
|
|
2597
|
-
this.onPageChange.emit({ data: null, index: this.currentpage - 1 });
|
|
2598
|
-
// Delay pseudo-intelligente per click compulsivi.
|
|
2599
|
-
// Se dopo questo delay sono andato avanti solo di 1 effettuo il callback altrimenti incremento l'indice
|
|
2600
|
-
setTimeout(() => {
|
|
2601
|
-
if (this.currentindex == this.currentpage - 2)
|
|
2602
|
-
this.handlePageChange();
|
|
2603
|
-
else
|
|
2604
|
-
this.currentindex++;
|
|
2605
|
-
}, this.BrowseDelayMs);
|
|
2606
|
-
}
|
|
2607
|
-
/**
|
|
2608
|
-
* Visualizza il grafico precedente
|
|
2609
|
-
*/
|
|
2610
|
-
Previous() {
|
|
2611
|
-
// Per passare da page a index è sempre un -1
|
|
2612
|
-
this.currentpage--;
|
|
2613
|
-
this.onPageChange.emit({ data: null, index: this.currentpage - 1 });
|
|
2614
|
-
// Delay pseudo-intelligente per click compulsivi.
|
|
2615
|
-
// Se dopo questo delay sono andato indietro solo di 1 effettuo il callback altrimenti decremento l'indice
|
|
2616
|
-
setTimeout(() => {
|
|
2617
|
-
if (this.currentindex == this.currentpage)
|
|
2618
|
-
this.handlePageChange();
|
|
2619
|
-
else
|
|
2620
|
-
this.currentindex--;
|
|
2621
|
-
}, this.BrowseDelayMs);
|
|
2622
|
-
}
|
|
2623
|
-
}
|
|
2624
|
-
PageChartSelector.decorators = [
|
|
2625
|
-
{ type: Component, args: [{
|
|
2626
|
-
selector: "chart-pager",
|
|
2627
|
-
template: "<div *ngIf=\"(Items || Dtos) && (Items || Dtos).length > 0\" class=\"pcs-no-selection\">\r\n <div class=\"pcs-button pcs-backward\">\r\n <svg class=\"pcs-svg-header\">\r\n <g class=\"pcs-svg-button-container\" role=\"button\" (click)=\"currentpage != 1 && Previous(); $event.stopPropagation(); $event.preventDefault();\">\r\n <!--Pulsante e freccettina all'interno-->\r\n <g class=\"pcs-svg-button\" [style.cursor]=\"currentpage == 1 ? 'not-allowed' : 'pointer'\"><path d=\"M3,0 L53.027,0 a3,3 0 0 1 3,3 L56.027,36.817 a3,3 0 0 1 -3,3 L3,39.817 a3,3 0 0 1 -3,-3 L0,3 a3,3 0 0 1 3,-3 Z\"></path></g>\r\n <g class=\"pcs-svg-arrow pcs-svg-arrow-left\"><path d=\"M26,14H10l5.17-6.79A2,2,0,0,0,12,4.79l-7.62,10a2,2,0,0,0,0,2.42l7.62,10a2,2,0,0,0,3.18-2.42L10,18H26a2,2,0,0,0,0-4Z\"></path></g>\r\n </g>\r\n </svg>\r\n </div>\r\n <div class=\"pcs-infos\">\r\n <ng-container *ngIf=\"headerInner_tr\">\r\n <ng-container *ngTemplateOutlet=\"headerInner_tr; context : {$implicit: (Items || Dtos)[currentpage - 1]}\"></ng-container>\r\n </ng-container>\r\n </div>\r\n <div class=\"pcs-button pcs-forward\">\r\n <svg class=\"pcs-svg-header\">\r\n <g class=\"pcs-svg-button-container\" role=\"button\" (click)=\"(Items || Dtos).length != currentpage && Next(); $event.stopPropagation(); $event.preventDefault();\">\r\n <!--Pulsante e freccettina all'interno-->\r\n <g class=\"pcs-svg-button\" [style.cursor]=\"(Items || Dtos).length == currentpage ? 'not-allowed' : 'pointer'\"><path d=\"M3,0 L53.027,0 a3,3 0 0 1 3,3 L56.027,36.817 a3,3 0 0 1 -3,3 L3,39.817 a3,3 0 0 1 -3,-3 L0,3 a3,3 0 0 1 3,-3 Z\"></path></g>\r\n <g class=\"pcs-svg-arrow pcs-svg-arrow-right\"><path d=\"M26,14H10l5.17-6.79A2,2,0,0,0,12,4.79l-7.62,10a2,2,0,0,0,0,2.42l7.62,10a2,2,0,0,0,3.18-2.42L10,18H26a2,2,0,0,0,0-4Z\"></path></g>\r\n </g>\r\n </svg>\r\n </div>\r\n <div style=\"clear: both;\"></div>\r\n</div>",
|
|
2628
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2629
|
-
styles: [".pcs-button{width:60px}.pcs-forward{float:right;text-align:end}.pcs-backward{float:left}.pcs-svg-header{width:57px;height:40px}.pcs-svg-button-container{outline:medium none currentcolor}.pcs-svg-arrow{pointer-events:none;fill:#555}.pcs-svg-arrow-right{transform:translate(44px,36px) rotate(180deg)}.pcs-svg-arrow-left{transform:translate(13px,4px)}.pcs-svg-button{fill:#d9d9d9;stroke:#fff;fill-opacity:1;stroke-opacity:1}.pcs-svg-button:hover{fill:#a3a3a3;cursor:pointer}.pcs-infos{width:calc(100% - 120px);height:44px;float:left}.pcs-no-selection{-webkit-user-select:none;-moz-user-select:none;-khtml-user-select:none;-ms-user-select:none}"]
|
|
2630
|
-
},] }
|
|
2631
|
-
];
|
|
2632
|
-
PageChartSelector.propDecorators = {
|
|
2633
|
-
Items: [{ type: Input }],
|
|
2634
|
-
Dtos: [{ type: Input }],
|
|
2635
|
-
BrowseDelayMs: [{ type: Input }],
|
|
2636
|
-
StartIndex: [{ type: Input }],
|
|
2637
|
-
onPageChange: [{ type: Output }],
|
|
2638
|
-
headerInner_tr: [{ type: ContentChild, args: ['header_inner', { static: false },] }]
|
|
2639
|
-
};
|
|
2640
|
-
|
|
2641
2622
|
/** Componenti esportati dal modulo */
|
|
2642
2623
|
const COMPONENTS = [
|
|
2643
2624
|
EsChartComponent,
|
|
@@ -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,
|
|
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, PageChartSelector, 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 };
|
|
2686
2667
|
//# sourceMappingURL=esfaenza-es-charts.js.map
|