@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.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/ar-SA.js +1 -1
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/de-DE.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/id-ID.js +1 -1
- package/lib/cjs/locale/it-IT.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/pl-PL.js +1 -1
- package/lib/cjs/locale/pt-BR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-HK.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/es/locale/ar-SA.js +1 -1
- package/lib/es/locale/ca-ES.js +1 -1
- package/lib/es/locale/de-DE.js +1 -1
- package/lib/es/locale/en-US.js +1 -1
- package/lib/es/locale/es-ES.js +1 -1
- package/lib/es/locale/fa-IR.js +1 -1
- package/lib/es/locale/fr-FR.js +1 -1
- package/lib/es/locale/id-ID.js +1 -1
- package/lib/es/locale/it-IT.js +1 -1
- package/lib/es/locale/ja-JP.js +1 -1
- package/lib/es/locale/ko-KR.js +1 -1
- package/lib/es/locale/pl-PL.js +1 -1
- package/lib/es/locale/pt-BR.js +1 -1
- package/lib/es/locale/ru-RU.js +1 -1
- package/lib/es/locale/sk-SK.js +1 -1
- package/lib/es/locale/vi-VN.js +1 -1
- package/lib/es/locale/zh-CN.js +1 -1
- package/lib/es/locale/zh-HK.js +1 -1
- package/lib/es/locale/zh-TW.js +1 -1
- package/lib/facade.js +1 -1
- package/lib/index.js +1 -1
- package/lib/locale/ar-SA.js +1 -1
- package/lib/locale/ca-ES.js +1 -1
- package/lib/locale/de-DE.js +1 -1
- package/lib/locale/en-US.js +1 -1
- package/lib/locale/es-ES.js +1 -1
- package/lib/locale/fa-IR.js +1 -1
- package/lib/locale/fr-FR.js +1 -1
- package/lib/locale/id-ID.js +1 -1
- package/lib/locale/it-IT.js +1 -1
- package/lib/locale/ja-JP.js +1 -1
- package/lib/locale/ko-KR.js +1 -1
- package/lib/locale/pl-PL.js +1 -1
- package/lib/locale/pt-BR.js +1 -1
- package/lib/locale/ru-RU.js +1 -1
- package/lib/locale/sk-SK.js +1 -1
- package/lib/locale/vi-VN.js +1 -1
- package/lib/locale/zh-CN.js +1 -1
- package/lib/locale/zh-HK.js +1 -1
- package/lib/locale/zh-TW.js +1 -1
- package/lib/types/chart-builder/index.d.ts +10 -0
- package/lib/types/chart-builder/sheet-chart-builder-adapter.d.ts +41 -0
- package/lib/types/chart-builder/sheet-chart-builder.d.ts +17 -0
- package/lib/types/chart-builder/sheet-chart-create-spec.d.ts +6 -0
- package/lib/types/chart-builder/sheet-chart-description.d.ts +5 -0
- package/lib/types/chart-builder/sheet-chart-layout.d.ts +21 -0
- package/lib/types/chart-builder/sheet-chart-source.d.ts +32 -0
- package/lib/types/chart-builder/types.d.ts +159 -0
- package/lib/types/chart-source/chart-source.d.ts +14 -6
- package/lib/types/commands/commands/sheets-chart-update-config.command.d.ts +2 -0
- package/lib/types/commands/mutations/sheets-chart-update-config.mutation.d.ts +1 -0
- package/lib/types/facade/chart/f-sheet-chart-builder.d.ts +83 -0
- package/lib/types/facade/chart/f-sheet-charts.d.ts +100 -0
- package/lib/types/facade/chart/index.d.ts +2 -0
- package/lib/types/facade/chart/sheet-chart-command-adapter.d.ts +13 -0
- package/lib/types/facade/f-chart.d.ts +1 -166
- package/lib/types/facade/f-enum.d.ts +7 -205
- package/lib/types/facade/f-worksheet-charts.d.ts +3 -84
- package/lib/types/facade/index.d.ts +3 -24
- package/lib/types/index.d.ts +3 -1
- package/lib/types/models/types.d.ts +10 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +9 -9
- package/lib/types/facade/chart-builder/builder-util.d.ts +0 -5
- package/lib/types/facade/chart-builder/chart-builder-base.d.ts +0 -919
- package/lib/types/facade/chart-builder/line-chart-builder.d.ts +0 -165
- package/lib/types/facade/chart-builder/pie-chart-builder.d.ts +0 -196
- package/lib/types/facade/chart-builder/radar-chart-builder.d.ts +0 -100
- package/lib/types/facade/chart-builder/types.d.ts +0 -34
- package/lib/types/facade/chart-facade-adapter.d.ts +0 -68
- package/lib/types/facade/chart-facade-builders.d.ts +0 -67
- package/lib/types/facade/chart-facade-types.d.ts +0 -212
- package/lib/types/facade/f-worksheet.d.ts +0 -208
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import type { ChartKnownTypeName, ChartModelCapabilities, ChartModelChangedGroup, ChartModelCreateSpec, ChartModelDescription, ChartModelPatch, ChartModelPatchGroup, ChartTypeName, DeepReadonly, FChartDescription, FChartUpdateResult, IChartRenderModelImageExportOptions, IChartRenderModelImageExportResult, IEchartTheme } from '@univerjs-pro/engine-chart';
|
|
2
|
-
import type { IRange } from '@univerjs/core';
|
|
3
|
-
import type { FChart } from './f-chart';
|
|
4
|
-
export declare const ChartSourceOrientation: {
|
|
5
|
-
readonly Auto: "auto";
|
|
6
|
-
readonly Row: "row";
|
|
7
|
-
readonly Column: "column";
|
|
8
|
-
readonly Rows: "rows";
|
|
9
|
-
readonly Columns: "columns";
|
|
10
|
-
readonly RowsAsSeries: "rowsAsSeries";
|
|
11
|
-
readonly ColumnsAsSeries: "columnsAsSeries";
|
|
12
|
-
};
|
|
13
|
-
export type ChartSourceOrientation = typeof ChartSourceOrientation[keyof typeof ChartSourceOrientation];
|
|
14
|
-
export declare enum ChartSourceKind {
|
|
15
|
-
Range = "range",
|
|
16
|
-
Ranges = "ranges"
|
|
17
|
-
}
|
|
18
|
-
export type ChartRangeSpec = string | IRange;
|
|
19
|
-
export interface IChartSourceVectorSpec {
|
|
20
|
-
/** One row or one column of values. All vectors are aligned by position. */
|
|
21
|
-
range: ChartRangeSpec;
|
|
22
|
-
/** Optional single-cell display name. It never consumes a value from `range`. */
|
|
23
|
-
header?: ChartRangeSpec;
|
|
24
|
-
}
|
|
25
|
-
export type ChartSourceVectorSpec = IChartSourceVectorSpec;
|
|
26
|
-
interface IChartSourceLocationSpec {
|
|
27
|
-
sheetName?: string;
|
|
28
|
-
sheetId?: string;
|
|
29
|
-
unitId?: string;
|
|
30
|
-
orientation?: ChartSourceOrientation;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Chart data from either one rectangular table or explicit positional vectors.
|
|
34
|
-
* Exactly one of `range` and `ranges` may be provided.
|
|
35
|
-
*
|
|
36
|
-
* @example Single rectangular table
|
|
37
|
-
* ```ts
|
|
38
|
-
* { sheetName: 'Sales', range: 'A1:C7', orientation: 'columns' }
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @example Equal-length positional vectors with optional single-cell headers
|
|
42
|
-
* ```ts
|
|
43
|
-
* {
|
|
44
|
-
* sheetName: 'Sales',
|
|
45
|
-
* orientation: 'columns',
|
|
46
|
-
* ranges: [
|
|
47
|
-
* { header: 'A1', range: 'A2:A7' },
|
|
48
|
-
* { header: 'C1', range: 'C2:C7' },
|
|
49
|
-
* ],
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
52
|
-
* Vector array order defines mapping indexes. Vectors must have equal lengths
|
|
53
|
-
* and a common row-or-column orientation; no join or padding is performed.
|
|
54
|
-
*/
|
|
55
|
-
export type ChartSourceSpec = ChartRangeSpec | (IChartSourceLocationSpec & {
|
|
56
|
-
range: ChartRangeSpec;
|
|
57
|
-
ranges?: never;
|
|
58
|
-
}) | (IChartSourceLocationSpec & {
|
|
59
|
-
range?: never;
|
|
60
|
-
ranges: readonly ChartSourceVectorSpec[];
|
|
61
|
-
});
|
|
62
|
-
export type ChartAnchorSpec = string | {
|
|
63
|
-
row: number;
|
|
64
|
-
column: number;
|
|
65
|
-
rowOffset?: number;
|
|
66
|
-
columnOffset?: number;
|
|
67
|
-
};
|
|
68
|
-
export interface IChartSizeSpec {
|
|
69
|
-
width?: number;
|
|
70
|
-
height?: number;
|
|
71
|
-
}
|
|
72
|
-
export type ChartSizeSpec = IChartSizeSpec;
|
|
73
|
-
export interface IChartLayoutPatch {
|
|
74
|
-
anchor?: ChartAnchorSpec;
|
|
75
|
-
position?: {
|
|
76
|
-
x: number;
|
|
77
|
-
y: number;
|
|
78
|
-
};
|
|
79
|
-
size?: ChartSizeSpec;
|
|
80
|
-
}
|
|
81
|
-
export type ChartLayoutPatch = IChartLayoutPatch;
|
|
82
|
-
export interface IChartCreateSpec extends ChartModelCreateSpec {
|
|
83
|
-
source: ChartSourceSpec;
|
|
84
|
-
anchor?: ChartAnchorSpec;
|
|
85
|
-
position?: {
|
|
86
|
-
x: number;
|
|
87
|
-
y: number;
|
|
88
|
-
};
|
|
89
|
-
size?: ChartSizeSpec;
|
|
90
|
-
}
|
|
91
|
-
export type ChartCreateSpec = IChartCreateSpec;
|
|
92
|
-
export interface IChartUpdatePatch extends ChartModelPatch {
|
|
93
|
-
source?: ChartSourceSpec;
|
|
94
|
-
layout?: ChartLayoutPatch;
|
|
95
|
-
}
|
|
96
|
-
export type ChartUpdatePatch = IChartUpdatePatch;
|
|
97
|
-
export declare const ChartDiagnosticCode: {
|
|
98
|
-
readonly ChartNotFound: "CHART_NOT_FOUND";
|
|
99
|
-
readonly SeriesNotFound: "SERIES_NOT_FOUND";
|
|
100
|
-
readonly AmbiguousSeriesSelector: "AMBIGUOUS_SERIES_SELECTOR";
|
|
101
|
-
readonly InvalidRange: "INVALID_RANGE";
|
|
102
|
-
readonly SingleCellSource: "SINGLE_CELL_SOURCE";
|
|
103
|
-
readonly NoNumericSeries: "NO_NUMERIC_SERIES";
|
|
104
|
-
readonly NoPositiveParetoValues: "NO_POSITIVE_PARETO_VALUES";
|
|
105
|
-
readonly UnknownChartType: "UNKNOWN_CHART_TYPE";
|
|
106
|
-
readonly UnsupportedChartType: "UNSUPPORTED_CHART_TYPE";
|
|
107
|
-
readonly InvalidSize: "INVALID_SIZE";
|
|
108
|
-
readonly InvalidColor: "INVALID_COLOR";
|
|
109
|
-
readonly CommandFailed: "COMMAND_FAILED";
|
|
110
|
-
readonly UnknownOption: "UNKNOWN_OPTION";
|
|
111
|
-
};
|
|
112
|
-
export type ChartDiagnosticCode = typeof ChartDiagnosticCode[keyof typeof ChartDiagnosticCode];
|
|
113
|
-
export declare enum ChartFacadeHostGroup {
|
|
114
|
-
Source = "source",
|
|
115
|
-
Layout = "layout"
|
|
116
|
-
}
|
|
117
|
-
export declare enum ChartFacadeCreateLayoutKey {
|
|
118
|
-
Anchor = "anchor",
|
|
119
|
-
Position = "position",
|
|
120
|
-
Size = "size"
|
|
121
|
-
}
|
|
122
|
-
export type ChartFacadeCapabilityGroup = ChartModelPatchGroup | ChartFacadeHostGroup;
|
|
123
|
-
export type ChartChangedGroup = ChartModelChangedGroup | ChartFacadeHostGroup;
|
|
124
|
-
export interface IChartDiagnostic {
|
|
125
|
-
code: ChartDiagnosticCode;
|
|
126
|
-
severity: 'error' | 'warning';
|
|
127
|
-
message: string;
|
|
128
|
-
path?: string;
|
|
129
|
-
details?: unknown;
|
|
130
|
-
allowedValues?: readonly unknown[];
|
|
131
|
-
suggestion?: string;
|
|
132
|
-
}
|
|
133
|
-
export type ChartDiagnostic = IChartDiagnostic;
|
|
134
|
-
export interface IChartValidationResult<TNormalized = unknown> {
|
|
135
|
-
ok: boolean;
|
|
136
|
-
diagnostics: ChartDiagnostic[];
|
|
137
|
-
normalized?: DeepReadonly<TNormalized>;
|
|
138
|
-
}
|
|
139
|
-
export type ChartValidationResult<TNormalized = unknown> = IChartValidationResult<TNormalized>;
|
|
140
|
-
export interface IChartUpdateResult extends FChartUpdateResult<FChart, ChartChangedGroup, ChartDiagnostic> {
|
|
141
|
-
ok: boolean;
|
|
142
|
-
chart: FChart | null;
|
|
143
|
-
diagnostics: ChartDiagnostic[];
|
|
144
|
-
changed: ChartChangedGroup[];
|
|
145
|
-
}
|
|
146
|
-
export type ChartUpdateResult = IChartUpdateResult;
|
|
147
|
-
export interface IChartSuggestion {
|
|
148
|
-
type: ChartKnownTypeName;
|
|
149
|
-
orientation: 'rows' | 'columns';
|
|
150
|
-
reason?: string;
|
|
151
|
-
}
|
|
152
|
-
export type ChartSuggestion = IChartSuggestion;
|
|
153
|
-
export interface IChartCapabilities extends Omit<ChartModelCapabilities, 'createGroups' | 'updateGroups'> {
|
|
154
|
-
createGroups: readonly ChartFacadeCapabilityGroup[];
|
|
155
|
-
updateGroups: readonly ChartFacadeCapabilityGroup[];
|
|
156
|
-
}
|
|
157
|
-
export type ChartCapabilities = IChartCapabilities;
|
|
158
|
-
export interface IChartInstanceCapabilities extends IChartCapabilities {
|
|
159
|
-
chartId: string;
|
|
160
|
-
type: ChartTypeName;
|
|
161
|
-
rawType?: number;
|
|
162
|
-
unsupportedGroups: readonly ChartFacadeCapabilityGroup[];
|
|
163
|
-
}
|
|
164
|
-
export type ChartInstanceCapabilities = IChartInstanceCapabilities;
|
|
165
|
-
export type ChartExportImageOptions = IChartRenderModelImageExportOptions;
|
|
166
|
-
export type ChartExportImageResult = IChartRenderModelImageExportResult;
|
|
167
|
-
export interface IChartRangeSourceDescription {
|
|
168
|
-
range: IRange;
|
|
169
|
-
ranges?: never;
|
|
170
|
-
sheetName?: string;
|
|
171
|
-
sheetId: string;
|
|
172
|
-
unitId: string;
|
|
173
|
-
orientation: ChartSourceOrientation;
|
|
174
|
-
}
|
|
175
|
-
export interface IChartSourceVectorDescription {
|
|
176
|
-
range: IChartRangeSourceDescription;
|
|
177
|
-
header?: IChartRangeSourceDescription;
|
|
178
|
-
}
|
|
179
|
-
export interface IChartMultiRangeSourceDescription {
|
|
180
|
-
range?: never;
|
|
181
|
-
ranges: IChartSourceVectorDescription[];
|
|
182
|
-
orientation: 'rows' | 'columns';
|
|
183
|
-
}
|
|
184
|
-
export type ChartSourceDescription = IChartRangeSourceDescription | IChartMultiRangeSourceDescription;
|
|
185
|
-
export interface IChartLayoutDescription {
|
|
186
|
-
position?: {
|
|
187
|
-
x: number;
|
|
188
|
-
y: number;
|
|
189
|
-
};
|
|
190
|
-
size?: ChartSizeSpec;
|
|
191
|
-
anchor?: {
|
|
192
|
-
row: number;
|
|
193
|
-
column: number;
|
|
194
|
-
rowOffset?: number;
|
|
195
|
-
columnOffset?: number;
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
export type ChartLayoutDescription = IChartLayoutDescription;
|
|
199
|
-
export interface IChartDescription extends Omit<ChartModelDescription, 'diagnostics'>, FChartDescription<{
|
|
200
|
-
unitId: string;
|
|
201
|
-
subUnitId: string;
|
|
202
|
-
chartId: string;
|
|
203
|
-
}, {
|
|
204
|
-
kind: ChartSourceKind;
|
|
205
|
-
source: ChartSourceDescription | null;
|
|
206
|
-
}> {
|
|
207
|
-
diagnostics?: ChartDiagnostic[];
|
|
208
|
-
source: ChartSourceDescription | null;
|
|
209
|
-
layout?: ChartLayoutDescription;
|
|
210
|
-
}
|
|
211
|
-
export type ChartDescription = IChartDescription;
|
|
212
|
-
export type { IEchartTheme };
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import type { IEchartTheme } from '@univerjs-pro/engine-chart';
|
|
2
|
-
import type { IChartBuilderInfo } from './chart-builder/chart-builder-base';
|
|
3
|
-
import { FWorksheet } from '@univerjs/sheets/facade';
|
|
4
|
-
import { FChartBuilderBase } from './chart-builder/chart-builder-base';
|
|
5
|
-
import { FChart } from './f-chart';
|
|
6
|
-
/**
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
export interface IFWorksheetChartMixin {
|
|
10
|
-
/**
|
|
11
|
-
* Adds a new chart to this sheet.
|
|
12
|
-
* @param {IChartBuilderInfo} chartBuildInfo - The chart builder info.
|
|
13
|
-
* @returns {Promise<FChart>} - The new chart.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
18
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
19
|
-
* if (!fWorksheet) return;
|
|
20
|
-
*
|
|
21
|
-
* // Create a column chart with data source A1:D6.
|
|
22
|
-
* // The starting position is upper-left corner of cell B2.
|
|
23
|
-
* const chartInfo = fWorksheet.newChart()
|
|
24
|
-
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
25
|
-
* .addRange('A1:D6')
|
|
26
|
-
* .setPosition(1, 1, 0, 0)
|
|
27
|
-
* .build();
|
|
28
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
29
|
-
* ```
|
|
30
|
-
* @see {@link FWorksheetCharts.create} for structured specs and validation diagnostics.
|
|
31
|
-
*/
|
|
32
|
-
insertChart(chartBuildInfo: IChartBuilderInfo): Promise<FChart>;
|
|
33
|
-
/**
|
|
34
|
-
* Updates the chart on this sheet. This api can not update source range, please use FChart.updateRange.
|
|
35
|
-
* @param {IChartBuilderInfo} chartBuildInfo - The chart builder info.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```ts
|
|
39
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
40
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
41
|
-
* if (!fWorksheet) return;
|
|
42
|
-
*
|
|
43
|
-
* // Create a column chart with data source A1:D6.
|
|
44
|
-
* // The starting position is upper-left corner of cell B2.
|
|
45
|
-
* const chartInfo = fWorksheet.newChart()
|
|
46
|
-
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
47
|
-
* .addRange('A1:D6')
|
|
48
|
-
* .setPosition(1, 1, 0, 0)
|
|
49
|
-
* .build();
|
|
50
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
51
|
-
*
|
|
52
|
-
* // Get all charts on the active sheet.
|
|
53
|
-
* const charts = fWorksheet.getCharts();
|
|
54
|
-
*
|
|
55
|
-
* // Update the first chart after 3 seconds.
|
|
56
|
-
* setTimeout(() => {
|
|
57
|
-
* const newChartInfo = fWorksheet.newChart(charts[0])
|
|
58
|
-
* .asLineChart()
|
|
59
|
-
* .setOptions('legend.position', univerAPI.Enum.LegendPositionEnum.Right)
|
|
60
|
-
* .build();
|
|
61
|
-
* fWorksheet.updateChart(newChartInfo);
|
|
62
|
-
* }, 3000);
|
|
63
|
-
* ```
|
|
64
|
-
* @see {@link FChart.update} for semantic merge patches and structured diagnostics.
|
|
65
|
-
*/
|
|
66
|
-
updateChart(chartBuildInfo: IChartBuilderInfo): void;
|
|
67
|
-
/**
|
|
68
|
-
* Returns a builder to create a new chart for this sheet.The builder will not automatically create the chart. You must call build() on the returned builder to create the chart by calling insertChart(chartBuilder).
|
|
69
|
-
* @description If the fChart is provided, the builder will be initialized with the existing chart's data.
|
|
70
|
-
* @param {FChart} [fChart] - The chart to update.
|
|
71
|
-
* @returns {FChartBuilderBase} - a new chart builder
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
76
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
77
|
-
* if (!fWorksheet) return;
|
|
78
|
-
*
|
|
79
|
-
* // Create a column chart with data source A1:D6.
|
|
80
|
-
* // The starting position is upper-left corner of cell B2.
|
|
81
|
-
* // The width of the chart is 600 and the height is 400.
|
|
82
|
-
* const chartInfo = fWorksheet.newChart()
|
|
83
|
-
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
84
|
-
* .addRange('A1:D6')
|
|
85
|
-
* .setPosition(1, 1, 0, 0)
|
|
86
|
-
* .setWidth(600)
|
|
87
|
-
* .setHeight(400)
|
|
88
|
-
* .build();
|
|
89
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
90
|
-
* ```
|
|
91
|
-
* @see {@link FWorksheetCharts} for the canonical structured chart Interface.
|
|
92
|
-
*/
|
|
93
|
-
newChart(fChart?: FChart): FChartBuilderBase;
|
|
94
|
-
/**
|
|
95
|
-
* Returns an array of charts on this sheet.
|
|
96
|
-
* @returns {FChart[]} - An array of charts on this sheet.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
101
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
102
|
-
* if (!fWorksheet) return;
|
|
103
|
-
*
|
|
104
|
-
* // Get all charts on the active sheet.
|
|
105
|
-
* const charts = fWorksheet.getCharts();
|
|
106
|
-
* console.log(charts);
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
getCharts(): FChart[];
|
|
110
|
-
/**
|
|
111
|
-
* Removes a chart from the parent sheet.
|
|
112
|
-
* @param {FChart} chart - The chart to remove.
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
117
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
118
|
-
* if (!fWorksheet) return;
|
|
119
|
-
*
|
|
120
|
-
* // Create a column chart with data source A1:D6.
|
|
121
|
-
* // The starting position is upper-left corner of cell B2.
|
|
122
|
-
* const chartInfo = fWorksheet.newChart()
|
|
123
|
-
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
124
|
-
* .addRange('A1:D6')
|
|
125
|
-
* .setPosition(1, 1, 0, 0)
|
|
126
|
-
* .build();
|
|
127
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
128
|
-
*
|
|
129
|
-
* // Get all charts on the active sheet.
|
|
130
|
-
* const charts = fWorksheet.getCharts();
|
|
131
|
-
*
|
|
132
|
-
* // Remove the first chart after 3 seconds.
|
|
133
|
-
* setTimeout(async () => {
|
|
134
|
-
* await fWorksheet.removeChart(charts[0]);
|
|
135
|
-
* console.log(fWorksheet.getCharts());
|
|
136
|
-
* }, 3000);
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
139
|
-
removeChart(chart: FChart): Promise<boolean>;
|
|
140
|
-
/**
|
|
141
|
-
* Univer chart is base on echarts, you can register your own theme by echart theme builder.
|
|
142
|
-
* @description The theme object should be a valid echarts theme object.The online builder is available at https://echarts.apache.org/zh/theme-builder.html
|
|
143
|
-
* @param {string} themeName - The name of the theme.
|
|
144
|
-
* @param {IEchartTheme} theme - The theme object.
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```ts
|
|
148
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
149
|
-
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
150
|
-
* if (!fWorksheet) return;
|
|
151
|
-
*
|
|
152
|
-
* // register your theme
|
|
153
|
-
* const theme = { // your theme object
|
|
154
|
-
* 'version': 1,
|
|
155
|
-
* 'themeName': 'myTheme',
|
|
156
|
-
* 'theme': {
|
|
157
|
-
* // ... Some code is omitted for brevity
|
|
158
|
-
* color: [
|
|
159
|
-
* '#893448',
|
|
160
|
-
* '#d95850',
|
|
161
|
-
* '#eb8146',
|
|
162
|
-
* '#ffb248',
|
|
163
|
-
* '#f2d643',
|
|
164
|
-
* '#ebdba4'
|
|
165
|
-
* ],
|
|
166
|
-
* // ... Some code is omitted for brevity
|
|
167
|
-
* visualMapColor: [
|
|
168
|
-
* '#893448',
|
|
169
|
-
* '#d95850',
|
|
170
|
-
* '#eb8146',
|
|
171
|
-
* '#ffb248',
|
|
172
|
-
* '#f2d643',
|
|
173
|
-
* 'rgb(247,238,173)'
|
|
174
|
-
* ],
|
|
175
|
-
* // ... Some code is omitted for brevity
|
|
176
|
-
* 'axes': []
|
|
177
|
-
* // ... Some code is omitted for brevity
|
|
178
|
-
* }
|
|
179
|
-
* };
|
|
180
|
-
* fWorksheet.registerChartTheme('myTheme', theme);
|
|
181
|
-
*
|
|
182
|
-
* // use your theme for chart
|
|
183
|
-
* const chartInfo = fWorksheet.newChart()
|
|
184
|
-
* .asLineChart()
|
|
185
|
-
* .addRange('A1:D6')
|
|
186
|
-
* .setPosition(1, 1, 0, 0)
|
|
187
|
-
* .setTheme('myTheme')
|
|
188
|
-
* .build();
|
|
189
|
-
* await fWorksheet.insertChart(chartInfo);
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
registerChartTheme(themeName: string, theme: IEchartTheme): void;
|
|
193
|
-
}
|
|
194
|
-
export declare class FWorksheetChartMixin extends FWorksheet implements IFWorksheetChartMixin {
|
|
195
|
-
insertChart(chartBuildInfo: IChartBuilderInfo): Promise<FChart>;
|
|
196
|
-
updateChart(chartBuilder: IChartBuilderInfo): void;
|
|
197
|
-
newChart(fChart?: FChart): FChartBuilderBase;
|
|
198
|
-
getCharts(): FChart[];
|
|
199
|
-
removeChart(chart: FChart): Promise<boolean>;
|
|
200
|
-
registerChartTheme(themeName: string, theme: IEchartTheme): void;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* @ignore
|
|
204
|
-
*/
|
|
205
|
-
declare module '@univerjs/sheets/facade' {
|
|
206
|
-
interface FWorksheet extends IFWorksheetChartMixin {
|
|
207
|
-
}
|
|
208
|
-
}
|