@univerjs-pro/sheets-chart-ui 0.5.1 → 0.5.2

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 (56) hide show
  1. package/README.md +40 -7
  2. package/lib/cjs/facade.js +1 -0
  3. package/lib/cjs/index.js +1 -1
  4. package/lib/cjs/locale/en-US.js +1 -1
  5. package/lib/cjs/locale/fa-IR.js +1 -1
  6. package/lib/cjs/locale/fr-FR.js +1 -1
  7. package/lib/cjs/locale/ru-RU.js +1 -1
  8. package/lib/cjs/locale/vi-VN.js +1 -1
  9. package/lib/cjs/locale/zh-CN.js +1 -1
  10. package/lib/cjs/locale/zh-TW.js +1 -1
  11. package/lib/es/facade.js +1 -0
  12. package/lib/es/index.js +1 -1
  13. package/lib/es/locale/en-US.js +1 -1
  14. package/lib/es/locale/fa-IR.js +1 -1
  15. package/lib/es/locale/fr-FR.js +1 -1
  16. package/lib/es/locale/ru-RU.js +1 -1
  17. package/lib/es/locale/vi-VN.js +1 -1
  18. package/lib/es/locale/zh-CN.js +1 -1
  19. package/lib/es/locale/zh-TW.js +1 -1
  20. package/lib/index.css +1 -1
  21. package/lib/types/commands/commands/sheets-chart.command.d.ts +11 -1
  22. package/lib/types/const.d.ts +1 -0
  23. package/lib/types/facade/chart-builder/builder-util.d.ts +4 -0
  24. package/lib/types/facade/chart-builder/chart-builder-base.d.ts +568 -0
  25. package/lib/types/facade/chart-builder/line-chart-builder.d.ts +55 -0
  26. package/lib/types/facade/chart-builder/pie-chart-builder.d.ts +70 -0
  27. package/lib/types/facade/chart-builder/radar-chart-builder.d.ts +42 -0
  28. package/lib/types/facade/chart-builder/types.d.ts +22 -0
  29. package/lib/types/facade/f-chart.d.ts +86 -0
  30. package/lib/types/facade/f-worksheet.d.ts +120 -0
  31. package/lib/types/facade/index.d.ts +16 -0
  32. package/lib/types/index.d.ts +1 -0
  33. package/lib/types/locale/zh-CN.d.ts +19 -0
  34. package/lib/types/models/echart-render-engine.d.ts +2 -0
  35. package/lib/types/models/echart-render-model.d.ts +1 -1
  36. package/lib/types/models/render-spec-operators/axis-title.operator.d.ts +2 -0
  37. package/lib/types/models/render-spec-operators/index.d.ts +2 -1
  38. package/lib/types/models/render-spec-operators/title-style.operator.d.ts +1 -1
  39. package/lib/types/models/render-spec-operators/tools.d.ts +4 -2
  40. package/lib/types/services/sheets-chart-ui.service.d.ts +2 -1
  41. package/lib/types/views/chart-edit-panel/options.d.ts +5 -5
  42. package/lib/types/views/chart-edit-panel/style-tab-panel/DataLabelOptions.d.ts +1 -1
  43. package/lib/types/views/chart-edit-panel/style-tab-panel/IndicatorLine.d.ts +19 -0
  44. package/lib/types/views/chart-edit-panel/style-tab-panel/series-style-edit/RadarPoints.d.ts +2 -2
  45. package/lib/types/views/chart-edit-panel/style-tab-panel/series-style-edit/const.d.ts +2 -0
  46. package/lib/types/views/chart-edit-panel/style-tab-panel/series-style-edit/widgets.d.ts +3 -6
  47. package/lib/umd/facade.js +1 -0
  48. package/lib/umd/index.js +1 -1
  49. package/lib/umd/locale/en-US.js +1 -1
  50. package/lib/umd/locale/fa-IR.js +1 -1
  51. package/lib/umd/locale/fr-FR.js +1 -1
  52. package/lib/umd/locale/ru-RU.js +1 -1
  53. package/lib/umd/locale/vi-VN.js +1 -1
  54. package/lib/umd/locale/zh-CN.js +1 -1
  55. package/lib/umd/locale/zh-TW.js +1 -1
  56. package/package.json +29 -17
@@ -1,4 +1,4 @@
1
- import { ChartTypeBits } from '@univerjs-pro/sheets-chart';
1
+ import { IChartUpdateConfigMutationParams, ChartTypeBits } from '@univerjs-pro/sheets-chart';
2
2
  import { ICommand, IRange } from '@univerjs/core';
3
3
  import { ISheetCommandSharedParams } from '@univerjs/sheets';
4
4
  export interface IInsertChartCommandParams extends ISheetCommandSharedParams {
@@ -6,6 +6,16 @@ export interface IInsertChartCommandParams extends ISheetCommandSharedParams {
6
6
  chartId: string;
7
7
  theme?: string;
8
8
  chartType: ChartTypeBits;
9
+ position?: {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ width?: number;
14
+ height?: number;
15
+ backgroundColor?: string;
16
+ borderColor?: string;
17
+ config?: IChartUpdateConfigMutationParams;
18
+ isRowDirection?: boolean;
9
19
  }
10
20
  /**
11
21
  */
@@ -6,3 +6,4 @@ export declare const TitleOrLegendPadding = 12;
6
6
  export declare const TitleDefaultStartPosition = 8;
7
7
  export declare const defaultChartPadding = 14;
8
8
  export declare const TitleLineHeightBase = 1.2;
9
+ export declare const AxisLabelMaxPercent = 0.15;
@@ -0,0 +1,4 @@
1
+ import { ChartTypeBits, IChartUpdateConfigMutationParams } from '@univerjs-pro/sheets-chart';
2
+ import { IChartBuildOptions } from './chart-builder-base';
3
+ export declare const setPropertyIfExist: (spec: Record<string, any>, path: string, value: unknown) => void;
4
+ export declare const transformBuildInfoToMutation: (unitId: string, chartId: string, chartType: ChartTypeBits, buildInfo?: IChartBuildOptions) => undefined | IChartUpdateConfigMutationParams;
@@ -0,0 +1,568 @@
1
+ import { AreaLineStyle, ChartBorderDashType, ChartTypeBits, IAllSeriesStyle, IAxisOptions, InvalidValueType, ISeriesStyle, LegendPositionEnum, SelectModeEnum, TitlePositionEnum } from '@univerjs-pro/sheets-chart';
2
+ import { Injector, IRange, Workbook, FBase } from '@univerjs/core';
3
+ export interface IChartBuilderInfo {
4
+ unitId: string;
5
+ subUnitId: string;
6
+ chartId: string;
7
+ range: IRange | undefined;
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ chartType: ChartTypeBits;
13
+ options: IChartBuildOptions;
14
+ isRowDirection: boolean;
15
+ }
16
+ export interface IChartTextStyle {
17
+ /**
18
+ * @property {string} [titleContent] The content of the chart title.
19
+ */
20
+ content?: string;
21
+ /**
22
+ * @property {number} [font] The font family for the chart title.
23
+ */
24
+ font?: number;
25
+ /**
26
+ * @property {number} [fontSize] The font size for the chart title.
27
+ */
28
+ fontSize?: number;
29
+ /**
30
+ * @property {string} [fontColor] The font color for the chart title.
31
+ */
32
+ fontColor?: string;
33
+ /**
34
+ * @property {string} [fontStyle] The font style for the chart title.
35
+ */
36
+ fontStyle?: string;
37
+ /**
38
+ * @property {string} [fontWeight] The font weight for the chart title.
39
+ */
40
+ fontWeight?: string;
41
+ /**
42
+ * @property {string} [alignment] The alignment of the chart title.
43
+ */
44
+ alignment?: string;
45
+ }
46
+ export interface IChartBuildOptions {
47
+ /**
48
+ * @property {string} [title] The title of the chart.
49
+ */
50
+ title?: {
51
+ /**
52
+ * @property {string} [titlePosition] The position of the chart title.
53
+ */
54
+ position?: TitlePositionEnum;
55
+ } & IChartTextStyle;
56
+ /**
57
+ * @property {string} [legend] The legend of the chart.
58
+ */
59
+ legend?: {
60
+ /**
61
+ * @property {string} [legendPosition] The position of the legend.The possible values are 'top', 'bottom', 'left', 'right' & 'hide'.
62
+ */
63
+ position?: LegendPositionEnum;
64
+ /**
65
+ * @property {number} [fontSize] The font size of the legend.
66
+ */
67
+ fontSize?: number;
68
+ /**
69
+ * @property {string} [color] The font color of the legend.
70
+ */
71
+ color?: string;
72
+ /**
73
+ * @property {string} [bold] The font style of the legend.
74
+ */
75
+ bold?: boolean;
76
+ /**
77
+ * @property {string} [italic] The font weight of the legend.
78
+ */
79
+ italic?: boolean;
80
+ /**
81
+ * @property {SelectModeEnum} [selectMode] The select mode of the legend.The possible values are 'single', 'multiple' & 'close'.
82
+ */
83
+ selectMode?: SelectModeEnum;
84
+ };
85
+ /**
86
+ * @property {string} [xAxisTitle] The x-axis title of the chart.
87
+ * @example
88
+ * ```ts
89
+ * chartBuilder.setOptions('xAxisTitle.content', 'xAxis Title text')
90
+ * .setOptions('xAxisTitle.font', 1)
91
+ * .setOptions('xAxisTitle.fontSize', 12)
92
+ * .setOptions('xAxisTitle.fontColor', '#ff0000')
93
+ * .build();
94
+ * ```
95
+ */
96
+ xAxisTitle?: IChartTextStyle;
97
+ /**
98
+ * @property {string} [rightYAxisTitle] The right y-axis title of the chart.
99
+ */
100
+ yAxisTitle?: IChartTextStyle;
101
+ /**
102
+ * @property {string} [rightYAxisTitle] The right y-axis title of the chart.
103
+ */
104
+ rightYAxisTitle?: IChartTextStyle;
105
+ xAxis?: IAxisOptions;
106
+ yAxis?: IAxisOptions;
107
+ yRightAxis?: IAxisOptions;
108
+ axisPointer?: {
109
+ /**
110
+ * @property {string} [indicatorLineType] The line type of the axis pointer.
111
+ */
112
+ indicatorLineType?: string;
113
+ /**
114
+ * @property {ChartBorderDashType} [indicatorLineColor] The line color of the axis pointer.The maybe values are 'solid', 'dotted', 'dashed'.
115
+ */
116
+ indicatorLineColor?: ChartBorderDashType;
117
+ /**
118
+ * @property {string} [indicatorLabelColor] The line width of the axis pointer.
119
+ */
120
+ indicatorLabelColor?: string;
121
+ /**
122
+ * @property {string} [indicatorLabelTextColor] The font color of the axis pointer.
123
+ */
124
+ indicatorLabelTextColor?: string;
125
+ };
126
+ allSeriesStyle?: IAllSeriesStyle;
127
+ seriesStyleMap?: {
128
+ [id: string]: ISeriesStyle;
129
+ };
130
+ /**
131
+ * @property {string} [area] The area of line/area chart.
132
+ */
133
+ area?: {
134
+ lineStyle: AreaLineStyle;
135
+ };
136
+ backgroundColor?: string;
137
+ borderColor?: string;
138
+ gradientFill?: boolean;
139
+ theme?: string;
140
+ invalidValueType?: InvalidValueType;
141
+ }
142
+ export declare class FChartBuilderBase extends FBase {
143
+ protected readonly _workbook: Workbook;
144
+ protected readonly _injector: Injector;
145
+ unitId: string;
146
+ subUnitId: string;
147
+ chartId: string;
148
+ range: IRange | undefined;
149
+ sourceSheetName: string | undefined;
150
+ x: number;
151
+ y: number;
152
+ width: number;
153
+ height: number;
154
+ chartType: ChartTypeBits;
155
+ options: IChartBuildOptions;
156
+ transposeRowsAndColumns: boolean;
157
+ constructor(unitId: string, subUnitId: string, workbook: Workbook, injector: Injector, chartId?: string);
158
+ /**
159
+ * Gets the chart type of the chart this builder modifies.
160
+ * @description The chart type of the chart this builder modifies. The chart type (ChartTypeBits) can be found from package @univerjs-pro/sheets-chart.
161
+ * 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.
162
+ * @returns {ChartTypeBits} ChartType - The chart type of the chart this builder modifies.
163
+ */
164
+ getChartType(): ChartTypeBits;
165
+ /**
166
+ * Adds a range to the chart this builder modifies
167
+ * @param {IRange | string} range The range string or object to add for chart source data.
168
+ * @returns {FChartBuilderBase} -this builder, for chaining
169
+ */
170
+ addRange(range: IRange | string): FChartBuilderBase;
171
+ /**
172
+ * Clears the range from the chart this builder modifies
173
+ * @returns {FChartBuilderBase} -this builder, for chaining
174
+ */
175
+ clearRange(): FChartBuilderBase;
176
+ /**
177
+ * Sets the position, changing where the chart appears on the sheet. anchorRowPos and anchorColPos are 0-indexed.This api can only work in the active sheet.
178
+ * @description The chart's start anchor position is the top left-hand corner of the chart. The rowOffset and columnOffset are the pixel offsets from the anchor position.
179
+ * @param {number} anchorRowPos The chart's top side is anchored in this row.
180
+ * @param {number} anchorColPos The chart's left side is anchored in this column.
181
+ * @param {number} rowOffset The chart's top left-hand corner is offset by this many pixels.
182
+ * @param {number} columnOffset The chart's lower left-hand corner is offset by this many pixels.
183
+ * @returns -this builder, for chaining
184
+ * @example
185
+ * ```ts
186
+ * const fWorkbook = univerAPI.getActiveWorkbook();
187
+ * const fSheet = fWorkbook.getActiveSheet();
188
+ * const chartBuilder = fSheet.newChart();
189
+ * const chartInfo = chartBuilder.addRange('A1:D6')
190
+ * .setChartType(ChartTypeBits.Column)
191
+ * // 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.
192
+ * .setPosition(2, 5, 20, 20)
193
+ * .build();
194
+ * fSheet.insertChart(chartInfo);
195
+ * ```
196
+ */
197
+ setPosition(anchorRowPos: number, anchorColPos: number, rowOffset: number, columnOffset: number): FChartBuilderBase;
198
+ /**
199
+ * Sets the position, changing where the chart appears on the sheet by pixel.
200
+ * @description The chart's start anchor position is the top left-hand corner of the chart. This api is opposite to setPosition.
201
+ * @param {number} x The x-coordinate of the chart's top left-hand corner.
202
+ * @param {number} y The y-coordinate of the chart's top left-hand corner.
203
+ * @returns -this builder, for chaining.
204
+ * @example
205
+ * ```ts
206
+ * const fWorkbook = univerAPI.getActiveWorkbook();
207
+ * const fSheet = fWorkbook.getActiveSheet();
208
+ * const chartBuilder = fSheet.newChart();
209
+ * const chartInfo = chartBuilder.addRange('A1:D6')
210
+ * .setChartType(ChartTypeBits.Column)
211
+ * // set the chart's top left-hand corner is at (100, 200) pixels.
212
+ * .setAbsolutePosition(100, 200)
213
+ * .build();
214
+ * fSheet.insertChart(chartInfo);
215
+ * ```
216
+ */
217
+ setAbsolutePosition(x: number, y: number): FChartBuilderBase;
218
+ /**
219
+ * The type of chart to create.
220
+ * @param {ChartTypeBits} chartType The type of chart to create.Which can be found from package @univerjs-pro/sheets-chart.
221
+ * @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
222
+ * @returns -this builder, for chaining.
223
+ * @example
224
+ * ```ts
225
+ * const fWorkbook = univerAPI.getActiveWorkbook();
226
+ * const fSheet = fWorkbook.getActiveSheet();
227
+ * const chartBuilder = fSheet.newChart();
228
+ * const chartInfo = chartBuilder.addRange('A1:D6')
229
+ * .setChartType(ChartTypeBits.Column)
230
+ * .setPosition(1, 1, 0, 0)
231
+ * .build();
232
+ * fSheet.insertChart(chartInfo);
233
+ * // update chart type to line
234
+ * const updateBuilder = fSheet.newChart();
235
+ * const updateChartInfo = updateBuilder.setChartType(ChartTypeBits.Line).build();
236
+ * fSheet.updateChart(updateChartInfo);
237
+ * ```
238
+ */
239
+ setChartType(chartType: ChartTypeBits): FChartBuilderBase;
240
+ /**
241
+ * Sets the width of the chart in pixels.
242
+ * @param {number} width The width of the chart in pixels.
243
+ * @returns -this builder, for chaining.
244
+ */
245
+ setWidth(width: number): FChartBuilderBase;
246
+ /**
247
+ * Sets the height of the chart in pixels.
248
+ * @param {number} height The height of the chart in pixels.
249
+ * @returns -this builder, for chaining.
250
+ */
251
+ setHeight(height: number): FChartBuilderBase;
252
+ /**
253
+ * The options for the chart. This function will overwrite existing options and merge new options property.
254
+ * @param {string} optionPath The path of the option to set. A '' path means the root of the options object.
255
+ * @param {IChartBuildOptions[T] | IChartBuildOptions} 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.
256
+ * @returns The builder, for chaining.
257
+ * @example
258
+ * ```ts
259
+ * const fWorkbook = univerAPI.getActiveWorkbook();
260
+ * const fWorkSheet = fWorkbook.getActiveSheet();
261
+ * const chartBuilder = fWorkSheet.newChart().asPieChart();
262
+ *
263
+ * const chartBuilderInfo1 = chartBuilder
264
+ * .addRange('A1:D6')
265
+ * .setOptions('title.content', 'mcc')
266
+ * .setOptions('legend.position', 'right')
267
+ * .setDoughnutHole(0.5)
268
+ * .setHasPaddingAngle(true)
269
+ * .setRosePie(true)
270
+ * .setIsHalfPie(true)
271
+ * .build();
272
+ * // setOptions can be replaced by setOptions('', { ... })
273
+ * const chartBuilderInfo2 = chartBuilder
274
+ * .addRange('A1:D6')
275
+ * .setOptions('', {
276
+ * "title": {
277
+ * "content": "mcc"
278
+ * },
279
+ * "legend": {
280
+ * "position": "right"
281
+ * },
282
+ * "pie": {
283
+ * "doughnutHole": 0.5,
284
+ * "hasPaddingAngle": true,
285
+ * "isHalfPie": true,
286
+ * "rosePie": true
287
+ * }
288
+ * }).build();
289
+ * fWorkSheet.insertChart(chartBuilderInfo1);
290
+ * // or they are same effect
291
+ * // fWorkSheet.insertChart(chartBuilderInfo2);
292
+ */
293
+ setOptions<T extends keyof IChartBuildOptions>(optionPath: T | '', optionVal: IChartBuildOptions[T] | IChartBuildOptions): FChartBuilderBase;
294
+ /**
295
+ * Sets whether to transpose the rows and columns of the chart.
296
+ * @param {boolean} transposeRowsAndColumns Whether to transpose the rows and columns of the chart.The default value is false.
297
+ * @returns -this builder, for chaining.
298
+ */
299
+ setTransposeRowsAndColumns(transposeRowsAndColumns: boolean): FChartBuilderBase;
300
+ /**
301
+ * Sets the theme of the chart. If the theme name not registered, a default theme will be used.
302
+ * @param {string} theme The theme name of the chart.
303
+ * @returns -this builder, for chaining.
304
+ * @example
305
+ * ```ts
306
+ * const fWorkbook = univerAPI.getActiveWorkbook();
307
+ * const fSheet = fWorkbook.getActiveSheet();
308
+ * const chartBuilder = fSheet.newChart();
309
+ * const chartInfo = chartBuilder.addRange('A1:D6')
310
+ * .setChartType(ChartTypeBits.Column)
311
+ * .setPosition(1, 1, 0, 0)
312
+ * .setTheme('univer1')
313
+ * .build();
314
+ * fSheet.insertChart(chartInfo);
315
+ * ```
316
+ */
317
+ setTheme(theme: string): FChartBuilderBase;
318
+ /**
319
+ * Sets the title of the chart x-axis.
320
+ * @param {string} title The title of the chart x-axis.
321
+ * @returns -this builder, for chaining.
322
+ * @example
323
+ * ```ts
324
+ * const fWorkbook = univerAPI.getActiveWorkbook();
325
+ * const fSheet = fWorkbook.getActiveSheet();
326
+ * const chartBuilder = fSheet.newChart();
327
+ * const chartInfo = chartBuilder.addRange('A1:D6')
328
+ * .setChartType(ChartTypeBits.Column)
329
+ * .setPosition(1, 1, 0, 0)
330
+ * .setXAxisTitle('xAxis Title text')
331
+ * .build();
332
+ * fSheet.insertChart(chartInfo);
333
+ * ```
334
+ */
335
+ setXAxisTitle(title: string): FChartBuilderBase;
336
+ /**
337
+ * Sets the title of the chart y-axis.
338
+ * @param {string} title The title of the chart y-axis.
339
+ * @returns -this builder, for chaining.
340
+ * @example
341
+ * ```ts
342
+ * const fWorkbook = univerAPI.getActiveWorkbook();
343
+ * const fSheet = fWorkbook.getActiveSheet();
344
+ * const chartBuilder = fSheet.newChart();
345
+ * const chartInfo = chartBuilder.addRange('A1:D6')
346
+ * .setChartType(ChartTypeBits.Line)
347
+ * .setPosition(1, 1, 0, 0)
348
+ * .setYAxisTitle('yAxis Title text')
349
+ * .build();
350
+ * fSheet.insertChart(chartInfo);
351
+ * ```
352
+ */
353
+ setYAxisTitle(title: string): FChartBuilderBase;
354
+ /**
355
+ * Sets the title of the chart right y-axis.
356
+ * @param {string} title The title of the chart right y-axis.
357
+ * @returns -this builder, for chaining.
358
+ * @example
359
+ * ```ts
360
+ * const fWorkbook = univerAPI.getActiveWorkbook();
361
+ * const fSheet = fWorkbook.getActiveSheet();
362
+ * const chartBuilder = fSheet.newChart();
363
+ * const chartInfo = chartBuilder.addRange('A1:D6')
364
+ * .setChartType(ChartTypeBits.Line)
365
+ * .setPosition(1, 1, 0, 0)
366
+ * .setRightYAxisTitle('rightYAxis Title text')
367
+ * .build();
368
+ * fSheet.insertChart(chartInfo);
369
+ * ```
370
+ */
371
+ setRightYAxisTitle(title: string): FChartBuilderBase;
372
+ /**
373
+ * Sets the text style for the chart x-axis.
374
+ * @param {IChartTextStyle} textStyle The text style for the chart x-axis.
375
+ * @returns -this builder, for chaining.
376
+ * @example
377
+ * ```ts
378
+ * const fWorkbook = univerAPI.getActiveWorkbook();
379
+ * const fSheet = fWorkbook.getActiveSheet();
380
+ * const chartBuilder = fSheet.newChart();
381
+ * const chartInfo = chartBuilder.addRange('A1:D6')
382
+ * .setChartType(ChartTypeBits.Column)
383
+ * .setPosition(1, 1, 0, 0)
384
+ * .setXAxisTextStyle({ content: 'xAxis Title text', fontSize: 12, fontColor: '#ff0000' })
385
+ * .build();
386
+ * fSheet.insertChart(chartInfo);
387
+ * ```
388
+ */
389
+ setXAxisTextStyle(textStyle: IChartTextStyle): FChartBuilderBase;
390
+ /**
391
+ * Sets the text style for the chart y-axis.
392
+ * @param {IChartTextStyle} textStyle The text style for the chart y-axis.
393
+ * @returns -this builder, for chaining.
394
+ * @example
395
+ * ```ts
396
+ * const fWorkbook = univerAPI.getActiveWorkbook();
397
+ * const fSheet = fWorkbook.getActiveSheet();
398
+ * const chartBuilder = fSheet.newChart();
399
+ * const chartInfo = chartBuilder.addRange('A1:D6')
400
+ * .setChartType(ChartTypeBits.Line)
401
+ * .setPosition(1, 1, 0, 0)
402
+ * .setYAxisTextStyle({ content: 'yAxis Title text', fontSize: 12, fontColor: '#ff0000' })
403
+ * .build();
404
+ * fSheet.insertChart(chartInfo);
405
+ * ```
406
+ */
407
+ setYAxisTextStyle(textStyle: IChartTextStyle): FChartBuilderBase;
408
+ /**
409
+ * Sets the text style for the chart right y-axis. Only works in charts have right y-axis.
410
+ * @param {IChartTextStyle} textStyle The text style for the chart right y-axis.
411
+ * @returns -this builder, for chaining.
412
+ * @example
413
+ * ```ts
414
+ * const fWorkbook = univerAPI.getActiveWorkbook();
415
+ * const fSheet = fWorkbook.getActiveSheet();
416
+ * const chartBuilder = fSheet.newChart();
417
+ * const chartInfo = chartBuilder.addRange('A1:D6')
418
+ * .setChartType(ChartTypeBits.Line)
419
+ * .setPosition(1, 1, 0, 0)
420
+ * .setRightYAxisTextStyle({ content: 'rightYAxis Title text', fontSize: 12, fontColor: '#ff0000' })
421
+ * .build();
422
+ * fSheet.insertChart(chartInfo);
423
+ * ```
424
+ */
425
+ setRightYAxisTextStyle(textStyle: IChartTextStyle): FChartBuilderBase;
426
+ /**
427
+ * Sets how to handle invalid data in the chart.The possible values are 'zero', 'break' & 'link'.
428
+ * @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.
429
+ * @param {InvalidValueType} invalidValueType The type of invalid value to use.
430
+ * @returns -this builder, for chaining.
431
+ * @example
432
+ * ```ts
433
+ * const fWorkbook = univerAPI.getActiveWorkbook();
434
+ * const fSheet = fWorkbook.getActiveSheet();
435
+ * const chartBuilder = fSheet.newChart();
436
+ * const chartInfo = chartBuilder.addRange('A1:D6')
437
+ * .setChartType(ChartTypeBits.Line)
438
+ * .setPosition(1, 1, 0, 0)
439
+ * .setInvalidValueAs(InvalidValueType.Zero)
440
+ * .build();
441
+ * fSheet.insertChart(chartInfo);
442
+ * ```
443
+ */
444
+ setInvalidValueStrategy(invalidValueType: InvalidValueType): FChartBuilderBase;
445
+ /**
446
+ * Sets the axis pointer style
447
+ * @param {IChartBuildOptions['axisPointer']} style The style for the axis pointer.
448
+ * @typedef AxisPointerStyle
449
+ * @property {string} [indicatorLabelColor] The line color of the axis pointer.
450
+ * @property {string} [indicatorLabelTextColor] The font color of the axis pointer.
451
+ * @property {ChartBorderDashType} [indicatorLineType] The line type of the axis pointer.
452
+ * @property {string} [indicatorLineColor] The line width of the axis pointer.
453
+ * @returns {FChartBuilderBase} -this builder, for chaining.
454
+ * @example
455
+ * ```ts
456
+ * const fWorkbook = univerAPI.getActiveWorkbook();
457
+ * const fSheet = fWorkbook.getActiveSheet();
458
+ * const chartBuilder = fSheet.newChart();
459
+ * const chartInfo = chartBuilder.addRange('A1:D6')
460
+ * .setChartType(ChartTypeBits.Line)
461
+ * .setPosition(1, 1, 0, 0)
462
+ * .setAxisPointerStyle({
463
+ * indicatorLabelColor: '#ff0000',
464
+ * indicatorLineType: ChartBorderDashType.Solid,
465
+ * indicatorLineColor: '#00ff00',
466
+ * indicatorLabelTextColor: '#0000ff',
467
+ * })
468
+ * .build();
469
+ * fSheet.insertChart(chartInfo);
470
+ *
471
+ * // a AxisPointerStyle can be defined like following:
472
+ * const chartInfo = chartBuilder.setOptions('axisPointer.indicatorLineColor', '#ff0000')
473
+ * .setOptions('axisPointer.indicatorLineType', ChartBorderDashType.Solid)
474
+ * .setOptions('axisPointer.indicatorLineColor', '#00ff00')
475
+ * .setOptions('axisPointer.indicatorLabelTextColor', '#0000ff')
476
+ * .build();
477
+ * ```
478
+ */
479
+ setAxisPointerStyle(style: IChartBuildOptions['axisPointer']): FChartBuilderBase;
480
+ /**
481
+ * Sets styles for all series.
482
+ * @typedef allSeriesStyle
483
+ * @property {ChartTypeBits} chartType The chart type of the series.It only works in combination chart, and the value must be one of ChartTypeBits.Line | ChartTypeBits.Column | ChartTypeBits.Area;
484
+ * @property {boolean} rightYAxis Use the right y-axis for the series.
485
+ * @property {string} color The color of the series.
486
+ * @property {number} fillOpacity The opacity of the series fill.
487
+ * @property {string} border.color The color of the series border.
488
+ * @property {number} border.opacity The opacity of the series border.
489
+ * @property {number} border.width The width of the series border.
490
+ * @property {ChartBorderDashType} border.dashType The dash type of the series border.
491
+ * @property {ISeriesLabelStyle} label The label style of the series.
492
+ * @property {IPointStyle} point The point style of the series.
493
+ * @property {IDataPointStyle} dataPoints The data point style of the series.Radar chart does not support this property.
494
+ * @param {allSeriesStyle} allSeriesStyle The style for all series.
495
+ * @returns {FChartBuilderBase} -this builder, for chaining.
496
+ * @example
497
+ * ```ts
498
+ * const fWorkbook = univerAPI.getActiveWorkbook();
499
+ * const fSheet = fWorkbook.getActiveSheet();
500
+ * const chartBuilder = fSheet.newChart();
501
+ * const chartInfo = chartBuilder.addRange('A1:D6')
502
+ * .setChartType(ChartTypeBits.Line)
503
+ * .setPosition(1, 1, 0, 0)
504
+ * .setALLSeriesStyle({
505
+ * chartType: ChartTypeBits.Line,
506
+ * rightYAxis: false,
507
+ * color: '#ff0000',
508
+ * fillOpacity: 0.5,
509
+ * border: {
510
+ * color: '#00ff00',
511
+ * opacity: 0.5,
512
+ * width: 1,
513
+ * dashType: ChartBorderDashType.Solid,
514
+ * })
515
+ * .build();
516
+ * fSheet.insertChart(chartInfo);
517
+ * ```
518
+ */
519
+ setAllSeriesStyle(allSeriesStyle: IAllSeriesStyle): FChartBuilderBase;
520
+ /**
521
+ * Sets the series style by series index.
522
+ * @description Like setALLSeriesStyle, this difference is the style only set for the provide sty
523
+ * @param {number | string} index The index of the series to set the style for.
524
+ * @param {ISeriesStyle} seriesStyle The style for the series.
525
+ * @returns {FChartBuilderBase} -this builder, for chaining.
526
+ * @example
527
+ * ```ts
528
+ * const fWorkbook = univerAPI.getActiveWorkbook();
529
+ * const fSheet = fWorkbook.getActiveSheet();
530
+ * const chartBuilder = fSheet.newChart();
531
+ * const chartInfo = chartBuilder.addRange('A1:D6').setChartType(2).setPosition(1, 1, 0, 0).build();
532
+ * const fChart = await fSheet.insertChart(chartInfo);
533
+ * // should wait the chart rendered
534
+ * setTimeout( () => {
535
+ * if (fChart) {
536
+ * const chartBuilder = fSheet.newChart(fChart);
537
+ * // get the series data
538
+ * const first = fChart.getSeriesData()[0];
539
+ * chartBuilder.setSeriesStyle(first.index, {
540
+ * color: '#ff0000',
541
+ * }).build();
542
+ * fSheet.updateChart(chartBuilder);
543
+ * }
544
+ * }
545
+ * , 1000);
546
+ * ```
547
+ */
548
+ setSeriesStyle(index: number | string, seriesStyle: ISeriesStyle): FChartBuilderBase;
549
+ /**
550
+ * Builds the chart to reflect all changes made to it.
551
+ * @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).
552
+ * @returns {IChartBuilderInfo} -The chart builder info.
553
+ * @example
554
+ * ```ts
555
+ * const fWorkbook = univerAPI.getActiveWorkbook();
556
+ * const fSheet = fWorkbook.getActiveSheet();
557
+ * const chartBuilder = fSheet.newChart();
558
+ * const chartInfo = chartBuilder.addRange('A1:D6')
559
+ * .setChartType(ChartTypeBits.Column)
560
+ * .setPosition(1, 1, 0, 0)
561
+ * .setWidth(600)
562
+ * .setHeight(400)
563
+ * .build();
564
+ * fSheet.insertChart(chartInfo);
565
+ * ```
566
+ */
567
+ build(): IChartBuilderInfo;
568
+ }
@@ -0,0 +1,55 @@
1
+ import { AreaLineStyle, LinePointShape } from '@univerjs-pro/sheets-chart';
2
+ import { Injector, Workbook } from '@univerjs/core';
3
+ import { IChartBuilderInfo, FChartBuilderBase } from './chart-builder-base';
4
+ export declare class LineChartBuilder extends FChartBuilderBase {
5
+ lineStyle: AreaLineStyle;
6
+ dataPointShape: LinePointShape;
7
+ dataPointColor: string;
8
+ dataPointSize: number;
9
+ constructor(unitId: string, subUnitId: string, workbook: Workbook, injector: Injector, chartId?: string);
10
+ /**
11
+ * The line style of the area chart.
12
+ * @param lineStyle
13
+ * @returns - The builder, for chaining.
14
+ */
15
+ setLineStyle(lineStyle: AreaLineStyle): LineChartBuilder;
16
+ /**
17
+ * The shape of the data point in the line chart.
18
+ * @param dataPointShape
19
+ * @returns - The builder, for chaining.
20
+ */
21
+ setDataPointShape(dataPointShape: LinePointShape): LineChartBuilder;
22
+ /**
23
+ * The color of the data point in the line chart.
24
+ * @param dataPointColor
25
+ * @returns - The builder, for chaining.
26
+ */
27
+ setDataPointColor(dataPointColor: string): LineChartBuilder;
28
+ /**
29
+ * The size of the data point in the line chart.
30
+ * @param dataPointSize
31
+ * @returns - The builder, for chaining.
32
+ */
33
+ setDataPointSize(dataPointSize: number): LineChartBuilder;
34
+ /**
35
+ * Builds the chart to reflect all changes made to it.
36
+ * @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).
37
+ * @returns {IChartBuilderInfo} The chart builder info.
38
+ * @example
39
+ * ```ts
40
+ * const fWorkbook = univerAPI.getActiveWorkbook();
41
+ * const fSheet = fWorkbook.getActiveSheet();
42
+ * const chartBuilder = fSheet.newChart().asLineChart();
43
+ * const chartInfo = chartBuilder.addRange('A1:B8')
44
+ * .setLineStyle('smooth') // AreaLineStyle.Smooth
45
+ * .setDataPointShape('triangle')
46
+ * .setDataPointSize(10)
47
+ * .build();
48
+ * fSheet.insertChart(chartInfo);
49
+ * ```
50
+ */
51
+ build(): IChartBuilderInfo;
52
+ }
53
+ export declare class LineChartBuilderMixin extends FChartBuilderBase {
54
+ asLineChart(): LineChartBuilder;
55
+ }