cats-charts 0.0.95 → 0.0.97

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.
@@ -6,7 +6,7 @@ import { LineChart, BarChart as BarChart$1, PieChart as PieChart$1, CustomChart,
6
6
  import { GridComponent, TooltipComponent, LegendComponent, TitleComponent, ToolboxComponent, DataZoomInsideComponent, DataZoomComponent, MarkAreaComponent, MarkLineComponent, DatasetComponent, VisualMapComponent, GraphicComponent } from 'echarts/components';
7
7
  import { CanvasRenderer } from 'echarts/renderers';
8
8
  import * as i2 from '@angular/common';
9
- import { isPlatformBrowser, CommonModule } from '@angular/common';
9
+ import { isPlatformBrowser, CommonModule, DOCUMENT } from '@angular/common';
10
10
 
11
11
  class RightClickCard {
12
12
  cardPosition;
@@ -1046,7 +1046,7 @@ class Charts {
1046
1046
  color:#434A51;
1047
1047
  padding-top: 0.5rem;
1048
1048
  ">
1049
- ${data[0]}: <b style="color:#111;font-weight:600;">${data[1]}</b>
1049
+ ${data[0]}: <b style="color:#111;font-weight:600;">${this.formatTooltipValue(data[1], config?.tooltipCompactValue)}</b>
1050
1050
  </div>`;
1051
1051
  });
1052
1052
  }
@@ -1085,7 +1085,7 @@ class Charts {
1085
1085
  font-size: 12px;
1086
1086
  color: #434A51;
1087
1087
  ">
1088
- ${name}: <b style="color:#111; font-weight:600;">${config.valueFormatter ? config.valueFormatter(value) : this.formatTooltipValue(value, config.tooltipCompactValue)}</b> ${config.showTooltipPercent ? '(' + percent + '%)' : ''}
1088
+ ${name}: <b style="color:#111; font-weight:600;">${config.valueFormatter ? config.valueFormatter(value) : this.formatTooltipValue(value, config?.tooltipCompactValue)}</b> ${config.showTooltipPercent ? '(' + percent + '%)' : ''}
1089
1089
  </span>
1090
1090
  </div>
1091
1091
  ${extraTooltipDataTemplate}
@@ -1110,7 +1110,7 @@ class Charts {
1110
1110
  color:#434A51;
1111
1111
  padding-top: 0.5rem;
1112
1112
  ">
1113
- ${data[0]}: <b style="color:#111;font-weight:600;">${data[1]}</b>
1113
+ ${data[0]}: <b style="color:#111;font-weight:600;">${this.formatTooltipValue(data[1], config?.tooltipCompactValue)}</b>
1114
1114
  </div>`;
1115
1115
  });
1116
1116
  }
@@ -1198,6 +1198,8 @@ class Charts {
1198
1198
  return `${scaled}${units[unitIndex].suffix}`;
1199
1199
  }
1200
1200
  formatTooltipValue(value, compact = false) {
1201
+ if (typeof Number(value) !== 'number')
1202
+ return value;
1201
1203
  const roundedValue = this.toMaxDecimals(value);
1202
1204
  return compact ? this.compactValueFormat(roundedValue) : roundedValue;
1203
1205
  }
@@ -1694,7 +1696,7 @@ class LinesChart {
1694
1696
  confine: true,
1695
1697
  formatter: (params) => this.config?.tooltipFormatter
1696
1698
  ? this.config?.tooltipFormatter(params)
1697
- : this.chartService.barLineTooltipFormatter(params, 'line'),
1699
+ : this.chartService.barLineTooltipFormatter(params, 'line', this.config),
1698
1700
  },
1699
1701
  legend: {
1700
1702
  show: false,
@@ -2388,7 +2390,7 @@ class BarChart {
2388
2390
  confine: true,
2389
2391
  formatter: (params) => this.config.tooltipFormatter
2390
2392
  ? this.config.tooltipFormatter(params)
2391
- : this.chartService.barLineTooltipFormatter(params),
2393
+ : this.chartService.barLineTooltipFormatter(params, 'bar', this.config),
2392
2394
  },
2393
2395
  legend: {
2394
2396
  show: false,
@@ -6330,6 +6332,7 @@ const COLLAPSED_GROUP_ICON = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org
6330
6332
  class GanttChart {
6331
6333
  chartService;
6332
6334
  cdr;
6335
+ document;
6333
6336
  config = { series: [], groups: [] };
6334
6337
  theme;
6335
6338
  events = [];
@@ -6348,14 +6351,21 @@ class GanttChart {
6348
6351
  horizontalZoomLayoutFrame;
6349
6352
  isApplyingHorizontalZoomLayout = false;
6350
6353
  zoomWheelHandler;
6354
+ dataZoomPointerDownHandler;
6355
+ nativeDragStartHandler;
6356
+ nativePointerEndHandler;
6357
+ dataZoomGestureActive = false;
6358
+ isBrowser;
6351
6359
  visibleRows = [];
6352
6360
  rowIndexMap = new Map();
6353
- constructor(chartService, cdr) {
6361
+ constructor(chartService, cdr, document, platformId) {
6354
6362
  this.chartService = chartService;
6355
6363
  this.cdr = cdr;
6364
+ this.document = document;
6365
+ this.isBrowser = isPlatformBrowser(platformId);
6356
6366
  }
6357
6367
  get deafultColors() {
6358
- return this.chartService.defaultColors;
6368
+ return this.chartService.defaultLegendColors;
6359
6369
  }
6360
6370
  get rowHeight() {
6361
6371
  const configuredHeight = Number(this.config?.rowHeight ?? DEFAULT_ROW_HEIGHT);
@@ -6365,6 +6375,12 @@ class GanttChart {
6365
6375
  const configuredGap = Number(this.config?.xAxisMinLabelGap ?? 100);
6366
6376
  return Number.isFinite(configuredGap) ? Math.max(1, configuredGap) : 100;
6367
6377
  }
6378
+ get yAxisLabelWidth() {
6379
+ const chartWidth = this.chartContainer?.nativeElement.getBoundingClientRect().width ||
6380
+ this.chartInstance?.getWidth?.() ||
6381
+ 360;
6382
+ return Math.max(100, Math.min(240, Math.round(chartWidth * 0.22)));
6383
+ }
6368
6384
  getAggregationLabelCount() {
6369
6385
  const values = [];
6370
6386
  const addTimestamp = (value) => {
@@ -6438,7 +6454,7 @@ class GanttChart {
6438
6454
  return weekStart.getTime();
6439
6455
  }
6440
6456
  resolveSeriesColor(series, index) {
6441
- const colors = this.config?.colors || this.deafultColors;
6457
+ const colors = this.config?.colors || this.chartService.defaultLegendColors;
6442
6458
  return series?.itemStyle?.color ?? colors[index % Math.max(colors.length, 1)] ?? '#64748b';
6443
6459
  }
6444
6460
  createBarLabel(label, rect) {
@@ -6550,6 +6566,7 @@ class GanttChart {
6550
6566
  if (this.horizontalZoomLayoutFrame) {
6551
6567
  cancelAnimationFrame(this.horizontalZoomLayoutFrame);
6552
6568
  }
6569
+ this.unbindDataZoomDragIsolation();
6553
6570
  // ngx-echarts can dispose the ECharts instance before this component's
6554
6571
  // destroy hook runs. A disposed instance no longer has a ZRender surface,
6555
6572
  // so do not try to remove the wheel listener from it.
@@ -6567,6 +6584,7 @@ class GanttChart {
6567
6584
  this.rowIndexMap = new Map(this.visibleRows.map((row, index) => [row.name, index]));
6568
6585
  const selected = this.readLegendSelected();
6569
6586
  const selectedMode = this.config?.customLegend?.selectionMode === 'exclusive' ? 'single' : true;
6587
+ const yAxisLabelWidth = this.yAxisLabelWidth;
6570
6588
  const option = {
6571
6589
  animation: false,
6572
6590
  backgroundColor: 'transparent',
@@ -6698,6 +6716,7 @@ class GanttChart {
6698
6716
  axisLabel: {
6699
6717
  show: this.config?.showYAxisLabel ?? true,
6700
6718
  color: '#434A51',
6719
+ width: yAxisLabelWidth,
6701
6720
  overflow: 'truncate',
6702
6721
  align: 'right',
6703
6722
  fontSize: 12,
@@ -6986,6 +7005,7 @@ class GanttChart {
6986
7005
  this.buildOption();
6987
7006
  this.bindEvents();
6988
7007
  this.bindZoomWheel();
7008
+ this.bindDataZoomDragIsolation();
6989
7009
  this.chartInstance.on('finished', () => {
6990
7010
  this.scheduleVerticalZoomLayout();
6991
7011
  this.scheduleHorizontalZoomLayout();
@@ -7024,6 +7044,65 @@ class GanttChart {
7024
7044
  };
7025
7045
  zr.on('mousewheel', this.zoomWheelHandler);
7026
7046
  }
7047
+ /**
7048
+ * A native draggable ancestor starts its drag after the slider's mousedown
7049
+ * event. Since the native `dragstart` targets that ancestor rather than the
7050
+ * canvas, suppress it at document capture phase while a data-zoom gesture is
7051
+ * active. This keeps the fix inside the chart library and leaves parent drag
7052
+ * behaviour unchanged everywhere else.
7053
+ */
7054
+ bindDataZoomDragIsolation() {
7055
+ if (!this.chartInstance || !this.isBrowser)
7056
+ return;
7057
+ const zr = this.chartInstance.getZr();
7058
+ if (this.dataZoomPointerDownHandler) {
7059
+ zr.off('mousedown', this.dataZoomPointerDownHandler);
7060
+ }
7061
+ this.dataZoomPointerDownHandler = (event) => {
7062
+ this.dataZoomGestureActive = this.isDataZoomTarget(event?.target);
7063
+ };
7064
+ zr.on('mousedown', this.dataZoomPointerDownHandler);
7065
+ if (!this.nativeDragStartHandler) {
7066
+ this.nativeDragStartHandler = (event) => {
7067
+ if (!this.dataZoomGestureActive)
7068
+ return;
7069
+ event.preventDefault();
7070
+ event.stopPropagation();
7071
+ this.dataZoomGestureActive = false;
7072
+ };
7073
+ this.document.addEventListener('dragstart', this.nativeDragStartHandler, true);
7074
+ }
7075
+ if (!this.nativePointerEndHandler) {
7076
+ this.nativePointerEndHandler = () => {
7077
+ this.dataZoomGestureActive = false;
7078
+ };
7079
+ this.document.addEventListener('pointerup', this.nativePointerEndHandler, true);
7080
+ this.document.addEventListener('pointercancel', this.nativePointerEndHandler, true);
7081
+ }
7082
+ }
7083
+ unbindDataZoomDragIsolation() {
7084
+ if (this.chartInstance && !this.chartInstance.isDisposed() && this.dataZoomPointerDownHandler) {
7085
+ this.chartInstance.getZr()?.off('mousedown', this.dataZoomPointerDownHandler);
7086
+ }
7087
+ if (this.nativeDragStartHandler) {
7088
+ this.document.removeEventListener('dragstart', this.nativeDragStartHandler, true);
7089
+ }
7090
+ if (this.nativePointerEndHandler) {
7091
+ this.document.removeEventListener('pointerup', this.nativePointerEndHandler, true);
7092
+ this.document.removeEventListener('pointercancel', this.nativePointerEndHandler, true);
7093
+ }
7094
+ this.dataZoomPointerDownHandler = undefined;
7095
+ this.nativeDragStartHandler = undefined;
7096
+ this.nativePointerEndHandler = undefined;
7097
+ this.dataZoomGestureActive = false;
7098
+ }
7099
+ isDataZoomTarget(target) {
7100
+ for (let element = target; element; element = element.parent) {
7101
+ if (element.__ecComponentInfo?.mainType === 'dataZoom')
7102
+ return true;
7103
+ }
7104
+ return false;
7105
+ }
7027
7106
  moveDataZoomWindow(sliderId, insideId, delta) {
7028
7107
  const option = this.chartInstance.getOption();
7029
7108
  const slider = option.dataZoom?.find((zoom) => zoom['id'] === sliderId);
@@ -7159,7 +7238,8 @@ class GanttChart {
7159
7238
  refreshAxisNameSpace() {
7160
7239
  if (!this.chartInstance)
7161
7240
  return;
7162
- this.chartInstance.setOption({
7241
+ const yAxisLabelWidth = this.yAxisLabelWidth;
7242
+ const option = {
7163
7243
  xAxis: {
7164
7244
  name: this.resolveAxisName(this.config?.xAxisName, 'x'),
7165
7245
  nameTextStyle: this.resolveAxisNameTextStyle('x'),
@@ -7170,7 +7250,11 @@ class GanttChart {
7170
7250
  nameTextStyle: this.resolveAxisNameTextStyle('y'),
7171
7251
  },
7172
7252
  ],
7173
- });
7253
+ };
7254
+ if (this.config?.yAxis?.axisLabel?.width == null) {
7255
+ option.yAxis[0].axisLabel = { width: yAxisLabelWidth };
7256
+ }
7257
+ this.chartInstance.setOption(option);
7174
7258
  this.scheduleVerticalZoomLayout();
7175
7259
  this.scheduleHorizontalZoomLayout();
7176
7260
  }
@@ -7352,13 +7436,19 @@ class GanttChart {
7352
7436
  ...(customStyle || {}),
7353
7437
  };
7354
7438
  }
7355
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: GanttChart, deps: [{ token: Charts }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
7439
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: GanttChart, deps: [{ token: Charts }, { token: i0.ChangeDetectorRef }, { token: DOCUMENT }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component });
7356
7440
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: GanttChart, isStandalone: true, selector: "lib-gantt-chart", inputs: { config: "config", theme: "theme", events: "events", contextMenuOptions: "contextMenuOptions", showContextMenu: "showContextMenu" }, outputs: { contextMenuClick: "contextMenuClick", chartEvent: "chartEvent", legendEvent: "legendEvent" }, host: { listeners: { "document:click": "closeCard()", "window:resize": "refreshAxisNameSpace()" } }, providers: [provideEchartsCore({ echarts })], viewQueries: [{ propertyName: "chartContainer", first: true, predicate: ["chartContainer"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div\n class=\"gantt-chart-shell\"\n [class.gantt-chart-shell--legend-left]=\"config.customLegend?.position === 'left'\"\n [class.gantt-chart-shell--legend-right]=\"config.customLegend?.position === 'right'\"\n [class.gantt-chart-shell--legend-bottom]=\"config.customLegend?.position === 'bottom'\"\n>\n @if (\n !config.hideLegend &&\n config.customLegend?.position !== 'bottom' &&\n config.customLegend?.position !== 'right'\n ) {\n <lib-chart-legend\n class=\"gantt-chart-shell__legend\"\n [class.gantt-chart-shell__legend--custom-width]=\"hasSideLegendWidth\"\n [style.--gantt-chart-legend-max-width]=\"legendShellMaxWidth\"\n [chart]=\"chartInstance\"\n [series]=\"config.series\"\n [colors]=\"config.colors || deafultColors\"\n [config]=\"config.customLegend || {}\"\n (legendEvent)=\"onLegendEvent($event)\"\n ></lib-chart-legend>\n }\n\n <div\n #chartContainer\n echarts\n [options]=\"chartOption\"\n [theme]=\"theme\"\n (chartInit)=\"onChartInit($event)\"\n class=\"chart-container\"\n ></div>\n\n @if (\n !config.hideLegend &&\n (config.customLegend?.position === 'bottom' || config.customLegend?.position === 'right')\n ) {\n <lib-chart-legend\n class=\"gantt-chart-shell__legend\"\n [class.gantt-chart-shell__legend--custom-width]=\"hasSideLegendWidth\"\n [style.--gantt-chart-legend-max-width]=\"legendShellMaxWidth\"\n [chart]=\"chartInstance\"\n [series]=\"config.series\"\n [colors]=\"config.colors || deafultColors\"\n [config]=\"config.customLegend || {}\"\n (legendEvent)=\"onLegendEvent($event)\"\n ></lib-chart-legend>\n }\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: [".gantt-chart-shell{display:flex;flex-direction:column;gap:8px;height:100%;min-height:0;min-width:0;width:100%}.gantt-chart-shell--legend-left,.gantt-chart-shell--legend-right{flex-direction:row}.gantt-chart-shell--legend-bottom{flex-direction:column}.gantt-chart-shell__legend{flex:0 0 auto;min-width:0}.gantt-chart-shell--legend-left .gantt-chart-shell__legend,.gantt-chart-shell--legend-right .gantt-chart-shell__legend{height:100%;max-width:min(var(--gantt-chart-legend-max-width, 360px),70%);min-height:0}.chart-container{width:100%;height:100%;position:relative;flex:1 1 auto;min-height:0;min-width:0}@media (max-width: 640px){.gantt-chart-shell,.gantt-chart-shell--legend-left,.gantt-chart-shell--legend-right{flex-direction:column}.gantt-chart-shell--legend-left .gantt-chart-shell__legend,.gantt-chart-shell--legend-right .gantt-chart-shell__legend{flex-basis:auto;max-width:none;width:auto}}\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"] }, { kind: "component", type: ChartLegendComponent, selector: "lib-chart-legend", inputs: ["chart", "series", "colors", "config", "itemTemplate"], outputs: ["legendEvent"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
7357
7441
  }
7358
7442
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: GanttChart, decorators: [{
7359
7443
  type: Component,
7360
7444
  args: [{ selector: 'lib-gantt-chart', imports: [NgxEchartsDirective, RightClickCard, ChartLegendComponent], providers: [provideEchartsCore({ echarts })], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"gantt-chart-shell\"\n [class.gantt-chart-shell--legend-left]=\"config.customLegend?.position === 'left'\"\n [class.gantt-chart-shell--legend-right]=\"config.customLegend?.position === 'right'\"\n [class.gantt-chart-shell--legend-bottom]=\"config.customLegend?.position === 'bottom'\"\n>\n @if (\n !config.hideLegend &&\n config.customLegend?.position !== 'bottom' &&\n config.customLegend?.position !== 'right'\n ) {\n <lib-chart-legend\n class=\"gantt-chart-shell__legend\"\n [class.gantt-chart-shell__legend--custom-width]=\"hasSideLegendWidth\"\n [style.--gantt-chart-legend-max-width]=\"legendShellMaxWidth\"\n [chart]=\"chartInstance\"\n [series]=\"config.series\"\n [colors]=\"config.colors || deafultColors\"\n [config]=\"config.customLegend || {}\"\n (legendEvent)=\"onLegendEvent($event)\"\n ></lib-chart-legend>\n }\n\n <div\n #chartContainer\n echarts\n [options]=\"chartOption\"\n [theme]=\"theme\"\n (chartInit)=\"onChartInit($event)\"\n class=\"chart-container\"\n ></div>\n\n @if (\n !config.hideLegend &&\n (config.customLegend?.position === 'bottom' || config.customLegend?.position === 'right')\n ) {\n <lib-chart-legend\n class=\"gantt-chart-shell__legend\"\n [class.gantt-chart-shell__legend--custom-width]=\"hasSideLegendWidth\"\n [style.--gantt-chart-legend-max-width]=\"legendShellMaxWidth\"\n [chart]=\"chartInstance\"\n [series]=\"config.series\"\n [colors]=\"config.colors || deafultColors\"\n [config]=\"config.customLegend || {}\"\n (legendEvent)=\"onLegendEvent($event)\"\n ></lib-chart-legend>\n }\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: [".gantt-chart-shell{display:flex;flex-direction:column;gap:8px;height:100%;min-height:0;min-width:0;width:100%}.gantt-chart-shell--legend-left,.gantt-chart-shell--legend-right{flex-direction:row}.gantt-chart-shell--legend-bottom{flex-direction:column}.gantt-chart-shell__legend{flex:0 0 auto;min-width:0}.gantt-chart-shell--legend-left .gantt-chart-shell__legend,.gantt-chart-shell--legend-right .gantt-chart-shell__legend{height:100%;max-width:min(var(--gantt-chart-legend-max-width, 360px),70%);min-height:0}.chart-container{width:100%;height:100%;position:relative;flex:1 1 auto;min-height:0;min-width:0}@media (max-width: 640px){.gantt-chart-shell,.gantt-chart-shell--legend-left,.gantt-chart-shell--legend-right{flex-direction:column}.gantt-chart-shell--legend-left .gantt-chart-shell__legend,.gantt-chart-shell--legend-right .gantt-chart-shell__legend{flex-basis:auto;max-width:none;width:auto}}\n"] }]
7361
- }], ctorParameters: () => [{ type: Charts }, { type: i0.ChangeDetectorRef }], propDecorators: { config: [{
7445
+ }], ctorParameters: () => [{ type: Charts }, { type: i0.ChangeDetectorRef }, { type: Document, decorators: [{
7446
+ type: Inject,
7447
+ args: [DOCUMENT]
7448
+ }] }, { type: undefined, decorators: [{
7449
+ type: Inject,
7450
+ args: [PLATFORM_ID]
7451
+ }] }], propDecorators: { config: [{
7362
7452
  type: Input
7363
7453
  }], theme: [{
7364
7454
  type: Input