@visionaris-bruno/vs-echarts 9.0.7 → 9.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { provideEchartsCore, NgxEchartsDirective } from 'ngx-echarts';
|
|
2
2
|
import * as echarts from 'echarts/core';
|
|
3
|
-
import { BarChart, PieChart, LineChart, ScatterChart, FunnelChart, SunburstChart, SankeyChart, BoxplotChart } from 'echarts/charts';
|
|
4
|
-
import { TooltipComponent, GridComponent, LegendComponent, GraphicComponent, PolarComponent, DatasetComponent, DataZoomComponent } from 'echarts/components';
|
|
3
|
+
import { BarChart, PieChart, LineChart, ScatterChart, FunnelChart, SunburstChart, SankeyChart, BoxplotChart, HeatmapChart } from 'echarts/charts';
|
|
4
|
+
import { TooltipComponent, GridComponent, CalendarComponent, LegendComponent, GraphicComponent, PolarComponent, DatasetComponent, DataZoomComponent, VisualMapComponent } from 'echarts/components';
|
|
5
5
|
import { CanvasRenderer, SVGRenderer } from 'echarts/renderers';
|
|
6
6
|
import * as i0 from '@angular/core';
|
|
7
|
-
import {
|
|
7
|
+
import { Inject, Injectable, InjectionToken, EventEmitter, inject, Output, Input, ViewChild, Directive, Component } from '@angular/core';
|
|
8
8
|
import langES from 'echarts/lib/i18n/langES.js';
|
|
9
9
|
import langDE from 'echarts/lib/i18n/langDE.js';
|
|
10
10
|
import langFR from 'echarts/lib/i18n/langFR.js';
|
|
@@ -17,6 +17,55 @@ import { CommonModule } from '@angular/common';
|
|
|
17
17
|
import { merge as merge$1 } from 'lodash';
|
|
18
18
|
import { TranslateService } from '@ngx-translate/core';
|
|
19
19
|
|
|
20
|
+
// TODO: Exportar valores por defecto de vs-echarts.config.ts por este servicio y actualizar en logica de frontend.
|
|
21
|
+
let activeLocale = undefined;
|
|
22
|
+
function getActiveLocale() {
|
|
23
|
+
return activeLocale;
|
|
24
|
+
}
|
|
25
|
+
function setActiveLocale(locale) {
|
|
26
|
+
activeLocale = locale;
|
|
27
|
+
}
|
|
28
|
+
class VSEchartsConfigService {
|
|
29
|
+
vsEchartsConfig;
|
|
30
|
+
mapping = {
|
|
31
|
+
es: 'ES',
|
|
32
|
+
en: 'EN',
|
|
33
|
+
us: 'EN',
|
|
34
|
+
de: 'DE',
|
|
35
|
+
fr: 'FR',
|
|
36
|
+
it: 'IT',
|
|
37
|
+
pt: 'PT-br',
|
|
38
|
+
br: 'PT-br',
|
|
39
|
+
};
|
|
40
|
+
constructor(vsEchartsConfig) {
|
|
41
|
+
this.vsEchartsConfig = vsEchartsConfig;
|
|
42
|
+
if (this.vsEchartsConfig?.locale) {
|
|
43
|
+
setActiveLocale(this.vsEchartsConfig.locale);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
setLocale(language) {
|
|
47
|
+
if (!language) {
|
|
48
|
+
this.vsEchartsConfig.locale = 'ES';
|
|
49
|
+
setActiveLocale('ES');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const echartsLocale = this.mapping[language.toLowerCase()] || 'ES';
|
|
53
|
+
this.vsEchartsConfig.locale = echartsLocale;
|
|
54
|
+
setActiveLocale(echartsLocale);
|
|
55
|
+
}
|
|
56
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, deps: [{ token: VS_ECHARTS_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
57
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, providedIn: 'root' });
|
|
58
|
+
}
|
|
59
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, decorators: [{
|
|
60
|
+
type: Injectable,
|
|
61
|
+
args: [{
|
|
62
|
+
providedIn: 'root'
|
|
63
|
+
}]
|
|
64
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
65
|
+
type: Inject,
|
|
66
|
+
args: [VS_ECHARTS_CONFIG]
|
|
67
|
+
}] }] });
|
|
68
|
+
|
|
20
69
|
/**
|
|
21
70
|
* Global Design Tokens for ECharts
|
|
22
71
|
*/
|
|
@@ -44,7 +93,7 @@ function getDefaultPalette() {
|
|
|
44
93
|
* pero por algun motivo esto es distinto en este tipo de graficos.
|
|
45
94
|
*
|
|
46
95
|
* apache echarts version: 5.6.0
|
|
47
|
-
*/
|
|
96
|
+
* */
|
|
48
97
|
const fixPieDataIndexInside = (e) => {
|
|
49
98
|
/** selected serie index */
|
|
50
99
|
const ssi = e.fromActionPayload.seriesIndex;
|
|
@@ -56,11 +105,47 @@ const fixPieDataIndexInside = (e) => {
|
|
|
56
105
|
e.fromActionPayload.dataIndexInside = fixedDataIndex; // aplico corrección de index inside.
|
|
57
106
|
return e;
|
|
58
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Retorna valor con formato local establecido por configuracion de biblioteca.
|
|
110
|
+
* Utilizara el del navegador si el locale y activeLocale es indefinido.
|
|
111
|
+
* @param value
|
|
112
|
+
* @param opts
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
const valueToLocale = (value, opts) => {
|
|
116
|
+
const locale = opts?.locale ?? getActiveLocale();
|
|
117
|
+
const officialLocale = locale ? localeMapper[locale] : undefined;
|
|
118
|
+
// 1. Si ya es una instancia de Date
|
|
119
|
+
if (value instanceof Date) {
|
|
120
|
+
return value.toLocaleString(officialLocale);
|
|
121
|
+
}
|
|
122
|
+
// 2. Si es un string, intentamos ver si es una fecha válida
|
|
123
|
+
if (typeof value === 'string') {
|
|
124
|
+
const parsedDate = Date.parse(value);
|
|
125
|
+
if (!isNaN(parsedDate)) {
|
|
126
|
+
return new Date(parsedDate).toLocaleString(officialLocale);
|
|
127
|
+
}
|
|
128
|
+
// Si no era una fecha válida, devolvemos el string tal cual
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
// 3. Si es un número o bigint
|
|
132
|
+
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
133
|
+
return value.toLocaleString(officialLocale);
|
|
134
|
+
}
|
|
135
|
+
// Fallback por si llega algo inesperado (null, undefined, etc.)
|
|
136
|
+
return String(value);
|
|
137
|
+
};
|
|
138
|
+
const defaultValueFormatter = (value) => {
|
|
139
|
+
return valueToLocale(value);
|
|
140
|
+
};
|
|
59
141
|
|
|
60
142
|
/// <reference path="./typings.d.ts" />
|
|
61
143
|
const VS_ECHARTS_CONFIG = new InjectionToken('VS_ECHARTS_CONFIG', {
|
|
62
144
|
providedIn: 'root',
|
|
63
|
-
factory: () => ({
|
|
145
|
+
factory: () => ({
|
|
146
|
+
renderer: 'svg',
|
|
147
|
+
locale: 'AR',
|
|
148
|
+
}),
|
|
64
149
|
});
|
|
65
150
|
/**
|
|
66
151
|
* Inicialización centralizada de ECharts para evitar duplicación y efectos secundarios
|
|
@@ -78,6 +163,8 @@ function initializeEcharts() {
|
|
|
78
163
|
BoxplotChart,
|
|
79
164
|
TooltipComponent,
|
|
80
165
|
GridComponent,
|
|
166
|
+
HeatmapChart,
|
|
167
|
+
CalendarComponent,
|
|
81
168
|
LegendComponent,
|
|
82
169
|
CanvasRenderer,
|
|
83
170
|
SVGRenderer,
|
|
@@ -85,6 +172,7 @@ function initializeEcharts() {
|
|
|
85
172
|
PolarComponent,
|
|
86
173
|
DatasetComponent,
|
|
87
174
|
DataZoomComponent,
|
|
175
|
+
VisualMapComponent,
|
|
88
176
|
]);
|
|
89
177
|
// Register additional locales in ECharts
|
|
90
178
|
echarts.registerLocale('ES', langES);
|
|
@@ -102,6 +190,47 @@ function provideVSEcharts() {
|
|
|
102
190
|
initializeEcharts();
|
|
103
191
|
return provideEchartsCore({ echarts });
|
|
104
192
|
}
|
|
193
|
+
// 2. Diccionario de mapeo interno a códigos BCP 47 oficiales
|
|
194
|
+
const localeMapper = {
|
|
195
|
+
ZH: 'zh-CN', // Chino Simplificado (puedes cambiarlo a zh-TW si prefieres)
|
|
196
|
+
EN: 'en-US', // Inglés (o en-GB)
|
|
197
|
+
AR: 'ar-EG', // Árabe
|
|
198
|
+
CS: 'cs-CZ', // Checo
|
|
199
|
+
DE: 'de-DE', // Alemán
|
|
200
|
+
EL: 'el-GR', // Griego
|
|
201
|
+
ES: 'es-ES', // Español
|
|
202
|
+
FA: 'fa-IR', // Persa
|
|
203
|
+
FI: 'fi-FI', // Finlandés
|
|
204
|
+
FR: 'fr-FR', // Francés
|
|
205
|
+
HU: 'hu-HU', // Húngaro
|
|
206
|
+
IT: 'it-IT', // Italiano
|
|
207
|
+
JA: 'ja-JP', // Japonés
|
|
208
|
+
KO: 'ko-KR', // Coreano
|
|
209
|
+
LV: 'lv-LV', // Letón
|
|
210
|
+
'nb-NO': 'nb-NO', // Noruego Bokmål (ya es estándar)
|
|
211
|
+
NL: 'nl-NL', // Neerlandés
|
|
212
|
+
PL: 'pl-PL', // Polaco
|
|
213
|
+
'PT-br': 'pt-BR', // Portugués de Brasil (corregido a camelCase estándar)
|
|
214
|
+
RO: 'ro-RO', // Rumano
|
|
215
|
+
RU: 'ru-RU', // Ruso
|
|
216
|
+
SI: 'si-LK', // Cingalés
|
|
217
|
+
SV: 'sv-SE', // Sueco
|
|
218
|
+
TH: 'th-TH', // Tailandés
|
|
219
|
+
TR: 'tr-TR', // Turco
|
|
220
|
+
UK: 'uk-UA', // Ucraniano
|
|
221
|
+
VI: 'vi-VN', // Vietnamita
|
|
222
|
+
};
|
|
223
|
+
// 3. Función formateadora universal (para números)
|
|
224
|
+
function formatNumberByLocale(value, customLocale, options) {
|
|
225
|
+
// Obtenemos el locale oficial, si no existe por alguna razón, usamos el del sistema
|
|
226
|
+
const officialLocale = localeMapper[customLocale] || undefined;
|
|
227
|
+
return value.toLocaleString(officialLocale, options);
|
|
228
|
+
}
|
|
229
|
+
// 4. Función formateadora universal (para fechas)
|
|
230
|
+
function formatDateByLocale(date, customLocale, options) {
|
|
231
|
+
const officialLocale = localeMapper[customLocale] || undefined;
|
|
232
|
+
return date.toLocaleString(officialLocale, options);
|
|
233
|
+
}
|
|
105
234
|
function defaultOptionsOverrides() {
|
|
106
235
|
return {
|
|
107
236
|
tooltip: {
|
|
@@ -183,46 +312,11 @@ function defaultOptionsOverrides() {
|
|
|
183
312
|
hBoxplot: {
|
|
184
313
|
series: {}
|
|
185
314
|
},
|
|
315
|
+
heatmapCalendar: {
|
|
316
|
+
series: {},
|
|
317
|
+
},
|
|
186
318
|
};
|
|
187
319
|
}
|
|
188
|
-
const defaultValueFormatter = (value) => `${value}`;
|
|
189
|
-
|
|
190
|
-
// TODO: Exportar valores por defecto de vs-echarts.config.ts por este servicio y actualizar en logica de frontend.
|
|
191
|
-
class VSEchartsConfigService {
|
|
192
|
-
vsEchartsConfig;
|
|
193
|
-
mapping = {
|
|
194
|
-
es: 'ES',
|
|
195
|
-
en: 'EN',
|
|
196
|
-
us: 'EN',
|
|
197
|
-
de: 'DE',
|
|
198
|
-
fr: 'FR',
|
|
199
|
-
it: 'IT',
|
|
200
|
-
pt: 'PT-br',
|
|
201
|
-
br: 'PT-br',
|
|
202
|
-
};
|
|
203
|
-
constructor(vsEchartsConfig) {
|
|
204
|
-
this.vsEchartsConfig = vsEchartsConfig;
|
|
205
|
-
}
|
|
206
|
-
setLocale(language) {
|
|
207
|
-
if (!language) {
|
|
208
|
-
this.vsEchartsConfig.locale = 'ES';
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const echartsLocale = this.mapping[language.toLowerCase()] || 'ES';
|
|
212
|
-
this.vsEchartsConfig.locale = echartsLocale;
|
|
213
|
-
}
|
|
214
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, deps: [{ token: VS_ECHARTS_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
215
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, providedIn: 'root' });
|
|
216
|
-
}
|
|
217
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, decorators: [{
|
|
218
|
-
type: Injectable,
|
|
219
|
-
args: [{
|
|
220
|
-
providedIn: 'root'
|
|
221
|
-
}]
|
|
222
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
223
|
-
type: Inject,
|
|
224
|
-
args: [VS_ECHARTS_CONFIG]
|
|
225
|
-
}] }] });
|
|
226
320
|
|
|
227
321
|
/**
|
|
228
322
|
* BaseEchartsComponent
|
|
@@ -247,6 +341,7 @@ class BaseEchartsComponent {
|
|
|
247
341
|
/** Subject para debouncing de actualizaciones. ReplaySubject asegura no perder el primer renderizado. */
|
|
248
342
|
updateSubject = new ReplaySubject(1);
|
|
249
343
|
updateSubscription;
|
|
344
|
+
afterSetOptionsHook;
|
|
250
345
|
chartInstance;
|
|
251
346
|
vsEchartsConfig = (() => {
|
|
252
347
|
try {
|
|
@@ -290,6 +385,9 @@ class BaseEchartsComponent {
|
|
|
290
385
|
replaceMerge,
|
|
291
386
|
};
|
|
292
387
|
this.chartInstance?.setOption(chartOptions, _opts);
|
|
388
|
+
if (this.afterSetOptionsHook) {
|
|
389
|
+
this.afterSetOptionsHook();
|
|
390
|
+
}
|
|
293
391
|
}
|
|
294
392
|
// metodos protegidos //
|
|
295
393
|
dispatchAction(type, d) {
|
|
@@ -435,12 +533,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
435
533
|
*
|
|
436
534
|
* @see {@link VisionarisFrontEnd/docs/technical/echarts-architecture.md}
|
|
437
535
|
*/
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
536
|
+
const formattersCache = new Map();
|
|
537
|
+
function getCompactFormatter() {
|
|
538
|
+
const locale = getActiveLocale();
|
|
539
|
+
const officialLocale = locale ? localeMapper[locale] : undefined;
|
|
540
|
+
const cacheKey = officialLocale || 'default';
|
|
541
|
+
let formatter = formattersCache.get(cacheKey);
|
|
542
|
+
if (!formatter) {
|
|
543
|
+
formatter = new Intl.NumberFormat(officialLocale, {
|
|
544
|
+
notation: 'compact',
|
|
545
|
+
compactDisplay: 'short',
|
|
546
|
+
maximumFractionDigits: 1
|
|
547
|
+
});
|
|
548
|
+
formattersCache.set(cacheKey, formatter);
|
|
549
|
+
}
|
|
550
|
+
return formatter;
|
|
551
|
+
}
|
|
552
|
+
// Wrap with custom formatter implementation to keep identical signature/API dynamically
|
|
553
|
+
const compactFormatter = {
|
|
554
|
+
format: (value) => getCompactFormatter().format(value)
|
|
555
|
+
};
|
|
444
556
|
/**
|
|
445
557
|
* Formats a value using native browser SI suffixes (k, M, B).
|
|
446
558
|
*/
|
|
@@ -1135,7 +1247,8 @@ class BoxPlotBuilder {
|
|
|
1135
1247
|
{
|
|
1136
1248
|
type: 'slider',
|
|
1137
1249
|
height: 20,
|
|
1138
|
-
bottom: 10
|
|
1250
|
+
bottom: 10,
|
|
1251
|
+
labelFormatter: (value) => valueToLocale(value)
|
|
1139
1252
|
}
|
|
1140
1253
|
];
|
|
1141
1254
|
}
|
|
@@ -1935,6 +2048,123 @@ class SankeyBuilder {
|
|
|
1935
2048
|
}
|
|
1936
2049
|
}
|
|
1937
2050
|
|
|
2051
|
+
class HeatmapCalendarBuilder {
|
|
2052
|
+
baseProduct;
|
|
2053
|
+
result = {};
|
|
2054
|
+
calendarHeight = 0;
|
|
2055
|
+
valueFormatter = defaultValueFormatter;
|
|
2056
|
+
palette = [];
|
|
2057
|
+
colorResolver;
|
|
2058
|
+
constructor(baseProduct) {
|
|
2059
|
+
this.baseProduct = baseProduct;
|
|
2060
|
+
}
|
|
2061
|
+
reset() {
|
|
2062
|
+
this.result = {};
|
|
2063
|
+
}
|
|
2064
|
+
addCommons() {
|
|
2065
|
+
const opts = {
|
|
2066
|
+
palette: this.palette,
|
|
2067
|
+
};
|
|
2068
|
+
const commonsOverrides = getCommons(opts);
|
|
2069
|
+
merge$1(this.result, commonsOverrides, { grid: {} });
|
|
2070
|
+
}
|
|
2071
|
+
addDataset(data, opts) { }
|
|
2072
|
+
addVisualmap(data) { }
|
|
2073
|
+
addCalendar(data) { }
|
|
2074
|
+
addSeries(data, overrides, opts) {
|
|
2075
|
+
if (!data || !data.dimensions || !data.source || data.source.length === 0)
|
|
2076
|
+
return;
|
|
2077
|
+
const calendarOverrides = opts.calendar;
|
|
2078
|
+
const visualMapOverrides = opts.visualMap;
|
|
2079
|
+
const measureDim = data.dimensions.find(d => d.name !== 'category');
|
|
2080
|
+
const dimKey = measureDim ? measureDim.name : '';
|
|
2081
|
+
const dataByYear = new Map();
|
|
2082
|
+
let min = Infinity;
|
|
2083
|
+
let max = -Infinity;
|
|
2084
|
+
data.source.forEach((s) => {
|
|
2085
|
+
if (!s.category)
|
|
2086
|
+
return;
|
|
2087
|
+
const dateObj = new Date(s.category);
|
|
2088
|
+
if (isNaN(dateObj.getTime()))
|
|
2089
|
+
return;
|
|
2090
|
+
const year = dateObj.getFullYear().toString();
|
|
2091
|
+
const value = s[dimKey] !== undefined && s[dimKey] !== null ? Number(s[dimKey]) : 0;
|
|
2092
|
+
if (value < min)
|
|
2093
|
+
min = value;
|
|
2094
|
+
if (value > max)
|
|
2095
|
+
max = value;
|
|
2096
|
+
if (!dataByYear.has(year)) {
|
|
2097
|
+
dataByYear.set(year, []);
|
|
2098
|
+
}
|
|
2099
|
+
const formattedDate = dateObj.toISOString().split('T')[0];
|
|
2100
|
+
dataByYear.get(year).push([formattedDate, value]);
|
|
2101
|
+
});
|
|
2102
|
+
if (min === Infinity)
|
|
2103
|
+
min = 0;
|
|
2104
|
+
if (max === -Infinity)
|
|
2105
|
+
max = 0;
|
|
2106
|
+
const sortedYears = Array.from(dataByYear.keys()).sort();
|
|
2107
|
+
const calendars = [];
|
|
2108
|
+
const series = [];
|
|
2109
|
+
sortedYears.forEach((year, index) => {
|
|
2110
|
+
calendars.push(merge$1({
|
|
2111
|
+
top: 120 + index * 180,
|
|
2112
|
+
range: year,
|
|
2113
|
+
}, calendarOverrides));
|
|
2114
|
+
series.push(merge$1({
|
|
2115
|
+
calendarIndex: index,
|
|
2116
|
+
data: dataByYear.get(year) || []
|
|
2117
|
+
}, overrides));
|
|
2118
|
+
});
|
|
2119
|
+
this.result.calendar = calendars;
|
|
2120
|
+
this.result.series = series;
|
|
2121
|
+
const visualMap = merge$1({
|
|
2122
|
+
min: min,
|
|
2123
|
+
max: max,
|
|
2124
|
+
}, visualMapOverrides);
|
|
2125
|
+
if (this.palette && this.palette.length > 0) {
|
|
2126
|
+
visualMap.inRange = {
|
|
2127
|
+
color: this.palette
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2130
|
+
this.result.visualMap = visualMap;
|
|
2131
|
+
}
|
|
2132
|
+
addTooltip(data, overrides) {
|
|
2133
|
+
const mainDim = data.dimensions.filter(d => d.name != 'category')[0];
|
|
2134
|
+
const valueFormatter = this.valueFormatter;
|
|
2135
|
+
const dimkey = mainDim.name, dimAlias = mainDim.displayName;
|
|
2136
|
+
const tooltipFormatter = (params) => {
|
|
2137
|
+
const date = params.value[params.encode['time']], value = params.value[params.encode['value']];
|
|
2138
|
+
return `<div style="text-align: center;" ><b>${date}</b></br>${params.marker} ${mainDim.displayName}</br><b>${valueFormatter(value, dimkey)}</b></div>`;
|
|
2139
|
+
};
|
|
2140
|
+
const tooltipOptions = getTooltipOptions({
|
|
2141
|
+
trigger: 'item',
|
|
2142
|
+
formatter: tooltipFormatter,
|
|
2143
|
+
});
|
|
2144
|
+
this.result.tooltip = tooltipOptions;
|
|
2145
|
+
}
|
|
2146
|
+
addPolar() { }
|
|
2147
|
+
addXAxis(data, overrides, type) { }
|
|
2148
|
+
addYAxis(data, overrides, type) { }
|
|
2149
|
+
addRadiusAxis(data, overrides) { }
|
|
2150
|
+
addAngleAxis(data, overrides) { }
|
|
2151
|
+
addLegend() { }
|
|
2152
|
+
addGraphic() { }
|
|
2153
|
+
addDataZoom() { }
|
|
2154
|
+
setValueFormatter(formatter) {
|
|
2155
|
+
this.valueFormatter = formatter;
|
|
2156
|
+
}
|
|
2157
|
+
setPalette(palette) {
|
|
2158
|
+
this.palette = palette;
|
|
2159
|
+
}
|
|
2160
|
+
setColorResolver(resolver) {
|
|
2161
|
+
this.colorResolver = resolver;
|
|
2162
|
+
}
|
|
2163
|
+
getResult() {
|
|
2164
|
+
return this.result;
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
|
|
1938
2168
|
/**
|
|
1939
2169
|
* Director de Builds.
|
|
1940
2170
|
*/
|
|
@@ -2206,6 +2436,30 @@ class VSECDirector {
|
|
|
2206
2436
|
this.builder.addTooltip(data, overrides.tooltip);
|
|
2207
2437
|
this.builder.addDataZoom();
|
|
2208
2438
|
}
|
|
2439
|
+
makeHeatmapCalendar(data, overrides, opts = {}) {
|
|
2440
|
+
if (this.builder instanceof HeatmapCalendarBuilder == false) {
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
const { valueFormatter = undefined, palette = undefined, colorResolver = undefined, axisTypes = {
|
|
2444
|
+
x: 'value',
|
|
2445
|
+
y: 'category',
|
|
2446
|
+
}, } = opts;
|
|
2447
|
+
this.builder.reset();
|
|
2448
|
+
// El orden importa, primero callbacks y despues componentes.
|
|
2449
|
+
// chart callbaks
|
|
2450
|
+
if (valueFormatter)
|
|
2451
|
+
this.builder.setValueFormatter(valueFormatter);
|
|
2452
|
+
const product = this.builder.baseProduct;
|
|
2453
|
+
const seriesOverrides = merge$1({}, product.baseOptions.series, overrides[product.chartKey].series);
|
|
2454
|
+
// chart components
|
|
2455
|
+
this.builder.addCommons();
|
|
2456
|
+
const seriesConfigOpts = {
|
|
2457
|
+
calendar: product.baseOptions.calendar,
|
|
2458
|
+
visualMap: product.baseOptions.visualMap,
|
|
2459
|
+
};
|
|
2460
|
+
this.builder.addSeries(data, seriesOverrides, seriesConfigOpts);
|
|
2461
|
+
this.builder.addTooltip(data, overrides.tooltip);
|
|
2462
|
+
}
|
|
2209
2463
|
}
|
|
2210
2464
|
|
|
2211
2465
|
/**
|
|
@@ -3008,6 +3262,104 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
3008
3262
|
], template: "<div\n class=\"echarts-container\"\n echarts\n [options]=\"{}\"\n [initOpts]=\"initOptions\"\n [autoResize]=\"true\"\n (chartInit)=\"onChartInit($event)\"\n></div>\n", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"] }]
|
|
3009
3263
|
}] });
|
|
3010
3264
|
|
|
3265
|
+
class EChartsHeatmapCalendar extends BaseEchartsComponent {
|
|
3266
|
+
/** aires para el calculo de resize y posicionamientos de distintos componentes */
|
|
3267
|
+
calendarPaddings = {
|
|
3268
|
+
visualMapTop: 5,
|
|
3269
|
+
};
|
|
3270
|
+
baseSeriesOptions = {
|
|
3271
|
+
type: 'heatmap',
|
|
3272
|
+
coordinateSystem: 'calendar',
|
|
3273
|
+
selectedMode: 'single',
|
|
3274
|
+
select: {
|
|
3275
|
+
itemStyle: {
|
|
3276
|
+
borderWidth: 2,
|
|
3277
|
+
borderColor: EChartsTokens.sBorderColor,
|
|
3278
|
+
shadowColor: EChartsTokens.sShadowColor,
|
|
3279
|
+
shadowBlur: 6,
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
};
|
|
3283
|
+
baseProduct = {
|
|
3284
|
+
chartKey: 'heatmapCalendar',
|
|
3285
|
+
baseOptions: {
|
|
3286
|
+
visualMap: {
|
|
3287
|
+
calculable: true,
|
|
3288
|
+
orient: 'horizontal',
|
|
3289
|
+
left: 'center',
|
|
3290
|
+
top: this.calendarPaddings.visualMapTop,
|
|
3291
|
+
formatter: (dv) => {
|
|
3292
|
+
const value = dv ?? '';
|
|
3293
|
+
return valueToLocale(value);
|
|
3294
|
+
},
|
|
3295
|
+
}, // dinamico
|
|
3296
|
+
calendar: {
|
|
3297
|
+
cellSize: ['auto', 20],
|
|
3298
|
+
right: 5,
|
|
3299
|
+
left: 60,
|
|
3300
|
+
yearLabel: { show: true },
|
|
3301
|
+
dayLabel: { firstDay: 1 },
|
|
3302
|
+
},
|
|
3303
|
+
series: this.baseSeriesOptions, // dinamico, uno por año.
|
|
3304
|
+
}
|
|
3305
|
+
};
|
|
3306
|
+
builder = new HeatmapCalendarBuilder(this.baseProduct);
|
|
3307
|
+
director = new VSECDirector(this.builder);
|
|
3308
|
+
make() {
|
|
3309
|
+
const makeOpts = {
|
|
3310
|
+
palette: this.palette,
|
|
3311
|
+
valueFormatter: this.valueFormatter,
|
|
3312
|
+
colorResolver: this.colorResolver,
|
|
3313
|
+
};
|
|
3314
|
+
this.director.makeHeatmapCalendar(this.data, this.optionsOverrides, makeOpts);
|
|
3315
|
+
}
|
|
3316
|
+
afterSetOptionsHook = () => {
|
|
3317
|
+
if (!this.chartInstance)
|
|
3318
|
+
return;
|
|
3319
|
+
let chartHeight = 0;
|
|
3320
|
+
const gElements = this.chartInstance.getDom().getElementsByTagName("g");
|
|
3321
|
+
for (let i = 0; i < gElements.length; i++) {
|
|
3322
|
+
const ge = gElements[i];
|
|
3323
|
+
const geHeight = ge.getBBox().height;
|
|
3324
|
+
if (chartHeight < geHeight) {
|
|
3325
|
+
chartHeight = geHeight;
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
const { visualMapTop } = this.calendarPaddings;
|
|
3329
|
+
/**
|
|
3330
|
+
* aire inferior para el svg maestro.
|
|
3331
|
+
*/
|
|
3332
|
+
const svgBottom = 5;
|
|
3333
|
+
this.chartInstance.resize({ height: chartHeight + visualMapTop + svgBottom });
|
|
3334
|
+
};
|
|
3335
|
+
onChartClick(event) {
|
|
3336
|
+
if (event.componentType === 'series') {
|
|
3337
|
+
const dimension = this.data.dimensions.filter(d => d.name != 'category')[0];
|
|
3338
|
+
const dimensionAlias = dimension.displayName;
|
|
3339
|
+
const dimensionKey = dimension.name;
|
|
3340
|
+
const itemValue = event.value[event.encode['value']];
|
|
3341
|
+
const date = event.value[event.encode['time']];
|
|
3342
|
+
// opero event para que sea compatible con el de base
|
|
3343
|
+
event.value = {
|
|
3344
|
+
category: date,
|
|
3345
|
+
[dimensionKey]: itemValue,
|
|
3346
|
+
};
|
|
3347
|
+
event.name = date;
|
|
3348
|
+
event.seriesName = dimensionAlias;
|
|
3349
|
+
super.onChartClick(event);
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EChartsHeatmapCalendar, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
3353
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: EChartsHeatmapCalendar, isStandalone: true, selector: "vs-echarts-heatmapCalendar", usesInheritance: true, ngImport: i0, template: "<div\n class=\"echarts-container\"\n echarts\n [options]=\"{}\"\n [initOpts]=\"initOptions\"\n [autoResize]=\"true\"\n (chartInit)=\"onChartInit($event)\"\n (chartClick)=\"onChartClick($event)\"\n (chartSelectChanged)=\"onChartSelectChanged($event)\"\n></div>", styles: [".echarts-container{width:100%;height:100%;position:relative;overflow-y:auto;scrollbar-gutter:stable}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: NgxEchartsDirective, selector: "echarts, [echarts]", inputs: ["options", "theme", "initOpts", "merge", "autoResize", "loading", "loadingType", "loadingOpts"], outputs: ["chartInit", "optionsError", "chartClick", "chartDblClick", "chartMouseDown", "chartMouseMove", "chartMouseUp", "chartMouseOver", "chartMouseOut", "chartGlobalOut", "chartContextMenu", "chartHighlight", "chartDownplay", "chartSelectChanged", "chartLegendSelectChanged", "chartLegendSelected", "chartLegendUnselected", "chartLegendLegendSelectAll", "chartLegendLegendInverseSelect", "chartLegendScroll", "chartDataZoom", "chartDataRangeSelected", "chartGraphRoam", "chartGeoRoam", "chartTreeRoam", "chartTimelineChanged", "chartTimelinePlayChanged", "chartRestore", "chartDataViewChanged", "chartMagicTypeChanged", "chartGeoSelectChanged", "chartGeoSelected", "chartGeoUnselected", "chartAxisAreaSelected", "chartBrush", "chartBrushEnd", "chartBrushSelected", "chartGlobalCursorTaken", "chartRendered", "chartFinished"], exportAs: ["echarts"] }] });
|
|
3354
|
+
}
|
|
3355
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EChartsHeatmapCalendar, decorators: [{
|
|
3356
|
+
type: Component,
|
|
3357
|
+
args: [{ selector: 'vs-echarts-heatmapCalendar', standalone: true, imports: [
|
|
3358
|
+
CommonModule,
|
|
3359
|
+
NgxEchartsDirective,
|
|
3360
|
+
], template: "<div\n class=\"echarts-container\"\n echarts\n [options]=\"{}\"\n [initOpts]=\"initOptions\"\n [autoResize]=\"true\"\n (chartInit)=\"onChartInit($event)\"\n (chartClick)=\"onChartClick($event)\"\n (chartSelectChanged)=\"onChartSelectChanged($event)\"\n></div>", styles: [".echarts-container{width:100%;height:100%;position:relative;overflow-y:auto;scrollbar-gutter:stable}\n"] }]
|
|
3361
|
+
}] });
|
|
3362
|
+
|
|
3011
3363
|
// Interfaces de Inputs de Base EChart Component //
|
|
3012
3364
|
// TopLevelFormatterParams
|
|
3013
3365
|
|
|
@@ -3023,5 +3375,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
3023
3375
|
* Generated bundle index. Do not edit.
|
|
3024
3376
|
*/
|
|
3025
3377
|
|
|
3026
|
-
export { BaseEchartsComponent, EChartsAreaComponent, EChartsAreaStackComponent, EChartsBarStackedComponent, EChartsBarStackedRadialComponent, EChartsHBarComponent, EChartsHBarStackedComponent, EChartsHBoxplotComponent, EChartsSunburstComponent, EchartsBarComponent, EchartsFunnelComponent, EchartsLineComponent, EchartsPieComponent, EchartsRingComponent, EchartsSankeyComponent, EchartsScatterComponent, VSEchartsConfigService, defaultOptionsOverrides, provideVSEcharts };
|
|
3378
|
+
export { BaseEchartsComponent, EChartsAreaComponent, EChartsAreaStackComponent, EChartsBarStackedComponent, EChartsBarStackedRadialComponent, EChartsHBarComponent, EChartsHBarStackedComponent, EChartsHBoxplotComponent, EChartsHeatmapCalendar, EChartsSunburstComponent, EchartsBarComponent, EchartsFunnelComponent, EchartsLineComponent, EchartsPieComponent, EchartsRingComponent, EchartsSankeyComponent, EchartsScatterComponent, VSEchartsConfigService, defaultOptionsOverrides, getActiveLocale, provideVSEcharts, setActiveLocale };
|
|
3027
3379
|
//# sourceMappingURL=visionaris-bruno-vs-echarts.mjs.map
|