@univerjs-pro/sheets-chart-ui 0.6.3 → 0.6.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.
@@ -27,24 +27,98 @@ export declare class LineChartBuilder extends FChartBuilderBase {
27
27
  * The line style of the area chart.
28
28
  * @param {AreaLineStyle} lineStyle The line style of the line chart.
29
29
  * @returns {LineChartBuilder} - The builder, for chaining.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const fWorkbook = univerAPI.getActiveWorkbook();
34
+ * const fWorksheet = fWorkbook.getActiveSheet();
35
+ *
36
+ * // Create a line chart builder with data source A1:D6.
37
+ * // The starting position is upper-left corner of cell B2.
38
+ * // The line style is set to the step type.
39
+ * const chartInfo = fWorksheet.newChart()
40
+ * .asLineChart()
41
+ * .addRange('A1:D6')
42
+ * .setPosition(1, 1, 0, 0)
43
+ * .setLineStyle('step')
44
+ * .build();
45
+ * await fWorksheet.insertChart(chartInfo);
46
+ * ```
30
47
  */
31
48
  setLineStyle(lineStyle: AreaLineStyle): this;
32
49
  /**
33
50
  * The shape of the data point in the line chart.
34
51
  * @param {LinePointShape} dataPointShape The shape of the data point in the line chart.
35
52
  * @returns {LineChartBuilder} - The builder, for chaining.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * const fWorkbook = univerAPI.getActiveWorkbook();
57
+ * const fWorksheet = fWorkbook.getActiveSheet();
58
+ *
59
+ * // Create a line chart with data source A1:D6.
60
+ * // The starting position is upper-left corner of cell B2.
61
+ * // The data point shape is set to circle, color is red, and size is 10.
62
+ * const chartInfo = fWorksheet.newChart()
63
+ * .asLineChart()
64
+ * .addRange('A1:D6')
65
+ * .setPosition(1, 1, 0, 0)
66
+ * .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
67
+ * .setDataPointColor('#ff0000')
68
+ * .setDataPointSize(10)
69
+ * .build();
70
+ * await fWorksheet.insertChart(chartInfo);
71
+ * ```
36
72
  */
37
73
  setDataPointShape(dataPointShape: LinePointShape): this;
38
74
  /**
39
75
  * The color of the data point in the line chart.
40
76
  * @param {string} dataPointColor The color of the data point in the line chart.
41
77
  * @returns {LineChartBuilder} The builder, for chaining.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const fWorkbook = univerAPI.getActiveWorkbook();
82
+ * const fWorksheet = fWorkbook.getActiveSheet();
83
+ *
84
+ * // Create a line chart with data source A1:D6.
85
+ * // The starting position is upper-left corner of cell B2.
86
+ * // The data point shape is set to circle, color is red, and size is 10.
87
+ * const chartInfo = fWorksheet.newChart()
88
+ * .asLineChart()
89
+ * .addRange('A1:D6')
90
+ * .setPosition(1, 1, 0, 0)
91
+ * .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
92
+ * .setDataPointColor('#ff0000')
93
+ * .setDataPointSize(10)
94
+ * .build();
95
+ * await fWorksheet.insertChart(chartInfo);
96
+ * ```
42
97
  */
43
98
  setDataPointColor(dataPointColor: string): this;
44
99
  /**
45
100
  * The size of the data point in the line chart.
46
101
  * @param {number} dataPointSize The size of the data point in the line chart.
47
102
  * @returns {LineChartBuilder} The builder, for chaining.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const fWorkbook = univerAPI.getActiveWorkbook();
107
+ * const fWorksheet = fWorkbook.getActiveSheet();
108
+ *
109
+ * // Create a line chart with data source A1:D6.
110
+ * // The starting position is upper-left corner of cell B2.
111
+ * // The data point shape is set to circle, color is red, and size is 10.
112
+ * const chartInfo = fWorksheet.newChart()
113
+ * .asLineChart()
114
+ * .addRange('A1:D6')
115
+ * .setPosition(1, 1, 0, 0)
116
+ * .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
117
+ * .setDataPointColor('#ff0000')
118
+ * .setDataPointSize(10)
119
+ * .build();
120
+ * await fWorksheet.insertChart(chartInfo);
121
+ * ```
48
122
  */
49
123
  setDataPointSize(dataPointSize: number): this;
50
124
  /**
@@ -54,15 +128,25 @@ export declare class LineChartBuilder extends FChartBuilderBase {
54
128
  *
55
129
  * @example
56
130
  * ```ts
131
+ * @example
132
+ * ```ts
57
133
  * const fWorkbook = univerAPI.getActiveWorkbook();
58
- * const fSheet = fWorkbook.getActiveSheet();
59
- * const chartBuilder = fSheet.newChart().asLineChart();
60
- * const chartInfo = chartBuilder.addRange('A1:B8')
61
- * .setLineStyle('smooth') // AreaLineStyle.Smooth
62
- * .setDataPointShape('triangle')
63
- * .setDataPointSize(10)
64
- * .build();
65
- * fSheet.insertChart(chartInfo);
134
+ * const fWorksheet = fWorkbook.getActiveSheet();
135
+ *
136
+ * // Create a line chart with data source A1:D6.
137
+ * // The starting position is upper-left corner of cell B2.
138
+ * // The line style is set to the step type.
139
+ * // The data point shape is set to circle, color is red, and size is 10.
140
+ * const chartInfo = fWorksheet.newChart()
141
+ * .asLineChart()
142
+ * .addRange('A1:D6')
143
+ * .setPosition(1, 1, 0, 0)
144
+ * .setLineStyle('step')
145
+ * .setDataPointShape(univerAPI.Enum.LinePointShape.CIRCLE)
146
+ * .setDataPointColor('#ff0000')
147
+ * .setDataPointSize(10)
148
+ * .build();
149
+ * await fWorksheet.insertChart(chartInfo);
66
150
  * ```
67
151
  */
68
152
  build(): IChartBuilderInfo;
@@ -16,36 +16,138 @@ export declare class PieChartBuilder extends FChartBuilderBase {
16
16
  * Sets the size of the hole in the center of the pie chart as a percentage of the chart size.The value should be in the range 0-1.
17
17
  * @param {number} doughnutHole The size of the hole in the center of the pie chart as a percentage of the chart size.
18
18
  * @returns {PieChartBuilder} this builder, for chaining.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const fWorkbook = univerAPI.getActiveWorkbook();
23
+ * const fWorksheet = fWorkbook.getActiveSheet();
24
+ *
25
+ * // Create a pie chart with data source A1:D6.
26
+ * // The starting position is upper-left corner of cell B2.
27
+ * // The doughnut hole is set to 0.5.
28
+ * const chartInfo = fWorksheet.newChart()
29
+ * .asPieChart()
30
+ * .addRange('A1:D6')
31
+ * .setPosition(1, 1, 0, 0)
32
+ * .setDoughnutHole(0.5)
33
+ * .build();
34
+ * await fWorksheet.insertChart(chartInfo);
35
+ * ```
19
36
  */
20
37
  setDoughnutHole(doughnutHole: number): this;
21
38
  /**
22
39
  * Sets the color of the border around the pie chart.
23
40
  * @param {string} borderColor The color of the border around the pie chart.
24
41
  * @returns {PieChartBuilder} this builder, for chaining.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const fWorkbook = univerAPI.getActiveWorkbook();
46
+ * const fWorksheet = fWorkbook.getActiveSheet();
47
+ *
48
+ * // Create a pie chart with data source A1:D6.
49
+ * // The starting position is upper-left corner of cell B2.
50
+ * // The border color is set to red.
51
+ * const chartInfo = fWorksheet.newChart()
52
+ * .asPieChart()
53
+ * .addRange('A1:D6')
54
+ * .setPosition(1, 1, 0, 0)
55
+ * .setBorderColor('#ff0000')
56
+ * .build();
57
+ * await fWorksheet.insertChart(chartInfo);
58
+ * ```
25
59
  */
26
60
  setBorderColor(borderColor: string): this;
27
61
  /**
28
62
  * Sets whether the pie chart has a padding angle.
29
63
  * @param {boolean} hasPaddingAngle True if the pie chart has a padding angle; false otherwise.
30
64
  * @returns {PieChartBuilder} this builder, for chaining.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const fWorkbook = univerAPI.getActiveWorkbook();
69
+ * const fWorksheet = fWorkbook.getActiveSheet();
70
+ *
71
+ * // Create a pie chart with data source A1:D6.
72
+ * // The starting position is upper-left corner of cell B2.
73
+ * // The pie chart has a padding angle.
74
+ * const chartInfo = fWorksheet.newChart()
75
+ * .asPieChart()
76
+ * .addRange('A1:D6')
77
+ * .setPosition(1, 1, 0, 0)
78
+ * .setHasPaddingAngle(true)
79
+ * .build();
80
+ * await fWorksheet.insertChart(chartInfo);
81
+ * ```
31
82
  */
32
83
  setHasPaddingAngle(hasPaddingAngle: boolean): this;
33
84
  /**
34
85
  * Sets whether the pie chart is a half pie chart.
35
86
  * @param {boolean} isHalfPie True if the pie chart is a half pie chart; false otherwise.
36
87
  * @returns {PieChartBuilder} this builder, for chaining.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const fWorkbook = univerAPI.getActiveWorkbook();
92
+ * const fWorksheet = fWorkbook.getActiveSheet();
93
+ *
94
+ * // Create a pie chart with data source A1:D6.
95
+ * // The starting position is upper-left corner of cell B2.
96
+ * // The pie chart is a half pie chart.
97
+ * const chartInfo = fWorksheet.newChart()
98
+ * .asPieChart()
99
+ * .addRange('A1:D6')
100
+ * .setPosition(1, 1, 0, 0)
101
+ * .setIsHalfPie(true)
102
+ * .build();
103
+ * await fWorksheet.insertChart(chartInfo);
104
+ * ```
37
105
  */
38
106
  setIsHalfPie(isHalfPie: boolean): this;
39
107
  /**
40
108
  * Sets whether the pie chart is a rose pie chart.
41
109
  * @param {boolean} rosePie True if the pie chart is a rose pie chart; false otherwise.
42
110
  * @returns {PieChartBuilder} this builder, for chaining.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * const fWorkbook = univerAPI.getActiveWorkbook();
115
+ * const fWorksheet = fWorkbook.getActiveSheet();
116
+ *
117
+ * // Create a pie chart with data source A1:D6.
118
+ * // The starting position is upper-left corner of cell B2.
119
+ * // The pie chart is a rose pie chart.
120
+ * const chartInfo = fWorksheet.newChart()
121
+ * .asPieChart()
122
+ * .addRange('A1:D6')
123
+ * .setPosition(1, 1, 0, 0)
124
+ * .setRosePie(true)
125
+ * .build();
126
+ * await fWorksheet.insertChart(chartInfo);
127
+ * ```
43
128
  */
44
129
  setRosePie(rosePie: boolean): this;
45
130
  /**
46
131
  * Sets whether the pie chart shows label lines.
47
132
  * @param {boolean} showLabelLine True if the pie chart shows label lines; false otherwise.
48
133
  * @returns {PieChartBuilder} this builder, for chaining.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * const fWorkbook = univerAPI.getActiveWorkbook();
138
+ * const fWorksheet = fWorkbook.getActiveSheet();
139
+ *
140
+ * // Create a pie chart with data source A1:D6.
141
+ * // The starting position is upper-left corner of cell B2.
142
+ * // The pie chart does not show label lines.
143
+ * const chartInfo = fWorksheet.newChart()
144
+ * .asPieChart()
145
+ * .addRange('A1:D6')
146
+ * .setPosition(1, 1, 0, 0)
147
+ * .setShowLabelLine(false)
148
+ * .build();
149
+ * await fWorksheet.insertChart(chartInfo);
150
+ * ```
49
151
  */
50
152
  setShowLabelLine(showLabelLine: boolean): this;
51
153
  /**
@@ -56,16 +158,24 @@ export declare class PieChartBuilder extends FChartBuilderBase {
56
158
  * @example
57
159
  * ```ts
58
160
  * const fWorkbook = univerAPI.getActiveWorkbook();
59
- * const fSheet = fWorkbook.getActiveSheet();
60
- * const chartBuilder = fSheet.newChart().asPieChart();
61
- * const chartInfo = chartBuilder.addRange('A1:B8')
62
- * .setChartType(univerAPI.Enum.ChartType.Pie)
63
- * .setDoughnutHole(0.5)
64
- * .setBorderColor('#ff0000')
65
- * .setHasPaddingAngle(true)
66
- * .setIsHalfPie(true)
67
- * .build();
68
- * fSheet.insertChart(chartInfo);
161
+ * const fWorksheet = fWorkbook.getActiveSheet();
162
+ *
163
+ * // Create a pie chart with data source A1:D6.
164
+ * // The starting position is upper-left corner of cell B2.
165
+ * // The doughnut hole is set to 0.5.
166
+ * // The border color is set to red.
167
+ * // The pie chart has a padding angle.
168
+ * // The pie chart is a half pie chart.
169
+ * const chartInfo = fWorksheet.newChart()
170
+ * .asPieChart()
171
+ * .addRange('A1:D6')
172
+ * .setPosition(1, 1, 0, 0)
173
+ * .setDoughnutHole(0.5)
174
+ * .setBorderColor('#ff0000')
175
+ * .setHasPaddingAngle(true)
176
+ * .setIsHalfPie(true)
177
+ * .build();
178
+ * await fWorksheet.insertChart(chartInfo);
69
179
  * ```
70
180
  */
71
181
  build(): IChartBuilderInfo;
@@ -22,14 +22,20 @@ export declare class RadarChartBuilder extends FChartBuilderBase {
22
22
  *
23
23
  * @example
24
24
  * ```ts
25
- * // import { ChartTypeBits, RadarShape } from '@univerjs-pro/sheets-chart';
26
25
  * const fWorkbook = univerAPI.getActiveWorkbook();
27
- * const fSheet = fWorkbook.getActiveSheet();
28
- * const chartBuilder = fSheet.newChart().asRadarChart();
29
- * const chartInfo = chartBuilder.addRange('A1:B8')
30
- * .setShape(RadarShape.Polygon)
31
- * .build();
32
- * fSheet.insertChart(chartInfo);
26
+ * const fWorksheet = fWorkbook.getActiveSheet();
27
+ *
28
+ * // Create a radar chart with data source A1:D6.
29
+ * // The starting position is upper-left corner of cell B2.
30
+ * // The shape of the radar chart is set to polygon and filled with red color.
31
+ * const chartInfo = fWorksheet.newChart()
32
+ * .asRadarChart()
33
+ * .addRange('A1:D6')
34
+ * .setPosition(1, 1, 0, 0)
35
+ * .setShape(univerAPI.Enum.RadarShape.Polygon)
36
+ * .setFill(true)
37
+ * .build();
38
+ * await fWorksheet.insertChart(chartInfo);
33
39
  * ```
34
40
  */
35
41
  setShape(shape: RadarShape): this;
@@ -40,14 +46,20 @@ export declare class RadarChartBuilder extends FChartBuilderBase {
40
46
  *
41
47
  * @example
42
48
  * ```ts
43
- * // import { ChartTypeBits } from '@univerjs-pro/sheets-chart';
44
49
  * const fWorkbook = univerAPI.getActiveWorkbook();
45
- * const fSheet = fWorkbook.getActiveSheet();
46
- * const chartBuilder = fSheet.newChart().asRadarChart();
47
- * const chartInfo = chartBuilder.addRange('A1:B8')
48
- * .setFill(true)
49
- * .build();
50
- * fSheet.insertChart(chartInfo);
50
+ * const fWorksheet = fWorkbook.getActiveSheet();
51
+ *
52
+ * // Create a radar chart with data source A1:D6.
53
+ * // The starting position is upper-left corner of cell B2.
54
+ * // The shape of the radar chart is set to polygon and filled with red color.
55
+ * const chartInfo = fWorksheet.newChart()
56
+ * .asRadarChart()
57
+ * .addRange('A1:D6')
58
+ * .setPosition(1, 1, 0, 0)
59
+ * .setShape(univerAPI.Enum.RadarShape.Polygon)
60
+ * .setFill(true)
61
+ * .build();
62
+ * await fWorksheet.insertChart(chartInfo);
51
63
  * ```
52
64
  */
53
65
  setFill(fill: boolean): this;
@@ -58,16 +70,20 @@ export declare class RadarChartBuilder extends FChartBuilderBase {
58
70
  *
59
71
  * @example
60
72
  * ```ts
61
- * // import { ChartTypeBits } from '@univerjs-pro/sheets-chart';
62
73
  * const fWorkbook = univerAPI.getActiveWorkbook();
63
- * const fSheet = fWorkbook.getActiveSheet();
64
- * const chartBuilder = fSheet.newChart().asRadarChart();
65
- * const chartInfo = chartBuilder.addRange('A1:B8')
66
- * .setChartType(univerAPI.Enum.ChartType.Radar)
67
- * .setShape(RadarShape.Polygon)
68
- * .setFill(true)
69
- * .build();
70
- * fSheet.insertChart(chartInfo);
74
+ * const fWorksheet = fWorkbook.getActiveSheet();
75
+ *
76
+ * // Create a radar chart with data source A1:D6.
77
+ * // The starting position is upper-left corner of cell B2.
78
+ * // The shape of the radar chart is set to polygon and filled with red color.
79
+ * const chartInfo = fWorksheet.newChart()
80
+ * .asRadarChart()
81
+ * .addRange('A1:D6')
82
+ * .setPosition(1, 1, 0, 0)
83
+ * .setShape(univerAPI.Enum.RadarShape.Polygon)
84
+ * .setFill(true)
85
+ * .build();
86
+ * await fWorksheet.insertChart(chartInfo);
71
87
  * ```
72
88
  */
73
89
  build(): IChartBuilderInfo;
@@ -23,30 +23,49 @@ export declare class FChart {
23
23
  /**
24
24
  * Get the chart id.
25
25
  * @returns {string} The chart id.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const fWorkbook = univerAPI.getActiveWorkbook();
30
+ * const fWorksheet = fWorkbook.getActiveSheet();
31
+ * const charts = fWorksheet.getCharts();
32
+ * console.log(charts[0]?.getChartId());
33
+ * ```
26
34
  */
27
35
  getChartId(): string;
28
36
  /**
29
37
  * Get the range of the chart.
30
38
  * @returns {ISheetChartSourceSingleRange|undefined} The range of the chart.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const fWorkbook = univerAPI.getActiveWorkbook();
43
+ * const fWorksheet = fWorkbook.getActiveSheet();
44
+ * const charts = fWorksheet.getCharts();
45
+ * console.log(charts[0]?.getRange());
46
+ * ```
31
47
  */
32
48
  getRange(): ISheetChartSourceSingleRange | undefined;
33
49
  /**
34
50
  * Update the range info of the chart. The range info includes the range of the chart and the direction in source.
35
- * @param rangeInfo The new range of the chart.
36
- * @param rangeInfo.range.range The new range of the chart.
37
- * @param rangeInfo.range.subUnitId The new sheet id of the chart.
38
- * @param rangeInfo.range.unitId The new workbook id of the chart.
51
+ * @param {ISheetChartSourceSingleRange} rangeInfo The new range of the chart.
52
+ * @param {IRange} rangeInfo.range.range The new range of the chart.
53
+ * @param {string} rangeInfo.range.subUnitId The new sheet id of the chart.
54
+ * @param {string} rangeInfo.range.unitId The new workbook id of the chart.
39
55
  * @param {boolean} [rangeInfo.isRowDirection] Is treat row as category.
40
56
  * @returns {Promise<boolean>} Whether the update is successful.
41
57
  *
42
58
  * @example
43
59
  * ```ts
44
60
  * const fWorkbook = univerAPI.getActiveWorkbook();
45
- * const fSheet = fWorkbook.getActiveSheet();
46
- * const charts = fSheet.getCharts();
47
- * // switch chart row direction
61
+ * const fWorksheet = fWorkbook.getActiveSheet();
62
+ *
63
+ * // Get all charts on the active sheet.
64
+ * const charts = fWorksheet.getCharts();
65
+ *
66
+ * // Switch chart row direction
48
67
  * if (charts.length > 0){
49
- * const rangeInfo = {...charts[0].getRange()}
68
+ * const rangeInfo = { ...charts[0].getRange() };
50
69
  * rangeInfo.isRowDirection = !rangeInfo.isRowDirection;
51
70
  * charts[0].updateRange(rangeInfo);
52
71
  * }
@@ -66,8 +85,8 @@ export declare class FChart {
66
85
  * @example
67
86
  * ```ts
68
87
  * const fWorkbook = univerAPI.getActiveWorkbook();
69
- * const fSheet = fWorkbook.getActiveSheet();
70
- * const charts = fSheet.getCharts();
88
+ * const fWorksheet = fWorkbook.getActiveSheet();
89
+ * const charts = fWorksheet.getCharts();
71
90
  * if (charts.length > 0){
72
91
  * const seriesData = charts[0].getSeriesData();
73
92
  * console.log(seriesData);
@@ -90,8 +109,8 @@ export declare class FChart {
90
109
  * @example
91
110
  * ```ts
92
111
  * const fWorkbook = univerAPI.getActiveWorkbook();
93
- * const fSheet = fWorkbook.getActiveSheet();
94
- * const charts = fSheet.getCharts();
112
+ * const fWorksheet = fWorkbook.getActiveSheet();
113
+ * const charts = fWorksheet.getCharts();
95
114
  * if (charts.length > 0){
96
115
  * const categoryData = charts[0].getCategoryData();
97
116
  * console.log(categoryData);