import { h as ChartWarning, c as ChartAssemblyInput, s as FormatSpec, B as SemanticResult } from '../types-DHaPWLqG.cjs'; /** * Excel backend types. * * The Excel "native spec" is a declarative description of an Office.js chart: * a wide/matrix data range plus chart type, axes, legend, and series config. * A host renders it imperatively via the Office.js Excel API * (`sheet.charts.add(type, range, seriesBy)` + `chart.getImage()`). * * This mirrors how the other backends emit a native artifact (Vega-Lite spec, * ECharts option, Chart.js config) — here the artifact targets Excel charts. */ /** Excel `ChartSeriesBy` orientation. */ type ExcelSeriesBy = 'Columns' | 'Rows'; /** Excel `ChartLegendPosition` (subset we emit). */ type ExcelLegendPosition = 'Top' | 'Bottom' | 'Left' | 'Right'; interface ExcelAxisSpec { /** Axis title text (from the field display name). */ title?: string; /** Axis-label font size in points, used when dense categories need explicit sizing. */ labelFontSize?: number; /** Number of categories between displayed labels; underlying data stays intact. */ tickLabelSpacing?: number; /** Excel number format string, e.g. `"$#,##0"`, `"0.0%"`, `"#,##0"`. */ numberFormat?: string; /** Reverse Excel's native category plotting order (horizontal nominal bars). */ reversePlotOrder?: boolean; /** Explicit native-axis minimum, used for zero-anchored length/area charts. */ minimumScale?: number; /** Explicit native-axis maximum, used to avoid excessive automatic headroom. */ maximumScale?: number; /** Interval between major ticks on a numeric axis. */ majorUnit?: number; } interface ExcelLegendSpec { visible: boolean; position?: ExcelLegendPosition; } interface ExcelDataLabelsSpec { visible: boolean; position?: 'BestFit' | 'Center' | 'InsideBase' | 'InsideEnd' | 'OutsideEnd'; numberFormat?: string; fontColor?: string; fontSize?: number; } interface ExcelNativeSeriesSpec { /** Legend/series name. */ name: string; /** Zero-based worksheet column containing X values, excluding the header row. */ xColumn: number; /** Zero-based worksheet column containing Y values, excluding the header row. */ yColumn: number; /** Number of populated worksheet rows in this series. */ rowCount: number; /** Optional zero-based worksheet column containing bubble sizes. */ bubbleSizeColumn?: number; } interface ExcelNativeSeriesFormatSpec { /** Native HTML color shared by related series segments. */ color?: string; /** Excel.ChartLineStyle string. */ lineStyle?: 'Continuous' | 'Dash' | 'DashDot' | 'DashDotDot' | 'Dot' | 'RoundDot'; } interface ExcelBoxWhiskerOptionsSpec { quartileCalculation?: 'Inclusive' | 'Exclusive'; showInnerPoints?: boolean; showMeanLine?: boolean; showMeanMarker?: boolean; showOutlierPoints?: boolean; } interface ExcelRenderSpecBase { /** Stable discriminator for serialized Flint Excel artifacts. */ schema: 'flint.excel.chart/v1'; /** Chart title. */ title?: string; /** Source values written to the worksheet. */ data: Array>; /** Target width/height in points (from Flint layout / baseSize). */ width?: number; height?: number; /** Flint assembler warnings (overflow, etc.). */ warnings?: ChartWarning[]; /** Provenance for debugging (not consumed by the renderer). */ _flint?: Record; } /** A conventional native Excel chart rendered through `Chart.getImage()`. */ interface ExcelNativeChartSpec extends ExcelRenderSpecBase { kind: 'chart'; /** * The Office.js `Excel.ChartType` enum string, e.g. `"ColumnClustered"`, * `"BarStacked"`, `"Line"`, `"XYScatter"`, `"Pie"`. */ chartType: string; /** Whether series run down columns or across rows of the data range. */ seriesBy: ExcelSeriesBy; /** Explicit bindings for XY/bubble series when Excel cannot infer grouped ranges. */ series?: ExcelNativeSeriesSpec[]; /** Formatting aligned with the rendered series order. */ seriesFormats?: ExcelNativeSeriesFormatSpec[]; /** Category (label) axis. Absent for pie/doughnut (no axes). */ categoryAxis?: ExcelAxisSpec; /** Value (measure) axis. Absent for pie/doughnut. */ valueAxis?: ExcelAxisSpec; /** Legend visibility + position. */ legend?: ExcelLegendSpec; /** Native chart data labels. */ dataLabels?: ExcelDataLabelsSpec; /** Bar/column gap width (%) — bar family only. */ gapWidth?: number; /** Bar/column series overlap (%) — 2-D bar family only. */ overlap?: number; /** Excel bubble-size percentage (0-300), applied to every bubble series. */ bubbleScale?: number; /** Doughnut hole size percentage (10-90), applied to every doughnut series. */ doughnutHoleSize?: number; /** Statistical options applied to every native box-and-whisker series. */ boxWhiskerOptions?: ExcelBoxWhiskerOptionsSpec; /** Display native connector lines between Waterfall points. */ showConnectorLines?: boolean; } /** A backend-native Excel chart artifact. */ type ExcelChartSpec = ExcelNativeChartSpec; /** * Excel chart assembly — Stage-3 code generator for Office.js Excel charts. * * Reuses the SAME core analysis pipeline as the other backends: * Phase 0: convertTemporalData + resolveChannelSemantics → ChannelSemantics * (this decides each channel's role: quantitative = MEASURE, * nominal/ordinal/temporal = CATEGORY — no heuristics) * Stage 3: pivot the long/tidy rows into Excel's WIDE matrix and emit an * ExcelChartSpec (native Office.js chart description). * * Excel charts consume a rectangular range (`charts.add(type, range, seriesBy)`), * so the long/tidy data is pivoted: category field → first column, series field * → series columns, measure → cells. Visual STYLE stays native to Excel (its * own palette/gridlines); only Flint's LAYOUT decisions (which field is the * category, number format, legend, orientation) are carried over. */ /** * Assemble an {@link ExcelChartSpec} from a {@link ChartAssemblyInput}. * * @throws if the chart type has no native Excel equivalent (e.g. Heatmap). */ declare function assembleExcel(input: ChartAssemblyInput): ExcelChartSpec; declare const EXCEL_ARTIFACT_SCHEMA: "flint.excel.chart/v1"; declare const SUPPORTED_EXCEL_CHART_TYPES: readonly ["Area", "AreaStacked", "BarClustered", "BarStacked", "BoxWhisker", "Bubble", "ColumnClustered", "ColumnStacked", "Doughnut", "Funnel", "Line", "Pie", "RadarMarkers", "StockOHLC", "Sunburst", "Treemap", "Waterfall", "XYScatter", "XYScatterLines"]; interface PreparedExcelArtifact { spec: ExcelNativeChartSpec; data: Array>; rows: number; columns: number; rangeA1: string; chartType: string; numericAxis: boolean; dateAxis: boolean; hasAxes: boolean; isBar: boolean; isLine: boolean; seriesCount: number; } declare function excelColumnLetter(index: number): string; declare function prepareExcelArtifact(value: unknown): PreparedExcelArtifact; interface OfficeJsCodegenOptions { scale?: number; cleanWorksheet?: boolean; functionName?: string; } interface GeneratedOfficeJs { code: string; meta: { schema: ExcelNativeChartSpec['schema']; rangeA1: string; chartType: string; rows: number; columns: number; }; } declare function generateOfficeJs(value: unknown, options?: OfficeJsCodegenOptions): GeneratedOfficeJs; interface OfficeJsExcelApi { run(callback: (context: any) => Promise): Promise; ImageFittingMode: { fit: any; }; } interface ExcelRenderOptions { scale?: number; cleanWorksheet?: boolean; inspectNativeChart?: boolean; } interface ExcelRenderResult { pngBase64: string; inspection: unknown | null; } declare function renderExcelChart(excelApi: OfficeJsExcelApi, value: unknown, options?: ExcelRenderOptions): Promise; /** * Excel chart-type mapping + FormatSpec → Excel number format. * * Excel's native chart types are a fixed enum (`Excel.ChartType`), so a Flint * chart type maps to the closest native Excel chart. Orientation (vertical vs * horizontal) is decided by the assembler from channel semantics and selects * the Column* vs Bar* family. */ /** Which native Excel family a Flint chart maps to. */ interface ExcelTypeMapping { /** Vertical (category on x) Excel.ChartType. */ vertical: string; /** Horizontal (category on y) Excel.ChartType, when the family supports it. */ horizontal?: string; /** True for pie/doughnut/… charts that have no value/category axes. */ noAxes?: boolean; /** True for XY (both-measure) charts. */ xy?: boolean; } /** Flint chart type (display name) → Excel chart family. */ declare const EXCEL_TYPE_MAP: Record; /** Chart types this backend can render natively in Excel. */ declare function isExcelSupported(flintChartType: string): boolean; /** * Map a Flint {@link FormatSpec} to an Excel number-format string. * * Excel formats are pattern strings (`"$#,##0"`, `"0.0%"`, `"#,##0"`), distinct * from d3/Vega patterns, so we translate from the FormatSpec's intent (prefix, * suffix, abbreviate) rather than its d3 `pattern`. */ declare function formatSpecToExcel(fmt: FormatSpec | undefined): string | undefined; interface ExcelTemplateContext { input: ChartAssemblyInput; table: any[]; semantics: SemanticResult; fieldOf: (channel: string) => string | undefined; typeOf: (channel: string) => string | undefined; } interface ExcelTemplateDef { chart: string; channels: string[]; typeMapping: ExcelTypeMapping; validate?: (context: ExcelTemplateContext) => string | undefined; instantiate?: (context: ExcelTemplateContext) => ExcelNativeChartSpec; } declare const excelAllTemplateDefs: ExcelTemplateDef[]; declare function excelGetTemplateDef(chartType: string): ExcelTemplateDef | undefined; declare function excelGetTemplateChannels(chartType: string): string[]; export { EXCEL_ARTIFACT_SCHEMA, EXCEL_TYPE_MAP, type ExcelAxisSpec, type ExcelBoxWhiskerOptionsSpec, type ExcelChartSpec, type ExcelDataLabelsSpec, type ExcelLegendPosition, type ExcelLegendSpec, type ExcelNativeChartSpec, type ExcelNativeSeriesFormatSpec, type ExcelNativeSeriesSpec, type ExcelRenderOptions, type ExcelRenderResult, type ExcelSeriesBy, type ExcelTemplateContext, type ExcelTemplateDef, type GeneratedOfficeJs, type OfficeJsCodegenOptions, type OfficeJsExcelApi, type PreparedExcelArtifact, SUPPORTED_EXCEL_CHART_TYPES, assembleExcel, excelAllTemplateDefs, excelColumnLetter, excelGetTemplateChannels, excelGetTemplateDef, formatSpecToExcel, generateOfficeJs, isExcelSupported, prepareExcelArtifact, renderExcelChart };