invensys-ng 21.3.5 → 21.3.6

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.
@@ -8993,36 +8993,6 @@ const CHART_COLOR_PALETTE = {
8993
8993
  950: '#020617',
8994
8994
  },
8995
8995
  };
8996
- /**
8997
- * Chart Component
8998
- *
8999
- * A Chart.js-based chart component for displaying various chart types.
9000
- * Supports multiple charts in a responsive grid layout.
9001
- *
9002
- * @example
9003
- * ```html
9004
- * <i-chart
9005
- * [charts]="myCharts"
9006
- * height="25rem">
9007
- * </i-chart>
9008
- * ```
9009
- *
9010
- * @example
9011
- * ```typescript
9012
- * myCharts: IChartData[] = [
9013
- * {
9014
- * chartId: 'sales-chart',
9015
- * chartType: 'bar',
9016
- * labels: ['Jan', 'Feb', 'Mar'],
9017
- * dataSets: [{
9018
- * label: 'Sales',
9019
- * data: [100, 200, 150],
9020
- * backgroundColors: ['--blue-500', '--green-500', '--orange-500']
9021
- * }]
9022
- * }
9023
- * ];
9024
- * ```
9025
- */
9026
8996
  class IChart {
9027
8997
  /**
9028
8998
  * Array of chart data objects to render
@@ -9053,6 +9023,11 @@ class IChart {
9053
9023
  * @internal
9054
9024
  */
9055
9025
  chartInstances = [];
9026
+ /**
9027
+ * Legend items generated from Chart.js for each chart instance.
9028
+ * @internal
9029
+ */
9030
+ chartLegendItems = [];
9056
9031
  /**
9057
9032
  * Flag to track if component has initialized
9058
9033
  * @internal
@@ -9123,6 +9098,7 @@ class IChart {
9123
9098
  if (chartDisplay && canvasRef?.nativeElement) {
9124
9099
  const chartInstance = this.createChartInstance(canvasRef.nativeElement, chartDisplay);
9125
9100
  this.chartInstances.push(chartInstance);
9101
+ this.updateLegendItems(index);
9126
9102
  }
9127
9103
  });
9128
9104
  }
@@ -9136,6 +9112,7 @@ class IChart {
9136
9112
  });
9137
9113
  this.chartInstances = [];
9138
9114
  this.chartDisplays = [];
9115
+ this.chartLegendItems = [];
9139
9116
  }
9140
9117
  /**
9141
9118
  * Create a Chart.js instance
@@ -9221,6 +9198,7 @@ class IChart {
9221
9198
  responsive: this.responsive,
9222
9199
  plugins: {
9223
9200
  legend: {
9201
+ display: false,
9224
9202
  labels: {
9225
9203
  color: textColor,
9226
9204
  },
@@ -9255,6 +9233,7 @@ class IChart {
9255
9233
  ...baseOptions,
9256
9234
  plugins: {
9257
9235
  legend: {
9236
+ display: false,
9258
9237
  labels: {
9259
9238
  color: textColor,
9260
9239
  },
@@ -9272,6 +9251,7 @@ class IChart {
9272
9251
  ...baseOptions,
9273
9252
  plugins: {
9274
9253
  legend: {
9254
+ display: false,
9275
9255
  labels: {
9276
9256
  color: textColor,
9277
9257
  },
@@ -9447,6 +9427,51 @@ class IChart {
9447
9427
  // If it's already rgba, leave as-is (user specified their own alpha)
9448
9428
  return color;
9449
9429
  }
9430
+ /**
9431
+ * Get legend items for a chart display.
9432
+ * @param chartIndex - The index of the chart display
9433
+ * @returns Legend items generated by Chart.js
9434
+ */
9435
+ getLegendItems(chartIndex) {
9436
+ return this.chartLegendItems[chartIndex] ?? [];
9437
+ }
9438
+ /**
9439
+ * Toggle a chart legend item using the same Chart.js behavior as the built-in legend.
9440
+ * @param chartIndex - The index of the chart display
9441
+ * @param item - The legend item to toggle
9442
+ */
9443
+ toggleLegendItem(chartIndex, item) {
9444
+ const chart = this.chartInstances[chartIndex];
9445
+ if (!chart) {
9446
+ return;
9447
+ }
9448
+ if (item.datasetIndex !== undefined) {
9449
+ chart.setDatasetVisibility(item.datasetIndex, !chart.isDatasetVisible(item.datasetIndex));
9450
+ }
9451
+ else if (item.index !== undefined) {
9452
+ chart.toggleDataVisibility(item.index);
9453
+ }
9454
+ chart.update();
9455
+ this.updateLegendItems(chartIndex);
9456
+ }
9457
+ /**
9458
+ * Refresh the custom legend items for a chart instance.
9459
+ * @internal
9460
+ */
9461
+ updateLegendItems(chartIndex) {
9462
+ const chart = this.chartInstances[chartIndex];
9463
+ const generateLabels = chart?.options.plugins?.legend?.labels?.generateLabels;
9464
+ if (!chart || !generateLabels) {
9465
+ this.chartLegendItems[chartIndex] = [];
9466
+ return;
9467
+ }
9468
+ this.chartLegendItems[chartIndex] = generateLabels(chart).map((item) => ({
9469
+ ...item,
9470
+ fillStyleText: String(item.fillStyle ?? 'transparent'),
9471
+ strokeStyleText: String(item.strokeStyle ?? item.fillStyle ?? 'transparent'),
9472
+ }));
9473
+ this.cdr.detectChanges();
9474
+ }
9450
9475
  /**
9451
9476
  * Get the height style for a chart display
9452
9477
  * @param display - The chart display configuration
@@ -9463,11 +9488,11 @@ class IChart {
9463
9488
  return this.chartInstances.length;
9464
9489
  }
9465
9490
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: IChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
9466
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: IChart, isStandalone: true, selector: "i-chart", inputs: { charts: "charts", height: "height", responsive: "responsive" }, viewQueries: [{ propertyName: "canvasElements", predicate: ["chartCanvas"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"i-charts-container\">\n @for (chartDisplay of chartDisplays; track chartDisplay.id) {\n <div class=\"i-chart-item\" [style.height]=\"getChartHeightStyle(chartDisplay)\">\n <canvas #chartCanvas></canvas>\n </div>\n }\n</div>\n", styles: [":host{--chart-grid-color: var(--surface-border);--chart-text-color: var(--color-text-primary);--chart-text-secondary: var(--color-text-secondary)}.i-charts-container{display:flex;flex-wrap:wrap;width:100%;gap:4rem}.i-chart-item{flex:1 1 45%;min-width:300px;box-sizing:border-box}@media(max-width:768px){.i-charts-container{flex-direction:column}.i-chart-item{width:100%}}\n"] });
9491
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: IChart, isStandalone: true, selector: "i-chart", inputs: { charts: "charts", height: "height", responsive: "responsive" }, viewQueries: [{ propertyName: "canvasElements", predicate: ["chartCanvas"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"i-charts-container\">\n @for (chartDisplay of chartDisplays; track chartDisplay.id; let chartIndex = $index) {\n <div class=\"i-chart-panel\">\n <div class=\"i-chart-item\" [style.height]=\"getChartHeightStyle(chartDisplay)\">\n <canvas #chartCanvas></canvas>\n </div>\n\n @if (getLegendItems(chartIndex).length) {\n <div class=\"i-chart-legend\" role=\"list\" aria-label=\"Chart data series\">\n @for (legendItem of getLegendItems(chartIndex); track $index) {\n <button\n class=\"i-chart-legend-item\"\n type=\"button\"\n role=\"listitem\"\n [class.i-chart-legend-item-hidden]=\"legendItem.hidden\"\n [attr.aria-pressed]=\"!legendItem.hidden\"\n (click)=\"toggleLegendItem(chartIndex, legendItem)\"\n >\n <span\n class=\"i-chart-legend-marker\"\n [style.background-color]=\"legendItem.fillStyleText\"\n [style.border-color]=\"legendItem.strokeStyleText\"\n ></span>\n <span class=\"i-chart-legend-label\">{{ legendItem.text }}</span>\n </button>\n }\n </div>\n }\n </div>\n }\n</div>\n", styles: [":host{--chart-grid-color: var(--surface-border);--chart-text-color: var(--color-text-primary);--chart-text-secondary: var(--color-text-secondary)}.i-charts-container{display:flex;flex-wrap:wrap;width:100%;gap:4rem}.i-chart-panel{flex:1 1 45%;min-width:300px;box-sizing:border-box}.i-chart-item{width:100%;box-sizing:border-box}.i-chart-legend{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.75rem 1rem;margin-top:1rem;padding:.75rem 1rem;border:1px solid var(--surface-border);border-radius:var(--border-radius, .5rem);background:var(--surface-card, var(--surface-ground, transparent))}.i-chart-legend-item{display:inline-flex;align-items:center;gap:.5rem;min-width:0;padding:.25rem .5rem;border:0;border-radius:var(--border-radius, .5rem);background:transparent;color:var(--chart-text-color);font:inherit;cursor:pointer;transition:background-color .2s ease,opacity .2s ease}.i-chart-legend-item:hover,.i-chart-legend-item:focus-visible{background:var(--surface-hover, rgba(148, 163, 184, .12));outline:none}.i-chart-legend-item-hidden{opacity:.55}.i-chart-legend-item-hidden .i-chart-legend-label{text-decoration:line-through}.i-chart-legend-marker{width:.875rem;height:.875rem;flex:0 0 .875rem;border:1px solid;border-radius:.25rem}.i-chart-legend-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media(max-width:768px){.i-charts-container{flex-direction:column}.i-chart-panel{width:100%}}\n"] });
9467
9492
  }
9468
9493
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: IChart, decorators: [{
9469
9494
  type: Component,
9470
- args: [{ selector: 'i-chart', standalone: true, imports: [], template: "<div class=\"i-charts-container\">\n @for (chartDisplay of chartDisplays; track chartDisplay.id) {\n <div class=\"i-chart-item\" [style.height]=\"getChartHeightStyle(chartDisplay)\">\n <canvas #chartCanvas></canvas>\n </div>\n }\n</div>\n", styles: [":host{--chart-grid-color: var(--surface-border);--chart-text-color: var(--color-text-primary);--chart-text-secondary: var(--color-text-secondary)}.i-charts-container{display:flex;flex-wrap:wrap;width:100%;gap:4rem}.i-chart-item{flex:1 1 45%;min-width:300px;box-sizing:border-box}@media(max-width:768px){.i-charts-container{flex-direction:column}.i-chart-item{width:100%}}\n"] }]
9495
+ args: [{ selector: 'i-chart', standalone: true, imports: [], template: "<div class=\"i-charts-container\">\n @for (chartDisplay of chartDisplays; track chartDisplay.id; let chartIndex = $index) {\n <div class=\"i-chart-panel\">\n <div class=\"i-chart-item\" [style.height]=\"getChartHeightStyle(chartDisplay)\">\n <canvas #chartCanvas></canvas>\n </div>\n\n @if (getLegendItems(chartIndex).length) {\n <div class=\"i-chart-legend\" role=\"list\" aria-label=\"Chart data series\">\n @for (legendItem of getLegendItems(chartIndex); track $index) {\n <button\n class=\"i-chart-legend-item\"\n type=\"button\"\n role=\"listitem\"\n [class.i-chart-legend-item-hidden]=\"legendItem.hidden\"\n [attr.aria-pressed]=\"!legendItem.hidden\"\n (click)=\"toggleLegendItem(chartIndex, legendItem)\"\n >\n <span\n class=\"i-chart-legend-marker\"\n [style.background-color]=\"legendItem.fillStyleText\"\n [style.border-color]=\"legendItem.strokeStyleText\"\n ></span>\n <span class=\"i-chart-legend-label\">{{ legendItem.text }}</span>\n </button>\n }\n </div>\n }\n </div>\n }\n</div>\n", styles: [":host{--chart-grid-color: var(--surface-border);--chart-text-color: var(--color-text-primary);--chart-text-secondary: var(--color-text-secondary)}.i-charts-container{display:flex;flex-wrap:wrap;width:100%;gap:4rem}.i-chart-panel{flex:1 1 45%;min-width:300px;box-sizing:border-box}.i-chart-item{width:100%;box-sizing:border-box}.i-chart-legend{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.75rem 1rem;margin-top:1rem;padding:.75rem 1rem;border:1px solid var(--surface-border);border-radius:var(--border-radius, .5rem);background:var(--surface-card, var(--surface-ground, transparent))}.i-chart-legend-item{display:inline-flex;align-items:center;gap:.5rem;min-width:0;padding:.25rem .5rem;border:0;border-radius:var(--border-radius, .5rem);background:transparent;color:var(--chart-text-color);font:inherit;cursor:pointer;transition:background-color .2s ease,opacity .2s ease}.i-chart-legend-item:hover,.i-chart-legend-item:focus-visible{background:var(--surface-hover, rgba(148, 163, 184, .12));outline:none}.i-chart-legend-item-hidden{opacity:.55}.i-chart-legend-item-hidden .i-chart-legend-label{text-decoration:line-through}.i-chart-legend-marker{width:.875rem;height:.875rem;flex:0 0 .875rem;border:1px solid;border-radius:.25rem}.i-chart-legend-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media(max-width:768px){.i-charts-container{flex-direction:column}.i-chart-panel{width:100%}}\n"] }]
9471
9496
  }], propDecorators: { charts: [{
9472
9497
  type: Input
9473
9498
  }], height: [{