import type { IShapeLineStyle } from '@univerjs-pro/engine-shape'; import type { ISlideChartElement, ISlidePlaceholderData, SlideModel } from '@univerjs-pro/slides'; import type { Injector } from '@univerjs/core'; import type { ISlideChartDataSource, ISlideChartResource } from './chart-builder/types'; import { FChartBuilderBase } from './chart-builder/chart-builder-base'; import { FPageElement } from './f-page-element'; /** * The facade class for a slide chart element. * @hideconstructor */ export declare class FChart extends FPageElement { constructor(unitId: string, subUnitId: string, elementId: string, slideModel: SlideModel, injector: Injector); /** * Get the chart resource id. * @returns {string} The chart resource id. * * @example * ```ts * const fPresentation = univerAPI.getActivePresentation(); * const fSlide = fPresentation.getActiveSlide(); * const charts = fSlide.getCharts(); * console.log(charts[0]?.getChartId()); * ``` */ getChartId(): string; /** * Update the chart resource id used by this chart element. * @param {string} chartId The new chart resource id. * @returns {FChart} This chart, for chaining. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * chart.setChartId('chart-1'); * ``` */ setChartId(chartId: string): this; /** * Get the placeholder metadata associated with this chart. * @returns {ISlidePlaceholderData|undefined} The placeholder metadata, or `undefined` if the chart is not created from a placeholder. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * console.log(chart.getPlaceholder()); * ``` */ getPlaceholder(): ISlidePlaceholderData | undefined; /** * Update the placeholder metadata associated with this chart. * @param {ISlidePlaceholderData} [placeholder] The placeholder metadata. Pass `undefined` to clear it. * @returns {FChart} This chart, for chaining. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * chart.setPlaceholder(undefined); * ``` */ setPlaceholder(placeholder?: ISlidePlaceholderData): this; /** * Get the chart frame stroke style. * @returns {IShapeLineStyle|undefined} The chart frame stroke style. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * console.log(chart.getStroke()); * ``` */ getStroke(): IShapeLineStyle | undefined; /** * Update the chart frame stroke style. * @param {IShapeLineStyle} [stroke] The stroke style. Pass `undefined` to clear it. * @returns {FChart} This chart, for chaining. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * chart.setStroke({ color: '#d1d5db', width: 1 }); * ``` */ setStroke(stroke?: IShapeLineStyle): this; /** * Get the chart resource data stored in the presentation snapshot. * @returns {ISlideChartResource|null} The chart resource data, or `null` when it does not exist. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * const chartData = chart.getChartData(); * console.log(chartData?.chartType); * ``` */ getChartData(): ISlideChartResource | null; /** * Get the chart data source. * @returns {ISlideChartDataSource|undefined} The chart data source. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * console.log(chart.getDataSource()?.values); * ``` */ getDataSource(): ISlideChartDataSource | undefined; /** * Update the chart data source. * @param {ISlideChartDataSource} dataSource The new two-dimensional chart data source. * @param {ISlideChartCellValue[][]} dataSource.values The chart source data. * @param {boolean} [dataSource.useFirstRowAsHeaders] Whether the first row should be used as series headers. * @param {boolean} [dataSource.useFirstColumnAsDomain] Whether the first column should be used as category/domain labels. * @returns {FChart} This chart, for chaining. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * chart.setDataSource({ * values: [ * ['Month', 'Sales'], * ['Jan', 120], * ['Feb', 180], * ], * useFirstRowAsHeaders: true, * useFirstColumnAsDomain: true, * }); * ``` */ setDataSource(dataSource: ISlideChartDataSource): this; /** * Update chart resource data. * @param {Partial>} resource The chart resource fields to update. * @param {ChartTypeBits} [resource.chartType] The chart type. * @param {ISlideChartDataSource} [resource.dataSource] The chart data source. * @param {ISlideChartBuildOptions} [resource.options] The chart build options. * @returns {FChart} This chart, for chaining. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * chart.updateChartData({ * options: { * title: { content: 'Sales' }, * }, * }); * ``` */ updateChartData(resource: Partial>): this; /** * Returns a chart builder initialized from this chart. * @returns {FChartBuilderBase} A chart builder that can be used with `fSlide.updateChart()`. * * @example * ```ts * const chart = fSlide.getCharts()[0]; * const chartInfo = chart.toBuilder() * .asLineChart() * .setTitle('Updated sales') * .build(); * fSlide.updateChart(chartInfo); * ``` */ toBuilder(): FChartBuilderBase; }