import { EdgeInsets, Widget } from "@meursyphus/flitter"; import { TitleConfig, Title } from "./component/Title"; import { PlotProps, PlotConfig, Plot } from "./component/Plot"; import { XAxisProps, XAxis } from "./component/XAxis"; import { YAxisProps, YAxis } from "./component/YAxis"; import { YAxisLabelProps, YAxisLabel } from "./component/YAxisLabel"; import { XAxisLabel } from "./component/XAxisLabel"; import { LayoutConfig, Layout } from "./component/Layout"; import { Scale as _Scale } from "./util/getScale"; import { ChartConfig, Chart } from "./component/Chart"; import { DataLabelConfig, DataLabel } from "./component/DataLabel"; import type { DeepPartial } from "../../utils"; import { XAxisTickProps, XAxisTick } from "./component/XAxisTick"; import { YAxisTickProps, YAxisTick } from "./component/YAxisTick"; import { SeriesConfig, Series } from "./component/Series"; import { LegendConfig, Legend } from "./component/Legend"; import type { CustomConfig, CustomWidget } from "../type"; import ChartContextWidget from "../ChartContextWidget"; export type Dependencies = { Plot: (...args: ConstructorParameters) => ChartContextWidget; XAxis: (...args: ConstructorParameters) => ChartContextWidget; YAxis: (...args: ConstructorParameters) => ChartContextWidget; YAxisLabel: (...args: ConstructorParameters) => ChartContextWidget; XAxisLabel: (...args: ConstructorParameters) => ChartContextWidget; Title: (...args: ConstructorParameters) => ChartContextWidget; XAxisTick: (...args: ConstructorParameters) => ChartContextWidget; YAxisTick: (...args: ConstructorParameters) => ChartContextWidget; DataLabel: (...args: ConstructorParameters) => ChartContextWidget; Layout: (...args: ConstructorParameters) => ChartContextWidget; Chart: (...args: ConstructorParameters) => ChartContextWidget; Series: (...args: ConstructorParameters) => ChartContextWidget; Legend: (...args: ConstructorParameters) => ChartContextWidget; }; export type LegendState = { visible: boolean; color: string; label: string; }; export type Theme = { text: Required; border: { color: string; width: number; }; series: { colors: string[]; }; }; export type Font = { fontSize?: number; color?: string; fontFamily?: string; lineHeight?: number; }; export type Scale = _Scale; export type CartesianChartProps = { data: Data; theme?: DeepPartial; custom?: Custom; }; export type Custom = { title: CustomTitle; layout: CustomLayout; xAxis: CustomXAxis; xAxisLabel: CustomXAxisLabel; yAxis: CustomYAxis; yAxisLabel: CustomYAxisLabel; chart: CustomChart; dataLabel: CustomDataLabel; xAxisTick: CUstomXAxisTick; yAxisTick: CustomYAxisTick; plot: CustomPlot; series: CustomSeries; legend: CustomLegend; }; export type Data = { title?: string; labels: string[]; datasets: { legend: string; data: V[]; }[]; }; export type CustomTitle = CustomConfig | CustomWidget<{}, { text: string; }, THEME, DATA>; type AxisLabel = { margin?: EdgeInsets; font?: Font; }; export type CustomXAxisLabel = CustomConfig | CustomWidget<{}, { text: string; index: number; }, THEME, DATA>; export type CustomYAxisLabel = CustomConfig | CustomWidget<{}, { text: string; index: number; }, THEME, DATA>; export type CustomXAxis = CustomConfig | ({ thickness: number; color: string; } & CustomWidget<{ XAxisTick: (props: XAxisTickProps) => Widget; XAxisLabel: (props: { index: number; text: string; }) => Widget; }, { data: Data; }, THEME, DATA>); export type CustomYAxis = CustomConfig | ({ thickness: number; color: string; } & CustomWidget<{ YAxisTick: (props: YAxisTickProps) => Widget; YAxisLabel: (props: YAxisLabelProps) => Widget; }, { data: Data; }, THEME, DATA>); type CustomLayout = CustomConfig | CustomWidget<"Title" | "Chart" | "Legend", { data: DATA; theme: THEME; }>; export type CUstomXAxisTick = CustomConfig | CustomWidget<{}, { data: Data; theme: Theme; index: number; }, THEME, DATA>; export type CustomYAxisTick = CustomConfig | CustomWidget<{}, { data: Data; theme: Theme; index: number; }, THEME, DATA>; type Tick = { color?: string; thickness?: number; length?: number; }; type Axis = { thickness?: number; color?: string; }; export type CustomDataLabel = CustomConfig | CustomWidget<{}, { value: number; index: number; legend: string; label: string; }, THEME, DATA>; export type CustomPlot = CustomConfig | ({ width?: number; height?: number; } & CustomWidget<{}, {}, THEME, DATA>); export type CustomChart = CustomConfig | CustomWidget<{ Plot: (props: PlotProps) => Widget; XAxis: (props: XAxisProps) => Widget; YAxis: (props: YAxisProps) => Widget; }, {}, THEME, DATA>; export type CustomSeries = CustomConfig | CustomWidget<{}, {}, THEME, DATA>; export type CustomLegend = CustomConfig | CustomWidget<{}, { legendStates: LegendState[]; }, THEME, DATA>; export {};