@visionaris-bruno/vs-echarts 8.5.1 → 8.6.0

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,12 @@ import { BarChart, PieChart, LineChart, ScatterChart, FunnelChart, SunburstChart
4
4
  import { TitleComponent, TooltipComponent, GridComponent, LegendComponent, GraphicComponent, ToolboxComponent, PolarComponent, DatasetComponent, DataZoomComponent } from 'echarts/components';
5
5
  import { CanvasRenderer, SVGRenderer } from 'echarts/renderers';
6
6
  import * as i0 from '@angular/core';
7
- import { EventEmitter, Output, Input, ViewChild, Directive, inject, Component } from '@angular/core';
7
+ import { InjectionToken, Inject, Injectable, EventEmitter, inject, Output, Input, ViewChild, Directive, Component } from '@angular/core';
8
+ import langES from 'echarts/lib/i18n/langES.js';
9
+ import langDE from 'echarts/lib/i18n/langDE.js';
10
+ import langFR from 'echarts/lib/i18n/langFR.js';
11
+ import langIT from 'echarts/lib/i18n/langIT.js';
12
+ import langPTbr from 'echarts/lib/i18n/langPT-br.js';
8
13
  import { ReplaySubject } from 'rxjs';
9
14
  import { debounceTime } from 'rxjs/operators';
10
15
  import merge from 'lodash/merge';
@@ -52,6 +57,11 @@ const fixPieDataIndexInside = (e) => {
52
57
  return e;
53
58
  };
54
59
 
60
+ /// <reference path="./typings.d.ts" />
61
+ const VS_ECHARTS_CONFIG = new InjectionToken('VS_ECHARTS_CONFIG', {
62
+ providedIn: 'root',
63
+ factory: () => ({ renderer: 'svg' }),
64
+ });
55
65
  /**
56
66
  * Inicialización centralizada de ECharts para evitar duplicación y efectos secundarios
57
67
  * no controlados en componentes standalone.
@@ -81,6 +91,13 @@ function initializeEcharts() {
81
91
  DatasetComponent,
82
92
  DataZoomComponent,
83
93
  ]);
94
+ // Register additional locales in ECharts
95
+ echarts.registerLocale('ES', langES);
96
+ echarts.registerLocale('DE', langDE);
97
+ echarts.registerLocale('FR', langFR);
98
+ echarts.registerLocale('IT', langIT);
99
+ echarts.registerLocale('PT-br', langPTbr);
100
+ echarts.registerLocale('PT', langPTbr);
84
101
  initialized = true;
85
102
  }
86
103
  /**
@@ -175,6 +192,43 @@ function defaultOptionsOverrides() {
175
192
  };
176
193
  }
177
194
 
195
+ // TODO: Exportar valores por defecto de vs-echarts.config.ts por este servicio y actualizar en logica de frontend.
196
+ class VSEchartsConfigService {
197
+ vsEchartsConfig;
198
+ mapping = {
199
+ es: 'ES',
200
+ en: 'EN',
201
+ us: 'EN',
202
+ de: 'DE',
203
+ fr: 'FR',
204
+ it: 'IT',
205
+ pt: 'PT-br',
206
+ br: 'PT-br',
207
+ };
208
+ constructor(vsEchartsConfig) {
209
+ this.vsEchartsConfig = vsEchartsConfig;
210
+ }
211
+ setLocale(language) {
212
+ if (!language) {
213
+ this.vsEchartsConfig.locale = 'ES';
214
+ return;
215
+ }
216
+ const echartsLocale = this.mapping[language.toLowerCase()] || 'ES';
217
+ this.vsEchartsConfig.locale = echartsLocale;
218
+ }
219
+ 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 });
220
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, providedIn: 'root' });
221
+ }
222
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: VSEchartsConfigService, decorators: [{
223
+ type: Injectable,
224
+ args: [{
225
+ providedIn: 'root'
226
+ }]
227
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
228
+ type: Inject,
229
+ args: [VS_ECHARTS_CONFIG]
230
+ }] }] });
231
+
178
232
  /**
179
233
  * BaseEchartsComponent
180
234
  *
@@ -199,12 +253,21 @@ class BaseEchartsComponent {
199
253
  updateSubject = new ReplaySubject(1);
200
254
  updateSubscription;
201
255
  chartInstance;
256
+ vsEchartsConfig = (() => {
257
+ try {
258
+ return inject(VS_ECHARTS_CONFIG, { optional: true });
259
+ }
260
+ catch {
261
+ return null;
262
+ }
263
+ })();
202
264
  /** Opciones de inicializacion de echarts
203
265
  *
204
266
  * NgxEchartsDirective.initOpts
205
267
  */
206
268
  initOptions = {
207
- renderer: 'svg', // svg se visualiza mejor en el reescalado de tableros.
269
+ renderer: this.vsEchartsConfig?.renderer || 'svg',
270
+ locale: this.vsEchartsConfig?.locale,
208
271
  };
209
272
  constructor() {
210
273
  this.updateSubscription = this.updateSubject.pipe(debounceTime(150)).subscribe(options => {
@@ -2910,5 +2973,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
2910
2973
  * Generated bundle index. Do not edit.
2911
2974
  */
2912
2975
 
2913
- export { BaseEchartsComponent, EChartsAreaComponent, EChartsAreaStackComponent, EChartsBarStackedComponent, EChartsBarStackedRadialComponent, EChartsHBarComponent, EChartsHBarStackedComponent, EChartsHBoxplotComponent, EChartsSunburstComponent, EchartsBarComponent, EchartsFunnelComponent, EchartsLineComponent, EchartsPieComponent, EchartsRingComponent, EchartsSankeyComponent, EchartsScatterComponent, defaultOptionsOverrides, initializeEcharts, provideVSEcharts };
2976
+ export { BaseEchartsComponent, EChartsAreaComponent, EChartsAreaStackComponent, EChartsBarStackedComponent, EChartsBarStackedRadialComponent, EChartsHBarComponent, EChartsHBarStackedComponent, EChartsHBoxplotComponent, EChartsSunburstComponent, EchartsBarComponent, EchartsFunnelComponent, EchartsLineComponent, EchartsPieComponent, EchartsRingComponent, EchartsSankeyComponent, EchartsScatterComponent, VSEchartsConfigService, defaultOptionsOverrides };
2914
2977
  //# sourceMappingURL=visionaris-bruno-vs-echarts.mjs.map