@univerjs-pro/sheets-chart 1.0.0-alpha.3 → 1.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +1 -1
  3. package/lib/cjs/locale/ar-SA.js +1 -1
  4. package/lib/cjs/locale/ca-ES.js +1 -1
  5. package/lib/cjs/locale/de-DE.js +1 -1
  6. package/lib/cjs/locale/en-US.js +1 -1
  7. package/lib/cjs/locale/es-ES.js +1 -1
  8. package/lib/cjs/locale/fa-IR.js +1 -1
  9. package/lib/cjs/locale/fr-FR.js +1 -1
  10. package/lib/cjs/locale/id-ID.js +1 -1
  11. package/lib/cjs/locale/it-IT.js +1 -1
  12. package/lib/cjs/locale/ja-JP.js +1 -1
  13. package/lib/cjs/locale/ko-KR.js +1 -1
  14. package/lib/cjs/locale/pl-PL.js +1 -1
  15. package/lib/cjs/locale/pt-BR.js +1 -1
  16. package/lib/cjs/locale/ru-RU.js +1 -1
  17. package/lib/cjs/locale/sk-SK.js +1 -1
  18. package/lib/cjs/locale/vi-VN.js +1 -1
  19. package/lib/cjs/locale/zh-CN.js +1 -1
  20. package/lib/cjs/locale/zh-HK.js +1 -1
  21. package/lib/cjs/locale/zh-TW.js +1 -1
  22. package/lib/es/facade.js +1 -1
  23. package/lib/es/index.js +1 -1
  24. package/lib/es/locale/ar-SA.js +1 -1
  25. package/lib/es/locale/ca-ES.js +1 -1
  26. package/lib/es/locale/de-DE.js +1 -1
  27. package/lib/es/locale/en-US.js +1 -1
  28. package/lib/es/locale/es-ES.js +1 -1
  29. package/lib/es/locale/fa-IR.js +1 -1
  30. package/lib/es/locale/fr-FR.js +1 -1
  31. package/lib/es/locale/id-ID.js +1 -1
  32. package/lib/es/locale/it-IT.js +1 -1
  33. package/lib/es/locale/ja-JP.js +1 -1
  34. package/lib/es/locale/ko-KR.js +1 -1
  35. package/lib/es/locale/pl-PL.js +1 -1
  36. package/lib/es/locale/pt-BR.js +1 -1
  37. package/lib/es/locale/ru-RU.js +1 -1
  38. package/lib/es/locale/sk-SK.js +1 -1
  39. package/lib/es/locale/vi-VN.js +1 -1
  40. package/lib/es/locale/zh-CN.js +1 -1
  41. package/lib/es/locale/zh-HK.js +1 -1
  42. package/lib/es/locale/zh-TW.js +1 -1
  43. package/lib/facade.js +1 -1
  44. package/lib/index.js +1 -1
  45. package/lib/locale/ar-SA.js +1 -1
  46. package/lib/locale/ca-ES.js +1 -1
  47. package/lib/locale/de-DE.js +1 -1
  48. package/lib/locale/en-US.js +1 -1
  49. package/lib/locale/es-ES.js +1 -1
  50. package/lib/locale/fa-IR.js +1 -1
  51. package/lib/locale/fr-FR.js +1 -1
  52. package/lib/locale/id-ID.js +1 -1
  53. package/lib/locale/it-IT.js +1 -1
  54. package/lib/locale/ja-JP.js +1 -1
  55. package/lib/locale/ko-KR.js +1 -1
  56. package/lib/locale/pl-PL.js +1 -1
  57. package/lib/locale/pt-BR.js +1 -1
  58. package/lib/locale/ru-RU.js +1 -1
  59. package/lib/locale/sk-SK.js +1 -1
  60. package/lib/locale/vi-VN.js +1 -1
  61. package/lib/locale/zh-CN.js +1 -1
  62. package/lib/locale/zh-HK.js +1 -1
  63. package/lib/locale/zh-TW.js +1 -1
  64. package/lib/types/chart-builder/index.d.ts +10 -0
  65. package/lib/types/chart-builder/sheet-chart-builder-adapter.d.ts +41 -0
  66. package/lib/types/chart-builder/sheet-chart-builder.d.ts +17 -0
  67. package/lib/types/chart-builder/sheet-chart-create-spec.d.ts +6 -0
  68. package/lib/types/chart-builder/sheet-chart-description.d.ts +5 -0
  69. package/lib/types/chart-builder/sheet-chart-layout.d.ts +21 -0
  70. package/lib/types/chart-builder/sheet-chart-source.d.ts +32 -0
  71. package/lib/types/chart-builder/types.d.ts +159 -0
  72. package/lib/types/chart-source/chart-source.d.ts +14 -6
  73. package/lib/types/commands/commands/sheets-chart-update-config.command.d.ts +2 -0
  74. package/lib/types/commands/mutations/sheets-chart-update-config.mutation.d.ts +1 -0
  75. package/lib/types/facade/chart/f-sheet-chart-builder.d.ts +83 -0
  76. package/lib/types/facade/chart/f-sheet-charts.d.ts +100 -0
  77. package/lib/types/facade/chart/index.d.ts +2 -0
  78. package/lib/types/facade/chart/sheet-chart-command-adapter.d.ts +13 -0
  79. package/lib/types/facade/f-chart.d.ts +1 -166
  80. package/lib/types/facade/f-enum.d.ts +7 -205
  81. package/lib/types/facade/f-worksheet-charts.d.ts +3 -84
  82. package/lib/types/facade/index.d.ts +3 -24
  83. package/lib/types/index.d.ts +3 -1
  84. package/lib/types/models/types.d.ts +10 -0
  85. package/lib/umd/facade.js +1 -1
  86. package/lib/umd/index.js +1 -1
  87. package/lib/umd/locale/ar-SA.js +1 -1
  88. package/lib/umd/locale/ca-ES.js +1 -1
  89. package/lib/umd/locale/de-DE.js +1 -1
  90. package/lib/umd/locale/en-US.js +1 -1
  91. package/lib/umd/locale/es-ES.js +1 -1
  92. package/lib/umd/locale/fa-IR.js +1 -1
  93. package/lib/umd/locale/fr-FR.js +1 -1
  94. package/lib/umd/locale/id-ID.js +1 -1
  95. package/lib/umd/locale/it-IT.js +1 -1
  96. package/lib/umd/locale/ja-JP.js +1 -1
  97. package/lib/umd/locale/ko-KR.js +1 -1
  98. package/lib/umd/locale/pl-PL.js +1 -1
  99. package/lib/umd/locale/pt-BR.js +1 -1
  100. package/lib/umd/locale/ru-RU.js +1 -1
  101. package/lib/umd/locale/sk-SK.js +1 -1
  102. package/lib/umd/locale/vi-VN.js +1 -1
  103. package/lib/umd/locale/zh-CN.js +1 -1
  104. package/lib/umd/locale/zh-HK.js +1 -1
  105. package/lib/umd/locale/zh-TW.js +1 -1
  106. package/package.json +9 -9
  107. package/lib/types/facade/chart-builder/builder-util.d.ts +0 -5
  108. package/lib/types/facade/chart-builder/chart-builder-base.d.ts +0 -919
  109. package/lib/types/facade/chart-builder/line-chart-builder.d.ts +0 -165
  110. package/lib/types/facade/chart-builder/pie-chart-builder.d.ts +0 -196
  111. package/lib/types/facade/chart-builder/radar-chart-builder.d.ts +0 -100
  112. package/lib/types/facade/chart-builder/types.d.ts +0 -34
  113. package/lib/types/facade/chart-facade-adapter.d.ts +0 -68
  114. package/lib/types/facade/chart-facade-builders.d.ts +0 -67
  115. package/lib/types/facade/chart-facade-types.d.ts +0 -212
  116. package/lib/types/facade/f-worksheet.d.ts +0 -208
@@ -0,0 +1,83 @@
1
+ import type { FChartBuilderBase, HostAnyChartBuilder, HostComposedChartBuilder, IChartBuilderTypeMap } from '@univerjs-pro/engine-chart/facade';
2
+ import type { ChartAnchorSpec, ChartSourceSpec } from '@univerjs-pro/sheets-chart';
3
+ export interface ISheetChartMethods {
4
+ /**
5
+ * Sets the source configuration and returns this builder for chaining.
6
+ *
7
+ * This method executes synchronously.
8
+ *
9
+ * @param source The host-owned chart source.
10
+ * @returns This builder for chaining.
11
+ * @example
12
+ * ```ts
13
+ * const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
14
+ * const builder = worksheet.charts.create();
15
+ * builder.setSource('A1:B8');
16
+ * ```
17
+ */
18
+ setSource(source: ChartSourceSpec): ISheetChartMethods;
19
+ /**
20
+ * Returns the current source value.
21
+ *
22
+ * This method executes synchronously.
23
+ *
24
+ * @returns The current host-owned chart source, or `undefined` when no source has been set.
25
+ * @example
26
+ * ```ts
27
+ * const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
28
+ * const builder = worksheet.charts.create();
29
+ * builder.getSource();
30
+ * ```
31
+ */
32
+ getSource(): Readonly<ChartSourceSpec> | undefined;
33
+ /**
34
+ * Sets the position configuration and returns this builder for chaining.
35
+ *
36
+ * This method executes synchronously.
37
+ *
38
+ * @param anchor The document or cell anchor.
39
+ * @returns This builder for chaining.
40
+ * @example
41
+ * ```ts
42
+ * const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
43
+ * const builder = worksheet.charts.create();
44
+ * builder.setPosition('D2');
45
+ * ```
46
+ */
47
+ setPosition(anchor: ChartAnchorSpec): ISheetChartMethods;
48
+ /**
49
+ * Sets the absolute position configuration and returns this builder for chaining.
50
+ *
51
+ * This method executes synchronously.
52
+ *
53
+ * @param x The horizontal position.
54
+ * @param y The vertical position.
55
+ * @returns This builder for chaining.
56
+ * @example
57
+ * ```ts
58
+ * const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
59
+ * const builder = worksheet.charts.create();
60
+ * builder.setAbsolutePosition(80, 80);
61
+ * ```
62
+ */
63
+ setAbsolutePosition(x: number, y: number): ISheetChartMethods;
64
+ /**
65
+ * Sets the size configuration and returns this builder for chaining.
66
+ *
67
+ * This method executes synchronously.
68
+ *
69
+ * @param width The width.
70
+ * @param height The height.
71
+ * @returns This builder for chaining.
72
+ * @example
73
+ * ```ts
74
+ * const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
75
+ * const builder = worksheet.charts.create();
76
+ * builder.setSize(640, 360);
77
+ * ```
78
+ */
79
+ setSize(width: number, height: number): ISheetChartMethods;
80
+ }
81
+ export type FSheetChartBuilder<TBuilder extends FChartBuilderBase = FChartBuilderBase> = HostComposedChartBuilder<TBuilder, ISheetChartMethods>;
82
+ export type FSheetChartBuilderOf<T extends keyof IChartBuilderTypeMap> = FSheetChartBuilder<IChartBuilderTypeMap[T]>;
83
+ export type FSheetAnyChartBuilder = HostAnyChartBuilder<ISheetChartMethods>;
@@ -0,0 +1,100 @@
1
+ import type { IEchartTheme } from '@univerjs-pro/engine-chart';
2
+ import type { IChartBuilderHostTypes } from '@univerjs-pro/engine-chart/facade';
3
+ import type { FWorksheet } from '@univerjs/sheets/facade';
4
+ import type { FSheetAnyChartBuilder, FSheetChartBuilder } from './f-sheet-chart-builder';
5
+ import { FChartsBase } from '@univerjs-pro/engine-chart/facade';
6
+ interface ISheetChartBuilderTypes extends IChartBuilderHostTypes {
7
+ Initial: FSheetChartBuilder;
8
+ Any: FSheetAnyChartBuilder;
9
+ }
10
+ export declare class FSheetCharts extends FChartsBase<ISheetChartBuilderTypes> {
11
+ private readonly _worksheet;
12
+ private readonly _commands;
13
+ constructor(_worksheet: FWorksheet);
14
+ /**
15
+ * Creates a detached chart builder without mutating the host.
16
+ *
17
+ * This method executes synchronously.
18
+ *
19
+ * @returns A detached chart builder.
20
+ * @example
21
+ * ```ts
22
+ * const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
23
+ * charts.create();
24
+ * ```
25
+ */
26
+ create(): FSheetChartBuilder;
27
+ /**
28
+ * Inserts a detached chart builder into this host.
29
+ *
30
+ * This method completes asynchronously.
31
+ *
32
+ * @param builder The detached chart builder to insert.
33
+ * @returns A promise that resolves to the inserted chart builder.
34
+ * @example
35
+ * ```ts
36
+ * const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
37
+ * const builder = charts.create().setSource('A1:B8');
38
+ * await charts.insert(builder);
39
+ * ```
40
+ */
41
+ insert<T extends FSheetAnyChartBuilder>(builder: T): Promise<T>;
42
+ /**
43
+ * Returns a chart builder by its host-owned ID.
44
+ *
45
+ * This method executes synchronously.
46
+ *
47
+ * @param chartId The host-owned chart ID.
48
+ * @returns The matching chart builder, or null when absent.
49
+ * @example
50
+ * ```ts
51
+ * const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
52
+ * charts.get('chart-id');
53
+ * ```
54
+ */
55
+ get(chartId: string): FSheetAnyChartBuilder | null;
56
+ /**
57
+ * Returns every chart builder owned by this host.
58
+ *
59
+ * This method executes synchronously.
60
+ *
61
+ * @returns All chart builders owned by this host.
62
+ * @example
63
+ * ```ts
64
+ * const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
65
+ * charts.list();
66
+ * ```
67
+ */
68
+ list(): FSheetAnyChartBuilder[];
69
+ /**
70
+ * Removes a chart from this host.
71
+ *
72
+ * This method completes asynchronously.
73
+ *
74
+ * @param builderOrId A builder from this host or its chart ID.
75
+ * @returns A promise that resolves to `true` when the chart is removed, or `false` when it is absent.
76
+ * @example
77
+ * ```ts
78
+ * const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
79
+ * await charts.remove('chart-id');
80
+ * ```
81
+ */
82
+ remove(builderOrId: FSheetAnyChartBuilder | string): Promise<boolean>;
83
+ /**
84
+ * Registers a chart theme shared by every chart host in this Univer runtime.
85
+ *
86
+ * This method executes synchronously.
87
+ *
88
+ * @param name The stable registered name.
89
+ * @param theme The ECharts theme definition.
90
+ * Returns no value.
91
+ * @example
92
+ * ```ts
93
+ * const charts = univerAPI.getActiveWorkbook().getActiveSheet().charts;
94
+ * charts.registerTheme('brand', { color: ['#1677ff'] });
95
+ * ```
96
+ */
97
+ registerTheme(name: string, theme: IEchartTheme): void;
98
+ private _wrap;
99
+ }
100
+ export {};
@@ -0,0 +1,2 @@
1
+ export type { FSheetAnyChartBuilder, FSheetChartBuilder, FSheetChartBuilderOf, ISheetChartMethods } from './f-sheet-chart-builder';
2
+ export { FSheetCharts } from './f-sheet-charts';
@@ -0,0 +1,13 @@
1
+ import type { IChartCreateSpec } from '@univerjs-pro/sheets-chart';
2
+ import type { FWorksheet } from '@univerjs/sheets/facade';
3
+ import { FChart } from '../f-chart';
4
+ /** Owns the Sheet collection-to-command boundary. It is not part of the public facade. */
5
+ export declare class SheetChartCommandAdapter {
6
+ private readonly _worksheet;
7
+ constructor(_worksheet: FWorksheet);
8
+ create(spec: IChartCreateSpec): Promise<FChart>;
9
+ get(chartId: string): FChart | null;
10
+ list(): FChart[];
11
+ remove(chartOrId: FChart | string): Promise<boolean>;
12
+ private _sourceContext;
13
+ }
@@ -1,166 +1 @@
1
- import type { ChartKnownTypeName, IChartDataCategory, IChartDataSeries } from '@univerjs-pro/engine-chart';
2
- import type { ISheetChartSourceSingleRange } from '@univerjs-pro/sheets-chart';
3
- import type { Injector } from '@univerjs/core';
4
- import type { ChartDescription, ChartExportImageOptions, ChartExportImageResult, ChartInstanceCapabilities, ChartLayoutPatch, ChartSourceSpec, ChartUpdatePatch, ChartUpdateResult, ChartValidationResult } from './chart-facade-types';
5
- import { FBaseChart } from '@univerjs-pro/engine-chart';
6
- import { FChartBuilderBase } from './chart-builder/chart-builder-base';
7
- import { ChartUpdateBuilder } from './chart-facade-builders';
8
- /**
9
- * The facade class for the chart.
10
- * @hideconstructor
11
- */
12
- export declare class FChart extends FBaseChart<ChartDescription, ChartUpdateResult> {
13
- /**
14
- * @ignore
15
- */
16
- unitId: string;
17
- /**
18
- * @ignore
19
- */
20
- subUnitId: string;
21
- /**
22
- * @ignore
23
- */
24
- chartId: string;
25
- private _injector;
26
- constructor(unitId: string, subUnitId: string, chartId: string, injector: Injector);
27
- /**
28
- * Get the chart id.
29
- * @returns {string} The chart id.
30
- *
31
- * @example
32
- * ```ts
33
- * const fWorkbook = univerAPI.getActiveWorkbook();
34
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
35
- * if (!fWorksheet) return;
36
- * const charts = fWorksheet.getCharts();
37
- * console.log(charts[0]?.getChartId());
38
- * ```
39
- */
40
- getChartId(): string;
41
- getId(): string;
42
- /**
43
- * Get the range of the chart.
44
- * @returns {ISheetChartSourceSingleRange|undefined} The range of the chart.
45
- *
46
- * @example
47
- * ```ts
48
- * const fWorkbook = univerAPI.getActiveWorkbook();
49
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
50
- * if (!fWorksheet) return;
51
- * const charts = fWorksheet.getCharts();
52
- * console.log(charts[0]?.getRange());
53
- * ```
54
- */
55
- getRange(): ISheetChartSourceSingleRange | undefined;
56
- /**
57
- * Update the range info of the chart. The range info includes the range of the chart and the direction in source.
58
- * @param {ISheetChartSourceSingleRange} rangeInfo The new range of the chart.
59
- * @param {IRange} rangeInfo.range.range The new range of the chart.
60
- * @param {string} rangeInfo.range.subUnitId The new sheet id of the chart.
61
- * @param {string} rangeInfo.range.unitId The new workbook id of the chart.
62
- * @param {boolean} [rangeInfo.isRowDirection] Is treat row as category.
63
- * @returns {Promise<boolean>} Whether the update is successful.
64
- *
65
- * @example
66
- * ```ts
67
- * const fWorkbook = univerAPI.getActiveWorkbook();
68
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
69
- * if (!fWorksheet) return;
70
- *
71
- * // Get all charts on the active sheet.
72
- * const charts = fWorksheet.getCharts();
73
- *
74
- * // Switch chart row direction
75
- * if (charts.length > 0){
76
- * const rangeInfo = { ...charts[0].getRange() };
77
- * rangeInfo.isRowDirection = !rangeInfo.isRowDirection;
78
- * charts[0].updateRange(rangeInfo);
79
- * }
80
- * ```
81
- */
82
- updateRange(rangeInfo: ISheetChartSourceSingleRange): Promise<boolean>;
83
- /**
84
- * Get the series data list of the chart.
85
- * @typedef ChartSeriesData
86
- * @property {string} name The name of the series.
87
- * @property {number} index The index of the series.
88
- * @property {ChartSeriesItem[]} items The data of the series.
89
- * @property {number} items.value The value of the series.
90
- * @property {string} items.label The label of the series.
91
- * @returns {IChartDataSeries[]|undefined} The series data list of the chart.
92
- *
93
- * @example
94
- * ```ts
95
- * const fWorkbook = univerAPI.getActiveWorkbook();
96
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
97
- * if (!fWorksheet) return;
98
- * const charts = fWorksheet.getCharts();
99
- * if (charts.length > 0){
100
- * const seriesData = charts[0].getSeriesData();
101
- * console.log(seriesData);
102
- * }
103
- * ```
104
- */
105
- getSeriesData(): IChartDataSeries[] | undefined;
106
- /**
107
- * Get the category data of the chart.
108
- * @type ChartCategoryData
109
- * @property {string} name The name of the category.
110
- * @property {number} index The index of the category.
111
- * @property {CategoryType} type The type of the category.
112
- * @property {string[]} keys The keys of the category.
113
- * @property {IChartDataItem[]} items The data of the category.
114
- * @property {number} items.value The value of the category.
115
- * @property {string} items.label The label of the category.
116
- * @returns The category data of the chart.
117
- *
118
- * @example
119
- * ```ts
120
- * const fWorkbook = univerAPI.getActiveWorkbook();
121
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
122
- * if (!fWorksheet) return;
123
- * const charts = fWorksheet.getCharts();
124
- * if (charts.length > 0){
125
- * const categoryData = charts[0].getCategoryData();
126
- * console.log(categoryData);
127
- * }
128
- * ```
129
- */
130
- getCategoryData(): IChartDataCategory | undefined;
131
- /**
132
- * Returns a new FChartBuilderBase instance that modifies this chart.
133
- * @returns {FChartBuilderBase} The new FChartBuilderBase instance.
134
- * @see {@link update} for structured semantic patches and diagnostics.
135
- */
136
- modify(): FChartBuilderBase;
137
- /**
138
- * Returns a frozen semantic snapshot of this chart, or null if it no longer exists.
139
- * `rawStyle` is read-only debug information and is not accepted as update input.
140
- */
141
- describe(): ChartDescription | null;
142
- /** Returns verified patch groups for this chart's concrete type. */
143
- getCapabilities(): ChartInstanceCapabilities | null;
144
- /**
145
- * Renders this chart through the shared engine-chart image export Seam.
146
- * Returns data URL metadata, or null when the chart/drawing input is unavailable.
147
- * The promise rejects when no render model is registered or rendering fails.
148
- */
149
- exportImage(options?: ChartExportImageOptions): Promise<ChartExportImageResult | null>;
150
- /** Validates and normalizes a semantic patch without executing commands. */
151
- validateUpdate(patch: ChartUpdatePatch): ChartValidationResult<ChartUpdatePatch>;
152
- /** Returns a convenience adapter that builds the same JSON patch accepted by `update()`. */
153
- newUpdateBuilder(): ChartUpdateBuilder;
154
- /**
155
- * Applies a semantic merge patch.
156
- *
157
- * Omitted/undefined fields are unchanged; null clears fields that explicitly
158
- * support clearing. The result contains diagnostics and changed groups rather
159
- * than throwing for validation or command failures.
160
- */
161
- update(patch: ChartUpdatePatch): Promise<ChartUpdateResult>;
162
- setSource(source: ChartSourceSpec): Promise<ChartUpdateResult>;
163
- setType(type: ChartKnownTypeName): Promise<ChartUpdateResult>;
164
- setLayout(layout: ChartLayoutPatch): Promise<ChartUpdateResult>;
165
- remove(): Promise<boolean>;
166
- }
1
+ export {};
@@ -1,210 +1,12 @@
1
- import { AxisAlignEnum, ChartBorderDashType, ChartTypeBits, LegendPositionEnum, LinePointShape, RadarShape, SelectModeEnum, TitlePositionEnum } from '@univerjs-pro/engine-chart';
2
- /**
3
- * @ignore
4
- */
1
+ import { ChartSourceOrientation } from '@univerjs-pro/sheets-chart';
2
+ import { FEnum } from '@univerjs/core/facade';
3
+ /** @ignore */
5
4
  export interface IFSheetsChartEnumMixin {
6
- /**
7
- * Represents the type of the chart. {@link ChartTypeBits}
8
- * @description This enum is used to specify the type of the chart. Which is binary-like value, each bit represents a type of the chart.
9
- *
10
- * @example
11
- * ```ts
12
- * const fWorkbook = univerAPI.getActiveWorkbook();
13
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
14
- * if (!fWorksheet) return;
15
- *
16
- * // Create a column chart with data source A1:D6.
17
- * // The starting position is upper-left corner of cell B2.
18
- * const chartInfo = fWorksheet.newChart()
19
- * .setChartType(univerAPI.Enum.ChartType.Column)
20
- * .addRange('A1:D6')
21
- * .setPosition(1, 1, 0, 0)
22
- * .build();
23
- * await fWorksheet.insertChart(chartInfo);
24
- * ```
25
- */
26
- ChartType: typeof ChartTypeBits;
27
- /**
28
- * Represents the position of the legend in the chart. {@link LegendPositionEnum}
29
- * The possible values are: BOTTOM, TOP, LEFT, RIGHT, HIDE.
30
- *
31
- * @example
32
- * ```ts
33
- * const fWorkbook = univerAPI.getActiveWorkbook();
34
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
35
- * if (!fWorksheet) return;
36
- *
37
- * // Create a line chart with data source A1:D6.
38
- * // The starting position is upper-left corner of cell B2.
39
- * // The legend is positioned at the top of the chart.
40
- * const chartInfo = fWorksheet.newChart()
41
- * .asLineChart()
42
- * .addRange('A1:D6')
43
- * .setPosition(1, 1, 0, 0)
44
- * .setOptions('legend.position', univerAPI.Enum.LegendPositionEnum.Top)
45
- * .build();
46
- * await fWorksheet.insertChart(chartInfo);
47
- * ```
48
- */
49
- LegendPositionEnum: typeof LegendPositionEnum;
50
- /**
51
- * Represents the selection mode of the chart. {@link SelectModeEnum}
52
- * The possible values are: SINGLE, MULTIPLE, Close. It used to specify the selection mode of the chart legend.
53
- *
54
- * @example
55
- * ```ts
56
- * const fWorkbook = univerAPI.getActiveWorkbook();
57
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
58
- * if (!fWorksheet) return;
59
- *
60
- * // Create a line chart with data source A1:D6.
61
- * // The starting position is upper-left corner of cell B2.
62
- * // The legend is in single selection mode.
63
- * const chartInfo = fWorksheet.newChart()
64
- * .asLineChart()
65
- * .addRange('A1:D6')
66
- * .setPosition(1, 1, 0, 0)
67
- * .setOptions('legend.selectMode', univerAPI.Enum.SelectModeEnum.Single)
68
- * .build();
69
- * await fWorksheet.insertChart(chartInfo);
70
- * ```
71
- */
72
- SelectModeEnum: typeof SelectModeEnum;
73
- /**
74
- * Represents the alignment of the axis. {@link AxisAlignEnum}
75
- * The possible values are: START, CENTER, END.
76
- *
77
- * @example
78
- * ```ts
79
- * const fWorkbook = univerAPI.getActiveWorkbook();
80
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
81
- * if (!fWorksheet) return;
82
- *
83
- * // Create a line chart with data source A1:D6.
84
- * // The starting position is upper-left corner of cell B2.
85
- * // The x-axis title is set to 'X Axis Title' with red font color and aligned to the end of the axis.
86
- * const chartInfo = fWorksheet.newChart()
87
- * .asLineChart()
88
- * .addRange('A1:D6')
89
- * .setPosition(1, 1, 0, 0)
90
- * .setOptions('', {
91
- * xAxisTitle: {
92
- * content: 'X Axis Title',
93
- * fontColor: '#ff0000',
94
- * axisAlignment: univerAPI.Enum.AxisAlignEnum.End,
95
- * }
96
- * })
97
- * .build();
98
- * await fWorksheet.insertChart(chartInfo);
99
- * ```
100
- */
101
- AxisAlignEnum: typeof AxisAlignEnum;
102
- /**
103
- * Represents the type of the border dash. {@link ChartBorderDashType}
104
- * The possible values are: SOLID, DOTTED, DASHED.
105
- *
106
- * @example
107
- * ```ts
108
- * const fWorkbook = univerAPI.getActiveWorkbook();
109
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
110
- * if (!fWorksheet) return;
111
- *
112
- * // Create a line chart with data source A1:D6.
113
- * // The starting position is upper-left corner of cell B2.
114
- * // The axis pointer style is set.
115
- * const chartInfo = fWorksheet.newChart()
116
- * .asLineChart()
117
- * .addRange('A1:D6')
118
- * .setPosition(1, 1, 0, 0)
119
- * .setAxisPointerStyle({
120
- * indicatorLabelColor: '#ff0000',
121
- * indicatorLineType: univerAPI.Enum.ChartBorderDashType.Solid,
122
- * indicatorLineColor: '#00ff00',
123
- * indicatorLabelTextColor: '#0000ff',
124
- * })
125
- * .build();
126
- * await fWorksheet.insertChart(chartInfo);
127
- * ```
128
- */
129
- ChartBorderDashType: typeof ChartBorderDashType;
130
- /**
131
- * Represents the shape of the data point in the line chart. {@link LinePointShape}
132
- *
133
- * @example
134
- * ```ts
135
- * const fWorkbook = univerAPI.getActiveWorkbook();
136
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
137
- * if (!fWorksheet) return;
138
- *
139
- * // Create a line chart with data source A1:D6.
140
- * // The starting position is upper-left corner of cell B2.
141
- * // The data point shape is set to circle, color is red, and size is 10.
142
- * const chartInfo = fWorksheet.newChart()
143
- * .asLineChart()
144
- * .addRange('A1:D6')
145
- * .setPosition(1, 1, 0, 0)
146
- * .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
147
- * .setDataPointColor('#ff0000')
148
- * .setDataPointSize(10)
149
- * .build();
150
- * await fWorksheet.insertChart(chartInfo);
151
- * ```
152
- */
153
- LinePointShape: typeof LinePointShape;
154
- /**
155
- * Represents the position of the title in the chart. {@link TitlePositionEnum}
156
- *
157
- * @example
158
- * ```ts
159
- * const fWorkbook = univerAPI.getActiveWorkbook();
160
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
161
- * if (!fWorksheet) return;
162
- *
163
- * // Create a line chart with data source A1:D6.
164
- * // The starting position is upper-left corner of cell B2.
165
- * // The title is positioned at the top of the chart.
166
- * const chartInfo = fWorksheet.newChart()
167
- * .asLineChart()
168
- * .addRange('A1:D6')
169
- * .setPosition(1, 1, 0, 0)
170
- * .setOptions('', {
171
- * title: {
172
- * content: 'Chart Title',
173
- * position: univerAPI.Enum.TitlePositionEnum.TOP,
174
- * },
175
- * })
176
- * .build();
177
- * await fWorksheet.insertChart(chartInfo);
178
- * ```
179
- */
180
- TitlePositionEnum: typeof TitlePositionEnum;
181
- /**
182
- * Represents the shape of the radar chart. {@link RadarShape}
183
- *
184
- * @example
185
- * ```ts
186
- * const fWorkbook = univerAPI.getActiveWorkbook();
187
- * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
188
- * if (!fWorksheet) return;
189
- *
190
- * // Create a radar chart with data source A1:D6.
191
- * // The starting position is upper-left corner of cell B2.
192
- * // The shape of the radar chart is set to polygon and filled with red color.
193
- * const chartInfo = fWorksheet.newChart()
194
- * .asRadarChart()
195
- * .addRange('A1:D6')
196
- * .setPosition(1, 1, 0, 0)
197
- * .setShape(univerAPI.Enum.RadarShape.Polygon)
198
- * .setFill(true)
199
- * .build();
200
- * await fWorksheet.insertChart(chartInfo);
201
- * ```
202
- */
203
- RadarShape: typeof RadarShape;
5
+ ChartSourceOrientation: typeof ChartSourceOrientation;
6
+ }
7
+ export declare class FSheetsChartEnumMixin extends FEnum implements IFSheetsChartEnumMixin {
8
+ get ChartSourceOrientation(): typeof ChartSourceOrientation;
204
9
  }
205
- /**
206
- * @ignore
207
- */
208
10
  declare module '@univerjs/core/facade' {
209
11
  interface FEnum extends IFSheetsChartEnumMixin {
210
12
  }
@@ -1,91 +1,10 @@
1
- import type { ChartCapabilities, ChartCreateSpec, ChartSourceSpec, ChartSuggestion, ChartUpdatePatch, ChartUpdateResult, ChartValidationResult } from './chart-facade-types';
2
- import { FBaseCharts } from '@univerjs-pro/engine-chart';
3
1
  import { FWorksheet } from '@univerjs/sheets/facade';
4
- import { ChartCreateBuilder } from './chart-facade-builders';
5
- import { FChart } from './f-chart';
6
- /**
7
- * Structured chart authoring for a worksheet.
8
- *
9
- * JSON create/update specs are the canonical Interface. Builders returned by
10
- * `newBuilder()` compile to the same specs and are optional convenience adapters.
11
- */
12
- export declare class FWorksheetCharts extends FBaseCharts<FChart, ChartCreateSpec, ChartCapabilities> {
13
- private readonly _worksheet;
14
- constructor(_worksheet: FWorksheet);
15
- /**
16
- * Creates a chart from a serializable semantic spec.
17
- *
18
- * Call `validateCreate()` for a side-effect-free preflight. Validation or
19
- * command failure throws `ChartFacadeError`, whose `diagnostics` explain the
20
- * rejected fields.
21
- */
22
- create(spec: ChartCreateSpec): Promise<FChart>;
23
- /** Applies a semantic merge patch and returns diagnostics plus changed groups. */
24
- update(chart: FChart | string, patch: ChartUpdatePatch): Promise<ChartUpdateResult>;
25
- remove(chart: FChart | string): Promise<boolean>;
26
- /** Returns chart handles owned by this worksheet. */
27
- list(): FChart[];
28
- /** Returns the worksheet chart with `chartId`, or null when it is absent. */
29
- get(chartId: string): FChart | null;
30
- /** Validates and normalizes a create spec without executing commands. */
31
- validateCreate(spec: ChartCreateSpec): ChartValidationResult<ChartCreateSpec>;
32
- /** Describes runtime chart types, patch semantics, and available groups. */
33
- getCapabilities(): ChartCapabilities;
34
- /** Returns a convenience adapter that builds the same JSON spec accepted by `create()`. */
35
- newBuilder(): ChartCreateBuilder;
36
- suggest(source: ChartSourceSpec): ChartSuggestion[];
37
- private _sourceContext;
38
- }
2
+ import { FSheetCharts } from './chart/f-sheet-charts';
39
3
  export interface IFWorksheetChartsMixin {
40
- /**
41
- * Structured chart authoring, inspection, repair, and image export.
42
- *
43
- * @example
44
- * ```ts
45
- * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
46
- * if (!worksheet) return;
47
- *
48
- * const chart = await worksheet.charts.create({
49
- * type: 'pareto',
50
- * source: 'A1:B8',
51
- * pareto: {
52
- * barColor: '#1677ff',
53
- * cumulativeLineColor: '#f5222d',
54
- * },
55
- * });
56
- * const before = chart.describe();
57
- * const result = await chart.update({
58
- * pareto: { cumulativeLineColor: '#722ed1' },
59
- * });
60
- * if (!result.ok) console.log(result.diagnostics);
61
- * const after = chart.describe();
62
- * const image = await chart.exportImage({ pixelRatio: 2 });
63
- * console.log({ before, after, image });
64
- * ```
65
- */
66
- readonly charts: FWorksheetCharts;
4
+ readonly charts: FSheetCharts;
67
5
  }
68
6
  export declare class FWorksheetChartsMixin extends FWorksheet implements IFWorksheetChartsMixin {
69
- /**
70
- * Structured chart authoring, inspection, repair, capabilities, and image export.
71
- * Prefer serializable create/update specs; use `describe()` before repairing an
72
- * existing chart and inspect update diagnostics before reading it back.
73
- *
74
- * @example
75
- * ```ts
76
- * const chart = await worksheet.charts.create({
77
- * type: 'pareto',
78
- * source: 'A1:B8',
79
- * pareto: { barColor: '#1677ff', cumulativeLineColor: '#f5222d' },
80
- * });
81
- * const before = chart.describe();
82
- * const result = await chart.update({ pareto: { barColor: '#722ed1' } });
83
- * if (!result.ok) console.log(result.diagnostics);
84
- * const after = chart.describe();
85
- * const image = await chart.exportImage({ pixelRatio: 2 });
86
- * ```
87
- */
88
- get charts(): FWorksheetCharts;
7
+ get charts(): FSheetCharts;
89
8
  }
90
9
  declare module '@univerjs/sheets/facade' {
91
10
  interface FWorksheet extends IFWorksheetChartsMixin {