import type { Theme } from '@mui/material' import type { EChartsOption } from 'echarts' import type { WidgetSeries } from '../types' /** * A single point on a time series. `name` is the time coordinate — accepts a * Date object, a number (ms-since-epoch), or an ISO-8601 string. ECharts' * time axis parses any of these. */ export interface TimeseriesDatum { name: Date | number | string value: number } /** Timeseries widget data — one array of points per series. */ export type TimeseriesWidgetData = readonly (readonly TimeseriesDatum[])[] /** Inputs to the structural-only {@link timeseriesOptions} builder. */ export interface TimeseriesOptionsInput { theme: Theme formatter?: (value: number) => string /** Optional formatter for the time-axis tick labels. Receives a JS Date. */ labelFormatter?: (value: Date) => string } /** * Combined inputs for the timeseries option factory creator. Carries * everything the widget needs across BOTH phases — the structural-build * (`theme`, `formatter`, `labelFormatter`, `optionsOverride`) AND the * data merge (`series`, `smooth`, `area`, `selection`). */ export interface TimeseriesOptionFactoryInput { theme: Theme formatter?: (value: number) => string /** * Time-axis label formatter (also used in the tooltip name). Receives * a JS Date — applied both at structural-build time (x-axis ticks) and * at fusion time (tooltip name) so the date-aware labeling survives * RelativeData's reactive formatter swaps. */ labelFormatter?: (value: Date) => string /** * Per-series metadata — drives the legend, `series[i].name`, and * (when `color` is set) per-series line + marker colour overrides. */ series?: readonly WidgetSeries[] /** Smooth lines (default `true`). */ smooth?: boolean /** Filled area below each line (default `false`). */ area?: boolean /** * Selected point keys (matched against `TimeseriesDatum.name`; `Date` * names are normalized to ms-since-epoch). Points 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 TimeseriesEChartsOption = EChartsOption