import type { Theme } from '@mui/material' import type { EChartsOption } from 'echarts' import type { WidgetSeries } from '../types' /** A single slice of a pie series. */ export interface PieDatum { name: string | number value: number } /** Pie widget data — one slice array per series (rendered as side-by-side donuts). */ export type PieWidgetData = readonly (readonly PieDatum[])[] /** Inputs to the structural-only {@link pieOptions} builder. */ export interface PieOptionsInput { theme: Theme /** Numeric value formatter — drives the tooltip value and center label. */ formatter?: (value: number) => string /** Optional slice-name formatter — also forwarded to the legend. */ labelFormatter?: (value: string | number) => string | number } /** * Combined inputs for the pie option factory creator. Carries everything * the widget needs across BOTH phases — the structural-build (`theme`, * `formatter`, `labelFormatter`, `optionsOverride`) AND the data merge * (`series`, `radius`, `selection`). The merger emits different * chart shapes by series count: single → donut, multi → horizontal-bar * fallback (mirrors v1 pie); both branches read `theme` for styling. */ export interface PieOptionFactoryInput { theme: Theme formatter?: (value: number) => string labelFormatter?: (value: string | number) => string | number /** * Per-series metadata — drives the legend, `series[i].name`, and (in * the multi-series bar fallback) per-series colour overrides. * Single-series donuts always use the per-slice palette regardless of * any `series[0].color`, since the donut palette is keyed by data * index, not series index. */ series?: readonly WidgetSeries[] /** * Inner/outer radius (percent). Default `['58%', '74%']` produces a * donut sized to leave room for the wrappable bottom legend. Set * inner to `'0%'` for a solid pie. */ radius?: readonly [string, string] /** * Selected slice names. Slices not in this list render dimmed * (`itemStyle.opacity: 0.15`). `null`/empty means no selection. */ selection?: readonly (string | number)[] | null /** * Consumer-supplied partial option merged into the structural option at * structural-build time. Lets stories override pieces of the theme-aware * base without forking the structural builder. */ optionsOverride?: Partial } export type PieEChartsOption = EChartsOption