import type { Theme } from '@mui/material' import type { EChartsOption } from 'echarts' import type { WidgetSeries } from '../types' /** * Histogram widget data — array of series, each a flat array of bin counts. * The option factory's merge phase (see {@link createHistogramOptionFactory}) * combines this with `ticks` to produce a 2-column dataset (`[binLabel, count]`) * for ECharts. */ export type HistogramWidgetData = readonly (readonly number[])[] /** Inputs to the structural-only {@link histogramOptions} builder. */ export interface HistogramOptionsInput { theme: Theme formatter?: (value: number) => string } /** * Combined inputs for the histogram option factory creator. Carries * everything the widget needs across BOTH phases — the structural-build * (`theme`, `formatter`, `optionsOverride`) AND the data merge (`ticks`, * `series`, `labelFormatter`, `selection`). */ export interface HistogramOptionFactoryInput { theme: Theme formatter?: (value: number) => string /** Bin boundaries — length = bins + 1. */ ticks: readonly number[] /** * Per-series metadata — drives the legend, `series[i].name`, and * (when `color` is set) a per-series colour override on the bars. */ series?: readonly WidgetSeries[] /** * Bin-range label transform (e.g. `"0–10"` → `"[0–10)"`). Distinct from * the standard `OptionFactoryContext.labelFormatter` (which operates on * categories): this one is histogram-specific and runs only on the * generated bin-range strings before they hit the x-axis. */ labelFormatter?: (label: string) => string /** * Selected bin indices. Bins not in this list render dimmed * (`itemStyle.opacity: 0.15`). `null`/empty means no selection. */ selection?: readonly 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 HistogramEChartsOption = EChartsOption