@visionaris-bruno/vs-echarts 9.1.0 → 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.
|
@@ -4,7 +4,7 @@ import { BarChart, PieChart, LineChart, ScatterChart, FunnelChart, SunburstChart
|
|
|
4
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
|
|
@@ -105,6 +190,47 @@ function provideVSEcharts() {
|
|
|
105
190
|
initializeEcharts();
|
|
106
191
|
return provideEchartsCore({ echarts });
|
|
107
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
|
+
}
|
|
108
234
|
function defaultOptionsOverrides() {
|
|
109
235
|
return {
|
|
110
236
|
tooltip: {
|
|
@@ -191,44 +317,6 @@ function defaultOptionsOverrides() {
|
|
|
191
317
|
},
|
|
192
318
|
};
|
|
193
319
|
}
|
|
194
|
-
const defaultValueFormatter = (value) => `${value}`;
|
|
195
|
-
|
|
196
|
-
// TODO: Exportar valores por defecto de vs-echarts.config.ts por este servicio y actualizar en logica de frontend.
|
|
197
|
-
class VSEchartsConfigService {
|
|
198
|
-
vsEchartsConfig;
|
|
199
|
-
mapping = {
|
|
200
|
-
es: 'ES',
|
|
201
|
-
en: 'EN',
|
|
202
|
-
us: 'EN',
|
|
203
|
-
de: 'DE',
|
|
204
|
-
fr: 'FR',
|
|
205
|
-
it: 'IT',
|
|
206
|
-
pt: 'PT-br',
|
|
207
|
-
br: 'PT-br',
|
|
208
|
-
};
|
|
209
|
-
constructor(vsEchartsConfig) {
|
|
210
|
-
this.vsEchartsConfig = vsEchartsConfig;
|
|
211
|
-
}
|
|
212
|
-
setLocale(language) {
|
|
213
|
-
if (!language) {
|
|
214
|
-
this.vsEchartsConfig.locale = 'ES';
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
const echartsLocale = this.mapping[language.toLowerCase()] || 'ES';
|
|
218
|
-
this.vsEchartsConfig.locale = echartsLocale;
|
|
219
|
-
}
|
|
220
|
-
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 });
|
|
221
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, providedIn: 'root' });
|
|
222
|
-
}
|
|
223
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, decorators: [{
|
|
224
|
-
type: Injectable,
|
|
225
|
-
args: [{
|
|
226
|
-
providedIn: 'root'
|
|
227
|
-
}]
|
|
228
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
229
|
-
type: Inject,
|
|
230
|
-
args: [VS_ECHARTS_CONFIG]
|
|
231
|
-
}] }] });
|
|
232
320
|
|
|
233
321
|
/**
|
|
234
322
|
* BaseEchartsComponent
|
|
@@ -445,12 +533,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
445
533
|
*
|
|
446
534
|
* @see {@link VisionarisFrontEnd/docs/technical/echarts-architecture.md}
|
|
447
535
|
*/
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
+
};
|
|
454
556
|
/**
|
|
455
557
|
* Formats a value using native browser SI suffixes (k, M, B).
|
|
456
558
|
*/
|
|
@@ -1145,7 +1247,8 @@ class BoxPlotBuilder {
|
|
|
1145
1247
|
{
|
|
1146
1248
|
type: 'slider',
|
|
1147
1249
|
height: 20,
|
|
1148
|
-
bottom: 10
|
|
1250
|
+
bottom: 10,
|
|
1251
|
+
labelFormatter: (value) => valueToLocale(value)
|
|
1149
1252
|
}
|
|
1150
1253
|
];
|
|
1151
1254
|
}
|
|
@@ -3187,7 +3290,7 @@ class EChartsHeatmapCalendar extends BaseEchartsComponent {
|
|
|
3187
3290
|
top: this.calendarPaddings.visualMapTop,
|
|
3188
3291
|
formatter: (dv) => {
|
|
3189
3292
|
const value = dv ?? '';
|
|
3190
|
-
return value
|
|
3293
|
+
return valueToLocale(value);
|
|
3191
3294
|
},
|
|
3192
3295
|
}, // dinamico
|
|
3193
3296
|
calendar: {
|
|
@@ -3272,5 +3375,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
3272
3375
|
* Generated bundle index. Do not edit.
|
|
3273
3376
|
*/
|
|
3274
3377
|
|
|
3275
|
-
export { BaseEchartsComponent, EChartsAreaComponent, EChartsAreaStackComponent, EChartsBarStackedComponent, EChartsBarStackedRadialComponent, EChartsHBarComponent, EChartsHBarStackedComponent, EChartsHBoxplotComponent, EChartsHeatmapCalendar, 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 };
|
|
3276
3379
|
//# sourceMappingURL=visionaris-bruno-vs-echarts.mjs.map
|