@oicl/openbridge-webcomponents 2.1.0 → 2.1.1
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.
- package/bundle/openbridge-webcomponents.bundle.js +46 -37
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/dist/bars-graphs/donut-chart/donut-chart.d.ts.map +1 -1
- package/dist/bars-graphs/donut-chart/donut-chart.js +3 -4
- package/dist/bars-graphs/donut-chart/donut-chart.js.map +1 -1
- package/dist/bars-graphs/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/bars-graphs/pie-chart/pie-chart.js +3 -4
- package/dist/bars-graphs/pie-chart/pie-chart.js.map +1 -1
- package/dist/bars-graphs/polar-chart/polar-chart.d.ts.map +1 -1
- package/dist/bars-graphs/polar-chart/polar-chart.js +3 -4
- package/dist/bars-graphs/polar-chart/polar-chart.js.map +1 -1
- package/dist/bars-graphs/radial-bar-chart/radial-bar-chart.d.ts.map +1 -1
- package/dist/bars-graphs/radial-bar-chart/radial-bar-chart.js +3 -4
- package/dist/bars-graphs/radial-bar-chart/radial-bar-chart.js.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.d.ts.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.js +3 -6
- package/dist/building-blocks/chart-line/chart-line-base.js.map +1 -1
- package/dist/charthelpers/index.js +2 -2
- package/dist/charthelpers/legend.d.ts +24 -7
- package/dist/charthelpers/legend.d.ts.map +1 -1
- package/dist/charthelpers/legend.js +40 -16
- package/dist/charthelpers/legend.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donut-chart.d.ts","sourceRoot":"","sources":["../../../src/bars-graphs/donut-chart/donut-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,cAAc,EAAkB,MAAM,KAAK,CAAC;AAOhE,OAAO,EAAC,QAAQ,EAAC,MAAM,uCAAuC,CAAC;AAgE/D,MAA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e,CAAgB;IAEhD,gBAAgB;IACC,OAAO,CAAC,QAAQ,CAAC,CAAoB;IAEtD,gBAAgB;IACE,OAAO,CAAC,SAAS,CAAC,CAAiB;IAErD,gBAAgB;IAChB,OAAO,CAAC,KAAK,CAAC,CAAQ;IAEtB,yEAAyE;IACzE,OAAO,CAAC,cAAc,CAAC,CAA6B;IAEpD,gBAAgB;IAChB,OAAO,CAAC,aAAa,CAAC,CAAmB;IAEzC,+GAA+G;IAC/G,OAAO,CAAC,cAAc,CAAC,CAAiB;IAExC,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,OAAO,CAAC,eAAe;IAgBd,UAAU,CAAC,OAAO,EAAE,cAAc;IAOlC,OAAO,CAAC,OAAO,EAAE,cAAc;IAoB/B,YAAY;IAMZ,oBAAoB;IAO7B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,gBAAgB;IA2BxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAiB3B;;OAEG;IACH,OAAO,CAAC,eAAe;IA0FvB,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,8BAA8B;IA6KtC,OAAO,CAAC,eAAe;IAyCvB,OAAO,CAAC,WAAW;IAmCnB,OAAO,CAAC,WAAW;IA6BnB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAmBzB;;OAEG;IACH,OAAO,CAAC,YAAY;IAoDX,MAAM;IASf,OAAgB,MAAM,4BAKpB;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}
|
|
@@ -5,7 +5,7 @@ import { calculateFixedHeightChartLayout, formatChartNumber } from "../../charth
|
|
|
5
5
|
import { observeThemeChanges } from "../../charthelpers/theme.js";
|
|
6
6
|
import { calculateSumTotal, createArcOuterLabelPlugin } from "../../charthelpers/outer-labels.js";
|
|
7
7
|
import { getChartTooltipOptions } from "../../charthelpers/tooltip.js";
|
|
8
|
-
import {
|
|
8
|
+
import { renderLegend } from "../../charthelpers/legend.js";
|
|
9
9
|
import { observeLabelThreshold } from "../../charthelpers/label-threshold.js";
|
|
10
10
|
import "../../charthelpers/index.js";
|
|
11
11
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js";
|
|
@@ -372,7 +372,7 @@ var ObcDonutChart = class ObcDonutChart extends LitElement {
|
|
|
372
372
|
const meta = this.chart.getDatasetMeta(0);
|
|
373
373
|
if (!meta || !meta.controller) return;
|
|
374
374
|
if (!this.data || this.data.length === 0) {
|
|
375
|
-
this.legendDiv
|
|
375
|
+
renderLegend(this.legendDiv, []);
|
|
376
376
|
return;
|
|
377
377
|
}
|
|
378
378
|
const denominator = this.max > 0 ? this.max : this.total > 0 ? this.total : 1;
|
|
@@ -391,8 +391,7 @@ var ObcDonutChart = class ObcDonutChart extends LitElement {
|
|
|
391
391
|
unit
|
|
392
392
|
};
|
|
393
393
|
});
|
|
394
|
-
|
|
395
|
-
this.legendDiv.innerHTML = legendHTML;
|
|
394
|
+
renderLegend(this.legendDiv, legendItems);
|
|
396
395
|
} catch (error) {
|
|
397
396
|
console.debug("[obc-donut-chart] updateLegend: error generating legend HTML", error);
|
|
398
397
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donut-chart.js","names":[],"sources":["../../../src/bars-graphs/donut-chart/donut-chart.ts"],"sourcesContent":["import {LitElement, PropertyValues, html, unsafeCSS} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport componentStyle from './donut-chart.css?inline';\nimport chartCommonStyle from '../../charthelpers/chart-common.css?inline';\nimport chartDebugStyle from '../../charthelpers/chart-debug.css?inline';\nimport chartLegendStyle from '../../charthelpers/chart-legend.css?inline';\nimport {customElement} from '../../decorator.js';\nimport {Priority} from '../../navigation-instruments/types.js';\nimport {Chart, DoughnutController, ArcElement, Tooltip} from 'chart.js';\nimport type {Plugin, ChartOptions, ChartDataset} from 'chart.js';\nimport {\n CHART_SECTOR_DEFAULT_COLORS,\n CHART_SECTOR_ENHANCED_COLORS,\n CHART_DIMENSIONS,\n OUTER_LABEL_CONFIG,\n CENTER_READOUT_CONFIG,\n getCssVariableValue,\n getChartColorsOrDefault,\n observeThemeChanges,\n calculateSumTotal,\n formatChartNumber,\n createArcOuterLabelPlugin,\n calculateFixedHeightChartLayout,\n getChartTooltipOptions,\n generateLegendHTML,\n observeLabelThreshold,\n} from '../../charthelpers/index.js';\nimport type {FixedHeightChartDimensions} from '../../charthelpers/canvas-layout.js';\n\n// Register Chart.js components\nChart.register(DoughnutController, ArcElement, Tooltip);\n\n// Donut-specific dimension constants (extends shared CHART_DIMENSIONS)\nconst DONUT_DIMENSIONS = {\n ...CHART_DIMENSIONS,\n GAP_WIDTH: 0,\n GAP_AND_BORDER_COLOR: '--container-section-color',\n REMAINING_COLOR: '--border-outline-color',\n BORDER_RADIUS: 4,\n} as const;\n\nconst DONUT_RECREATE_PROP_NAMES = [\n 'half',\n 'showOuterLabels',\n 'showUnit',\n 'outerLabelUnit',\n 'outerLabelMaxLength',\n 'outerLabelDecimalPlaces',\n 'showDebugOverlay',\n 'fixedHeight',\n] as const;\n\nconst DONUT_WATCHED_PROP_NAMES = [\n 'legend',\n 'data',\n 'colors',\n 'priority',\n 'half',\n 'thickness',\n 'max',\n 'showOuterLabels',\n 'showUnit',\n 'centerReadoutLabel',\n 'centerReadoutUnit',\n 'outerLabelUnit',\n 'outerLabelMaxLength',\n 'outerLabelDecimalPlaces',\n 'showDebugOverlay',\n 'fixedHeight',\n] as const;\n\nexport type DonutChartDataItem = {\n label: string;\n value: number;\n};\n\n/**\n * `<obc-donut-chart>` – A customizable donut chart component for visualizing proportional data with a center total readout.\n *\n * This component renders an interactive donut chart powered by Chart.js, displaying data segments as arcs with optional outer labels and a centered total value. It supports both full-circle (360°) and half-circle (180°) layouts, making it versatile for dashboards, analytics, and data visualization interfaces.\n *\n * The chart automatically calculates percentages, handles remaining/unfilled capacity, and adapts its layout based on available space. Labels and center readouts are hidden when the chart is too small (`fixedHeight` < 192px; the same threshold applies to half circles, whose arc is just as large as a full circle's at the same `fixedHeight`), ensuring visual clarity at all sizes.\n *\n * ## Features\n * - **Fixed Height ⇒ Fixed Circumference:** The chart's circumference is determined by the `fixedHeight` property (default: 320px). This ensures the donut's circumference remains consistent and matches other radial instruments, regardless of the available browser or container width. The chart does not scale to fill the width; instead, it always uses the specified fixed height to define its size and circumference.\n * - **Layout Modes:**\n * - `Full Circle` (default): Complete 360° donut chart.\n * - `Half Circle`: Semicircular 180° layout, useful for gauges or space-constrained displays.\n * - **Center Readout:**\n * - Displays the sum total of all data values with a customizable label (e.g., \"Total\", \"Power\", \"Usage\").\n * - **Outer Labels:**\n * - Optional labels positioned outside the chart showing segment names and values.\n * - Supports percentage or custom units (e.g., \"kW\", \"kg\", \"MB\").\n * - Configurable decimal places and maximum label length (with trimming).\n * - **Capacity Visualization:**\n * - Optionally show remaining/unfilled capacity when `max` is set higher than the total.\n * - Remaining sector uses a distinct color to indicate available space.\n * - **Customization:**\n * - Custom segment colors (with automatic fallback to theme palette).\n * - Adjustable ring thickness (default 24px).\n * - **Color Priority:** Set `priority` to `Priority.enhanced` to use the blue/enhanced\n * color palette instead of the default gray/regular palette (default: `Priority.regular`).\n * - **Responsive Behavior:**\n * - Automatically hides labels and center readout when `fixedHeight` < 192px\n * (same threshold for full and half circle mode).\n * - Maintains aspect ratio and adjusts padding for optimal label positioning.\n * - **Theme Integration:**\n * - Colors update automatically when the `data-obc-theme` attribute changes on the `<html>` element.\n * - Example:\n * ```\n * <html lang=\"en\" data-obc-theme=\"day\"></html>\n * ```\n *\n * ## Example\n *\n * **Basic Usage (Half Circle)**\n * ```html\n * <obc-donut-chart\n * half\n * ></obc-donut-chart>\n * <script>\n * document.querySelector('obc-donut-chart').data = [\n * {label: 'Engine', value: 75.5},\n * {label: 'HVAC', value: 42.3},\n * {label: 'Lights', value: 12.8}\n * ];\n * </script>\n * ```\n *\n * **Custom Colors**\n * ```html\n * <obc-donut-chart></obc-donut-chart>\n * <script>\n * const chart = document.querySelector('obc-donut-chart');\n * chart.data = [\n * {label: 'Critical', value: 20},\n * {label: 'Warning', value: 35},\n * {label: 'Normal', value: 45}\n * ];\n * chart.colors = ['#e74c3c', '#f39c12', '#2ecc71'];\n * </script>\n * ```\n *\n * @property data - Chart data segments (set via JavaScript)\n * @property colors - Custom segment colors (set via JavaScript) with fallback to theme palette\n * @property half - Whether to display as half-circle (180°) or full circle (360°), default: false\n * @property showOuterLabels - Show outer labels, default: false\n * @property showUnit - Whether to show unit in labels, default: false\n * @property outerLabelUnit - Unit string to append to outer labels, default: \"%\"\n * @property outerLabelMaxLength - Maximum character length for labels before trim (0 = no limit), default: 0\n * @availableWhen outerLabelMaxLength showOuterLabels==true\n * @property outerLabelDecimalPlaces - Number of decimal places in labels, default: 0\n * @property centerReadoutLabel - Text label shown below the center total value, default: \"Total\"\n * @property centerReadoutUnit - Unit string shown inline after the label in the center readout, default: \"%\"\n * @property max - Maximum value for calculating remaining empty sector, default: 100\n * @property thickness - Donut ring thickness in pixels, default: 24\n * @property legend - Whether to display the legend below the chart, default: false\n * @property showDebugOverlay - Show debug overlay for development, default: false\n * @property fixedHeight - Fixed height of the chart in pixels (determines chart circumference), default: 320. The chart's circumference is always based on this fixed height to match other radial instruments.\n * @beta\n */\n@customElement('obc-donut-chart')\nexport class ObcDonutChart extends LitElement {\n @property({type: Array, attribute: false})\n data: DonutChartDataItem[] = [];\n\n @property({type: Array, attribute: false})\n colors: string[] = [];\n\n @property({type: String})\n priority: Priority = Priority.regular;\n\n @property({type: Boolean, reflect: true})\n half = false;\n\n @property({type: Boolean})\n showOuterLabels = false;\n\n @property({type: Boolean})\n showUnit = false;\n\n @property({type: String})\n outerLabelUnit = '%';\n\n @property({\n type: Number,\n })\n outerLabelMaxLength = 0;\n\n @property({\n type: Number,\n })\n outerLabelDecimalPlaces = 0;\n\n @property({type: String})\n centerReadoutLabel = 'Total';\n\n @property({type: String})\n centerReadoutUnit = '%';\n\n @property({type: Number})\n max = 100;\n\n @property({type: Number})\n thickness = 24;\n\n @property({type: Boolean, reflect: true})\n legend = false;\n\n @property({type: Boolean, reflect: true})\n showDebugOverlay = false;\n\n @property({type: Number, reflect: true})\n fixedHeight = 320;\n\n /** @internal */\n @state() private total = 0;\n\n /** @internal - Pre-formatted labels for outer label rendering */\n @state() private formattedLabels: string[] = [];\n\n /** @internal */\n @query('canvas') private canvasEl?: HTMLCanvasElement;\n\n /** @internal */\n @query('.legend') private legendDiv?: HTMLDivElement;\n\n /** @internal */\n private chart?: Chart;\n\n /** @internal - Latest layout dimensions computed by getChartOptions() */\n private lastDimensions?: FixedHeightChartDimensions;\n\n /** @internal */\n private themeObserver?: MutationObserver;\n\n /** @internal - ResizeObserver for tracking height threshold crossings (e.g. MIN_HEIGHT_WITH_LABELS = 192px) */\n private resizeObserver?: ResizeObserver;\n\n private hasAnyChanged(\n changed: PropertyValues,\n props: readonly (keyof ObcDonutChart)[]\n ): boolean {\n return props.some((prop) => changed.has(prop));\n }\n\n /**\n * Get layout configuration for canvas calculation\n */\n private getLayoutConfig() {\n // Denominator: use max if set, otherwise total, with minimum of 1\n const denominator =\n this.max > 0 ? this.max : this.total > 0 ? this.total : 1;\n\n return {\n unit: this.outerLabelUnit,\n showUnit: this.showUnit,\n outerLabelMaxLength: this.outerLabelMaxLength,\n decimalPlaces: this.outerLabelDecimalPlaces,\n data: this.data,\n denominator,\n };\n }\n\n // Calculate derived state BEFORE render\n override willUpdate(changed: PropertyValues) {\n if (changed.has('data')) {\n this.total = calculateSumTotal(this.data);\n }\n }\n\n // Update external library AFTER render\n override updated(changed: PropertyValues) {\n super.updated(changed);\n\n if (this.hasAnyChanged(changed, DONUT_WATCHED_PROP_NAMES)) {\n // Recreate chart when major layout properties change or when plugin configuration changes\n // These properties affect aspect ratio calculation, plugin registration, or outer label rendering\n const needsRecreation = this.hasAnyChanged(\n changed,\n DONUT_RECREATE_PROP_NAMES\n );\n\n if (needsRecreation) {\n this.chart?.destroy();\n this.createChart();\n } else {\n this.updateChart();\n }\n }\n }\n\n override firstUpdated() {\n this.createChart();\n this.themeObserver = observeThemeChanges(() => this.updateChartColors());\n this.setupResizeObserver();\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.chart?.destroy();\n this.themeObserver?.disconnect();\n this.resizeObserver?.disconnect();\n }\n\n /**\n * The layout's isTooSmall decides which side the chart is on (one\n * threshold serves half and full circles); a flip changes the plugin\n * set, so the chart is rebuilt rather than updated.\n */\n private setupResizeObserver() {\n if (!this.canvasEl) return;\n\n this.resizeObserver = observeLabelThreshold(\n this.canvasEl,\n () => !this.lastDimensions?.isTooSmall,\n {\n rebuild: () => {\n this.chart?.destroy();\n this.createChart();\n },\n update: () => this.updateChart(),\n }\n );\n }\n\n private prepareChartData() {\n const values = this.data.map((d) => d.value);\n const labels = this.data.map((d) => d.label);\n const remaining = Math.max(0, this.max - this.total);\n const chartColors = getChartColorsOrDefault(\n this,\n this.colors,\n this.priority === Priority.enhanced\n ? CHART_SECTOR_ENHANCED_COLORS\n : CHART_SECTOR_DEFAULT_COLORS\n );\n const segmentColors = values.map(\n (_, index) =>\n chartColors[index % chartColors.length] ??\n getCssVariableValue(this, DONUT_DIMENSIONS.REMAINING_COLOR)\n );\n\n return {\n values: [...values, remaining],\n labels: [...labels, 'Remaining'],\n colors: [\n ...segmentColors,\n getCssVariableValue(this, DONUT_DIMENSIONS.REMAINING_COLOR),\n ],\n };\n }\n\n /**\n * Build a dataset configuration object shared by both createChart and updateChart\n */\n private createDatasetConfig(\n values: number[],\n colors: (string | CanvasGradient | CanvasPattern)[]\n ): ChartDataset<'doughnut', number[]> {\n return {\n data: values,\n backgroundColor: colors,\n borderWidth: 1,\n borderColor: getCssVariableValue(\n this,\n DONUT_DIMENSIONS.GAP_AND_BORDER_COLOR\n ),\n borderRadius: this.getBorderRadius(values),\n spacing: DONUT_DIMENSIONS.GAP_WIDTH,\n };\n }\n\n /**\n * Get Chart.js options using centralized fixed height layout calculation\n */\n private getChartOptions(): ChartOptions<'doughnut'> {\n // Use centralized layout calculation helper\n const dimensions = calculateFixedHeightChartLayout({\n fixedHeight: this.fixedHeight,\n isHalfMode: this.half,\n showOuterLabels: this.showOuterLabels,\n canvasEl: this.canvasEl,\n layoutConfig: this.getLayoutConfig(),\n host: this,\n });\n\n // Store dimensions for explicit canvas sizing in createChart/updateChart\n this.lastDimensions = dimensions;\n\n // Store formatted labels for use in plugins\n this.formattedLabels = dimensions.formattedLabels;\n\n // Set CSS variables for wrapper and canvas sizing\n this.style.setProperty('--chart-width', `${dimensions.calculatedWidth}px`);\n this.style.setProperty('--chart-height', `${dimensions.actualHeight}px`);\n\n // Calculate dynamic padding for Chart.js layout\n const dynamicPadding = dimensions.isTooSmall\n ? {top: 0, right: 0, bottom: 0, left: 0}\n : {\n top: dimensions.topPadding,\n right: dimensions.rightPadding,\n bottom: dimensions.bottomPadding,\n left: dimensions.leftPadding,\n };\n\n return {\n // Chart.js responsive mode must stay off: it measures the wrapper,\n // whose size derives from the canvas, and re-applies stale deferred\n // resizes on the first mouse-over (#1061).\n responsive: false,\n maintainAspectRatio: false,\n devicePixelRatio: window.devicePixelRatio,\n rotation: this.half ? -90 : 0,\n circumference: this.half ? 180 : 360,\n cutout: `${((DONUT_DIMENSIONS.CHART_WIDTH - this.thickness * 2) / DONUT_DIMENSIONS.CHART_WIDTH) * 100}%`,\n layout: {\n padding: dynamicPadding ?? DONUT_DIMENSIONS.CANVAS_PADDING,\n },\n plugins: {\n legend: {\n display: false,\n labels: {\n generateLabels: () => [], // Prevent Chart.js from generating labels internally\n },\n onClick: () => {}, // Disable legend click handler\n },\n tooltip: {\n ...getChartTooltipOptions(this),\n enabled: !dimensions.isTooSmall,\n filter: (tooltipItem) => tooltipItem.label !== 'Remaining',\n callbacks: {\n title: () => '', // No title line\n label: (context) => {\n const label = context.label ?? '';\n const value = context.parsed;\n // Denominator: use max if set, otherwise total, with minimum of 1\n const denominator =\n this.max > 0 ? this.max : this.total > 0 ? this.total : 1;\n // Calculate percentage if unit is \"%\", otherwise use raw value\n const isPercentage = this.outerLabelUnit === '%';\n const numericValue = formatChartNumber(\n value,\n denominator,\n isPercentage,\n this.outerLabelDecimalPlaces\n );\n const showUnit = this.showUnit && this.outerLabelUnit;\n // Chart.js core only supports string/array-of-string for label callback\n // For now, return a single string (styled via global tooltip options)\n // To support per-span styling, a custom HTML tooltip plugin is needed\n return showUnit\n ? `${label} ${numericValue}${this.outerLabelUnit}`\n : `${label} ${numericValue}`;\n },\n },\n },\n },\n animation: {\n animateRotate: false,\n animateScale: false,\n },\n };\n }\n\n private createOuterLabelDonutPlugin(): Plugin<'doughnut'> {\n const basePlugin = createArcOuterLabelPlugin(this, {\n formattedLabels: this.formattedLabels,\n }) as Plugin<'doughnut'>;\n\n // Wrap the afterDatasetsDraw to check the size threshold first\n const originalAfterDatasetsDraw = basePlugin.afterDatasetsDraw;\n if (originalAfterDatasetsDraw) {\n basePlugin.afterDatasetsDraw = (chart, args, pluginOptions, options) => {\n // Use the layout decision (fixedHeight-based), NOT the rendered canvas\n // height: in half mode the canvas is only about half of fixedHeight\n // tall while the arc is just as large as a full donut's\n if (this.lastDimensions?.isTooSmall) {\n return;\n }\n originalAfterDatasetsDraw(chart, args, pluginOptions, options);\n };\n }\n\n return basePlugin;\n }\n\n private createCenterReadoutDonutPlugin(): Plugin<'doughnut'> {\n return {\n id: 'centerText',\n beforeDraw: (chart) => {\n const {ctx, chartArea} = chart;\n const {width, height, left, top} = chartArea;\n\n // Hide center readout if the chart is too small; use the layout\n // decision (fixedHeight-based), not the rendered canvas height, so\n // half and full mode agree\n if (this.lastDimensions?.isTooSmall) {\n return;\n }\n\n ctx.save();\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n\n const centerX = left + width / 2;\n const fontFamily = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontFamily\n );\n const lineGap = 4;\n\n // Setup and measure centered readout value text\n const valueFontWeight = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.value.fontWeightVar\n );\n const valueFontSize = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.value.fontSizeVar\n );\n const valueColor = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.value.fontColorVar\n );\n ctx.font = `${valueFontWeight} ${valueFontSize} ${fontFamily}`;\n // Center readout always shows raw total value without decimal places\n const centerValueText = this.total.toFixed(0);\n const valueMetrics = ctx.measureText(centerValueText);\n const valueHeight =\n valueMetrics.actualBoundingBoxAscent +\n valueMetrics.actualBoundingBoxDescent;\n\n // Setup and measure centered readout label and unit text (inline, different styles)\n const labelFontWeight = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.label.fontWeightVar\n );\n const labelFontSize = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.label.fontSizeVar\n );\n const labelColor = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.label.fontColorVar\n );\n const unitFontWeight = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.unit.fontWeightVar\n );\n const unitFontSize = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.unit.fontSizeVar\n );\n const unitColor = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.unit.fontColorVar\n );\n const centerReadoutLabelText = this.centerReadoutLabel;\n const centerReadoutUnitText = this.centerReadoutUnit;\n const space = centerReadoutUnitText ? ' ' : '';\n ctx.font = `${labelFontWeight} ${labelFontSize} ${fontFamily}`;\n const labelMetrics = ctx.measureText(centerReadoutLabelText);\n const spaceMetrics = ctx.measureText(space);\n ctx.font = `${unitFontWeight} ${unitFontSize} ${fontFamily}`;\n const unitMetrics = ctx.measureText(centerReadoutUnitText);\n // Height is max of label and unit\n const labelHeight = Math.max(\n labelMetrics.actualBoundingBoxAscent +\n labelMetrics.actualBoundingBoxDescent,\n unitMetrics.actualBoundingBoxAscent +\n unitMetrics.actualBoundingBoxDescent\n );\n\n // Calculate Y positions\n let valueY: number;\n let labelY: number;\n\n if (this.half) {\n // For half donut: Get the actual arc center Y position from the chart metadata\n const meta = chart.getDatasetMeta(0);\n const arcCenterY = meta.data[0]\n ? (meta.data[0] as ArcElement).y\n : top + height;\n labelY =\n arcCenterY -\n Math.max(\n labelMetrics.actualBoundingBoxDescent,\n unitMetrics.actualBoundingBoxDescent\n );\n valueY =\n labelY -\n labelHeight -\n lineGap -\n valueHeight +\n valueMetrics.actualBoundingBoxAscent;\n } else {\n // For full donut: center both lines vertically as a unit\n const totalTextHeight = valueHeight + lineGap + labelHeight;\n const centerY = top + height / 2;\n valueY =\n centerY -\n totalTextHeight / 2 +\n valueMetrics.actualBoundingBoxAscent;\n labelY =\n valueY +\n valueMetrics.actualBoundingBoxDescent +\n lineGap +\n Math.max(\n labelMetrics.actualBoundingBoxAscent,\n unitMetrics.actualBoundingBoxAscent\n );\n }\n\n // Draw centered readout value\n ctx.font = `${valueFontWeight} ${valueFontSize} ${fontFamily}`;\n ctx.fillStyle = valueColor;\n ctx.fillText(centerValueText, centerX, valueY);\n\n // Draw centered readout label and unit inline, with different styles\n // Measure total width for centering\n ctx.font = `${labelFontWeight} ${labelFontSize} ${fontFamily}`;\n const labelWidth = labelMetrics.width;\n const spaceWidth = spaceMetrics.width;\n ctx.font = `${unitFontWeight} ${unitFontSize} ${fontFamily}`;\n const unitWidth = unitMetrics.width;\n const totalWidth =\n labelWidth + (centerReadoutUnitText ? spaceWidth + unitWidth : 0);\n ctx.font = `${labelFontWeight} ${labelFontSize} ${fontFamily}`;\n ctx.fillStyle = labelColor;\n ctx.fillText(\n centerReadoutLabelText,\n centerX - totalWidth / 2 + labelWidth / 2,\n labelY\n );\n // Draw space and unit (if present)\n if (centerReadoutUnitText) {\n // Draw space (in label font)\n ctx.font = `${labelFontWeight} ${labelFontSize} ${fontFamily}`;\n ctx.fillStyle = labelColor;\n ctx.fillText(\n space,\n centerX - totalWidth / 2 + labelWidth + spaceWidth / 2,\n labelY\n );\n // Draw unit (in unit font)\n ctx.font = `${unitFontWeight} ${unitFontSize} ${fontFamily}`;\n ctx.fillStyle = unitColor;\n ctx.fillText(\n centerReadoutUnitText,\n centerX + totalWidth / 2 - unitWidth / 2,\n labelY\n );\n }\n\n ctx.restore();\n },\n };\n }\n\n private getBorderRadius(values: number[]) {\n // Full donuts don't need border radius (from Figma design)\n if (!this.half) {\n return undefined;\n }\n\n // For half donuts, apply different radius to first and last segments (detail from Figma)\n const remaining = Math.max(0, this.max - this.total);\n const hasRemainingSegment = remaining > 0;\n\n return values.map((_value, index) => {\n // First segment gets left-side radius\n if (index === 0) {\n return {\n outerStart: DONUT_DIMENSIONS.BORDER_RADIUS,\n outerEnd: 0,\n innerStart: DONUT_DIMENSIONS.BORDER_RADIUS,\n innerEnd: 0,\n };\n }\n\n // Last visible segment gets right-side radius\n // If there's a remaining segment, it's always last; otherwise the last data segment is last\n const isLastVisibleSegment = hasRemainingSegment\n ? index === values.length - 1\n : index === values.length - 2;\n\n if (isLastVisibleSegment) {\n return {\n outerStart: 0,\n outerEnd: DONUT_DIMENSIONS.BORDER_RADIUS,\n innerStart: 0,\n innerEnd: DONUT_DIMENSIONS.BORDER_RADIUS,\n };\n }\n\n // Middle segments don't need radius\n return 0;\n });\n }\n\n private createChart() {\n // Guard: Verify canvas exists and is connected to DOM\n if (!this.canvasEl || !this.canvasEl.isConnected) return;\n\n const ctx = this.canvasEl.getContext('2d');\n if (!ctx) return;\n\n const {values, labels, colors} = this.prepareChartData();\n const options = this.getChartOptions();\n\n // Non-responsive mode: set the canvas render size explicitly from the\n // computed layout; Chart.js applies devicePixelRatio scaling on top\n if (this.lastDimensions) {\n this.canvasEl.width = this.lastDimensions.calculatedWidth;\n this.canvasEl.height = this.lastDimensions.actualHeight;\n }\n\n this.chart = new Chart(ctx, {\n type: 'doughnut',\n data: {\n labels,\n datasets: [this.createDatasetConfig(values, colors)],\n },\n options,\n plugins: [\n // Always include plugins; they check height internally during rendering\n ...(this.showOuterLabels ? [this.createOuterLabelDonutPlugin()] : []),\n this.createCenterReadoutDonutPlugin(),\n ],\n });\n\n // Defer legend update to next tick to ensure Chart.js metadata is initialized\n requestAnimationFrame(() => this.updateLegend());\n }\n\n private updateChart() {\n // Guard: Verify chart and canvas still exist and are connected\n if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected) return;\n\n const {values, labels, colors} = this.prepareChartData();\n\n this.chart.data.labels = labels;\n this.chart.data.datasets = [this.createDatasetConfig(values, colors)];\n\n const latestOptions = this.getChartOptions();\n if (this.chart.options) {\n Object.assign(this.chart.options, latestOptions);\n }\n\n // Non-responsive mode: apply the computed layout size explicitly\n // (no-op when the size is unchanged)\n if (this.lastDimensions) {\n this.chart.resize(\n this.lastDimensions.calculatedWidth,\n this.lastDimensions.actualHeight\n );\n }\n\n this.chart.update();\n\n // Update legend after chart update completes to ensure metadata is ready\n requestAnimationFrame(() => this.updateLegend());\n }\n\n /**\n * Update only chart colors without recalculating layout\n * Used by theme observer for efficient theme changes\n */\n private updateChartColors() {\n if (!this.chart) return;\n\n const {colors} = this.prepareChartData();\n\n if (this.chart.data.datasets[0]) {\n this.chart.data.datasets[0].backgroundColor = colors;\n this.chart.data.datasets[0].borderColor = getCssVariableValue(\n this,\n DONUT_DIMENSIONS.GAP_AND_BORDER_COLOR\n );\n }\n\n // Update without animation for instant theme change\n this.chart.update('none');\n\n this.updateLegend();\n }\n\n /**\n * Update the legend HTML content\n */\n private updateLegend() {\n // Guard: Check if legend should be shown and chart is ready\n if (!this.legend || !this.legendDiv || !this.chart) return;\n\n // Guard: Check if chart metadata is available\n const meta = this.chart.getDatasetMeta(0);\n if (!meta || !meta.controller) {\n return;\n }\n\n // Guard: Check if dataset has data\n if (!this.data || this.data.length === 0) {\n this.legendDiv.innerHTML = '';\n return;\n }\n\n // Denominator: use max if set, otherwise total, with minimum of 1\n const denominator =\n this.max > 0 ? this.max : this.total > 0 ? this.total : 1;\n const isPercentage = this.outerLabelUnit === '%';\n\n try {\n const legendItems = this.data.map((item, i) => {\n const style = meta.controller.getStyle(i, false);\n const numericValue = formatChartNumber(\n item.value,\n denominator,\n isPercentage,\n this.outerLabelDecimalPlaces\n );\n const showUnit = this.showUnit && this.outerLabelUnit;\n const value = `${numericValue}`;\n const unit = showUnit ? `${this.outerLabelUnit}` : '';\n\n return {\n fillStyle: style.backgroundColor as string,\n label: item.label as string,\n value: value as string,\n unit: unit as string,\n };\n });\n\n const legendHTML = generateLegendHTML(legendItems);\n this.legendDiv.innerHTML = legendHTML;\n } catch (error) {\n console.debug(\n '[obc-donut-chart] updateLegend: error generating legend HTML',\n error\n );\n // Silent failure - don't throw, just skip legend update this time\n }\n }\n\n override render() {\n return html`\n <div class=\"wrapper\">\n <canvas></canvas>\n ${this.legend ? html`<div class=\"legend\"></div>` : ''}\n </div>\n `;\n }\n\n static override styles = [\n unsafeCSS(componentStyle),\n unsafeCSS(chartCommonStyle),\n unsafeCSS(chartLegendStyle),\n unsafeCSS(chartDebugStyle),\n ];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-donut-chart': ObcDonutChart;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,SAAS,oBAAoB,YAAY,OAAO;AAGtD,IAAM,mBAAmB;CACvB,GAAG;CACH,WAAW;CACX,sBAAsB;CACtB,iBAAiB;CACjB,eAAe;AACjB;AAEA,IAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,2BAA2B;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AA6FO,IAAM,gBAAN,MAAM,sBAAsB,WAAW;;;EAEf,KAAA,OAAA,CAAC;EAGX,KAAA,SAAA,CAAC;EAGC,KAAA,WAAA,SAAS;EAGvB,KAAA,OAAA;EAGW,KAAA,kBAAA;EAGP,KAAA,WAAA;EAGM,KAAA,iBAAA;EAKK,KAAA,sBAAA;EAKI,KAAA,0BAAA;EAGL,KAAA,qBAAA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A,cAAA,WAAA,sBAAA,KAAA,CAAA;AAGvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,cAAA,WAAA,qBAAA,KAAA,CAAA;AAGvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,cAAA,WAAA,OAAA,KAAA,CAAA;AAGvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,cAAA,WAAA,aAAA,KAAA,CAAA;AAGvB,WAAA,CAAA,SAAS;CAAC,MAAM;CAAS,SAAS;AAAI,CAAC,CAAA,GAAA,cAAA,WAAA,UAAA,KAAA,CAAA;AAGvC,WAAA,CAAA,SAAS;CAAC,MAAM;CAAS,SAAS;AAAI,CAAC,CAAA,GAAA,cAAA,WAAA,oBAAA,KAAA,CAAA;AAGvC,WAAA,CAAA,SAAS;CAAC,MAAM;CAAQ,SAAS;AAAI,CAAC,CAAA,GAAA,cAAA,WAAA,eAAA,KAAA,CAAA;AAItC,WAAA,CAAA,MAAM,CAAA,GAAA,cAAA,WAAA,SAAA,KAAA,CAAA;AAGN,WAAA,CAAA,MAAM,CAAA,GAAA,cAAA,WAAA,mBAAA,KAAA,CAAA;AAGN,WAAA,CAAA,MAAM,QAAQ,CAAA,GAAA,cAAA,WAAA,YAAA,KAAA,CAAA;AAGd,WAAA,CAAA,MAAM,SAAS,CAAA,GAAA,cAAA,WAAA,aAAA,KAAA,CAAA;AAhEjB,gBAAA,WAAA,CAAA,cAAc,iBAAiB,CAAA,GAAA,aAAA"}
|
|
1
|
+
{"version":3,"file":"donut-chart.js","names":[],"sources":["../../../src/bars-graphs/donut-chart/donut-chart.ts"],"sourcesContent":["import {LitElement, PropertyValues, html, unsafeCSS} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport componentStyle from './donut-chart.css?inline';\nimport chartCommonStyle from '../../charthelpers/chart-common.css?inline';\nimport chartDebugStyle from '../../charthelpers/chart-debug.css?inline';\nimport chartLegendStyle from '../../charthelpers/chart-legend.css?inline';\nimport {customElement} from '../../decorator.js';\nimport {Priority} from '../../navigation-instruments/types.js';\nimport {Chart, DoughnutController, ArcElement, Tooltip} from 'chart.js';\nimport type {Plugin, ChartOptions, ChartDataset} from 'chart.js';\nimport {\n CHART_SECTOR_DEFAULT_COLORS,\n CHART_SECTOR_ENHANCED_COLORS,\n CHART_DIMENSIONS,\n OUTER_LABEL_CONFIG,\n CENTER_READOUT_CONFIG,\n getCssVariableValue,\n getChartColorsOrDefault,\n observeThemeChanges,\n calculateSumTotal,\n formatChartNumber,\n createArcOuterLabelPlugin,\n calculateFixedHeightChartLayout,\n getChartTooltipOptions,\n renderLegend,\n observeLabelThreshold,\n} from '../../charthelpers/index.js';\nimport type {FixedHeightChartDimensions} from '../../charthelpers/canvas-layout.js';\n\n// Register Chart.js components\nChart.register(DoughnutController, ArcElement, Tooltip);\n\n// Donut-specific dimension constants (extends shared CHART_DIMENSIONS)\nconst DONUT_DIMENSIONS = {\n ...CHART_DIMENSIONS,\n GAP_WIDTH: 0,\n GAP_AND_BORDER_COLOR: '--container-section-color',\n REMAINING_COLOR: '--border-outline-color',\n BORDER_RADIUS: 4,\n} as const;\n\nconst DONUT_RECREATE_PROP_NAMES = [\n 'half',\n 'showOuterLabels',\n 'showUnit',\n 'outerLabelUnit',\n 'outerLabelMaxLength',\n 'outerLabelDecimalPlaces',\n 'showDebugOverlay',\n 'fixedHeight',\n] as const;\n\nconst DONUT_WATCHED_PROP_NAMES = [\n 'legend',\n 'data',\n 'colors',\n 'priority',\n 'half',\n 'thickness',\n 'max',\n 'showOuterLabels',\n 'showUnit',\n 'centerReadoutLabel',\n 'centerReadoutUnit',\n 'outerLabelUnit',\n 'outerLabelMaxLength',\n 'outerLabelDecimalPlaces',\n 'showDebugOverlay',\n 'fixedHeight',\n] as const;\n\nexport type DonutChartDataItem = {\n label: string;\n value: number;\n};\n\n/**\n * `<obc-donut-chart>` – A customizable donut chart component for visualizing proportional data with a center total readout.\n *\n * This component renders an interactive donut chart powered by Chart.js, displaying data segments as arcs with optional outer labels and a centered total value. It supports both full-circle (360°) and half-circle (180°) layouts, making it versatile for dashboards, analytics, and data visualization interfaces.\n *\n * The chart automatically calculates percentages, handles remaining/unfilled capacity, and adapts its layout based on available space. Labels and center readouts are hidden when the chart is too small (`fixedHeight` < 192px; the same threshold applies to half circles, whose arc is just as large as a full circle's at the same `fixedHeight`), ensuring visual clarity at all sizes.\n *\n * ## Features\n * - **Fixed Height ⇒ Fixed Circumference:** The chart's circumference is determined by the `fixedHeight` property (default: 320px). This ensures the donut's circumference remains consistent and matches other radial instruments, regardless of the available browser or container width. The chart does not scale to fill the width; instead, it always uses the specified fixed height to define its size and circumference.\n * - **Layout Modes:**\n * - `Full Circle` (default): Complete 360° donut chart.\n * - `Half Circle`: Semicircular 180° layout, useful for gauges or space-constrained displays.\n * - **Center Readout:**\n * - Displays the sum total of all data values with a customizable label (e.g., \"Total\", \"Power\", \"Usage\").\n * - **Outer Labels:**\n * - Optional labels positioned outside the chart showing segment names and values.\n * - Supports percentage or custom units (e.g., \"kW\", \"kg\", \"MB\").\n * - Configurable decimal places and maximum label length (with trimming).\n * - **Capacity Visualization:**\n * - Optionally show remaining/unfilled capacity when `max` is set higher than the total.\n * - Remaining sector uses a distinct color to indicate available space.\n * - **Customization:**\n * - Custom segment colors (with automatic fallback to theme palette).\n * - Adjustable ring thickness (default 24px).\n * - **Color Priority:** Set `priority` to `Priority.enhanced` to use the blue/enhanced\n * color palette instead of the default gray/regular palette (default: `Priority.regular`).\n * - **Responsive Behavior:**\n * - Automatically hides labels and center readout when `fixedHeight` < 192px\n * (same threshold for full and half circle mode).\n * - Maintains aspect ratio and adjusts padding for optimal label positioning.\n * - **Theme Integration:**\n * - Colors update automatically when the `data-obc-theme` attribute changes on the `<html>` element.\n * - Example:\n * ```\n * <html lang=\"en\" data-obc-theme=\"day\"></html>\n * ```\n *\n * ## Example\n *\n * **Basic Usage (Half Circle)**\n * ```html\n * <obc-donut-chart\n * half\n * ></obc-donut-chart>\n * <script>\n * document.querySelector('obc-donut-chart').data = [\n * {label: 'Engine', value: 75.5},\n * {label: 'HVAC', value: 42.3},\n * {label: 'Lights', value: 12.8}\n * ];\n * </script>\n * ```\n *\n * **Custom Colors**\n * ```html\n * <obc-donut-chart></obc-donut-chart>\n * <script>\n * const chart = document.querySelector('obc-donut-chart');\n * chart.data = [\n * {label: 'Critical', value: 20},\n * {label: 'Warning', value: 35},\n * {label: 'Normal', value: 45}\n * ];\n * chart.colors = ['#e74c3c', '#f39c12', '#2ecc71'];\n * </script>\n * ```\n *\n * @property data - Chart data segments (set via JavaScript)\n * @property colors - Custom segment colors (set via JavaScript) with fallback to theme palette\n * @property half - Whether to display as half-circle (180°) or full circle (360°), default: false\n * @property showOuterLabels - Show outer labels, default: false\n * @property showUnit - Whether to show unit in labels, default: false\n * @property outerLabelUnit - Unit string to append to outer labels, default: \"%\"\n * @property outerLabelMaxLength - Maximum character length for labels before trim (0 = no limit), default: 0\n * @availableWhen outerLabelMaxLength showOuterLabels==true\n * @property outerLabelDecimalPlaces - Number of decimal places in labels, default: 0\n * @property centerReadoutLabel - Text label shown below the center total value, default: \"Total\"\n * @property centerReadoutUnit - Unit string shown inline after the label in the center readout, default: \"%\"\n * @property max - Maximum value for calculating remaining empty sector, default: 100\n * @property thickness - Donut ring thickness in pixels, default: 24\n * @property legend - Whether to display the legend below the chart, default: false\n * @property showDebugOverlay - Show debug overlay for development, default: false\n * @property fixedHeight - Fixed height of the chart in pixels (determines chart circumference), default: 320. The chart's circumference is always based on this fixed height to match other radial instruments.\n * @beta\n */\n@customElement('obc-donut-chart')\nexport class ObcDonutChart extends LitElement {\n @property({type: Array, attribute: false})\n data: DonutChartDataItem[] = [];\n\n @property({type: Array, attribute: false})\n colors: string[] = [];\n\n @property({type: String})\n priority: Priority = Priority.regular;\n\n @property({type: Boolean, reflect: true})\n half = false;\n\n @property({type: Boolean})\n showOuterLabels = false;\n\n @property({type: Boolean})\n showUnit = false;\n\n @property({type: String})\n outerLabelUnit = '%';\n\n @property({\n type: Number,\n })\n outerLabelMaxLength = 0;\n\n @property({\n type: Number,\n })\n outerLabelDecimalPlaces = 0;\n\n @property({type: String})\n centerReadoutLabel = 'Total';\n\n @property({type: String})\n centerReadoutUnit = '%';\n\n @property({type: Number})\n max = 100;\n\n @property({type: Number})\n thickness = 24;\n\n @property({type: Boolean, reflect: true})\n legend = false;\n\n @property({type: Boolean, reflect: true})\n showDebugOverlay = false;\n\n @property({type: Number, reflect: true})\n fixedHeight = 320;\n\n /** @internal */\n @state() private total = 0;\n\n /** @internal - Pre-formatted labels for outer label rendering */\n @state() private formattedLabels: string[] = [];\n\n /** @internal */\n @query('canvas') private canvasEl?: HTMLCanvasElement;\n\n /** @internal */\n @query('.legend') private legendDiv?: HTMLDivElement;\n\n /** @internal */\n private chart?: Chart;\n\n /** @internal - Latest layout dimensions computed by getChartOptions() */\n private lastDimensions?: FixedHeightChartDimensions;\n\n /** @internal */\n private themeObserver?: MutationObserver;\n\n /** @internal - ResizeObserver for tracking height threshold crossings (e.g. MIN_HEIGHT_WITH_LABELS = 192px) */\n private resizeObserver?: ResizeObserver;\n\n private hasAnyChanged(\n changed: PropertyValues,\n props: readonly (keyof ObcDonutChart)[]\n ): boolean {\n return props.some((prop) => changed.has(prop));\n }\n\n /**\n * Get layout configuration for canvas calculation\n */\n private getLayoutConfig() {\n // Denominator: use max if set, otherwise total, with minimum of 1\n const denominator =\n this.max > 0 ? this.max : this.total > 0 ? this.total : 1;\n\n return {\n unit: this.outerLabelUnit,\n showUnit: this.showUnit,\n outerLabelMaxLength: this.outerLabelMaxLength,\n decimalPlaces: this.outerLabelDecimalPlaces,\n data: this.data,\n denominator,\n };\n }\n\n // Calculate derived state BEFORE render\n override willUpdate(changed: PropertyValues) {\n if (changed.has('data')) {\n this.total = calculateSumTotal(this.data);\n }\n }\n\n // Update external library AFTER render\n override updated(changed: PropertyValues) {\n super.updated(changed);\n\n if (this.hasAnyChanged(changed, DONUT_WATCHED_PROP_NAMES)) {\n // Recreate chart when major layout properties change or when plugin configuration changes\n // These properties affect aspect ratio calculation, plugin registration, or outer label rendering\n const needsRecreation = this.hasAnyChanged(\n changed,\n DONUT_RECREATE_PROP_NAMES\n );\n\n if (needsRecreation) {\n this.chart?.destroy();\n this.createChart();\n } else {\n this.updateChart();\n }\n }\n }\n\n override firstUpdated() {\n this.createChart();\n this.themeObserver = observeThemeChanges(() => this.updateChartColors());\n this.setupResizeObserver();\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.chart?.destroy();\n this.themeObserver?.disconnect();\n this.resizeObserver?.disconnect();\n }\n\n /**\n * The layout's isTooSmall decides which side the chart is on (one\n * threshold serves half and full circles); a flip changes the plugin\n * set, so the chart is rebuilt rather than updated.\n */\n private setupResizeObserver() {\n if (!this.canvasEl) return;\n\n this.resizeObserver = observeLabelThreshold(\n this.canvasEl,\n () => !this.lastDimensions?.isTooSmall,\n {\n rebuild: () => {\n this.chart?.destroy();\n this.createChart();\n },\n update: () => this.updateChart(),\n }\n );\n }\n\n private prepareChartData() {\n const values = this.data.map((d) => d.value);\n const labels = this.data.map((d) => d.label);\n const remaining = Math.max(0, this.max - this.total);\n const chartColors = getChartColorsOrDefault(\n this,\n this.colors,\n this.priority === Priority.enhanced\n ? CHART_SECTOR_ENHANCED_COLORS\n : CHART_SECTOR_DEFAULT_COLORS\n );\n const segmentColors = values.map(\n (_, index) =>\n chartColors[index % chartColors.length] ??\n getCssVariableValue(this, DONUT_DIMENSIONS.REMAINING_COLOR)\n );\n\n return {\n values: [...values, remaining],\n labels: [...labels, 'Remaining'],\n colors: [\n ...segmentColors,\n getCssVariableValue(this, DONUT_DIMENSIONS.REMAINING_COLOR),\n ],\n };\n }\n\n /**\n * Build a dataset configuration object shared by both createChart and updateChart\n */\n private createDatasetConfig(\n values: number[],\n colors: (string | CanvasGradient | CanvasPattern)[]\n ): ChartDataset<'doughnut', number[]> {\n return {\n data: values,\n backgroundColor: colors,\n borderWidth: 1,\n borderColor: getCssVariableValue(\n this,\n DONUT_DIMENSIONS.GAP_AND_BORDER_COLOR\n ),\n borderRadius: this.getBorderRadius(values),\n spacing: DONUT_DIMENSIONS.GAP_WIDTH,\n };\n }\n\n /**\n * Get Chart.js options using centralized fixed height layout calculation\n */\n private getChartOptions(): ChartOptions<'doughnut'> {\n // Use centralized layout calculation helper\n const dimensions = calculateFixedHeightChartLayout({\n fixedHeight: this.fixedHeight,\n isHalfMode: this.half,\n showOuterLabels: this.showOuterLabels,\n canvasEl: this.canvasEl,\n layoutConfig: this.getLayoutConfig(),\n host: this,\n });\n\n // Store dimensions for explicit canvas sizing in createChart/updateChart\n this.lastDimensions = dimensions;\n\n // Store formatted labels for use in plugins\n this.formattedLabels = dimensions.formattedLabels;\n\n // Set CSS variables for wrapper and canvas sizing\n this.style.setProperty('--chart-width', `${dimensions.calculatedWidth}px`);\n this.style.setProperty('--chart-height', `${dimensions.actualHeight}px`);\n\n // Calculate dynamic padding for Chart.js layout\n const dynamicPadding = dimensions.isTooSmall\n ? {top: 0, right: 0, bottom: 0, left: 0}\n : {\n top: dimensions.topPadding,\n right: dimensions.rightPadding,\n bottom: dimensions.bottomPadding,\n left: dimensions.leftPadding,\n };\n\n return {\n // Chart.js responsive mode must stay off: it measures the wrapper,\n // whose size derives from the canvas, and re-applies stale deferred\n // resizes on the first mouse-over (#1061).\n responsive: false,\n maintainAspectRatio: false,\n devicePixelRatio: window.devicePixelRatio,\n rotation: this.half ? -90 : 0,\n circumference: this.half ? 180 : 360,\n cutout: `${((DONUT_DIMENSIONS.CHART_WIDTH - this.thickness * 2) / DONUT_DIMENSIONS.CHART_WIDTH) * 100}%`,\n layout: {\n padding: dynamicPadding ?? DONUT_DIMENSIONS.CANVAS_PADDING,\n },\n plugins: {\n legend: {\n display: false,\n labels: {\n generateLabels: () => [], // Prevent Chart.js from generating labels internally\n },\n onClick: () => {}, // Disable legend click handler\n },\n tooltip: {\n ...getChartTooltipOptions(this),\n enabled: !dimensions.isTooSmall,\n filter: (tooltipItem) => tooltipItem.label !== 'Remaining',\n callbacks: {\n title: () => '', // No title line\n label: (context) => {\n const label = context.label ?? '';\n const value = context.parsed;\n // Denominator: use max if set, otherwise total, with minimum of 1\n const denominator =\n this.max > 0 ? this.max : this.total > 0 ? this.total : 1;\n // Calculate percentage if unit is \"%\", otherwise use raw value\n const isPercentage = this.outerLabelUnit === '%';\n const numericValue = formatChartNumber(\n value,\n denominator,\n isPercentage,\n this.outerLabelDecimalPlaces\n );\n const showUnit = this.showUnit && this.outerLabelUnit;\n // Chart.js core only supports string/array-of-string for label callback\n // For now, return a single string (styled via global tooltip options)\n // To support per-span styling, a custom HTML tooltip plugin is needed\n return showUnit\n ? `${label} ${numericValue}${this.outerLabelUnit}`\n : `${label} ${numericValue}`;\n },\n },\n },\n },\n animation: {\n animateRotate: false,\n animateScale: false,\n },\n };\n }\n\n private createOuterLabelDonutPlugin(): Plugin<'doughnut'> {\n const basePlugin = createArcOuterLabelPlugin(this, {\n formattedLabels: this.formattedLabels,\n }) as Plugin<'doughnut'>;\n\n // Wrap the afterDatasetsDraw to check the size threshold first\n const originalAfterDatasetsDraw = basePlugin.afterDatasetsDraw;\n if (originalAfterDatasetsDraw) {\n basePlugin.afterDatasetsDraw = (chart, args, pluginOptions, options) => {\n // Use the layout decision (fixedHeight-based), NOT the rendered canvas\n // height: in half mode the canvas is only about half of fixedHeight\n // tall while the arc is just as large as a full donut's\n if (this.lastDimensions?.isTooSmall) {\n return;\n }\n originalAfterDatasetsDraw(chart, args, pluginOptions, options);\n };\n }\n\n return basePlugin;\n }\n\n private createCenterReadoutDonutPlugin(): Plugin<'doughnut'> {\n return {\n id: 'centerText',\n beforeDraw: (chart) => {\n const {ctx, chartArea} = chart;\n const {width, height, left, top} = chartArea;\n\n // Hide center readout if the chart is too small; use the layout\n // decision (fixedHeight-based), not the rendered canvas height, so\n // half and full mode agree\n if (this.lastDimensions?.isTooSmall) {\n return;\n }\n\n ctx.save();\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n\n const centerX = left + width / 2;\n const fontFamily = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontFamily\n );\n const lineGap = 4;\n\n // Setup and measure centered readout value text\n const valueFontWeight = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.value.fontWeightVar\n );\n const valueFontSize = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.value.fontSizeVar\n );\n const valueColor = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.value.fontColorVar\n );\n ctx.font = `${valueFontWeight} ${valueFontSize} ${fontFamily}`;\n // Center readout always shows raw total value without decimal places\n const centerValueText = this.total.toFixed(0);\n const valueMetrics = ctx.measureText(centerValueText);\n const valueHeight =\n valueMetrics.actualBoundingBoxAscent +\n valueMetrics.actualBoundingBoxDescent;\n\n // Setup and measure centered readout label and unit text (inline, different styles)\n const labelFontWeight = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.label.fontWeightVar\n );\n const labelFontSize = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.label.fontSizeVar\n );\n const labelColor = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.label.fontColorVar\n );\n const unitFontWeight = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.unit.fontWeightVar\n );\n const unitFontSize = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.unit.fontSizeVar\n );\n const unitColor = getCssVariableValue(\n this,\n CENTER_READOUT_CONFIG.unit.fontColorVar\n );\n const centerReadoutLabelText = this.centerReadoutLabel;\n const centerReadoutUnitText = this.centerReadoutUnit;\n const space = centerReadoutUnitText ? ' ' : '';\n ctx.font = `${labelFontWeight} ${labelFontSize} ${fontFamily}`;\n const labelMetrics = ctx.measureText(centerReadoutLabelText);\n const spaceMetrics = ctx.measureText(space);\n ctx.font = `${unitFontWeight} ${unitFontSize} ${fontFamily}`;\n const unitMetrics = ctx.measureText(centerReadoutUnitText);\n // Height is max of label and unit\n const labelHeight = Math.max(\n labelMetrics.actualBoundingBoxAscent +\n labelMetrics.actualBoundingBoxDescent,\n unitMetrics.actualBoundingBoxAscent +\n unitMetrics.actualBoundingBoxDescent\n );\n\n // Calculate Y positions\n let valueY: number;\n let labelY: number;\n\n if (this.half) {\n // For half donut: Get the actual arc center Y position from the chart metadata\n const meta = chart.getDatasetMeta(0);\n const arcCenterY = meta.data[0]\n ? (meta.data[0] as ArcElement).y\n : top + height;\n labelY =\n arcCenterY -\n Math.max(\n labelMetrics.actualBoundingBoxDescent,\n unitMetrics.actualBoundingBoxDescent\n );\n valueY =\n labelY -\n labelHeight -\n lineGap -\n valueHeight +\n valueMetrics.actualBoundingBoxAscent;\n } else {\n // For full donut: center both lines vertically as a unit\n const totalTextHeight = valueHeight + lineGap + labelHeight;\n const centerY = top + height / 2;\n valueY =\n centerY -\n totalTextHeight / 2 +\n valueMetrics.actualBoundingBoxAscent;\n labelY =\n valueY +\n valueMetrics.actualBoundingBoxDescent +\n lineGap +\n Math.max(\n labelMetrics.actualBoundingBoxAscent,\n unitMetrics.actualBoundingBoxAscent\n );\n }\n\n // Draw centered readout value\n ctx.font = `${valueFontWeight} ${valueFontSize} ${fontFamily}`;\n ctx.fillStyle = valueColor;\n ctx.fillText(centerValueText, centerX, valueY);\n\n // Draw centered readout label and unit inline, with different styles\n // Measure total width for centering\n ctx.font = `${labelFontWeight} ${labelFontSize} ${fontFamily}`;\n const labelWidth = labelMetrics.width;\n const spaceWidth = spaceMetrics.width;\n ctx.font = `${unitFontWeight} ${unitFontSize} ${fontFamily}`;\n const unitWidth = unitMetrics.width;\n const totalWidth =\n labelWidth + (centerReadoutUnitText ? spaceWidth + unitWidth : 0);\n ctx.font = `${labelFontWeight} ${labelFontSize} ${fontFamily}`;\n ctx.fillStyle = labelColor;\n ctx.fillText(\n centerReadoutLabelText,\n centerX - totalWidth / 2 + labelWidth / 2,\n labelY\n );\n // Draw space and unit (if present)\n if (centerReadoutUnitText) {\n // Draw space (in label font)\n ctx.font = `${labelFontWeight} ${labelFontSize} ${fontFamily}`;\n ctx.fillStyle = labelColor;\n ctx.fillText(\n space,\n centerX - totalWidth / 2 + labelWidth + spaceWidth / 2,\n labelY\n );\n // Draw unit (in unit font)\n ctx.font = `${unitFontWeight} ${unitFontSize} ${fontFamily}`;\n ctx.fillStyle = unitColor;\n ctx.fillText(\n centerReadoutUnitText,\n centerX + totalWidth / 2 - unitWidth / 2,\n labelY\n );\n }\n\n ctx.restore();\n },\n };\n }\n\n private getBorderRadius(values: number[]) {\n // Full donuts don't need border radius (from Figma design)\n if (!this.half) {\n return undefined;\n }\n\n // For half donuts, apply different radius to first and last segments (detail from Figma)\n const remaining = Math.max(0, this.max - this.total);\n const hasRemainingSegment = remaining > 0;\n\n return values.map((_value, index) => {\n // First segment gets left-side radius\n if (index === 0) {\n return {\n outerStart: DONUT_DIMENSIONS.BORDER_RADIUS,\n outerEnd: 0,\n innerStart: DONUT_DIMENSIONS.BORDER_RADIUS,\n innerEnd: 0,\n };\n }\n\n // Last visible segment gets right-side radius\n // If there's a remaining segment, it's always last; otherwise the last data segment is last\n const isLastVisibleSegment = hasRemainingSegment\n ? index === values.length - 1\n : index === values.length - 2;\n\n if (isLastVisibleSegment) {\n return {\n outerStart: 0,\n outerEnd: DONUT_DIMENSIONS.BORDER_RADIUS,\n innerStart: 0,\n innerEnd: DONUT_DIMENSIONS.BORDER_RADIUS,\n };\n }\n\n // Middle segments don't need radius\n return 0;\n });\n }\n\n private createChart() {\n // Guard: Verify canvas exists and is connected to DOM\n if (!this.canvasEl || !this.canvasEl.isConnected) return;\n\n const ctx = this.canvasEl.getContext('2d');\n if (!ctx) return;\n\n const {values, labels, colors} = this.prepareChartData();\n const options = this.getChartOptions();\n\n // Non-responsive mode: set the canvas render size explicitly from the\n // computed layout; Chart.js applies devicePixelRatio scaling on top\n if (this.lastDimensions) {\n this.canvasEl.width = this.lastDimensions.calculatedWidth;\n this.canvasEl.height = this.lastDimensions.actualHeight;\n }\n\n this.chart = new Chart(ctx, {\n type: 'doughnut',\n data: {\n labels,\n datasets: [this.createDatasetConfig(values, colors)],\n },\n options,\n plugins: [\n // Always include plugins; they check height internally during rendering\n ...(this.showOuterLabels ? [this.createOuterLabelDonutPlugin()] : []),\n this.createCenterReadoutDonutPlugin(),\n ],\n });\n\n // Defer legend update to next tick to ensure Chart.js metadata is initialized\n requestAnimationFrame(() => this.updateLegend());\n }\n\n private updateChart() {\n // Guard: Verify chart and canvas still exist and are connected\n if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected) return;\n\n const {values, labels, colors} = this.prepareChartData();\n\n this.chart.data.labels = labels;\n this.chart.data.datasets = [this.createDatasetConfig(values, colors)];\n\n const latestOptions = this.getChartOptions();\n if (this.chart.options) {\n Object.assign(this.chart.options, latestOptions);\n }\n\n // Non-responsive mode: apply the computed layout size explicitly\n // (no-op when the size is unchanged)\n if (this.lastDimensions) {\n this.chart.resize(\n this.lastDimensions.calculatedWidth,\n this.lastDimensions.actualHeight\n );\n }\n\n this.chart.update();\n\n // Update legend after chart update completes to ensure metadata is ready\n requestAnimationFrame(() => this.updateLegend());\n }\n\n /**\n * Update only chart colors without recalculating layout\n * Used by theme observer for efficient theme changes\n */\n private updateChartColors() {\n if (!this.chart) return;\n\n const {colors} = this.prepareChartData();\n\n if (this.chart.data.datasets[0]) {\n this.chart.data.datasets[0].backgroundColor = colors;\n this.chart.data.datasets[0].borderColor = getCssVariableValue(\n this,\n DONUT_DIMENSIONS.GAP_AND_BORDER_COLOR\n );\n }\n\n // Update without animation for instant theme change\n this.chart.update('none');\n\n this.updateLegend();\n }\n\n /**\n * Update the legend HTML content\n */\n private updateLegend() {\n // Guard: Check if legend should be shown and chart is ready\n if (!this.legend || !this.legendDiv || !this.chart) return;\n\n // Guard: Check if chart metadata is available\n const meta = this.chart.getDatasetMeta(0);\n if (!meta || !meta.controller) {\n return;\n }\n\n // Guard: Check if dataset has data\n if (!this.data || this.data.length === 0) {\n renderLegend(this.legendDiv, []);\n return;\n }\n\n // Denominator: use max if set, otherwise total, with minimum of 1\n const denominator =\n this.max > 0 ? this.max : this.total > 0 ? this.total : 1;\n const isPercentage = this.outerLabelUnit === '%';\n\n try {\n const legendItems = this.data.map((item, i) => {\n const style = meta.controller.getStyle(i, false);\n const numericValue = formatChartNumber(\n item.value,\n denominator,\n isPercentage,\n this.outerLabelDecimalPlaces\n );\n const showUnit = this.showUnit && this.outerLabelUnit;\n const value = `${numericValue}`;\n const unit = showUnit ? `${this.outerLabelUnit}` : '';\n\n return {\n fillStyle: style.backgroundColor as string,\n label: item.label as string,\n value: value as string,\n unit: unit as string,\n };\n });\n\n renderLegend(this.legendDiv, legendItems);\n } catch (error) {\n console.debug(\n '[obc-donut-chart] updateLegend: error generating legend HTML',\n error\n );\n // Silent failure - don't throw, just skip legend update this time\n }\n }\n\n override render() {\n return html`\n <div class=\"wrapper\">\n <canvas></canvas>\n ${this.legend ? html`<div class=\"legend\"></div>` : ''}\n </div>\n `;\n }\n\n static override styles = [\n unsafeCSS(componentStyle),\n unsafeCSS(chartCommonStyle),\n unsafeCSS(chartLegendStyle),\n unsafeCSS(chartDebugStyle),\n ];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-donut-chart': ObcDonutChart;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,SAAS,oBAAoB,YAAY,OAAO;AAGtD,IAAM,mBAAmB;CACvB,GAAG;CACH,WAAW;CACX,sBAAsB;CACtB,iBAAiB;CACjB,eAAe;AACjB;AAEA,IAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,2BAA2B;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AA6FO,IAAM,gBAAN,MAAM,sBAAsB,WAAW;;;EAEf,KAAA,OAAA,CAAC;EAGX,KAAA,SAAA,CAAC;EAGC,KAAA,WAAA,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AAiB;IAsBzB;;OAEG;IACH,OAAO,CAAC,YAAY;IAmDX,MAAM;IASf,OAAgB,MAAM,4BAKpB;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,WAAW,CAAC;KAC9B;CACF"}
|
|
@@ -5,7 +5,7 @@ import { calculateFixedHeightChartLayout, formatChartNumber, formatSingleLabel }
|
|
|
5
5
|
import { observeThemeChanges } from "../../charthelpers/theme.js";
|
|
6
6
|
import { calculateSumTotal, createArcOuterLabelPlugin } from "../../charthelpers/outer-labels.js";
|
|
7
7
|
import { getChartTooltipOptions } from "../../charthelpers/tooltip.js";
|
|
8
|
-
import {
|
|
8
|
+
import { renderLegend } from "../../charthelpers/legend.js";
|
|
9
9
|
import { observeLabelThreshold } from "../../charthelpers/label-threshold.js";
|
|
10
10
|
import "../../charthelpers/index.js";
|
|
11
11
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js";
|
|
@@ -383,7 +383,7 @@ var ObcPieChart = class ObcPieChart extends LitElement {
|
|
|
383
383
|
const meta = this.chart.getDatasetMeta(0);
|
|
384
384
|
if (!meta || !meta.controller) return;
|
|
385
385
|
if (!this.data || this.data.length === 0) {
|
|
386
|
-
this.legendDiv
|
|
386
|
+
renderLegend(this.legendDiv, []);
|
|
387
387
|
return;
|
|
388
388
|
}
|
|
389
389
|
const denominator = this.total > 0 ? this.total : 1;
|
|
@@ -402,8 +402,7 @@ var ObcPieChart = class ObcPieChart extends LitElement {
|
|
|
402
402
|
unit
|
|
403
403
|
};
|
|
404
404
|
});
|
|
405
|
-
|
|
406
|
-
this.legendDiv.innerHTML = legendHTML;
|
|
405
|
+
renderLegend(this.legendDiv, legendItems);
|
|
407
406
|
} catch (error) {
|
|
408
407
|
console.debug("[obc-pie-chart] updateLegend: error generating legend HTML", error);
|
|
409
408
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie-chart.js","names":[],"sources":["../../../src/bars-graphs/pie-chart/pie-chart.ts"],"sourcesContent":["import {LitElement, PropertyValues, html, unsafeCSS} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport componentStyle from './pie-chart.css?inline';\nimport chartCommonStyle from '../../charthelpers/chart-common.css?inline';\nimport chartDebugStyle from '../../charthelpers/chart-debug.css?inline';\nimport chartLegendStyle from '../../charthelpers/chart-legend.css?inline';\nimport {customElement} from '../../decorator.js';\nimport {Priority} from '../../navigation-instruments/types.js';\nimport {\n Chart,\n PieController,\n DoughnutController,\n ArcElement,\n Tooltip,\n} from 'chart.js';\nimport type {Plugin, ChartOptions, ChartDataset} from 'chart.js';\nimport {\n CHART_SECTOR_DEFAULT_COLORS,\n CHART_SECTOR_ENHANCED_COLORS,\n CHART_DIMENSIONS,\n OUTER_LABEL_CONFIG,\n getCssVariableValue,\n getChartColorsOrDefault,\n observeThemeChanges,\n calculateSumTotal,\n createArcOuterLabelPlugin,\n calculateFixedHeightChartLayout,\n formatSingleLabel,\n formatChartNumber,\n getChartTooltipOptions,\n generateLegendHTML,\n observeLabelThreshold,\n} from '../../charthelpers/index.js';\nimport type {FixedHeightChartDimensions} from '../../charthelpers/canvas-layout.js';\n\n// Register Chart.js components\nChart.register(PieController, DoughnutController, ArcElement, Tooltip);\n\n// Pie-specific dimension constants (extends shared CHART_DIMENSIONS)\nconst PIE_DIMENSIONS = {\n ...CHART_DIMENSIONS,\n GAP_AND_BORDER_COLOR: '--container-section-color',\n} as const;\n\nconst PIE_RECREATE_PROP_NAMES = [\n 'priority',\n 'sunburst',\n 'showOuterLabels',\n 'showUnit',\n 'outerLabelUnit',\n 'outerLabelMaxLength',\n 'outerLabelDecimalPlaces',\n 'showDebugOverlay',\n 'fixedHeight',\n] as const;\n\nconst PIE_WATCHED_PROP_NAMES = [\n 'legend',\n 'data',\n 'colors',\n 'priority',\n 'sunburst',\n 'showOuterLabels',\n 'showUnit',\n 'outerLabelUnit',\n 'outerLabelMaxLength',\n 'outerLabelDecimalPlaces',\n 'showDebugOverlay',\n 'fixedHeight',\n] as const;\n\ntype PieChartChildDataItem = {\n label: string;\n value: number;\n};\n\nexport type PieChartDataItem = {\n label: string;\n value: number;\n children?: PieChartChildDataItem[];\n};\n\n/**\n * `<obc-pie-chart>` – A customizable pie chart component for visualizing proportional data as segments, with optional sunburst subsegments and outer labels.\n *\n * This component renders an interactive pie chart powered by Chart.js, displaying data segments as arcs with optional outer labels and a sunburst mode for hierarchical data. It supports customizable colors, percentage or unit display, and adapts its layout based on available space. Labels are hidden when the chart is too small (< 192px height), ensuring clarity at all sizes.\n *\n * ## Features\n * - **Fixed Height ⇒ Fixed Circumference:** The chart's circumference is determined by the `fixedHeight` property (default: 320px). This ensures the donut's circumference remains consistent and matches other radial instruments, regardless of the available browser or container width. The chart does not scale to fill the width; instead, it always uses the specified fixed height to define its size and circumference.\n * - **Layout:**\n * - Full 360° pie chart layout.\n * - **Outer Labels:**\n * - Optional labels positioned outside the chart showing segment names and values.\n * - Supports percentage or custom units (e.g., \"kW\", \"kg\", \"MB\").\n * - Configurable decimal places and maximum label length (with trimming).\n * - **Sunburst Mode:**\n * - Enable hierarchical data display with interactive subsegments (children) as an outer ring.\n * - Click a segment to expand/collapse its children in the sunburst ring.\n * - **Customization:**\n * - Custom segment colors (with automatic fallback to theme palette).\n * - Adjustable outer label formatting and units.\n * - **Color Priority:** Set `priority` to `Priority.enhanced` to use the blue/enhanced\n * color palette instead of the default gray/regular palette (default: `Priority.regular`).\n * - **Responsive Behavior:**\n * - Automatically hides labels when height < 192px.\n * - Maintains aspect ratio and adjusts padding for optimal label positioning.\n * - **Theme Integration:**\n * - Colors update automatically when the `data-obc-theme` attribute changes on the `<html>` element.\n * - Example:\n * ```\n * <html lang=\"en\" data-obc-theme=\"day\"></html>\n * ```\n *\n * ## Example\n *\n * **Basic Usage**\n * ```html\n * <obc-pie-chart></obc-pie-chart>\n * <script>\n * document.querySelector('obc-pie-chart').data = [\n * {label: 'A', value: 50},\n * {label: 'B', value: 30},\n * {label: 'C', value: 20}\n * ];\n * </script>\n * ```\n *\n * **With Sunburst Subsegments**\n * ```html\n * <obc-pie-chart></obc-pie-chart>\n * <script>\n * const chart = document.querySelector('obc-pie-chart');\n * chart.sunburst = true;\n * chart.data = [\n * {label: 'A', value: 50, children: [\n * {label: 'A1', value: 30},\n * {label: 'A2', value: 20}\n * ]},\n * {label: 'B', value: 30}\n * ];\n * </script>\n * ```\n *\n * **Custom Colors and Units**\n * ```html\n * <obc-pie-chart></obc-pie-chart>\n * <script>\n * const chart = document.querySelector('obc-pie-chart');\n * chart.showOuterLabels = true;\n * chart.outerLabelUnit = 'kW';\n * chart.outerLabelDecimalPlaces = 2;\n * chart.data = [\n * {label: 'Critical', value: 20},\n * {label: 'Warning', value: 35},\n * {label: 'Normal', value: 45}\n * ];\n * chart.colors = ['#e74c3c', '#f39c12', '#2ecc71'];\n * </script>\n * ```\n *\n * @property data - Chart data segments with optional children subsegments for sunburst mode (set via JavaScript).\n * @property colors - Custom segment colors (set via JavaScript) with fallback to theme palette\n * @property showOuterLabels - Show outer labels, default: false\n * @property showUnit - Whether to show unit in labels, default: false\n * @property sunburst - Enable sunburst mode: clicking a segment expands or collapses its children as an outer ring, default: false\n * @property outerLabelUnit - Unit string to append to outer labels, default: \"%\"\n * @property outerLabelMaxLength - Maximum character length for labels before trim (0 = no limit), default: 0\n * @availableWhen outerLabelMaxLength showOuterLabels==true\n * @property outerLabelDecimalPlaces - Number of decimal places in labels, default: 0\n * @property legend - Whether to display the legend below the chart, default: false\n * @property showDebugOverlay - Show debug overlay for development, default: false\n * @property fixedHeight - Fixed height of the chart in pixels (determines chart circumference), default: 320. The chart's circumference is always based on this fixed height to match other radial instruments.\n * @beta\n */\n@customElement('obc-pie-chart')\nexport class ObcPieChart extends LitElement {\n @property({type: Array, attribute: false})\n data: PieChartDataItem[] = [];\n\n @property({type: Array, attribute: false})\n colors: string[] = [];\n\n @property({type: String})\n priority: Priority = Priority.regular;\n\n @property({type: Boolean})\n showOuterLabels = false;\n\n @property({type: Boolean})\n showUnit = false;\n\n @property({type: Boolean})\n sunburst = false;\n\n @property({type: String})\n outerLabelUnit = '%';\n\n @property({\n type: Number,\n })\n outerLabelMaxLength = 0;\n\n @property({\n type: Number,\n })\n outerLabelDecimalPlaces = 0;\n\n @property({type: Boolean, reflect: true})\n legend = false;\n\n @property({type: Boolean, reflect: true})\n showDebugOverlay = false;\n\n @property({type: Number, reflect: true})\n fixedHeight = 320;\n\n /** @internal */\n @state() private total = 0;\n\n /** @internal - Pre-formatted labels for outer label rendering */\n @state() private formattedLabels: string[] = [];\n\n /** @internal */\n @state() private activeSegmentIndex: number | null = null;\n\n /** @internal */\n @query('canvas') private canvasEl?: HTMLCanvasElement;\n\n /** @internal */\n @query('.legend') private legendDiv?: HTMLDivElement;\n\n /** @internal */\n private chart?: Chart;\n\n /** @internal - Latest layout dimensions computed by getChartOptions() */\n private lastDimensions?: FixedHeightChartDimensions;\n\n /** @internal */\n private themeObserver?: MutationObserver;\n\n /** @internal - ResizeObserver for tracking height threshold crossings */\n private resizeObserver?: ResizeObserver;\n\n private hasAnyChanged(\n changed: PropertyValues,\n props: readonly (keyof ObcPieChart)[]\n ): boolean {\n return props.some((prop) => changed.has(prop));\n }\n\n /**\n * Get layout configuration for canvas calculation\n */\n private getLayoutConfig() {\n return {\n unit: this.outerLabelUnit,\n showUnit: this.showUnit,\n outerLabelMaxLength: this.outerLabelMaxLength,\n decimalPlaces: this.outerLabelDecimalPlaces,\n data: this.data,\n denominator: this.total > 0 ? this.total : 1,\n };\n }\n\n // Calculate derived state BEFORE render\n override willUpdate(changed: PropertyValues) {\n if (changed.has('data')) {\n this.total = calculateSumTotal(this.data);\n }\n }\n\n // Update external library AFTER render\n override updated(changed: PropertyValues) {\n super.updated(changed);\n\n if (this.hasAnyChanged(changed, PIE_WATCHED_PROP_NAMES)) {\n // Recreate chart when major layout properties change or when plugin configuration changes\n // These properties affect aspect ratio calculation, plugin registration, or outer label rendering\n const needsRecreation = this.hasAnyChanged(\n changed,\n PIE_RECREATE_PROP_NAMES\n );\n\n if (needsRecreation) {\n this.chart?.destroy();\n this.removeSunburstInteraction();\n this.createChart();\n if (this.sunburst) {\n this.setupSunburstInteraction();\n }\n } else {\n this.updateChart();\n }\n }\n }\n\n override firstUpdated() {\n this.createChart();\n this.themeObserver = observeThemeChanges(() => this.updateChartColors());\n this.setupResizeObserver();\n\n // Add click listeners for sunburst interaction\n if (this.sunburst) {\n this.setupSunburstInteraction();\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.chart?.destroy();\n this.themeObserver?.disconnect();\n this.resizeObserver?.disconnect();\n this.removeSunburstInteraction();\n }\n\n /**\n * Crossing MIN_HEIGHT_WITH_LABELS changes the plugin set, so the chart is\n * rebuilt rather than updated.\n */\n private setupResizeObserver() {\n if (!this.canvasEl) return;\n\n this.resizeObserver = observeLabelThreshold(\n this.canvasEl,\n () =>\n (this.canvasEl?.clientHeight ?? 0) >=\n CHART_DIMENSIONS.MIN_HEIGHT_WITH_LABELS,\n {\n rebuild: () => {\n this.chart?.destroy();\n this.createChart();\n },\n update: () => this.updateChart(),\n }\n );\n }\n\n /** @internal */\n private handleCanvasClick = (event: MouseEvent) => {\n if (!this.chart || !this.sunburst) return;\n\n const elements = this.chart.getElementsAtEventForMode(\n event as unknown as Event,\n 'nearest',\n {intersect: true},\n false\n );\n\n if (elements.length > 0) {\n const clickedIndex = elements[0].index;\n // Toggle: if already active, deactivate; otherwise activate\n const newIndex =\n this.activeSegmentIndex === clickedIndex ? null : clickedIndex;\n this.activeSegmentIndex = newIndex;\n\n // Recreate chart to update plugins with new hideIndex and radius\n this.chart.destroy();\n this.createChart();\n }\n };\n\n private setupSunburstInteraction() {\n if (!this.canvasEl) return;\n this.canvasEl.addEventListener('click', this.handleCanvasClick);\n this.canvasEl.style.cursor = 'pointer';\n }\n\n private removeSunburstInteraction() {\n if (!this.canvasEl) return;\n this.canvasEl.removeEventListener('click', this.handleCanvasClick);\n this.canvasEl.style.cursor = '';\n }\n\n private prepareChartData() {\n const values = this.data.map((d) => d.value);\n const labels = this.data.map((d) => d.label);\n const chartColors = getChartColorsOrDefault(\n this,\n this.colors,\n this.priority === Priority.enhanced\n ? CHART_SECTOR_ENHANCED_COLORS\n : CHART_SECTOR_DEFAULT_COLORS\n );\n const segmentColors = values.map(\n (_, index) => chartColors[index % chartColors.length]\n );\n\n if (!this.sunburst) {\n return {\n values,\n labels,\n colors: segmentColors,\n sunburstValues: [],\n sunburstColors: [],\n sunburstLabels: [],\n };\n }\n\n // Sunburst mode: create outer ring dataset and shrink the 'inner' pie chart radius\n const sunburstValues: number[] = [];\n const sunburstColors: string[] = [];\n const sunburstLabels: string[] = [];\n\n this.data.forEach((segment, parentIndex) => {\n const children = segment.children || [];\n\n if (children.length > 0) {\n // Add children to outer/sunburst ring\n children.forEach((child, childIndex) => {\n sunburstValues.push(child.value);\n sunburstLabels.push(child.label);\n // Use next colors in sequence after parent color\n const colorIndex =\n (parentIndex + childIndex + 1) % chartColors.length;\n sunburstColors.push(chartColors[colorIndex]);\n });\n } else {\n // No children: add transparent placeholder with same value as parent\n sunburstValues.push(segment.value);\n sunburstLabels.push('');\n sunburstColors.push('transparent');\n }\n });\n\n return {\n values,\n labels,\n colors: segmentColors,\n sunburstValues,\n sunburstColors,\n sunburstLabels,\n };\n }\n\n /**\n * Get Chart.js options using centralized fixed height layout calculation\n */\n private getChartOptions(): ChartOptions<'pie'> {\n // If sunburst mode and a segment is active, reduce the pie chart radius\n // to make room for the outer ring while keeping total size at CHART_WIDTH\n const radiusPercentage =\n this.sunburst && this.activeSegmentIndex !== null ? 75 : 100;\n\n // Use centralized layout calculation helper\n const dimensions = calculateFixedHeightChartLayout({\n fixedHeight: this.fixedHeight,\n isHalfMode: false, // Pie charts are always full circles\n showOuterLabels: this.showOuterLabels,\n canvasEl: this.canvasEl,\n layoutConfig: this.getLayoutConfig(),\n host: this,\n });\n\n // Store dimensions for explicit canvas sizing in createChart/updateChart\n this.lastDimensions = dimensions;\n\n // Store formatted labels for use in plugins\n this.formattedLabels = dimensions.formattedLabels;\n\n // Set CSS variables for wrapper and canvas sizing\n this.style.setProperty('--chart-width', `${dimensions.calculatedWidth}px`);\n this.style.setProperty('--chart-height', `${dimensions.actualHeight}px`);\n\n // Calculate dynamic padding for Chart.js layout\n const dynamicPadding = dimensions.isTooSmall\n ? {top: 0, right: 0, bottom: 0, left: 0}\n : {\n top: dimensions.topPadding,\n right: dimensions.rightPadding,\n bottom: dimensions.bottomPadding,\n left: dimensions.leftPadding,\n };\n\n return {\n // Chart.js responsive mode stays off — see the note in donut-chart.ts (#1061).\n responsive: false,\n maintainAspectRatio: false,\n devicePixelRatio: window.devicePixelRatio,\n radius: `${radiusPercentage}%`,\n layout: {\n padding: dynamicPadding ?? PIE_DIMENSIONS.CANVAS_PADDING,\n },\n plugins: {\n legend: {\n display: false,\n labels: {\n generateLabels: () => [], // Prevent Chart.js from generating labels internally\n },\n onClick: () => {}, // Disable legend click handler\n },\n tooltip: {\n ...getChartTooltipOptions(this),\n enabled: !dimensions.isTooSmall,\n filter: (tooltipItem) => {\n // Hide tooltips for transparent placeholder segments\n const dataset = tooltipItem.dataset;\n const bgColor = Array.isArray(dataset.backgroundColor)\n ? dataset.backgroundColor[tooltipItem.dataIndex]\n : dataset.backgroundColor;\n return bgColor !== 'transparent';\n },\n callbacks: {\n title: () => '', // No title line\n label: (context) => {\n const label = context.label ?? '';\n const value = context.parsed;\n const denominator = this.total > 0 ? this.total : 1;\n const isPercentage = this.outerLabelUnit === '%';\n const numericValue = formatChartNumber(\n value,\n denominator,\n isPercentage,\n this.outerLabelDecimalPlaces\n );\n const showUnit = this.showUnit && this.outerLabelUnit;\n return showUnit\n ? `${label} ${numericValue}${this.outerLabelUnit}`\n : `${label} ${numericValue}`;\n },\n },\n },\n },\n animation: {\n animateRotate: false,\n animateScale: false,\n },\n };\n }\n\n private createOuterLabelPiePlugin(): Plugin {\n return createArcOuterLabelPlugin(this, {\n formattedLabels: this.formattedLabels,\n hideIndex: this.sunburst ? this.activeSegmentIndex : null,\n }) as Plugin;\n }\n\n private createChart() {\n // Guard: Verify canvas exists and is connected to DOM\n if (!this.canvasEl || !this.canvasEl.isConnected) return;\n\n const ctx = this.canvasEl.getContext('2d');\n if (!ctx) return;\n\n const {\n values,\n labels,\n colors,\n sunburstValues,\n sunburstColors,\n sunburstLabels,\n } = this.prepareChartData();\n\n // Always use pie chart type, add custom plugin for sunburst\n const datasets: ChartDataset<'pie', number[]>[] = [\n {\n data: values,\n backgroundColor: colors,\n borderWidth: 1,\n borderColor: getCssVariableValue(\n this,\n PIE_DIMENSIONS.GAP_AND_BORDER_COLOR\n ),\n },\n ];\n\n const options = this.getChartOptions();\n\n // Non-responsive mode: set the canvas render size explicitly from the\n // computed layout; Chart.js applies devicePixelRatio scaling on top\n if (this.lastDimensions) {\n this.canvasEl.width = this.lastDimensions.calculatedWidth;\n this.canvasEl.height = this.lastDimensions.actualHeight;\n }\n\n const isTooSmall = this.lastDimensions?.isTooSmall ?? false;\n\n this.chart = new Chart(ctx, {\n type: 'pie',\n data: {\n labels,\n datasets,\n },\n options,\n plugins: [\n // Only show outer labels if enabled AND height is large enough\n ...(this.showOuterLabels && !isTooSmall\n ? [this.createOuterLabelPiePlugin()]\n : []),\n this.sunburst && sunburstValues.length > 0\n ? this.createSunburstPlugin(\n sunburstValues,\n sunburstColors,\n sunburstLabels\n )\n : {id: 'sunburst'},\n ].filter((p) => p !== undefined),\n });\n\n // Defer legend update to next tick to ensure Chart.js metadata is initialized\n requestAnimationFrame(() => this.updateLegend());\n }\n\n private createSunburstPlugin(\n _outerValues: number[],\n sunburstColors: string[],\n sunburstLabels: string[]\n ): Plugin {\n return {\n id: 'sunburst',\n afterDatasetsDraw: (chart) => {\n const meta = chart.getDatasetMeta(0);\n if (!meta?.data.length) return;\n\n // Only draw if a segment is active (clicked)\n if (this.activeSegmentIndex === null) return;\n\n const {ctx} = chart;\n const centerX = chart.chartArea.left + chart.chartArea.width / 2;\n const centerY = chart.chartArea.top + chart.chartArea.height / 2;\n\n ctx.save();\n\n // Calculate radii to fit within CHART_WIDTH\n // Inner pie is now at 75% (radius property in getChartOptions)\n const firstArc = meta.data[0] as ArcElement;\n const innerPieRadius = firstArc.outerRadius;\n\n // The original 100% radius (before shrinking to 75%)\n // innerPieRadius = 0.75 * originalRadius, so originalRadius = innerPieRadius / 0.75\n const originalFullRadius = innerPieRadius / 0.75;\n\n // Determine if chart is below label threshold\n const height = this.canvasEl?.clientHeight ?? 0;\n const isTooSmall = height < PIE_DIMENSIONS.MIN_HEIGHT_WITH_LABELS;\n\n // Gap and thickness logic for small charts\n const gapWidth = isTooSmall ? 2 : 8;\n // For small charts, fill all available space with the sunburst arc\n const outerRingInnerRadius = innerPieRadius + gapWidth;\n const outerRingOuterRadius = isTooSmall\n ? originalFullRadius\n : originalFullRadius;\n // (If you want to reserve a gap to the edge, adjust here)\n\n // Setup font styling for labels\n const fontFamily = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontFamily\n );\n const fontWeight = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontWeightVar\n );\n const fontSize = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontSizeVar\n );\n const fontColor = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontColorVar\n );\n\n ctx.font = `${fontWeight} ${fontSize} ${fontFamily}`;\n ctx.fillStyle = fontColor;\n ctx.textBaseline = 'middle';\n\n // Draw outer ring segments only for the active parent\n let sunburstDataIndex = 0;\n this.data.forEach((segment, segmentIndex) => {\n const children = segment.children || [];\n\n if (children.length > 0) {\n // Only draw if this is the active segment\n if (segmentIndex === this.activeSegmentIndex) {\n // Calculate total for this parent's children\n const childrenTotal = children.reduce(\n (sum, child) => sum + child.value,\n 0\n );\n let startAngle = 0;\n\n // Find the parent arc to align with it\n const parentArc = meta.data[segmentIndex] as ArcElement;\n const parentStart = parentArc.startAngle;\n const parentEnd = parentArc.endAngle;\n const parentAngleRange = parentEnd - parentStart;\n\n children.forEach((child) => {\n const childValue = child.value;\n const childRatio = childValue / childrenTotal;\n const childAngleRange = parentAngleRange * childRatio;\n const childStartAngle = parentStart + startAngle;\n const childEndAngle = childStartAngle + childAngleRange;\n\n // Draw the outer/sunburst arc\n ctx.fillStyle =\n sunburstColors[sunburstDataIndex] || 'transparent';\n ctx.beginPath();\n ctx.arc(\n centerX,\n centerY,\n outerRingOuterRadius,\n childStartAngle,\n childEndAngle\n );\n ctx.arc(\n centerX,\n centerY,\n outerRingInnerRadius,\n childEndAngle,\n childStartAngle,\n true\n );\n ctx.closePath();\n ctx.fill();\n\n // Draw label for this sunburst segment (if showOuterLabels is enabled)\n if (this.showOuterLabels && sunburstLabels[sunburstDataIndex]) {\n const middleAngle = (childStartAngle + childEndAngle) / 2;\n const labelRadius =\n outerRingOuterRadius + OUTER_LABEL_CONFIG.labelGap;\n const x = centerX + Math.cos(middleAngle) * labelRadius;\n const y = centerY + Math.sin(middleAngle) * labelRadius;\n const alignLeft = Math.cos(middleAngle) >= 0;\n\n ctx.fillStyle = fontColor;\n ctx.textAlign = alignLeft ? 'left' : 'right';\n const textX = alignLeft\n ? x + OUTER_LABEL_CONFIG.labelGap\n : x - OUTER_LABEL_CONFIG.labelGap;\n\n // Format label using shared helper\n const total = this.total > 0 ? this.total : 1;\n const valueText = formatSingleLabel(childValue, total, {\n unit: this.outerLabelUnit,\n showUnit: this.showUnit,\n decimalPlaces: this.outerLabelDecimalPlaces,\n maxLength: this.outerLabelMaxLength,\n });\n\n ctx.fillText(valueText, textX, y);\n }\n\n startAngle += childAngleRange;\n sunburstDataIndex++;\n });\n } else {\n // Skip this parent's children\n sunburstDataIndex += children.length;\n }\n } else {\n sunburstDataIndex++; // Skip transparent placeholders\n }\n });\n\n ctx.restore();\n },\n };\n }\n\n private updateChart() {\n // Guard: Verify chart and canvas still exist and are connected\n if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected) return;\n\n // Non-responsive mode: apply the computed layout size explicitly\n // (no-op when the size is unchanged)\n if (this.lastDimensions) {\n this.chart.resize(\n this.lastDimensions.calculatedWidth,\n this.lastDimensions.actualHeight\n );\n }\n\n this.chart.update();\n\n // Update legend after chart update completes to ensure metadata is ready\n requestAnimationFrame(() => this.updateLegend());\n }\n\n /**\n * Update only chart colors without recreating the entire chart\n * Used by theme observer for efficient theme changes\n */\n private updateChartColors() {\n // Guard: Verify chart and canvas still exist and are connected\n if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected) return;\n\n const {colors, sunburstColors} = this.prepareChartData();\n\n if (this.chart.data.datasets[0]) {\n this.chart.data.datasets[0].backgroundColor = colors;\n }\n\n // Update sunburst dataset colors if in sunburst mode\n if (this.sunburst && this.chart.data.datasets[1]) {\n this.chart.data.datasets[1].backgroundColor = sunburstColors;\n }\n\n // Update without animation for instant theme change\n this.chart.update('none');\n\n // Defer legend update to next frame to ensure metadata is ready\n requestAnimationFrame(() => this.updateLegend());\n }\n\n /**\n * Update the legend HTML content\n */\n private updateLegend() {\n // Guard: Check if legend should be shown and chart is ready\n if (!this.legend || !this.legendDiv || !this.chart) return;\n\n // Guard: Check if chart metadata is available\n const meta = this.chart.getDatasetMeta(0);\n if (!meta || !meta.controller) {\n return;\n }\n\n // Guard: Check if dataset has data\n if (!this.data || this.data.length === 0) {\n this.legendDiv.innerHTML = '';\n return;\n }\n\n // Denominator: use max if set, otherwise total, with minimum of 1\n const denominator = this.total > 0 ? this.total : 1;\n const isPercentage = this.outerLabelUnit === '%';\n\n try {\n const legendItems = this.data.map((item, i) => {\n const style = meta.controller.getStyle(i, false);\n const numericValue = formatChartNumber(\n item.value,\n denominator,\n isPercentage,\n this.outerLabelDecimalPlaces\n );\n const showUnit = this.showUnit && this.outerLabelUnit;\n const value = `${numericValue}`;\n const unit = showUnit ? `${this.outerLabelUnit}` : '';\n\n return {\n fillStyle: style.backgroundColor as string,\n label: item.label as string,\n value: value as string,\n unit: unit as string,\n };\n });\n\n const legendHTML = generateLegendHTML(legendItems);\n this.legendDiv.innerHTML = legendHTML;\n } catch (error) {\n console.debug(\n '[obc-pie-chart] updateLegend: error generating legend HTML',\n error\n );\n // Silent failure - don't throw, just skip legend update this time\n }\n }\n\n override render() {\n return html`\n <div class=\"wrapper\">\n <canvas></canvas>\n ${this.legend ? html`<div class=\"legend\"></div>` : ''}\n </div>\n `;\n }\n\n static override styles = [\n unsafeCSS(componentStyle),\n unsafeCSS(chartCommonStyle),\n unsafeCSS(chartLegendStyle),\n unsafeCSS(chartDebugStyle),\n ];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-pie-chart': ObcPieChart;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,SAAS,eAAe,oBAAoB,YAAY,OAAO;AAGrE,IAAM,iBAAiB;CACrB,GAAG;CACH,sBAAsB;AACxB;AAEA,IAAM,0BAA0B;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,yBAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AA0GO,IAAM,cAAN,MAAM,oBAAoB,WAAW;;;EAEf,KAAA,OAAA,CAAC;EAGT,KAAA,SAAA,CAAC;EAGC,KAAA,WAAA,SAAS;EAGZ,KAAA,kBAAA;EAGP,KAAA,WAAA;EAGA,KAAA,WAAA;EAGM,KAAA,iBAAA;EAKK,KAAA,sBAAA;EAKI,KAAA,0BAAA;EAGjB,KAAA,SAAA;EAGU,KAAA,mBAAA;EAGL,KAAA,cAAA;EAGW,KAAA,QAAA;EAGoB,KAAA,kBAAA,CAAC;EAGO,KAAA,qBAAA;EAmHxB,KAAA,qBAAA,UAAsB;GACjD,IAAI,CAAC,KAAK,SAAS,CAAC,KAAK,UAAU;GAEnC,MAAM,WAAW,KAAK,MAAM,0BAC1B,OACA,WACA,EAAC,WAAW,KAAI,GAChB,KACF;GAEA,IAAI,SAAS,SAA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WAAA,CAAA,MAAM,CAAA,GAAA,YAAA,WAAA,mBAAA,KAAA,CAAA;AAGN,WAAA,CAAA,MAAM,CAAA,GAAA,YAAA,WAAA,sBAAA,KAAA,CAAA;AAGN,WAAA,CAAA,MAAM,QAAQ,CAAA,GAAA,YAAA,WAAA,YAAA,KAAA,CAAA;AAGd,WAAA,CAAA,MAAM,SAAS,CAAA,GAAA,YAAA,WAAA,aAAA,KAAA,CAAA;AAvDjB,cAAA,WAAA,CAAA,cAAc,eAAe,CAAA,GAAA,WAAA"}
|
|
1
|
+
{"version":3,"file":"pie-chart.js","names":[],"sources":["../../../src/bars-graphs/pie-chart/pie-chart.ts"],"sourcesContent":["import {LitElement, PropertyValues, html, unsafeCSS} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport componentStyle from './pie-chart.css?inline';\nimport chartCommonStyle from '../../charthelpers/chart-common.css?inline';\nimport chartDebugStyle from '../../charthelpers/chart-debug.css?inline';\nimport chartLegendStyle from '../../charthelpers/chart-legend.css?inline';\nimport {customElement} from '../../decorator.js';\nimport {Priority} from '../../navigation-instruments/types.js';\nimport {\n Chart,\n PieController,\n DoughnutController,\n ArcElement,\n Tooltip,\n} from 'chart.js';\nimport type {Plugin, ChartOptions, ChartDataset} from 'chart.js';\nimport {\n CHART_SECTOR_DEFAULT_COLORS,\n CHART_SECTOR_ENHANCED_COLORS,\n CHART_DIMENSIONS,\n OUTER_LABEL_CONFIG,\n getCssVariableValue,\n getChartColorsOrDefault,\n observeThemeChanges,\n calculateSumTotal,\n createArcOuterLabelPlugin,\n calculateFixedHeightChartLayout,\n formatSingleLabel,\n formatChartNumber,\n getChartTooltipOptions,\n renderLegend,\n observeLabelThreshold,\n} from '../../charthelpers/index.js';\nimport type {FixedHeightChartDimensions} from '../../charthelpers/canvas-layout.js';\n\n// Register Chart.js components\nChart.register(PieController, DoughnutController, ArcElement, Tooltip);\n\n// Pie-specific dimension constants (extends shared CHART_DIMENSIONS)\nconst PIE_DIMENSIONS = {\n ...CHART_DIMENSIONS,\n GAP_AND_BORDER_COLOR: '--container-section-color',\n} as const;\n\nconst PIE_RECREATE_PROP_NAMES = [\n 'priority',\n 'sunburst',\n 'showOuterLabels',\n 'showUnit',\n 'outerLabelUnit',\n 'outerLabelMaxLength',\n 'outerLabelDecimalPlaces',\n 'showDebugOverlay',\n 'fixedHeight',\n] as const;\n\nconst PIE_WATCHED_PROP_NAMES = [\n 'legend',\n 'data',\n 'colors',\n 'priority',\n 'sunburst',\n 'showOuterLabels',\n 'showUnit',\n 'outerLabelUnit',\n 'outerLabelMaxLength',\n 'outerLabelDecimalPlaces',\n 'showDebugOverlay',\n 'fixedHeight',\n] as const;\n\ntype PieChartChildDataItem = {\n label: string;\n value: number;\n};\n\nexport type PieChartDataItem = {\n label: string;\n value: number;\n children?: PieChartChildDataItem[];\n};\n\n/**\n * `<obc-pie-chart>` – A customizable pie chart component for visualizing proportional data as segments, with optional sunburst subsegments and outer labels.\n *\n * This component renders an interactive pie chart powered by Chart.js, displaying data segments as arcs with optional outer labels and a sunburst mode for hierarchical data. It supports customizable colors, percentage or unit display, and adapts its layout based on available space. Labels are hidden when the chart is too small (< 192px height), ensuring clarity at all sizes.\n *\n * ## Features\n * - **Fixed Height ⇒ Fixed Circumference:** The chart's circumference is determined by the `fixedHeight` property (default: 320px). This ensures the donut's circumference remains consistent and matches other radial instruments, regardless of the available browser or container width. The chart does not scale to fill the width; instead, it always uses the specified fixed height to define its size and circumference.\n * - **Layout:**\n * - Full 360° pie chart layout.\n * - **Outer Labels:**\n * - Optional labels positioned outside the chart showing segment names and values.\n * - Supports percentage or custom units (e.g., \"kW\", \"kg\", \"MB\").\n * - Configurable decimal places and maximum label length (with trimming).\n * - **Sunburst Mode:**\n * - Enable hierarchical data display with interactive subsegments (children) as an outer ring.\n * - Click a segment to expand/collapse its children in the sunburst ring.\n * - **Customization:**\n * - Custom segment colors (with automatic fallback to theme palette).\n * - Adjustable outer label formatting and units.\n * - **Color Priority:** Set `priority` to `Priority.enhanced` to use the blue/enhanced\n * color palette instead of the default gray/regular palette (default: `Priority.regular`).\n * - **Responsive Behavior:**\n * - Automatically hides labels when height < 192px.\n * - Maintains aspect ratio and adjusts padding for optimal label positioning.\n * - **Theme Integration:**\n * - Colors update automatically when the `data-obc-theme` attribute changes on the `<html>` element.\n * - Example:\n * ```\n * <html lang=\"en\" data-obc-theme=\"day\"></html>\n * ```\n *\n * ## Example\n *\n * **Basic Usage**\n * ```html\n * <obc-pie-chart></obc-pie-chart>\n * <script>\n * document.querySelector('obc-pie-chart').data = [\n * {label: 'A', value: 50},\n * {label: 'B', value: 30},\n * {label: 'C', value: 20}\n * ];\n * </script>\n * ```\n *\n * **With Sunburst Subsegments**\n * ```html\n * <obc-pie-chart></obc-pie-chart>\n * <script>\n * const chart = document.querySelector('obc-pie-chart');\n * chart.sunburst = true;\n * chart.data = [\n * {label: 'A', value: 50, children: [\n * {label: 'A1', value: 30},\n * {label: 'A2', value: 20}\n * ]},\n * {label: 'B', value: 30}\n * ];\n * </script>\n * ```\n *\n * **Custom Colors and Units**\n * ```html\n * <obc-pie-chart></obc-pie-chart>\n * <script>\n * const chart = document.querySelector('obc-pie-chart');\n * chart.showOuterLabels = true;\n * chart.outerLabelUnit = 'kW';\n * chart.outerLabelDecimalPlaces = 2;\n * chart.data = [\n * {label: 'Critical', value: 20},\n * {label: 'Warning', value: 35},\n * {label: 'Normal', value: 45}\n * ];\n * chart.colors = ['#e74c3c', '#f39c12', '#2ecc71'];\n * </script>\n * ```\n *\n * @property data - Chart data segments with optional children subsegments for sunburst mode (set via JavaScript).\n * @property colors - Custom segment colors (set via JavaScript) with fallback to theme palette\n * @property showOuterLabels - Show outer labels, default: false\n * @property showUnit - Whether to show unit in labels, default: false\n * @property sunburst - Enable sunburst mode: clicking a segment expands or collapses its children as an outer ring, default: false\n * @property outerLabelUnit - Unit string to append to outer labels, default: \"%\"\n * @property outerLabelMaxLength - Maximum character length for labels before trim (0 = no limit), default: 0\n * @availableWhen outerLabelMaxLength showOuterLabels==true\n * @property outerLabelDecimalPlaces - Number of decimal places in labels, default: 0\n * @property legend - Whether to display the legend below the chart, default: false\n * @property showDebugOverlay - Show debug overlay for development, default: false\n * @property fixedHeight - Fixed height of the chart in pixels (determines chart circumference), default: 320. The chart's circumference is always based on this fixed height to match other radial instruments.\n * @beta\n */\n@customElement('obc-pie-chart')\nexport class ObcPieChart extends LitElement {\n @property({type: Array, attribute: false})\n data: PieChartDataItem[] = [];\n\n @property({type: Array, attribute: false})\n colors: string[] = [];\n\n @property({type: String})\n priority: Priority = Priority.regular;\n\n @property({type: Boolean})\n showOuterLabels = false;\n\n @property({type: Boolean})\n showUnit = false;\n\n @property({type: Boolean})\n sunburst = false;\n\n @property({type: String})\n outerLabelUnit = '%';\n\n @property({\n type: Number,\n })\n outerLabelMaxLength = 0;\n\n @property({\n type: Number,\n })\n outerLabelDecimalPlaces = 0;\n\n @property({type: Boolean, reflect: true})\n legend = false;\n\n @property({type: Boolean, reflect: true})\n showDebugOverlay = false;\n\n @property({type: Number, reflect: true})\n fixedHeight = 320;\n\n /** @internal */\n @state() private total = 0;\n\n /** @internal - Pre-formatted labels for outer label rendering */\n @state() private formattedLabels: string[] = [];\n\n /** @internal */\n @state() private activeSegmentIndex: number | null = null;\n\n /** @internal */\n @query('canvas') private canvasEl?: HTMLCanvasElement;\n\n /** @internal */\n @query('.legend') private legendDiv?: HTMLDivElement;\n\n /** @internal */\n private chart?: Chart;\n\n /** @internal - Latest layout dimensions computed by getChartOptions() */\n private lastDimensions?: FixedHeightChartDimensions;\n\n /** @internal */\n private themeObserver?: MutationObserver;\n\n /** @internal - ResizeObserver for tracking height threshold crossings */\n private resizeObserver?: ResizeObserver;\n\n private hasAnyChanged(\n changed: PropertyValues,\n props: readonly (keyof ObcPieChart)[]\n ): boolean {\n return props.some((prop) => changed.has(prop));\n }\n\n /**\n * Get layout configuration for canvas calculation\n */\n private getLayoutConfig() {\n return {\n unit: this.outerLabelUnit,\n showUnit: this.showUnit,\n outerLabelMaxLength: this.outerLabelMaxLength,\n decimalPlaces: this.outerLabelDecimalPlaces,\n data: this.data,\n denominator: this.total > 0 ? this.total : 1,\n };\n }\n\n // Calculate derived state BEFORE render\n override willUpdate(changed: PropertyValues) {\n if (changed.has('data')) {\n this.total = calculateSumTotal(this.data);\n }\n }\n\n // Update external library AFTER render\n override updated(changed: PropertyValues) {\n super.updated(changed);\n\n if (this.hasAnyChanged(changed, PIE_WATCHED_PROP_NAMES)) {\n // Recreate chart when major layout properties change or when plugin configuration changes\n // These properties affect aspect ratio calculation, plugin registration, or outer label rendering\n const needsRecreation = this.hasAnyChanged(\n changed,\n PIE_RECREATE_PROP_NAMES\n );\n\n if (needsRecreation) {\n this.chart?.destroy();\n this.removeSunburstInteraction();\n this.createChart();\n if (this.sunburst) {\n this.setupSunburstInteraction();\n }\n } else {\n this.updateChart();\n }\n }\n }\n\n override firstUpdated() {\n this.createChart();\n this.themeObserver = observeThemeChanges(() => this.updateChartColors());\n this.setupResizeObserver();\n\n // Add click listeners for sunburst interaction\n if (this.sunburst) {\n this.setupSunburstInteraction();\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.chart?.destroy();\n this.themeObserver?.disconnect();\n this.resizeObserver?.disconnect();\n this.removeSunburstInteraction();\n }\n\n /**\n * Crossing MIN_HEIGHT_WITH_LABELS changes the plugin set, so the chart is\n * rebuilt rather than updated.\n */\n private setupResizeObserver() {\n if (!this.canvasEl) return;\n\n this.resizeObserver = observeLabelThreshold(\n this.canvasEl,\n () =>\n (this.canvasEl?.clientHeight ?? 0) >=\n CHART_DIMENSIONS.MIN_HEIGHT_WITH_LABELS,\n {\n rebuild: () => {\n this.chart?.destroy();\n this.createChart();\n },\n update: () => this.updateChart(),\n }\n );\n }\n\n /** @internal */\n private handleCanvasClick = (event: MouseEvent) => {\n if (!this.chart || !this.sunburst) return;\n\n const elements = this.chart.getElementsAtEventForMode(\n event as unknown as Event,\n 'nearest',\n {intersect: true},\n false\n );\n\n if (elements.length > 0) {\n const clickedIndex = elements[0].index;\n // Toggle: if already active, deactivate; otherwise activate\n const newIndex =\n this.activeSegmentIndex === clickedIndex ? null : clickedIndex;\n this.activeSegmentIndex = newIndex;\n\n // Recreate chart to update plugins with new hideIndex and radius\n this.chart.destroy();\n this.createChart();\n }\n };\n\n private setupSunburstInteraction() {\n if (!this.canvasEl) return;\n this.canvasEl.addEventListener('click', this.handleCanvasClick);\n this.canvasEl.style.cursor = 'pointer';\n }\n\n private removeSunburstInteraction() {\n if (!this.canvasEl) return;\n this.canvasEl.removeEventListener('click', this.handleCanvasClick);\n this.canvasEl.style.cursor = '';\n }\n\n private prepareChartData() {\n const values = this.data.map((d) => d.value);\n const labels = this.data.map((d) => d.label);\n const chartColors = getChartColorsOrDefault(\n this,\n this.colors,\n this.priority === Priority.enhanced\n ? CHART_SECTOR_ENHANCED_COLORS\n : CHART_SECTOR_DEFAULT_COLORS\n );\n const segmentColors = values.map(\n (_, index) => chartColors[index % chartColors.length]\n );\n\n if (!this.sunburst) {\n return {\n values,\n labels,\n colors: segmentColors,\n sunburstValues: [],\n sunburstColors: [],\n sunburstLabels: [],\n };\n }\n\n // Sunburst mode: create outer ring dataset and shrink the 'inner' pie chart radius\n const sunburstValues: number[] = [];\n const sunburstColors: string[] = [];\n const sunburstLabels: string[] = [];\n\n this.data.forEach((segment, parentIndex) => {\n const children = segment.children || [];\n\n if (children.length > 0) {\n // Add children to outer/sunburst ring\n children.forEach((child, childIndex) => {\n sunburstValues.push(child.value);\n sunburstLabels.push(child.label);\n // Use next colors in sequence after parent color\n const colorIndex =\n (parentIndex + childIndex + 1) % chartColors.length;\n sunburstColors.push(chartColors[colorIndex]);\n });\n } else {\n // No children: add transparent placeholder with same value as parent\n sunburstValues.push(segment.value);\n sunburstLabels.push('');\n sunburstColors.push('transparent');\n }\n });\n\n return {\n values,\n labels,\n colors: segmentColors,\n sunburstValues,\n sunburstColors,\n sunburstLabels,\n };\n }\n\n /**\n * Get Chart.js options using centralized fixed height layout calculation\n */\n private getChartOptions(): ChartOptions<'pie'> {\n // If sunburst mode and a segment is active, reduce the pie chart radius\n // to make room for the outer ring while keeping total size at CHART_WIDTH\n const radiusPercentage =\n this.sunburst && this.activeSegmentIndex !== null ? 75 : 100;\n\n // Use centralized layout calculation helper\n const dimensions = calculateFixedHeightChartLayout({\n fixedHeight: this.fixedHeight,\n isHalfMode: false, // Pie charts are always full circles\n showOuterLabels: this.showOuterLabels,\n canvasEl: this.canvasEl,\n layoutConfig: this.getLayoutConfig(),\n host: this,\n });\n\n // Store dimensions for explicit canvas sizing in createChart/updateChart\n this.lastDimensions = dimensions;\n\n // Store formatted labels for use in plugins\n this.formattedLabels = dimensions.formattedLabels;\n\n // Set CSS variables for wrapper and canvas sizing\n this.style.setProperty('--chart-width', `${dimensions.calculatedWidth}px`);\n this.style.setProperty('--chart-height', `${dimensions.actualHeight}px`);\n\n // Calculate dynamic padding for Chart.js layout\n const dynamicPadding = dimensions.isTooSmall\n ? {top: 0, right: 0, bottom: 0, left: 0}\n : {\n top: dimensions.topPadding,\n right: dimensions.rightPadding,\n bottom: dimensions.bottomPadding,\n left: dimensions.leftPadding,\n };\n\n return {\n // Chart.js responsive mode stays off — see the note in donut-chart.ts (#1061).\n responsive: false,\n maintainAspectRatio: false,\n devicePixelRatio: window.devicePixelRatio,\n radius: `${radiusPercentage}%`,\n layout: {\n padding: dynamicPadding ?? PIE_DIMENSIONS.CANVAS_PADDING,\n },\n plugins: {\n legend: {\n display: false,\n labels: {\n generateLabels: () => [], // Prevent Chart.js from generating labels internally\n },\n onClick: () => {}, // Disable legend click handler\n },\n tooltip: {\n ...getChartTooltipOptions(this),\n enabled: !dimensions.isTooSmall,\n filter: (tooltipItem) => {\n // Hide tooltips for transparent placeholder segments\n const dataset = tooltipItem.dataset;\n const bgColor = Array.isArray(dataset.backgroundColor)\n ? dataset.backgroundColor[tooltipItem.dataIndex]\n : dataset.backgroundColor;\n return bgColor !== 'transparent';\n },\n callbacks: {\n title: () => '', // No title line\n label: (context) => {\n const label = context.label ?? '';\n const value = context.parsed;\n const denominator = this.total > 0 ? this.total : 1;\n const isPercentage = this.outerLabelUnit === '%';\n const numericValue = formatChartNumber(\n value,\n denominator,\n isPercentage,\n this.outerLabelDecimalPlaces\n );\n const showUnit = this.showUnit && this.outerLabelUnit;\n return showUnit\n ? `${label} ${numericValue}${this.outerLabelUnit}`\n : `${label} ${numericValue}`;\n },\n },\n },\n },\n animation: {\n animateRotate: false,\n animateScale: false,\n },\n };\n }\n\n private createOuterLabelPiePlugin(): Plugin {\n return createArcOuterLabelPlugin(this, {\n formattedLabels: this.formattedLabels,\n hideIndex: this.sunburst ? this.activeSegmentIndex : null,\n }) as Plugin;\n }\n\n private createChart() {\n // Guard: Verify canvas exists and is connected to DOM\n if (!this.canvasEl || !this.canvasEl.isConnected) return;\n\n const ctx = this.canvasEl.getContext('2d');\n if (!ctx) return;\n\n const {\n values,\n labels,\n colors,\n sunburstValues,\n sunburstColors,\n sunburstLabels,\n } = this.prepareChartData();\n\n // Always use pie chart type, add custom plugin for sunburst\n const datasets: ChartDataset<'pie', number[]>[] = [\n {\n data: values,\n backgroundColor: colors,\n borderWidth: 1,\n borderColor: getCssVariableValue(\n this,\n PIE_DIMENSIONS.GAP_AND_BORDER_COLOR\n ),\n },\n ];\n\n const options = this.getChartOptions();\n\n // Non-responsive mode: set the canvas render size explicitly from the\n // computed layout; Chart.js applies devicePixelRatio scaling on top\n if (this.lastDimensions) {\n this.canvasEl.width = this.lastDimensions.calculatedWidth;\n this.canvasEl.height = this.lastDimensions.actualHeight;\n }\n\n const isTooSmall = this.lastDimensions?.isTooSmall ?? false;\n\n this.chart = new Chart(ctx, {\n type: 'pie',\n data: {\n labels,\n datasets,\n },\n options,\n plugins: [\n // Only show outer labels if enabled AND height is large enough\n ...(this.showOuterLabels && !isTooSmall\n ? [this.createOuterLabelPiePlugin()]\n : []),\n this.sunburst && sunburstValues.length > 0\n ? this.createSunburstPlugin(\n sunburstValues,\n sunburstColors,\n sunburstLabels\n )\n : {id: 'sunburst'},\n ].filter((p) => p !== undefined),\n });\n\n // Defer legend update to next tick to ensure Chart.js metadata is initialized\n requestAnimationFrame(() => this.updateLegend());\n }\n\n private createSunburstPlugin(\n _outerValues: number[],\n sunburstColors: string[],\n sunburstLabels: string[]\n ): Plugin {\n return {\n id: 'sunburst',\n afterDatasetsDraw: (chart) => {\n const meta = chart.getDatasetMeta(0);\n if (!meta?.data.length) return;\n\n // Only draw if a segment is active (clicked)\n if (this.activeSegmentIndex === null) return;\n\n const {ctx} = chart;\n const centerX = chart.chartArea.left + chart.chartArea.width / 2;\n const centerY = chart.chartArea.top + chart.chartArea.height / 2;\n\n ctx.save();\n\n // Calculate radii to fit within CHART_WIDTH\n // Inner pie is now at 75% (radius property in getChartOptions)\n const firstArc = meta.data[0] as ArcElement;\n const innerPieRadius = firstArc.outerRadius;\n\n // The original 100% radius (before shrinking to 75%)\n // innerPieRadius = 0.75 * originalRadius, so originalRadius = innerPieRadius / 0.75\n const originalFullRadius = innerPieRadius / 0.75;\n\n // Determine if chart is below label threshold\n const height = this.canvasEl?.clientHeight ?? 0;\n const isTooSmall = height < PIE_DIMENSIONS.MIN_HEIGHT_WITH_LABELS;\n\n // Gap and thickness logic for small charts\n const gapWidth = isTooSmall ? 2 : 8;\n // For small charts, fill all available space with the sunburst arc\n const outerRingInnerRadius = innerPieRadius + gapWidth;\n const outerRingOuterRadius = isTooSmall\n ? originalFullRadius\n : originalFullRadius;\n // (If you want to reserve a gap to the edge, adjust here)\n\n // Setup font styling for labels\n const fontFamily = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontFamily\n );\n const fontWeight = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontWeightVar\n );\n const fontSize = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontSizeVar\n );\n const fontColor = getCssVariableValue(\n this,\n OUTER_LABEL_CONFIG.fontColorVar\n );\n\n ctx.font = `${fontWeight} ${fontSize} ${fontFamily}`;\n ctx.fillStyle = fontColor;\n ctx.textBaseline = 'middle';\n\n // Draw outer ring segments only for the active parent\n let sunburstDataIndex = 0;\n this.data.forEach((segment, segmentIndex) => {\n const children = segment.children || [];\n\n if (children.length > 0) {\n // Only draw if this is the active segment\n if (segmentIndex === this.activeSegmentIndex) {\n // Calculate total for this parent's children\n const childrenTotal = children.reduce(\n (sum, child) => sum + child.value,\n 0\n );\n let startAngle = 0;\n\n // Find the parent arc to align with it\n const parentArc = meta.data[segmentIndex] as ArcElement;\n const parentStart = parentArc.startAngle;\n const parentEnd = parentArc.endAngle;\n const parentAngleRange = parentEnd - parentStart;\n\n children.forEach((child) => {\n const childValue = child.value;\n const childRatio = childValue / childrenTotal;\n const childAngleRange = parentAngleRange * childRatio;\n const childStartAngle = parentStart + startAngle;\n const childEndAngle = childStartAngle + childAngleRange;\n\n // Draw the outer/sunburst arc\n ctx.fillStyle =\n sunburstColors[sunburstDataIndex] || 'transparent';\n ctx.beginPath();\n ctx.arc(\n centerX,\n centerY,\n outerRingOuterRadius,\n childStartAngle,\n childEndAngle\n );\n ctx.arc(\n centerX,\n centerY,\n outerRingInnerRadius,\n childEndAngle,\n childStartAngle,\n true\n );\n ctx.closePath();\n ctx.fill();\n\n // Draw label for this sunburst segment (if showOuterLabels is enabled)\n if (this.showOuterLabels && sunburstLabels[sunburstDataIndex]) {\n const middleAngle = (childStartAngle + childEndAngle) / 2;\n const labelRadius =\n outerRingOuterRadius + OUTER_LABEL_CONFIG.labelGap;\n const x = centerX + Math.cos(middleAngle) * labelRadius;\n const y = centerY + Math.sin(middleAngle) * labelRadius;\n const alignLeft = Math.cos(middleAngle) >= 0;\n\n ctx.fillStyle = fontColor;\n ctx.textAlign = alignLeft ? 'left' : 'right';\n const textX = alignLeft\n ? x + OUTER_LABEL_CONFIG.labelGap\n : x - OUTER_LABEL_CONFIG.labelGap;\n\n // Format label using shared helper\n const total = this.total > 0 ? this.total : 1;\n const valueText = formatSingleLabel(childValue, total, {\n unit: this.outerLabelUnit,\n showUnit: this.showUnit,\n decimalPlaces: this.outerLabelDecimalPlaces,\n maxLength: this.outerLabelMaxLength,\n });\n\n ctx.fillText(valueText, textX, y);\n }\n\n startAngle += childAngleRange;\n sunburstDataIndex++;\n });\n } else {\n // Skip this parent's children\n sunburstDataIndex += children.length;\n }\n } else {\n sunburstDataIndex++; // Skip transparent placeholders\n }\n });\n\n ctx.restore();\n },\n };\n }\n\n private updateChart() {\n // Guard: Verify chart and canvas still exist and are connected\n if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected) return;\n\n // Non-responsive mode: apply the computed layout size explicitly\n // (no-op when the size is unchanged)\n if (this.lastDimensions) {\n this.chart.resize(\n this.lastDimensions.calculatedWidth,\n this.lastDimensions.actualHeight\n );\n }\n\n this.chart.update();\n\n // Update legend after chart update completes to ensure metadata is ready\n requestAnimationFrame(() => this.updateLegend());\n }\n\n /**\n * Update only chart colors without recreating the entire chart\n * Used by theme observer for efficient theme changes\n */\n private updateChartColors() {\n // Guard: Verify chart and canvas still exist and are connected\n if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected) return;\n\n const {colors, sunburstColors} = this.prepareChartData();\n\n if (this.chart.data.datasets[0]) {\n this.chart.data.datasets[0].backgroundColor = colors;\n }\n\n // Update sunburst dataset colors if in sunburst mode\n if (this.sunburst && this.chart.data.datasets[1]) {\n this.chart.data.datasets[1].backgroundColor = sunburstColors;\n }\n\n // Update without animation for instant theme change\n this.chart.update('none');\n\n // Defer legend update to next frame to ensure metadata is ready\n requestAnimationFrame(() => this.updateLegend());\n }\n\n /**\n * Update the legend HTML content\n */\n private updateLegend() {\n // Guard: Check if legend should be shown and chart is ready\n if (!this.legend || !this.legendDiv || !this.chart) return;\n\n // Guard: Check if chart metadata is available\n const meta = this.chart.getDatasetMeta(0);\n if (!meta || !meta.controller) {\n return;\n }\n\n // Guard: Check if dataset has data\n if (!this.data || this.data.length === 0) {\n renderLegend(this.legendDiv, []);\n return;\n }\n\n // Denominator: use max if set, otherwise total, with minimum of 1\n const denominator = this.total > 0 ? this.total : 1;\n const isPercentage = this.outerLabelUnit === '%';\n\n try {\n const legendItems = this.data.map((item, i) => {\n const style = meta.controller.getStyle(i, false);\n const numericValue = formatChartNumber(\n item.value,\n denominator,\n isPercentage,\n this.outerLabelDecimalPlaces\n );\n const showUnit = this.showUnit && this.outerLabelUnit;\n const value = `${numericValue}`;\n const unit = showUnit ? `${this.outerLabelUnit}` : '';\n\n return {\n fillStyle: style.backgroundColor as string,\n label: item.label as string,\n value: value as string,\n unit: unit as string,\n };\n });\n\n renderLegend(this.legendDiv, legendItems);\n } catch (error) {\n console.debug(\n '[obc-pie-chart] updateLegend: error generating legend HTML',\n error\n );\n // Silent failure - don't throw, just skip legend update this time\n }\n }\n\n override render() {\n return html`\n <div class=\"wrapper\">\n <canvas></canvas>\n ${this.legend ? html`<div class=\"legend\"></div>` : ''}\n </div>\n `;\n }\n\n static override styles = [\n unsafeCSS(componentStyle),\n unsafeCSS(chartCommonStyle),\n unsafeCSS(chartLegendStyle),\n unsafeCSS(chartDebugStyle),\n ];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-pie-chart': ObcPieChart;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,SAAS,eAAe,oBAAoB,YAAY,OAAO;AAGrE,IAAM,iBAAiB;CACrB,GAAG;CACH,sBAAsB;AACxB;AAEA,IAAM,0BAA0B;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,yBAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AA0GO,IAAM,cAAN,MAAM,oBAAoB,WAAW;;;EAEf,KAAA,OAAA,CAAC;EAGT,KAAA,SAAA,CAAC;EAGC,KAAA,WAAA,SAAS;EAGZ,KAAA,kBAAA;EAGP,KAAA,WAAA;EAGA,KAAA,WAAA;EAGM,KAAA,i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AgB;IAuCxB,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,eAAe;IAsHvB,OAAO,CAAC,yBAAyB;IAoGjC,OAAO,CAAC,WAAW;IAkEnB,OAAO,CAAC,WAAW;IAgCnB;;OAEG;IACH,OAAO,CAAC,YAAY;IAiEX,MAAM;IASf,OAAgB,MAAM,4BAKpB;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}
|
|
@@ -5,7 +5,7 @@ import { calculateFixedHeightChartLayout, formatChartNumber } from "../../charth
|
|
|
5
5
|
import { observeThemeChanges } from "../../charthelpers/theme.js";
|
|
6
6
|
import { createArcOuterLabelPlugin } from "../../charthelpers/outer-labels.js";
|
|
7
7
|
import { getChartTooltipOptions } from "../../charthelpers/tooltip.js";
|
|
8
|
-
import {
|
|
8
|
+
import { renderLegend } from "../../charthelpers/legend.js";
|
|
9
9
|
import { observeLabelThreshold } from "../../charthelpers/label-threshold.js";
|
|
10
10
|
import "../../charthelpers/index.js";
|
|
11
11
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js";
|
|
@@ -325,7 +325,7 @@ var ObcPolarChart = class ObcPolarChart extends LitElement {
|
|
|
325
325
|
const meta = this.chart.getDatasetMeta(0);
|
|
326
326
|
if (!meta || !meta.controller) return;
|
|
327
327
|
if (!this.data || this.data.length === 0) {
|
|
328
|
-
this.legendDiv
|
|
328
|
+
renderLegend(this.legendDiv, []);
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
331
331
|
const denominator = this.showSectorLabels ? 1 : 360;
|
|
@@ -353,8 +353,7 @@ var ObcPolarChart = class ObcPolarChart extends LitElement {
|
|
|
353
353
|
unit
|
|
354
354
|
};
|
|
355
355
|
});
|
|
356
|
-
|
|
357
|
-
this.legendDiv.innerHTML = legendHTML;
|
|
356
|
+
renderLegend(this.legendDiv, legendItems);
|
|
358
357
|
} catch (error) {
|
|
359
358
|
console.debug("[obc-polar-chart] updateLegend: error generating legend HTML", error);
|
|
360
359
|
}
|