@tetacom/svg-charts 1.7.13 → 1.7.15

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.
@@ -32,6 +32,7 @@ export declare class ChartComponent implements OnInit, OnDestroy {
32
32
  annotationMove: EventEmitter<IChartEvent<Annotation>>;
33
33
  zoomServiceInstance: EventEmitter<ZoomService>;
34
34
  brushServiceInstance: EventEmitter<BrushService>;
35
+ configUpdated: EventEmitter<string>;
35
36
  set config(config: IChartConfig);
36
37
  private _alive;
37
38
  constructor(chartService: ChartService, zoomService: ZoomService, brushService: BrushService, scaleService: ScaleService);
@@ -39,5 +40,5 @@ export declare class ChartComponent implements OnInit, OnDestroy {
39
40
  ngOnInit(): void;
40
41
  ngOnDestroy(): void;
41
42
  static ɵfac: i0.ɵɵFactoryDeclaration<ChartComponent, never>;
42
- static ɵcmp: i0.ɵɵComponentDeclaration<ChartComponent, "teta-svg-chart", never, { "config": { "alias": "config"; "required": false; }; }, { "pointerMove": "pointerMove"; "plotBandsMove": "plotBandsMove"; "plotBandClick": "plotBandClick"; "plotBandContextMenu": "plotBandContextMenu"; "plotLinesMove": "plotLinesMove"; "pointMove": "pointMove"; "chartClick": "chartClick"; "chartContextMenu": "chartContextMenu"; "annotationContextMenu": "annotationContextMenu"; "annotationClick": "annotationClick"; "annotationMove": "annotationMove"; "zoomServiceInstance": "zoomServiceInstance"; "brushServiceInstance": "brushServiceInstance"; }, never, ["*"], true, never>;
43
+ static ɵcmp: i0.ɵɵComponentDeclaration<ChartComponent, "teta-svg-chart", never, { "config": { "alias": "config"; "required": false; }; }, { "pointerMove": "pointerMove"; "plotBandsMove": "plotBandsMove"; "plotBandClick": "plotBandClick"; "plotBandContextMenu": "plotBandContextMenu"; "plotLinesMove": "plotLinesMove"; "pointMove": "pointMove"; "chartClick": "chartClick"; "chartContextMenu": "chartContextMenu"; "annotationContextMenu": "annotationContextMenu"; "annotationClick": "annotationClick"; "annotationMove": "annotationMove"; "zoomServiceInstance": "zoomServiceInstance"; "brushServiceInstance": "brushServiceInstance"; "configUpdated": "configUpdated"; }, never, ["*"], true, never>;
43
44
  }
@@ -0,0 +1 @@
1
+ export declare const chartConfigPostfix = "series_config";
@@ -26,6 +26,7 @@ export declare class ChartService {
26
26
  annotationContextMenu: Observable<IChartEvent<Annotation>>;
27
27
  chartClick: Observable<IChartEvent<BasePoint>>;
28
28
  chartContextMenu: Observable<IChartEvent<BasePoint>>;
29
+ configUpdated: Observable<string>;
29
30
  private config$;
30
31
  private configUpdates$;
31
32
  private size$;
@@ -38,7 +39,6 @@ export declare class ChartService {
38
39
  private chartContextMenu$;
39
40
  private annotationEvent$;
40
41
  private annotationMove$;
41
- private static _hiddenSeriesPostfix;
42
42
  constructor();
43
43
  setConfig(config: IChartConfig): void;
44
44
  setSize(size: DOMRect): void;
@@ -55,6 +55,7 @@ export declare class ChartService {
55
55
  emitChartClick(event: IChartEvent<BasePoint>): void;
56
56
  emitChartContextMenu(event: IChartEvent<BasePoint>): void;
57
57
  private saveCookie;
58
+ private getConfigString;
58
59
  private restoreLocalStorage;
59
60
  private setDefaults;
60
61
  private setPreparationData;
@@ -12,6 +12,8 @@ import * as i1 from '@angular/forms';
12
12
  import { FormsModule } from '@angular/forms';
13
13
  import { TranslocoPipe } from '@jsverse/transloco';
14
14
 
15
+ const chartConfigPostfix = 'series_config';
16
+
15
17
  class BroadcastService {
16
18
  constructor() {
17
19
  this.zoomEmitter = new ReplaySubject(1);
@@ -174,14 +176,13 @@ const defaultSeriesConfig = () => ({
174
176
  xAxisIndex: 0,
175
177
  yAxisIndex: 0,
176
178
  fillType: FillType.default,
177
- color: 'coral',
179
+ color: '#FF7F50',
178
180
  visible: true,
179
181
  enabled: true,
180
182
  clipPointsDirection: ClipPointsDirection.x,
181
183
  });
182
184
 
183
185
  class ChartService {
184
- static { this._hiddenSeriesPostfix = 'series_config'; }
185
186
  constructor() {
186
187
  this.config$ = new BehaviorSubject(defaultChartConfig());
187
188
  this.configUpdates$ = new Subject();
@@ -204,7 +205,7 @@ class ChartService {
204
205
  bufferSize: 1,
205
206
  refCount: true,
206
207
  }));
207
- this.config = merge(initialConfig, this.configUpdates$).pipe(shareReplay({
208
+ this.config = merge(initialConfig, this.configUpdates$).pipe(filter((_) => _ !== null), shareReplay({
208
209
  bufferSize: 1,
209
210
  refCount: true,
210
211
  }));
@@ -223,6 +224,9 @@ class ChartService {
223
224
  this.annotationMove = this.annotationMove$.asObservable();
224
225
  this.plotBandClick = this.plotBandEvent$.asObservable().pipe(filter((_) => _?.event?.type === 'click'));
225
226
  this.plotBandContextMenu = this.plotBandEvent$.asObservable().pipe(filter((_) => _?.event?.type === 'contextmenu'));
227
+ this.configUpdated = this.configUpdates$.asObservable().pipe(map((config) => {
228
+ return this.getConfigString(config);
229
+ }));
226
230
  }
227
231
  setConfig(config) {
228
232
  this.clearTooltips();
@@ -267,7 +271,8 @@ class ChartService {
267
271
  const config = await lastValueFrom(this.initialConfig.pipe(take(1)));
268
272
  if (!config.name)
269
273
  return;
270
- localStorage.removeItem(`${config.name}_${ChartService._hiddenSeriesPostfix}`);
274
+ localStorage.removeItem(`${config.name}_${chartConfigPostfix}`);
275
+ this.configUpdates$.next(null);
271
276
  this.config$.next({ ...config });
272
277
  }
273
278
  emitMoveAnnotation(event) {
@@ -294,7 +299,11 @@ class ChartService {
294
299
  saveCookie(config) {
295
300
  if (!config.name)
296
301
  return;
297
- const series = config.series?.map((_) => {
302
+ const seriesConfig = this.getConfigString(config);
303
+ localStorage.setItem(`${config.name}_${chartConfigPostfix}`, seriesConfig);
304
+ }
305
+ getConfigString(config) {
306
+ const series = config?.series?.map((_) => {
298
307
  return {
299
308
  id: _.id,
300
309
  visible: _.visible,
@@ -305,12 +314,12 @@ class ChartService {
305
314
  strokeWidth: _.style?.strokeWidth,
306
315
  };
307
316
  });
308
- localStorage.setItem(`${config.name}_${ChartService._hiddenSeriesPostfix}`, JSON.stringify(series));
317
+ return JSON.stringify(series ?? null);
309
318
  }
310
319
  restoreLocalStorage(config) {
311
320
  if (!config.name)
312
321
  return config;
313
- const seriesConfig = localStorage.getItem(`${config.name}_${ChartService._hiddenSeriesPostfix}`);
322
+ const seriesConfig = localStorage.getItem(`${config.name}_${chartConfigPostfix}`);
314
323
  if (seriesConfig) {
315
324
  const json = JSON.parse(seriesConfig);
316
325
  config.series = config.series.map((serie, index) => {
@@ -2908,6 +2917,7 @@ class ChartComponent {
2908
2917
  this.annotationMove = new EventEmitter();
2909
2918
  this.zoomServiceInstance = new EventEmitter();
2910
2919
  this.brushServiceInstance = new EventEmitter();
2920
+ this.configUpdated = new EventEmitter();
2911
2921
  this._alive = true;
2912
2922
  this.svcConfig = this.chartService.config;
2913
2923
  this.hasSeriesData = this.svcConfig.pipe(map((_) => _.series?.length > 0 && _.series?.some((_) => _.data?.length > 0)));
@@ -2980,12 +2990,15 @@ class ChartComponent {
2980
2990
  this.chartService.annotationMove.pipe(takeWhile(() => this._alive)).subscribe((_) => {
2981
2991
  this.annotationMove.emit(_);
2982
2992
  });
2993
+ this.chartService.configUpdated.pipe(takeWhile(() => this._alive)).subscribe((_) => {
2994
+ this.configUpdated.emit(_);
2995
+ });
2983
2996
  }
2984
2997
  ngOnDestroy() {
2985
2998
  this._alive = false;
2986
2999
  }
2987
3000
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ChartComponent, deps: [{ token: ChartService }, { token: ZoomService }, { token: BrushService }, { token: ScaleService }], target: i0.ɵɵFactoryTarget.Component }); }
2988
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: ChartComponent, isStandalone: true, selector: "teta-svg-chart", inputs: { config: "config" }, outputs: { pointerMove: "pointerMove", plotBandsMove: "plotBandsMove", plotBandClick: "plotBandClick", plotBandContextMenu: "plotBandContextMenu", plotLinesMove: "plotLinesMove", pointMove: "pointMove", chartClick: "chartClick", chartContextMenu: "chartContextMenu", annotationContextMenu: "annotationContextMenu", annotationClick: "annotationClick", annotationMove: "annotationMove", zoomServiceInstance: "zoomServiceInstance", brushServiceInstance: "brushServiceInstance" }, providers: [ChartService, ZoomService, ScaleService, BrushService], ngImport: i0, template: "@if ({ hasSeriesData: hasSeriesData | async, svcConfig: svcConfig | async }; as data) {\n @if (data.hasSeriesData === true) {\n <div class=\"column column_auto\">\n <teta-chart-container class=\"chart-container position-relative\"></teta-chart-container>\n </div>\n @if (data.svcConfig.legend?.enable === true) {\n <teta-legend [series]=\"data.svcConfig.series\"></teta-legend>\n }\n } @else {\n <div class=\"column column_auto justify-content-center\">\n <span class=\"font-body-3 color-text-40 overflow-hidden text-overflow-ellipsis nowrap text-align-center\">\n <div #ref><ng-content></ng-content></div>\n @if (!ref.hasChildNodes()) {\n <span> No data </span>\n }\n </span>\n </div>\n }\n}\n", styles: [":host{position:relative;display:flex;flex-direction:column;height:100%;width:100%}\n"], dependencies: [{ kind: "component", type: ChartContainerComponent, selector: "teta-chart-container" }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "component", type: LegendComponent, selector: "teta-legend", inputs: ["series"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
3001
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: ChartComponent, isStandalone: true, selector: "teta-svg-chart", inputs: { config: "config" }, outputs: { pointerMove: "pointerMove", plotBandsMove: "plotBandsMove", plotBandClick: "plotBandClick", plotBandContextMenu: "plotBandContextMenu", plotLinesMove: "plotLinesMove", pointMove: "pointMove", chartClick: "chartClick", chartContextMenu: "chartContextMenu", annotationContextMenu: "annotationContextMenu", annotationClick: "annotationClick", annotationMove: "annotationMove", zoomServiceInstance: "zoomServiceInstance", brushServiceInstance: "brushServiceInstance", configUpdated: "configUpdated" }, providers: [ChartService, ZoomService, ScaleService, BrushService], ngImport: i0, template: "@if ({ hasSeriesData: hasSeriesData | async, svcConfig: svcConfig | async }; as data) {\n @if (data.hasSeriesData === true) {\n <div class=\"column column_auto\">\n <teta-chart-container class=\"chart-container position-relative\"></teta-chart-container>\n </div>\n @if (data.svcConfig.legend?.enable === true) {\n <teta-legend [series]=\"data.svcConfig.series\"></teta-legend>\n }\n } @else {\n <div class=\"column column_auto justify-content-center\">\n <span class=\"font-body-3 color-text-40 overflow-hidden text-overflow-ellipsis nowrap text-align-center\">\n <div #ref><ng-content></ng-content></div>\n @if (!ref.hasChildNodes()) {\n <span> No data </span>\n }\n </span>\n </div>\n }\n}\n", styles: [":host{position:relative;display:flex;flex-direction:column;height:100%;width:100%}\n"], dependencies: [{ kind: "component", type: ChartContainerComponent, selector: "teta-chart-container" }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "component", type: LegendComponent, selector: "teta-legend", inputs: ["series"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2989
3002
  }
2990
3003
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ChartComponent, decorators: [{
2991
3004
  type: Component,
@@ -3016,6 +3029,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
3016
3029
  type: Output
3017
3030
  }], brushServiceInstance: [{
3018
3031
  type: Output
3032
+ }], configUpdated: [{
3033
+ type: Output
3019
3034
  }], config: [{
3020
3035
  type: Input
3021
3036
  }] } });
@@ -3067,5 +3082,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
3067
3082
  * Generated bundle index. Do not edit.
3068
3083
  */
3069
3084
 
3070
- export { AreaSeriesComponent, Axis, AxisOrientation, BarSeriesComponent, BlockAreaSeriesComponent, BlockHorizontalSeriesComponent, BlockSeriesComponent, BroadcastService, BrushMessage, BrushService, BrushType, ChartBounds, ChartComponent, ChartService, ClipPointsDirection, DragPointType, FillDirection, FillType, LegendComponent, LineSeriesComponent, LinearSeriesBaseComponent, PlotBand, PlotLine, ScaleService, ScaleType, ScatterSeriesComponent, SeriesBaseComponent, SeriesType, TooltipTracking, ZoomBehaviorType, ZoomMessage, ZoomService, ZoomType, generateTicks, getTextWidth };
3085
+ export { AreaSeriesComponent, Axis, AxisOrientation, BarSeriesComponent, BlockAreaSeriesComponent, BlockHorizontalSeriesComponent, BlockSeriesComponent, BroadcastService, BrushMessage, BrushService, BrushType, ChartBounds, ChartComponent, ChartService, ClipPointsDirection, DragPointType, FillDirection, FillType, LegendComponent, LineSeriesComponent, LinearSeriesBaseComponent, PlotBand, PlotLine, ScaleService, ScaleType, ScatterSeriesComponent, SeriesBaseComponent, SeriesType, TooltipTracking, ZoomBehaviorType, ZoomMessage, ZoomService, ZoomType, chartConfigPostfix, generateTicks, getTextWidth };
3071
3086
  //# sourceMappingURL=tetacom-svg-charts.mjs.map