@univerjs-pro/sheets-chart-ui 0.5.4 → 0.5.5-experimental.20250123-34738ff
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/en-US.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/ru-RU.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-TW.js +1 -1
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/es/locale/en-US.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/ru-RU.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-TW.js +1 -1
- package/lib/index.css +1 -1
- package/lib/types/facade/chart-builder/chart-builder-base.d.ts +287 -136
- package/lib/types/facade/chart-builder/line-chart-builder.d.ts +28 -8
- package/lib/types/facade/chart-builder/pie-chart-builder.d.ts +15 -7
- package/lib/types/facade/chart-builder/radar-chart-builder.d.ts +19 -3
- package/lib/types/facade/chart-builder/types.d.ts +9 -0
- package/lib/types/facade/f-chart.d.ts +34 -13
- package/lib/types/facade/f-enum.d.ts +135 -0
- package/lib/types/facade/f-worksheet.d.ts +13 -1
- package/lib/types/facade/index.d.ts +4 -0
- package/lib/types/views/chart-edit-panel/ChartEditPanel.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/ChartSelect.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/RadarChartOptionsEdit.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/button-switch/ButtonSwitch.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/color-picker-control/index.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/data-tab-panel/DataTabPanel.d.ts +2 -3
- package/lib/types/views/chart-edit-panel/dropdown-menu/index.d.ts +1 -1
- package/lib/types/views/chart-edit-panel/font-format-bar/FontFormatBar.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/AxisOptionsEdit.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/DataLabelOptions.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/IndicatorLine.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/PieChartStyleEdit.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/StyleTabPanel.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/grid-line-and-tick-options/GridLineAndTickOptions.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/series-style-edit/CombinationChartTypeSelect.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/series-style-edit/DataPointsEdit.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/series-style-edit/RadarPoints.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/series-style-edit/SeriesStyleEdit.d.ts +1 -2
- package/lib/types/views/chart-edit-panel/style-tab-panel/series-style-edit/widgets.d.ts +4 -5
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/en-US.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/ru-RU.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-TW.js +1 -1
- package/package.json +20 -20
|
@@ -1,18 +1,57 @@
|
|
|
1
1
|
import { AreaLineStyle, AxisAlignEnum, ChartBorderDashType, ChartTypeBits, IAllSeriesStyle, IAxisOptions, InvalidValueType, ISeriesStyle, LabelAlignEnum, LegendPositionEnum, RadarShape, SelectModeEnum, TitlePositionEnum } from '@univerjs-pro/sheets-chart';
|
|
2
2
|
import { Injector, IRange, Workbook, FBase } from '@univerjs/core';
|
|
3
|
+
/**
|
|
4
|
+
* The chart builder info.
|
|
5
|
+
*/
|
|
3
6
|
export interface IChartBuilderInfo {
|
|
7
|
+
/**
|
|
8
|
+
* @property {string} unitId The unit id of the chart.
|
|
9
|
+
*/
|
|
4
10
|
unitId: string;
|
|
11
|
+
/**
|
|
12
|
+
* @property {string} subUnitId The sub unit id of the chart.
|
|
13
|
+
*/
|
|
5
14
|
subUnitId: string;
|
|
15
|
+
/**
|
|
16
|
+
* @property {string} chartId The chart id of the chart.
|
|
17
|
+
*/
|
|
6
18
|
chartId: string;
|
|
19
|
+
/**
|
|
20
|
+
* @property {IRange} range The range of the chart.
|
|
21
|
+
*/
|
|
7
22
|
range: IRange | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* @property {number} x The x-coordinate of the chart.
|
|
25
|
+
*/
|
|
8
26
|
x: number;
|
|
27
|
+
/**
|
|
28
|
+
* @property {number} y The y-coordinate of the chart.
|
|
29
|
+
*/
|
|
9
30
|
y: number;
|
|
31
|
+
/**
|
|
32
|
+
* @property {number} width The width of the chart.
|
|
33
|
+
*/
|
|
10
34
|
width: number;
|
|
35
|
+
/**
|
|
36
|
+
* @property {number} height The height of the chart.
|
|
37
|
+
*/
|
|
11
38
|
height: number;
|
|
39
|
+
/**
|
|
40
|
+
* @property {ChartTypeBits} chartType The chart type of the chart.
|
|
41
|
+
*/
|
|
12
42
|
chartType: ChartTypeBits;
|
|
43
|
+
/**
|
|
44
|
+
* @property {IChartBuildOptions} options The options of the chart.
|
|
45
|
+
*/
|
|
13
46
|
options: IChartBuildOptions;
|
|
47
|
+
/**
|
|
48
|
+
* @property {boolean} isRowDirection Whether to read the data in the range as row direction.
|
|
49
|
+
*/
|
|
14
50
|
isRowDirection: boolean;
|
|
15
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* The chart text style.
|
|
54
|
+
*/
|
|
16
55
|
export interface IChartTextStyle {
|
|
17
56
|
/**
|
|
18
57
|
* @property {string} [titleContent] The content of the chart title.
|
|
@@ -43,6 +82,9 @@ export interface IChartTextStyle {
|
|
|
43
82
|
*/
|
|
44
83
|
axisAlignment?: AxisAlignEnum;
|
|
45
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* The chart build options.
|
|
87
|
+
*/
|
|
46
88
|
export interface IChartBuildOptions {
|
|
47
89
|
/**
|
|
48
90
|
* @property {string} [title] The title of the chart.
|
|
@@ -88,6 +130,7 @@ export interface IChartBuildOptions {
|
|
|
88
130
|
};
|
|
89
131
|
/**
|
|
90
132
|
* @property {string} [xAxisTitle] The x-axis title of the chart.
|
|
133
|
+
*
|
|
91
134
|
* @example
|
|
92
135
|
* ```ts
|
|
93
136
|
* chartBuilder.setOptions('xAxisTitle.content', 'xAxis Title text')
|
|
@@ -106,9 +149,21 @@ export interface IChartBuildOptions {
|
|
|
106
149
|
* @property {string} [rightYAxisTitle] The right y-axis title of the chart.
|
|
107
150
|
*/
|
|
108
151
|
rightYAxisTitle?: IChartTextStyle;
|
|
152
|
+
/**
|
|
153
|
+
* @property {IAxisOptions} [xAxis] The x-axis option of the chart.
|
|
154
|
+
*/
|
|
109
155
|
xAxis?: IAxisOptions;
|
|
156
|
+
/**
|
|
157
|
+
* @property {IAxisOptions} [yAxis] The y-axis option of the chart.
|
|
158
|
+
*/
|
|
110
159
|
yAxis?: IAxisOptions;
|
|
160
|
+
/**
|
|
161
|
+
* @property {IAxisOptions} [yRightAxis] The right y-axis option of the chart.
|
|
162
|
+
*/
|
|
111
163
|
yRightAxis?: IAxisOptions;
|
|
164
|
+
/**
|
|
165
|
+
* The axis pointer of the chart.
|
|
166
|
+
*/
|
|
112
167
|
axisPointer?: {
|
|
113
168
|
/**
|
|
114
169
|
* @property {string} [indicatorLineType] The line type of the axis pointer.
|
|
@@ -127,7 +182,13 @@ export interface IChartBuildOptions {
|
|
|
127
182
|
*/
|
|
128
183
|
indicatorLabelTextColor?: string;
|
|
129
184
|
};
|
|
185
|
+
/**
|
|
186
|
+
* @property {IAllSeriesStyle} [allSeriesStyle] The style of all series.
|
|
187
|
+
*/
|
|
130
188
|
allSeriesStyle?: Partial<IAllSeriesStyle>;
|
|
189
|
+
/**
|
|
190
|
+
* @property {string} [seriesStyleMap] The style of the series.
|
|
191
|
+
*/
|
|
131
192
|
seriesStyleMap?: {
|
|
132
193
|
[id: string]: ISeriesStyle;
|
|
133
194
|
};
|
|
@@ -137,30 +198,95 @@ export interface IChartBuildOptions {
|
|
|
137
198
|
area?: {
|
|
138
199
|
lineStyle: AreaLineStyle;
|
|
139
200
|
};
|
|
201
|
+
/**
|
|
202
|
+
* @property {string} [backgroundColor] The background color of the chart.
|
|
203
|
+
*/
|
|
140
204
|
backgroundColor?: string;
|
|
205
|
+
/**
|
|
206
|
+
* @property {string} [borderColor] The border color of the chart.
|
|
207
|
+
*/
|
|
141
208
|
borderColor?: string;
|
|
209
|
+
/**
|
|
210
|
+
* @property {boolean} [gradientFill] Whether to fill the chart with a gradient.
|
|
211
|
+
*/
|
|
142
212
|
gradientFill?: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* @property {string} [theme] The theme of the chart.
|
|
215
|
+
*/
|
|
143
216
|
theme?: string;
|
|
217
|
+
/**
|
|
218
|
+
* @property {InvalidValueType} [invalidValueType] The invalid value type of the chart.
|
|
219
|
+
*/
|
|
144
220
|
invalidValueType?: InvalidValueType;
|
|
221
|
+
/**
|
|
222
|
+
* @property {RadarShape} [radar] The radar of the chart.
|
|
223
|
+
*/
|
|
145
224
|
radar?: {
|
|
225
|
+
/**
|
|
226
|
+
* @property {RadarShape} [shape] The shape of the radar chart.
|
|
227
|
+
*/
|
|
146
228
|
shape?: RadarShape;
|
|
229
|
+
/**
|
|
230
|
+
* @property {boolean} [fill] True if the radar chart is filled; false otherwise.
|
|
231
|
+
*/
|
|
147
232
|
fill?: boolean;
|
|
148
233
|
};
|
|
149
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* The base class for chart builder.The chart builder is used to create a chart in the sheet.For line chart , radar chart and pie chart, you use the LineChartBuilder, RadarChartBuilder and PieChartBuilder classes respectively.
|
|
237
|
+
* @ignore
|
|
238
|
+
* @hideconstructor
|
|
239
|
+
*/
|
|
150
240
|
export declare class FChartBuilderBase extends FBase {
|
|
151
241
|
protected readonly _workbook: Workbook;
|
|
152
242
|
protected readonly _injector: Injector;
|
|
243
|
+
/**
|
|
244
|
+
* @property {string} unitId The unit id of the chart.
|
|
245
|
+
*/
|
|
153
246
|
unitId: string;
|
|
247
|
+
/**
|
|
248
|
+
* @property {string} subUnitId The sub unit id of the chart.
|
|
249
|
+
*/
|
|
154
250
|
subUnitId: string;
|
|
251
|
+
/**
|
|
252
|
+
* @property {string} chartId The chart id of the chart.
|
|
253
|
+
*/
|
|
155
254
|
chartId: string;
|
|
255
|
+
/**
|
|
256
|
+
* @property {IRange} range The source range of the chart.
|
|
257
|
+
*/
|
|
156
258
|
range: IRange | undefined;
|
|
259
|
+
/**
|
|
260
|
+
* @property {string} sourceSheetName The source sheet name of the chart.
|
|
261
|
+
*/
|
|
157
262
|
sourceSheetName: string | undefined;
|
|
263
|
+
/**
|
|
264
|
+
* @property {number} x The x-coordinate of the chart.
|
|
265
|
+
*/
|
|
158
266
|
x: number;
|
|
267
|
+
/**
|
|
268
|
+
* @property {number} y The y-coordinate of the chart.
|
|
269
|
+
*/
|
|
159
270
|
y: number;
|
|
271
|
+
/**
|
|
272
|
+
* @property {number} width The width of the chart.
|
|
273
|
+
*/
|
|
160
274
|
width: number;
|
|
275
|
+
/**
|
|
276
|
+
* @property {number} height The height of the chart.
|
|
277
|
+
*/
|
|
161
278
|
height: number;
|
|
279
|
+
/**
|
|
280
|
+
* @property {ChartTypeBits} chartType The chart type of the chart.
|
|
281
|
+
*/
|
|
162
282
|
chartType: ChartTypeBits;
|
|
283
|
+
/**
|
|
284
|
+
* @property {IChartBuildOptions} options The options of the chart.
|
|
285
|
+
*/
|
|
163
286
|
options: IChartBuildOptions;
|
|
287
|
+
/**
|
|
288
|
+
* @property {boolean} transposeRowsAndColumns Whether to read the data in the range as row direction.
|
|
289
|
+
*/
|
|
164
290
|
transposeRowsAndColumns: boolean;
|
|
165
291
|
constructor(unitId: string, subUnitId: string, workbook: Workbook, injector: Injector, chartId?: string);
|
|
166
292
|
/**
|
|
@@ -168,34 +294,37 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
168
294
|
* @description The chart type of the chart this builder modifies. The chart type (ChartTypeBits) can be found from package @univerjs-pro/sheets-chart.
|
|
169
295
|
* Please pay attention to the type of the chart you are creating, a Pie chart have a property of Doughnut is donut chart, and a Pie chart have a property of Rose is rose pie chart.But the chart builder will not change the chart type to the corresponding chart type.
|
|
170
296
|
* @returns {ChartTypeBits} ChartType - The chart type of the chart this builder modifies.
|
|
297
|
+
*
|
|
171
298
|
* @example
|
|
172
299
|
* ```ts
|
|
173
300
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
174
301
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
175
302
|
* const charts = fSheet.getCharts();
|
|
176
303
|
* if(charts.length > 0) {
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
304
|
+
* const chart = charts[0];
|
|
305
|
+
* const chartBuilder = chart.getChartBuilder();
|
|
306
|
+
* const chartType = chartBuilder.getChartType();
|
|
307
|
+
* console.log(chartType); // The chart type of first chart.
|
|
181
308
|
* }
|
|
309
|
+
* ```
|
|
182
310
|
*/
|
|
183
311
|
getChartType(): ChartTypeBits;
|
|
184
312
|
/**
|
|
185
313
|
* Adds a range to the chart this builder modifies
|
|
186
314
|
* @param {IRange | string} range The range string or object to add for chart source data.The should be not a single cell.
|
|
187
315
|
* @returns {FChartBuilderBase} -this builder, for chaining
|
|
316
|
+
*
|
|
188
317
|
* @example
|
|
189
318
|
* ```ts
|
|
190
319
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
191
320
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
192
321
|
* const chartBuilder = fSheet.newChart();
|
|
193
322
|
* const chartInfo = chartBuilder
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
323
|
+
* // set the source data range of the chart
|
|
324
|
+
* .addRange('A1:D6')
|
|
325
|
+
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
326
|
+
* .setPosition(1, 1, 0, 0)
|
|
327
|
+
* .build();
|
|
199
328
|
* fSheet.insertChart(chartInfo);
|
|
200
329
|
* ```
|
|
201
330
|
*/
|
|
@@ -212,17 +341,18 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
212
341
|
* @param {number} anchorColPos The chart's left side is anchored in this column.
|
|
213
342
|
* @param {number} rowOffset The chart's top left-hand corner is offset by this many pixels.
|
|
214
343
|
* @param {number} columnOffset The chart's lower left-hand corner is offset by this many pixels.
|
|
215
|
-
* @returns -this builder, for chaining
|
|
344
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
345
|
+
*
|
|
216
346
|
* @example
|
|
217
347
|
* ```ts
|
|
218
348
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
219
349
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
220
350
|
* const chartBuilder = fSheet.newChart();
|
|
221
351
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
352
|
+
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
353
|
+
* // set the chart's top side is anchored in row 2, left side is anchored in column 5, and the chart's top left-hand corner is offset by 20 pixels.
|
|
354
|
+
* .setPosition(2, 5, 20, 20)
|
|
355
|
+
* .build();
|
|
226
356
|
* fSheet.insertChart(chartInfo);
|
|
227
357
|
* ```
|
|
228
358
|
*/
|
|
@@ -232,17 +362,18 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
232
362
|
* @description The chart's start anchor position is the top left-hand corner of the chart. This api is opposite to setPosition.
|
|
233
363
|
* @param {number} x The x-coordinate of the chart's top left-hand corner.
|
|
234
364
|
* @param {number} y The y-coordinate of the chart's top left-hand corner.
|
|
235
|
-
* @returns -this builder, for chaining.
|
|
365
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
366
|
+
*
|
|
236
367
|
* @example
|
|
237
368
|
* ```ts
|
|
238
369
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
239
370
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
240
371
|
* const chartBuilder = fSheet.newChart();
|
|
241
372
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
373
|
+
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
374
|
+
* // set the chart's top left-hand corner is at (100, 200) pixels.
|
|
375
|
+
* .setAbsolutePosition(100, 200)
|
|
376
|
+
* .build();
|
|
246
377
|
* fSheet.insertChart(chartInfo);
|
|
247
378
|
* ```
|
|
248
379
|
*/
|
|
@@ -251,20 +382,21 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
251
382
|
* The type of chart to create.
|
|
252
383
|
* @param {ChartTypeBits} chartType The type of chart to create.Which can be found from package @univerjs-pro/sheets-chart.
|
|
253
384
|
* @description The type of chart to create. The following are the possible values: Line,Column,ColumnStacked,ColumnPercentStacked,Bar,BarStacked,BarPercentStacked,Pie,Doughnut,Area,AreaStacked,AreaPercentStacked,Radar,Scatter,Combination
|
|
254
|
-
* @returns -this builder, for chaining.
|
|
385
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
386
|
+
*
|
|
255
387
|
* @example
|
|
256
388
|
* ```ts
|
|
257
389
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
258
390
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
259
391
|
* const chartBuilder = fSheet.newChart();
|
|
260
392
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
261
|
-
* .setChartType(
|
|
393
|
+
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
262
394
|
* .setPosition(1, 1, 0, 0)
|
|
263
395
|
* .build();
|
|
264
396
|
* fSheet.insertChart(chartInfo);
|
|
265
397
|
* // update chart type to line
|
|
266
398
|
* const updateBuilder = fSheet.newChart();
|
|
267
|
-
* const updateChartInfo = updateBuilder.setChartType(
|
|
399
|
+
* const updateChartInfo = updateBuilder.setChartType(univerAPI.Enum.ChartType.Line).build();
|
|
268
400
|
* fSheet.updateChart(updateChartInfo);
|
|
269
401
|
* ```
|
|
270
402
|
*/
|
|
@@ -272,20 +404,21 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
272
404
|
/**
|
|
273
405
|
* Sets the width of the chart in pixels.
|
|
274
406
|
* @param {number} width The width of the chart in pixels.
|
|
275
|
-
* @returns -this builder, for chaining.
|
|
407
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
276
408
|
*/
|
|
277
409
|
setWidth(width: number): this;
|
|
278
410
|
/**
|
|
279
411
|
* Sets the height of the chart in pixels.
|
|
280
412
|
* @param {number} height The height of the chart in pixels.
|
|
281
|
-
* @returns -this builder, for chaining.
|
|
413
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
282
414
|
*/
|
|
283
415
|
setHeight(height: number): this;
|
|
284
416
|
/**
|
|
285
417
|
* The options for the chart. This function will overwrite existing options and merge new options property.
|
|
286
418
|
* @param {string} optionPath The path of the option to set. A '' path means the root of the options object.
|
|
287
|
-
* @param optionVal The value to set. Undefined value will be ignore , and null means delete the property.If a path is '', the value must be the whole options object.
|
|
288
|
-
* @returns The builder, for chaining.
|
|
419
|
+
* @param {object|number|string} optionVal The value to set. Undefined value will be ignore , and null means delete the property.If a path is '', the value must be the whole options object.
|
|
420
|
+
* @returns {FChartBuilderBase} The builder, for chaining.
|
|
421
|
+
*
|
|
289
422
|
* @example
|
|
290
423
|
* ```ts
|
|
291
424
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -293,31 +426,32 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
293
426
|
* const chartBuilder = fWorkSheet.newChart().asPieChart();
|
|
294
427
|
*
|
|
295
428
|
* const chartBuilderInfo1 = chartBuilder
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
429
|
+
* .addRange('A1:D6')
|
|
430
|
+
* .setOptions('title.content', 'Chart Title')
|
|
431
|
+
* .setOptions('legend.position', 'right')
|
|
432
|
+
* .setDoughnutHole(0.5)
|
|
433
|
+
* .setHasPaddingAngle(true)
|
|
434
|
+
* .setRosePie(true)
|
|
435
|
+
* .setIsHalfPie(true)
|
|
436
|
+
* .build();
|
|
304
437
|
* // setOptions can be replaced by setOptions('', { ... })
|
|
305
438
|
* const chartBuilderInfo2 = chartBuilder
|
|
306
|
-
*
|
|
307
|
-
*
|
|
439
|
+
* .addRange('A1:D6')
|
|
440
|
+
* .setOptions('', {
|
|
308
441
|
* "title": {
|
|
309
|
-
*
|
|
442
|
+
* "content": "Chart Title"
|
|
310
443
|
* },
|
|
311
444
|
* "legend": {
|
|
312
|
-
*
|
|
445
|
+
* "position": "right"
|
|
313
446
|
* },
|
|
314
447
|
* "pie": {
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
448
|
+
* "doughnutHole": 0.5,
|
|
449
|
+
* "hasPaddingAngle": true,
|
|
450
|
+
* "isHalfPie": true,
|
|
451
|
+
* "rosePie": true
|
|
319
452
|
* }
|
|
320
|
-
*
|
|
453
|
+
* })
|
|
454
|
+
* .build();
|
|
321
455
|
* fWorkSheet.insertChart(chartBuilderInfo1);
|
|
322
456
|
* // or they are same effect
|
|
323
457
|
* // fWorkSheet.insertChart(chartBuilderInfo2);
|
|
@@ -327,18 +461,19 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
327
461
|
/**
|
|
328
462
|
* Sets whether to transpose the rows and columns of the chart.
|
|
329
463
|
* @param {boolean} transposeRowsAndColumns Whether to transpose the rows and columns of the chart.The default value is false.
|
|
330
|
-
* @returns -this builder, for chaining.
|
|
464
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
465
|
+
*
|
|
331
466
|
* @example
|
|
332
467
|
* ```ts
|
|
333
468
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
334
469
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
335
470
|
* const chartBuilder = fSheet.newChart();
|
|
336
471
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
472
|
+
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
473
|
+
* .setPosition(1, 1, 0, 0)
|
|
474
|
+
* // the chart will transpose the rows and columns
|
|
475
|
+
* .setTransposeRowsAndColumns(true)
|
|
476
|
+
* .build();
|
|
342
477
|
* fSheet.insertChart(chartInfo);
|
|
343
478
|
* ```
|
|
344
479
|
*/
|
|
@@ -346,17 +481,18 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
346
481
|
/**
|
|
347
482
|
* Sets the theme of the chart. If the theme name not registered, a default theme will be used.
|
|
348
483
|
* @param {string} theme The theme name of the chart.
|
|
349
|
-
* @returns -this builder, for chaining.
|
|
484
|
+
* @returns {{FChartBuilderBase}} -this builder, for chaining.
|
|
485
|
+
*
|
|
350
486
|
* @example
|
|
351
487
|
* ```ts
|
|
352
488
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
353
489
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
354
490
|
* const chartBuilder = fSheet.newChart();
|
|
355
491
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
492
|
+
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
493
|
+
* .setPosition(1, 1, 0, 0)
|
|
494
|
+
* .setTheme('univer1')
|
|
495
|
+
* .build();
|
|
360
496
|
* fSheet.insertChart(chartInfo);
|
|
361
497
|
* ```
|
|
362
498
|
*/
|
|
@@ -364,14 +500,15 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
364
500
|
/**
|
|
365
501
|
* Sets the title of the chart x-axis.
|
|
366
502
|
* @param {string} title The title of the chart x-axis.
|
|
367
|
-
* @returns -this builder, for chaining.
|
|
503
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
504
|
+
*
|
|
368
505
|
* @example
|
|
369
506
|
* ```ts
|
|
370
507
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
371
508
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
372
509
|
* const chartBuilder = fSheet.newChart();
|
|
373
510
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
374
|
-
* .setChartType(
|
|
511
|
+
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
375
512
|
* .setPosition(1, 1, 0, 0)
|
|
376
513
|
* .setXAxisTitle('xAxis Title text')
|
|
377
514
|
* .build();
|
|
@@ -382,17 +519,18 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
382
519
|
/**
|
|
383
520
|
* Sets the title of the chart y-axis.
|
|
384
521
|
* @param {string} title The title of the chart y-axis.
|
|
385
|
-
* @returns -this builder, for chaining.
|
|
522
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
523
|
+
*
|
|
386
524
|
* @example
|
|
387
525
|
* ```ts
|
|
388
526
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
389
527
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
390
528
|
* const chartBuilder = fSheet.newChart();
|
|
391
529
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
530
|
+
* .setChartType(univerAPI.Enum.ChartType.Line)
|
|
531
|
+
* .setPosition(1, 1, 0, 0)
|
|
532
|
+
* .setYAxisTitle('yAxis Title text')
|
|
533
|
+
* .build();
|
|
396
534
|
* fSheet.insertChart(chartInfo);
|
|
397
535
|
* ```
|
|
398
536
|
*/
|
|
@@ -400,17 +538,18 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
400
538
|
/**
|
|
401
539
|
* Sets the title of the chart right y-axis.
|
|
402
540
|
* @param {string} title The title of the chart right y-axis.
|
|
403
|
-
* @returns -this builder, for chaining.
|
|
541
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
542
|
+
*
|
|
404
543
|
* @example
|
|
405
544
|
* ```ts
|
|
406
545
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
407
546
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
408
547
|
* const chartBuilder = fSheet.newChart();
|
|
409
548
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
549
|
+
* .setChartType(univerAPI.Enum.ChartType.Line)
|
|
550
|
+
* .setPosition(1, 1, 0, 0)
|
|
551
|
+
* .setRightYAxisTitle('rightYAxis Title text')
|
|
552
|
+
* .build();
|
|
414
553
|
* fSheet.insertChart(chartInfo);
|
|
415
554
|
* ```
|
|
416
555
|
*/
|
|
@@ -418,17 +557,18 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
418
557
|
/**
|
|
419
558
|
* Sets the text style for the chart x-axis.
|
|
420
559
|
* @param {IChartTextStyle} textStyle The text style for the chart x-axis.
|
|
421
|
-
* @returns -this builder, for chaining.
|
|
560
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
561
|
+
*
|
|
422
562
|
* @example
|
|
423
563
|
* ```ts
|
|
424
564
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
425
565
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
426
566
|
* const chartBuilder = fSheet.newChart();
|
|
427
567
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
*
|
|
568
|
+
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
569
|
+
* .setPosition(1, 1, 0, 0)
|
|
570
|
+
* .setXAxisTextStyle({ content: 'xAxis Title text', fontSize: 12, fontColor: '#ff0000' })
|
|
571
|
+
* .build();
|
|
432
572
|
* fSheet.insertChart(chartInfo);
|
|
433
573
|
* ```
|
|
434
574
|
*/
|
|
@@ -436,17 +576,18 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
436
576
|
/**
|
|
437
577
|
* Sets the text style for the chart y-axis.
|
|
438
578
|
* @param {IChartTextStyle} textStyle The text style for the chart y-axis.
|
|
439
|
-
* @returns -this builder, for chaining.
|
|
579
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
580
|
+
*
|
|
440
581
|
* @example
|
|
441
582
|
* ```ts
|
|
442
583
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
443
584
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
444
585
|
* const chartBuilder = fSheet.newChart();
|
|
445
586
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
587
|
+
* .setChartType(univerAPI.Enum.ChartType.Line)
|
|
588
|
+
* .setPosition(1, 1, 0, 0)
|
|
589
|
+
* .setYAxisTextStyle({ content: 'yAxis Title text', fontSize: 12, fontColor: '#ff0000' })
|
|
590
|
+
* .build();
|
|
450
591
|
* fSheet.insertChart(chartInfo);
|
|
451
592
|
* ```
|
|
452
593
|
*/
|
|
@@ -454,17 +595,22 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
454
595
|
/**
|
|
455
596
|
* Sets the text style for the chart right y-axis. Only works in charts have right y-axis.
|
|
456
597
|
* @param {IChartTextStyle} textStyle The text style for the chart right y-axis.
|
|
457
|
-
* @returns -this builder, for chaining.
|
|
598
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
599
|
+
*
|
|
458
600
|
* @example
|
|
459
601
|
* ```ts
|
|
460
602
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
461
603
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
462
604
|
* const chartBuilder = fSheet.newChart();
|
|
463
605
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
*
|
|
606
|
+
* .setChartType(univerAPI.Enum.ChartType.Line)
|
|
607
|
+
* .setPosition(1, 1, 0, 0)
|
|
608
|
+
* .setRightYAxisTextStyle({
|
|
609
|
+
* content: 'rightYAxis Title text',
|
|
610
|
+
* fontSize: 12,
|
|
611
|
+
* fontColor: '#ff0000'
|
|
612
|
+
* })
|
|
613
|
+
* .build();
|
|
468
614
|
* fSheet.insertChart(chartInfo);
|
|
469
615
|
* ```
|
|
470
616
|
*/
|
|
@@ -473,17 +619,18 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
473
619
|
* Sets how to handle invalid data in the chart.The possible values are 'zero', 'break' & 'link'.
|
|
474
620
|
* @description The default value is 'zero'. It means that invalid data will be treated as zero. 'break' means that the chart will have a gap where the invalid data is. 'link' means that the chart will connect the data points on either side of the invalid data.
|
|
475
621
|
* @param {InvalidValueType} invalidValueType The type of invalid value to use.
|
|
476
|
-
* @returns -this builder, for chaining.
|
|
622
|
+
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
623
|
+
*
|
|
477
624
|
* @example
|
|
478
625
|
* ```ts
|
|
479
626
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
480
627
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
481
628
|
* const chartBuilder = fSheet.newChart();
|
|
482
629
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
630
|
+
* .setChartType(univerAPI.Enum.ChartType.Line)
|
|
631
|
+
* .setPosition(1, 1, 0, 0)
|
|
632
|
+
* .setInvalidValueAs(InvalidValueType.Zero)
|
|
633
|
+
* .build();
|
|
487
634
|
* fSheet.insertChart(chartInfo);
|
|
488
635
|
* ```
|
|
489
636
|
*/
|
|
@@ -497,29 +644,30 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
497
644
|
* @property {ChartBorderDashType} [indicatorLineType] The line type of the axis pointer.
|
|
498
645
|
* @property {string} [indicatorLineColor] The line width of the axis pointer.
|
|
499
646
|
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
647
|
+
*
|
|
500
648
|
* @example
|
|
501
649
|
* ```ts
|
|
502
650
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
503
651
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
504
652
|
* const chartBuilder = fSheet.newChart();
|
|
505
653
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
654
|
+
* .setChartType(univerAPI.Enum.ChartType.Line)
|
|
655
|
+
* .setPosition(1, 1, 0, 0)
|
|
656
|
+
* .setAxisPointerStyle({
|
|
657
|
+
* indicatorLabelColor: '#ff0000',
|
|
658
|
+
* indicatorLineType: ChartBorderDashType.Solid,
|
|
659
|
+
* indicatorLineColor: '#00ff00',
|
|
660
|
+
* indicatorLabelTextColor: '#0000ff',
|
|
661
|
+
* })
|
|
662
|
+
* .build();
|
|
515
663
|
* fSheet.insertChart(chartInfo);
|
|
516
664
|
*
|
|
517
665
|
* // a AxisPointerStyle can be defined like following:
|
|
518
666
|
* const chartInfo = chartBuilder.setOptions('axisPointer.indicatorLineColor', '#ff0000')
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
667
|
+
* .setOptions('axisPointer.indicatorLineType', ChartBorderDashType.Solid)
|
|
668
|
+
* .setOptions('axisPointer.indicatorLineColor', '#00ff00')
|
|
669
|
+
* .setOptions('axisPointer.indicatorLabelTextColor', '#0000ff')
|
|
670
|
+
* .build();
|
|
523
671
|
* ```
|
|
524
672
|
*/
|
|
525
673
|
setAxisPointerStyle(style: IChartBuildOptions['axisPointer']): this;
|
|
@@ -540,26 +688,28 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
540
688
|
* @property {IDataPointStyle} [dataPoints] The data point style of the series.Radar chart does not support this property.
|
|
541
689
|
* @param {allSeriesStyle} allSeriesStyle The style for all series.
|
|
542
690
|
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
691
|
+
*
|
|
543
692
|
* @example
|
|
544
693
|
* ```ts
|
|
545
694
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
546
695
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
547
696
|
* const chartBuilder = fSheet.newChart();
|
|
548
697
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
698
|
+
* .setChartType(univerAPI.Enum.ChartType.Line)
|
|
699
|
+
* .setPosition(1, 1, 0, 0)
|
|
700
|
+
* .setALLSeriesStyle({
|
|
701
|
+
* chartType: ChartTypeBits.Line,
|
|
702
|
+
* rightYAxis: false,
|
|
703
|
+
* color: '#ff0000',
|
|
704
|
+
* fillOpacity: 0.5,
|
|
705
|
+
* border: {
|
|
706
|
+
* color: '#00ff00',
|
|
707
|
+
* opacity: 0.5,
|
|
708
|
+
* width: 1,
|
|
709
|
+
* dashType: ChartBorderDashType.Solid,
|
|
710
|
+
* },
|
|
711
|
+
* })
|
|
712
|
+
* .build();
|
|
563
713
|
* fSheet.insertChart(chartInfo);
|
|
564
714
|
* ```
|
|
565
715
|
*/
|
|
@@ -570,26 +720,26 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
570
720
|
* @param {number | string} index The index of the series to set the style for.
|
|
571
721
|
* @param {ISeriesStyle} seriesStyle The style for the series.
|
|
572
722
|
* @returns {FChartBuilderBase} -this builder, for chaining.
|
|
723
|
+
*
|
|
573
724
|
* @example
|
|
574
725
|
* ```ts
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
* , 1000);
|
|
726
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
727
|
+
* const fSheet = fWorkbook.getActiveSheet();
|
|
728
|
+
* const chartBuilder = fSheet.newChart();
|
|
729
|
+
* const chartInfo = chartBuilder.addRange('A1:D6').setChartType(2).setPosition(1, 1, 0, 0).build();
|
|
730
|
+
* const fChart = await fSheet.insertChart(chartInfo);
|
|
731
|
+
* // should wait the chart rendered
|
|
732
|
+
* setTimeout(() => {
|
|
733
|
+
* if (fChart) {
|
|
734
|
+
* const chartBuilder = fSheet.newChart(fChart);
|
|
735
|
+
* // get the series data
|
|
736
|
+
* const first = fChart.getSeriesData()[0];
|
|
737
|
+
* chartBuilder.setSeriesStyle(first.index, {
|
|
738
|
+
* color: '#ff0000',
|
|
739
|
+
* }).build();
|
|
740
|
+
* fSheet.updateChart(chartBuilder);
|
|
741
|
+
* }
|
|
742
|
+
* },1000);
|
|
593
743
|
* ```
|
|
594
744
|
*/
|
|
595
745
|
setSeriesStyle(index: number | string, seriesStyle: ISeriesStyle): this;
|
|
@@ -597,17 +747,18 @@ export declare class FChartBuilderBase extends FBase {
|
|
|
597
747
|
* Builds the chart to reflect all changes made to it.
|
|
598
748
|
* @description This method does not automatically draw the chart on top of the spreadsheet. A new chart must be inserted via sheet.insertChart(chart), and an existing chart should be updated via sheet.updateChart(chart).
|
|
599
749
|
* @returns {IChartBuilderInfo} -The chart builder info.
|
|
750
|
+
*
|
|
600
751
|
* @example
|
|
601
752
|
* ```ts
|
|
602
753
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
603
754
|
* const fSheet = fWorkbook.getActiveSheet();
|
|
604
755
|
* const chartBuilder = fSheet.newChart();
|
|
605
756
|
* const chartInfo = chartBuilder.addRange('A1:D6')
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
757
|
+
* .setChartType(univerAPI.Enum.ChartType.Column)
|
|
758
|
+
* .setPosition(1, 1, 0, 0)
|
|
759
|
+
* .setWidth(600)
|
|
760
|
+
* .setHeight(400)
|
|
761
|
+
* .build();
|
|
611
762
|
* fSheet.insertChart(chartInfo);
|
|
612
763
|
* ```
|
|
613
764
|
*/
|