cats-charts 0.0.28 → 0.0.29

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,11 +1,33 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, EventEmitter, Output, Input, ChangeDetectionStrategy, Component, HostListener } from '@angular/core';
2
+ import { EventEmitter, Output, Input, Component, Injectable, HostListener, ChangeDetectionStrategy } from '@angular/core';
3
3
  import * as echarts from 'echarts/core';
4
4
  import { NgxEchartsDirective, provideEchartsCore } from 'ngx-echarts';
5
5
  import { LineChart, BarChart as BarChart$1, PieChart as PieChart$1, CustomChart, SankeyChart as SankeyChart$1 } from 'echarts/charts';
6
6
  import { GridComponent, TooltipComponent, LegendComponent, TitleComponent, DatasetComponent, GraphicComponent } from 'echarts/components';
7
7
  import { CanvasRenderer } from 'echarts/renderers';
8
8
 
9
+ class RightClickCard {
10
+ cardPosition;
11
+ cardOptions;
12
+ contextMenuClick = new EventEmitter();
13
+ onMenuClick(item) {
14
+ this.contextMenuClick.emit(item);
15
+ // this.closeMenu();
16
+ }
17
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: RightClickCard, deps: [], target: i0.ɵɵFactoryTarget.Component });
18
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: RightClickCard, isStandalone: true, selector: "lib-right-click-card", inputs: { cardPosition: "cardPosition", cardOptions: "cardOptions" }, outputs: { contextMenuClick: "contextMenuClick" }, ngImport: i0, template: "<div\n class=\"context-card\"\n [style.left.px]=\"cardPosition.x\"\n [style.top.px]=\"cardPosition.y\"\n (click)=\"$event.stopPropagation()\"\n>\n @for (item of cardOptions; track item.value) {\n <div class=\"context-item\" (click)=\"onMenuClick(item)\">\n @if (item.icon) {\n <img [src]=\"item.icon\" alt=\"icon\" />\n }\n\n <span>{{ item.label }}</span>\n </div>\n }\n</div>\n", styles: [".context-card{position:absolute;background:#fff;border-radius:10px;padding:6px 0;min-width:160px;box-shadow:0 10px 25px #00000026;z-index:9999}.context-item{display:flex;align-items:center;gap:8px;padding:8px 14px;cursor:pointer;transition:background .2s ease}.context-item:hover{background:#f3f3f3}\n"] });
19
+ }
20
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: RightClickCard, decorators: [{
21
+ type: Component,
22
+ args: [{ selector: 'lib-right-click-card', imports: [], template: "<div\n class=\"context-card\"\n [style.left.px]=\"cardPosition.x\"\n [style.top.px]=\"cardPosition.y\"\n (click)=\"$event.stopPropagation()\"\n>\n @for (item of cardOptions; track item.value) {\n <div class=\"context-item\" (click)=\"onMenuClick(item)\">\n @if (item.icon) {\n <img [src]=\"item.icon\" alt=\"icon\" />\n }\n\n <span>{{ item.label }}</span>\n </div>\n }\n</div>\n", styles: [".context-card{position:absolute;background:#fff;border-radius:10px;padding:6px 0;min-width:160px;box-shadow:0 10px 25px #00000026;z-index:9999}.context-item{display:flex;align-items:center;gap:8px;padding:8px 14px;cursor:pointer;transition:background .2s ease}.context-item:hover{background:#f3f3f3}\n"] }]
23
+ }], propDecorators: { cardPosition: [{
24
+ type: Input
25
+ }], cardOptions: [{
26
+ type: Input
27
+ }], contextMenuClick: [{
28
+ type: Output
29
+ }] } });
30
+
9
31
  class Charts {
10
32
  legendSelected = {};
11
33
  defaultColors = ['#22c55e', '#3b82f6', '#ef4444', '#6b7280'];
@@ -478,64 +500,74 @@ echarts.use([
478
500
  ]);
479
501
  class LinesChart {
480
502
  chartService;
503
+ cdr;
481
504
  config;
482
505
  theme;
483
506
  events = [];
507
+ contextMenuOptions = [];
508
+ showContextMenu = false;
509
+ contextMenuClick = new EventEmitter();
484
510
  chartEvent = new EventEmitter();
485
511
  chartOption = {};
486
512
  chartInstance;
487
- constructor(chartService) {
513
+ cardPosition = { x: 0, y: 0 };
514
+ openCard = false;
515
+ constructor(chartService, cdr) {
488
516
  this.chartService = chartService;
517
+ this.cdr = cdr;
489
518
  }
490
519
  /* ------------------ CHANGE HANDLING ------------------ */
491
520
  ngOnChanges(changes) {
492
521
  if (!this.config)
493
522
  return;
494
- this.chartOption = this.buildOption(this.config);
495
- if (this.chartInstance) {
496
- this.chartInstance.setOption(this.chartOption, true);
523
+ if (changes['theme'] && this.chartInstance) {
524
+ this.chartInstance.dispose();
497
525
  }
526
+ this.buildOption();
498
527
  }
499
528
  /* ------------------ OPTION BUILDER ------------------ */
500
- buildOption(config) {
501
- const total = config.series?.reduce((seriesSum, series) => {
502
- const dataSum = series.data?.reduce((sum, value) => sum + value, 0) || 0;
503
- return seriesSum + dataSum;
504
- }, 0);
505
- return {
506
- backgroundColor: config.backgroundColor || 'transparent',
529
+ buildOption() {
530
+ this.chartOption = {
531
+ backgroundColor: this.config.backgroundColor || 'transparent',
532
+ color: this.config.colors || this.chartService.defaultColors,
507
533
  title: {
508
- show: config.showTitle ?? !!config.title,
509
- text: config.title,
510
- left: 'center',
534
+ show: this.config.showTitle ?? !!this.config.title,
535
+ text: this.config.title,
536
+ left: this.config.titlePosition || 'center',
511
537
  },
512
538
  tooltip: {
539
+ show: this.config.showTooltip,
513
540
  trigger: 'axis',
541
+ backgroundColor: 'transparent', // remove default box
542
+ borderWidth: 0,
514
543
  padding: 0,
515
- formatter: (params) => this.chartService.barLineTooltipFormatter(params),
544
+ confine: true,
545
+ formatter: (params) => this.config.tooltipFormatter
546
+ ? this.config.tooltipFormatter(params)
547
+ : this.chartService.barLineTooltipFormatter(params),
516
548
  },
517
- legend: {
549
+ legends: {
518
550
  show: false,
519
551
  },
520
552
  // graphic: this.chartService?.buildGraphicLegend(total, this.config, this.chartInstance),
521
553
  grid: this.config.isTrendChart
522
554
  ? { left: 0, right: 0, top: 0, bottom: 0 }
523
555
  : {
524
- left: config.grid?.left ?? '3%',
525
- right: config.grid?.right ?? '4%',
526
- bottom: config.grid?.bottom ?? '3%',
527
- top: config.grid?.top ?? '10%',
556
+ left: this.config.gridLeft ?? 0,
557
+ right: this.config.gridRight ?? 0,
558
+ bottom: this.config.gridBottom ?? 0,
559
+ top: this.config.gridTop ?? 0,
528
560
  containLabel: true,
529
561
  },
530
562
  xAxis: {
531
563
  show: !this.config.isTrendChart,
532
564
  type: 'category',
533
565
  boundaryGap: false,
534
- data: config.xAxisData,
566
+ data: this.config.xAxisData,
535
567
  axisLine: {
536
568
  show: this.config.showXAxisLine ?? true,
537
569
  },
538
- ...config.xAxis,
570
+ ...this.config.xAxis,
539
571
  },
540
572
  yAxis: {
541
573
  show: !this.config.isTrendChart,
@@ -544,15 +576,13 @@ class LinesChart {
544
576
  axisLine: {
545
577
  show: this.config.showYAxisLine ?? true,
546
578
  },
547
- ...config.yAxis,
579
+ ...this.config.yAxis,
548
580
  },
549
- series: config.series.map((s) => {
550
- const lineColor = s.color || '#3b82f6';
581
+ series: this.config.series.map((s) => {
582
+ const lineColor = s.areaColor || '#3b82f6';
551
583
  return {
552
- name: s.name,
553
584
  type: 'line',
554
585
  smooth: s.smooth ?? true,
555
- data: s.data,
556
586
  areaStyle: s.area
557
587
  ? {
558
588
  color: {
@@ -575,8 +605,16 @@ class LinesChart {
575
605
  opacity: 0.4,
576
606
  }
577
607
  : undefined,
578
- color: s.color,
579
- symbol: s.symbol,
608
+ ...s,
609
+ label: {
610
+ show: this.config.showLabel ?? false,
611
+ position: this.config.labelPosition ?? 'top',
612
+ ...(s['label'] ? s['label'] : {}),
613
+ },
614
+ itemStyle: {
615
+ borderRadius: this.config.borderRadius ?? 0,
616
+ ...(s['itemStyle'] ? s['itemStyle'] : {}),
617
+ },
580
618
  };
581
619
  }),
582
620
  };
@@ -584,6 +622,7 @@ class LinesChart {
584
622
  /* ------------------ INIT ------------------ */
585
623
  onChartInit(ec) {
586
624
  this.chartInstance = ec;
625
+ this.buildOption();
587
626
  this.bindEvents();
588
627
  }
589
628
  /* ------------------ EVENTS ------------------ */
@@ -595,6 +634,14 @@ class LinesChart {
595
634
  this.chartInstance.on(eventName, (params) => {
596
635
  if (eventName === 'contextmenu' && params.event?.event) {
597
636
  params.event.event.preventDefault();
637
+ const container = this.chartInstance.getDom();
638
+ const rect = container.getBoundingClientRect();
639
+ this.cardPosition = {
640
+ x: params.event.event.clientX - rect.left,
641
+ y: params.event.event.clientY - rect.top,
642
+ };
643
+ this.openCard = true;
644
+ this.cdr.markForCheck();
598
645
  }
599
646
  this.chartEvent.emit({
600
647
  type: eventName,
@@ -603,46 +650,43 @@ class LinesChart {
603
650
  });
604
651
  });
605
652
  }
653
+ onMenuClick(item) {
654
+ this.contextMenuClick.emit(item);
655
+ this.closeCard();
656
+ }
657
+ closeCard() {
658
+ this.openCard = false;
659
+ }
606
660
  /* ------------------ DESTROY ------------------ */
607
661
  ngOnDestroy() {
608
- this.chartInstance?.dispose();
662
+ if (this.chartInstance) {
663
+ this.chartInstance.off();
664
+ this.chartInstance.dispose();
665
+ }
609
666
  }
610
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: LinesChart, deps: [{ token: Charts }], target: i0.ɵɵFactoryTarget.Component });
611
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: LinesChart, isStandalone: true, selector: "lib-line-chart", inputs: { config: "config", theme: "theme", events: "events" }, outputs: { chartEvent: "chartEvent" }, providers: [provideEchartsCore({ echarts })], usesOnChanges: true, ngImport: i0, template: "\n<div\n echarts\n [options]=\"chartOption\"\n [theme]=\"theme\"\n (chartInit)=\"onChartInit($event)\"\n class=\"chart-container\">\n</div>\n", styles: [".chart-container{width:100%;height:100%}\n"], dependencies: [{ 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
667
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: LinesChart, deps: [{ token: Charts }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
668
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: LinesChart, isStandalone: true, selector: "lib-line-chart", inputs: { config: "config", theme: "theme", events: "events", contextMenuOptions: "contextMenuOptions", showContextMenu: "showContextMenu" }, outputs: { contextMenuClick: "contextMenuClick", chartEvent: "chartEvent" }, host: { listeners: { "document:click": "closeCard()" } }, providers: [provideEchartsCore({ echarts })], usesOnChanges: true, ngImport: i0, template: "<div\n echarts\n [options]=\"chartOption\"\n [theme]=\"theme\"\n (chartInit)=\"onChartInit($event)\"\n class=\"chart-container\"\n></div>\n@if (openCard) {\n <lib-right-click-card\n [cardOptions]=\"contextMenuOptions\"\n (contextMenuClick)=\"onMenuClick($event)\"\n [cardPosition]=\"cardPosition\"\n ></lib-right-click-card>\n}\n", styles: [".chart-container{width:100%;height:100%}\n"], dependencies: [{ 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"] }, { kind: "component", type: RightClickCard, selector: "lib-right-click-card", inputs: ["cardPosition", "cardOptions"], outputs: ["contextMenuClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
612
669
  }
613
670
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: LinesChart, decorators: [{
614
671
  type: Component,
615
- args: [{ selector: 'lib-line-chart', standalone: true, imports: [NgxEchartsDirective], providers: [provideEchartsCore({ echarts })], changeDetection: ChangeDetectionStrategy.OnPush, template: "\n<div\n echarts\n [options]=\"chartOption\"\n [theme]=\"theme\"\n (chartInit)=\"onChartInit($event)\"\n class=\"chart-container\">\n</div>\n", styles: [".chart-container{width:100%;height:100%}\n"] }]
616
- }], ctorParameters: () => [{ type: Charts }], propDecorators: { config: [{
672
+ args: [{ selector: 'lib-line-chart', standalone: true, imports: [NgxEchartsDirective, RightClickCard], providers: [provideEchartsCore({ echarts })], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n echarts\n [options]=\"chartOption\"\n [theme]=\"theme\"\n (chartInit)=\"onChartInit($event)\"\n class=\"chart-container\"\n></div>\n@if (openCard) {\n <lib-right-click-card\n [cardOptions]=\"contextMenuOptions\"\n (contextMenuClick)=\"onMenuClick($event)\"\n [cardPosition]=\"cardPosition\"\n ></lib-right-click-card>\n}\n", styles: [".chart-container{width:100%;height:100%}\n"] }]
673
+ }], ctorParameters: () => [{ type: Charts }, { type: i0.ChangeDetectorRef }], propDecorators: { config: [{
617
674
  type: Input
618
675
  }], theme: [{
619
676
  type: Input
620
677
  }], events: [{
621
678
  type: Input
622
- }], chartEvent: [{
623
- type: Output
624
- }] } });
625
-
626
- class RightClickCard {
627
- cardPosition;
628
- cardOptions;
629
- contextMenuClick = new EventEmitter();
630
- onMenuClick(item) {
631
- this.contextMenuClick.emit(item);
632
- // this.closeMenu();
633
- }
634
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: RightClickCard, deps: [], target: i0.ɵɵFactoryTarget.Component });
635
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: RightClickCard, isStandalone: true, selector: "lib-right-click-card", inputs: { cardPosition: "cardPosition", cardOptions: "cardOptions" }, outputs: { contextMenuClick: "contextMenuClick" }, ngImport: i0, template: "<div\n class=\"context-card\"\n [style.left.px]=\"cardPosition.x\"\n [style.top.px]=\"cardPosition.y\"\n (click)=\"$event.stopPropagation()\"\n>\n @for (item of cardOptions; track item.value) {\n <div class=\"context-item\" (click)=\"onMenuClick(item)\">\n @if (item.icon) {\n <img [src]=\"item.icon\" alt=\"icon\" />\n }\n\n <span>{{ item.label }}</span>\n </div>\n }\n</div>\n", styles: [".context-card{position:absolute;background:#fff;border-radius:10px;padding:6px 0;min-width:160px;box-shadow:0 10px 25px #00000026;z-index:9999}.context-item{display:flex;align-items:center;gap:8px;padding:8px 14px;cursor:pointer;transition:background .2s ease}.context-item:hover{background:#f3f3f3}\n"] });
636
- }
637
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: RightClickCard, decorators: [{
638
- type: Component,
639
- args: [{ selector: 'lib-right-click-card', imports: [], template: "<div\n class=\"context-card\"\n [style.left.px]=\"cardPosition.x\"\n [style.top.px]=\"cardPosition.y\"\n (click)=\"$event.stopPropagation()\"\n>\n @for (item of cardOptions; track item.value) {\n <div class=\"context-item\" (click)=\"onMenuClick(item)\">\n @if (item.icon) {\n <img [src]=\"item.icon\" alt=\"icon\" />\n }\n\n <span>{{ item.label }}</span>\n </div>\n }\n</div>\n", styles: [".context-card{position:absolute;background:#fff;border-radius:10px;padding:6px 0;min-width:160px;box-shadow:0 10px 25px #00000026;z-index:9999}.context-item{display:flex;align-items:center;gap:8px;padding:8px 14px;cursor:pointer;transition:background .2s ease}.context-item:hover{background:#f3f3f3}\n"] }]
640
- }], propDecorators: { cardPosition: [{
679
+ }], contextMenuOptions: [{
641
680
  type: Input
642
- }], cardOptions: [{
681
+ }], showContextMenu: [{
643
682
  type: Input
644
683
  }], contextMenuClick: [{
645
684
  type: Output
685
+ }], chartEvent: [{
686
+ type: Output
687
+ }], closeCard: [{
688
+ type: HostListener,
689
+ args: ['document:click']
646
690
  }] } });
647
691
 
648
692
  echarts.use([
@@ -686,35 +730,36 @@ class BarChart {
686
730
  // Common chart option
687
731
  this.chartOption = {
688
732
  backgroundColor: this.config.backgroundColor || 'transparent',
733
+ color: this.config.colors || this.chartService.defaultColors,
689
734
  title: {
690
735
  show: this.config.showTitle ?? !!this.config.title,
691
736
  text: this.config.title,
692
737
  left: this.config.titlePosition || 'center',
693
738
  },
694
- // tooltip: {
695
- // show: this.config.showTooltip ?? true,
696
- // trigger: 'axis',
697
- // },
698
739
  tooltip: {
740
+ show: this.config.showTooltip,
699
741
  trigger: 'axis',
700
742
  backgroundColor: 'transparent', // remove default box
701
743
  borderWidth: 0,
702
744
  padding: 0,
703
745
  confine: true,
704
- formatter: (params) => this.chartService.barLineTooltipFormatter(params),
746
+ formatter: (params) => this.config.tooltipFormatter
747
+ ? this.config.tooltipFormatter(params)
748
+ : this.chartService.barLineTooltipFormatter(params),
705
749
  },
706
750
  legends: {
707
751
  show: false,
708
752
  },
709
753
  grid: {
710
- left: this.config.gridLeft ?? '',
711
- right: this.config.gridRight ?? '',
712
- bottom: this.config.gridBottom ?? '',
754
+ left: this.config.gridLeft ?? 0,
755
+ right: this.config.gridRight ?? 0,
756
+ bottom: this.config.gridBottom ?? 0,
757
+ top: this.config.gridTop ?? 0,
713
758
  containLabel: true,
714
759
  },
715
760
  xAxis: {
716
761
  type: 'category',
717
- data: this.config.categories,
762
+ data: this.config.xAxisData,
718
763
  axisLine: { show: this.config.showXAxisLine ?? true },
719
764
  ...this.config.xAxis,
720
765
  },
@@ -723,58 +768,26 @@ class BarChart {
723
768
  axisLine: { show: this.config.showYAxisLine ?? true },
724
769
  ...this.config.yAxis,
725
770
  },
726
- // Handle both single-series and multi-series dynamically
727
- series: (() => {
728
- if (this.config.series && this.config.series.length) {
729
- // Multi-series (stacked or grouped)
730
- return this.config.series.map((s) => ({
731
- type: this.config.type ?? 'bar',
732
- name: s.name,
733
- data: s.data,
734
- stack: s.stack ?? undefined,
735
- barWidth: this.config.barWidth ?? '60%',
736
- color: s.color || this.config.colors,
737
- label: {
738
- show: this.config.showLabel ?? false,
739
- position: this.config.labelPosition ?? 'top',
740
- },
741
- itemStyle: {
742
- borderRadius: this.config.borderRadius ?? 0,
743
- },
744
- emphasis: {
745
- scale: false,
746
- },
747
- ...s,
748
- }));
749
- }
750
- else if (this.config.data) {
751
- // Single-series
752
- return [
753
- {
754
- type: this.config.type ?? 'bar',
755
- name: this.config.seriesName,
756
- data: this.config.data,
757
- barWidth: this.config.barWidth ?? 20,
758
- color: this.config.colors,
759
- label: {
760
- show: this.config.showLabel ?? false,
761
- position: this.config.labelPosition ?? 'top',
762
- },
763
- itemStyle: {
764
- borderRadius: this.config.borderRadius ?? 0,
765
- },
766
- emphasis: {
767
- focus: 'series',
768
- show: false,
769
- },
770
- // ...this.config,
771
- },
772
- ];
773
- }
774
- else {
775
- return [];
776
- }
777
- })(),
771
+ series: (this.config.series || []).map((s) => {
772
+ return {
773
+ type: 'bar',
774
+ stack: this.config.stacked ? 'total' : undefined,
775
+ emphasis: {
776
+ scale: false,
777
+ },
778
+ ...(this.config.barWidth && { barWidth: this.config.barWidth }),
779
+ ...s,
780
+ label: {
781
+ show: this.config.showLabel ?? false,
782
+ position: this.config.labelPosition ?? 'top',
783
+ ...(s['label'] ? s['label'] : {}),
784
+ },
785
+ itemStyle: {
786
+ borderRadius: this.config.borderRadius ?? 0,
787
+ ...(s['itemStyle'] ? s['itemStyle'] : {}),
788
+ },
789
+ };
790
+ }),
778
791
  };
779
792
  }
780
793
  /* ------------------ INIT ------------------ */
@@ -1079,7 +1092,6 @@ class DoughnutChart {
1079
1092
  },
1080
1093
  }), // grey
1081
1094
  }));
1082
- console.log(seriesData, 'seriesData');
1083
1095
  const innerRadius = this.config.innerRadius ?? '70%';
1084
1096
  const outerRadius = this.config.outerRadius ?? '90%';
1085
1097
  this.chartOption = {
@@ -1272,96 +1284,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
1272
1284
  type: Input
1273
1285
  }] } });
1274
1286
 
1275
- echarts.use([LineChart, GridComponent, TooltipComponent, LegendComponent, CanvasRenderer]);
1276
- class AreaChart {
1277
- config;
1278
- theme;
1279
- chartInstance;
1280
- chartOption;
1281
- ngOnChanges(changes) {
1282
- if (changes['theme'] && !changes['theme'].firstChange) {
1283
- // Dispose and let ngx-echarts recreate chart with new theme
1284
- if (this.chartInstance) {
1285
- this.chartInstance.dispose();
1286
- }
1287
- }
1288
- if (this.config) {
1289
- this.buildOption();
1290
- }
1291
- }
1292
- onChartInit(ec) {
1293
- this.chartInstance = ec;
1294
- }
1295
- buildOption() {
1296
- this.chartOption = {
1297
- backgroundColor: this.config.backgroundColor || 'transparent',
1298
- tooltip: {
1299
- show: this.config.showTooltip ?? true,
1300
- trigger: 'axis',
1301
- },
1302
- legned: true,
1303
- grid: {
1304
- left: this.config.grid?.left ?? 20,
1305
- right: this.config.grid?.right ?? 20,
1306
- top: this.config.grid?.top ?? 20,
1307
- bottom: this.config.grid?.bottom ?? 20,
1308
- containLabel: true,
1309
- },
1310
- xAxis: {
1311
- type: 'category',
1312
- boundaryGap: false,
1313
- data: this.config.xAxisData,
1314
- show: this.config.showXAxis ?? true,
1315
- axisLine: { show: this.config.showXAxisLine ?? true },
1316
- axisTick: { show: this.config.showXAxisTick ?? true },
1317
- axisLabel: { show: this.config.showXAxisLabel ?? true },
1318
- },
1319
- yAxis: {
1320
- type: 'value',
1321
- show: this.config.showYAxis ?? true,
1322
- axisLine: { show: this.config.showYAxisLine ?? true },
1323
- axisTick: { show: this.config.showYAxisTick ?? true },
1324
- axisLabel: { show: this.config.showYAxisLabel ?? true },
1325
- splitLine: { show: this.config.showGridLines ?? true },
1326
- },
1327
- series: [
1328
- {
1329
- type: 'line',
1330
- data: this.config.seriesData,
1331
- smooth: this.config.smooth ?? true,
1332
- showSymbol: this.config.showSymbol ?? false,
1333
- lineStyle: {
1334
- width: this.config.lineWidth ?? 2,
1335
- color: this.config.lineColor || '#16a34a',
1336
- },
1337
- itemStyle: {
1338
- color: this.config.lineColor || '#16a34a',
1339
- },
1340
- areaStyle: {
1341
- color: this.config.areaColor || 'rgba(22,163,74,0.25)',
1342
- ...this.config.areaColor,
1343
- },
1344
- },
1345
- ],
1346
- };
1347
- }
1348
- ngOnDestroy() {
1349
- if (this.chartInstance) {
1350
- this.chartInstance.dispose();
1351
- }
1352
- }
1353
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AreaChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
1354
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: AreaChart, isStandalone: true, selector: "lib-area-chart", inputs: { config: "config", theme: "theme" }, providers: [provideEchartsCore({ echarts })], usesOnChanges: true, ngImport: i0, template: "<div\n echarts\n [options]=\"chartOption\"\n [theme]=\"theme\"\n \n class=\"chart-container\"\n>\n</div>\n", styles: [".chart-container{width:100%;height:400px}\n"], dependencies: [{ 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"] }] });
1355
- }
1356
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: AreaChart, decorators: [{
1357
- type: Component,
1358
- args: [{ selector: 'lib-area-chart', imports: [NgxEchartsDirective], providers: [provideEchartsCore({ echarts })], template: "<div\n echarts\n [options]=\"chartOption\"\n [theme]=\"theme\"\n \n class=\"chart-container\"\n>\n</div>\n", styles: [".chart-container{width:100%;height:400px}\n"] }]
1359
- }], propDecorators: { config: [{
1360
- type: Input
1361
- }], theme: [{
1362
- type: Input
1363
- }] } });
1364
-
1365
1287
  echarts.use([CustomChart, GridComponent, TooltipComponent, LegendComponent, CanvasRenderer]);
1366
1288
  class CustomChartComponent {
1367
1289
  chartService;
@@ -1675,8 +1597,10 @@ class CustomChartComponent {
1675
1597
  },
1676
1598
  xAxis: {
1677
1599
  type: 'value',
1678
- min: this.config.startHour ?? 0,
1679
- max: this.config.endHour ?? 24,
1600
+ min: this.config.startHour
1601
+ ? Math.floor(this.convertTimeToNumber(this.config.startHour))
1602
+ : 0,
1603
+ max: this.config.endHour ? Math.ceil(this.convertTimeToNumber(this.config.endHour)) : 24,
1680
1604
  axisLine: {
1681
1605
  show: false,
1682
1606
  },
@@ -1878,5 +1802,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
1878
1802
  * Generated bundle index. Do not edit.
1879
1803
  */
1880
1804
 
1881
- export { AreaChart, BarChart, Charts, CustomChartComponent, DoughnutChart, LinesChart, PieChart, RightClickCard, SankeyChart, StackedAreaChart };
1805
+ export { BarChart, Charts, CustomChartComponent, DoughnutChart, LinesChart, PieChart, RightClickCard, SankeyChart, StackedAreaChart };
1882
1806
  //# sourceMappingURL=cats-charts.mjs.map