Skip to content

Commit 8ed5c49

Browse files
AlexJerabekCopilot
andauthored
[excel] (Charts) Add chart samples from charticle to ref docs (#404)
* Add chart samples from charticle to ref docs * Clean up comments * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Correct boolean --------- Co-authored-by: Copilot <[email protected]>
1 parent a6661c6 commit 8ed5c49

11 files changed

+3155
-1761
lines changed

docs/docs-ref-autogen/excelscript/excelscript.chart.yml

Lines changed: 95 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,25 @@ methods:
526526
content: 'getTitle(): ChartTitle;'
527527
return:
528528
type: <xref uid="ExcelScript!ExcelScript.ChartTitle:interface" />
529-
description: ''
529+
description: |-
530+
531+
532+
#### Examples
533+
534+
```TypeScript
535+
/**
536+
* This sample sets the title text for an existing chart.
537+
* This assumes the active worksheet has a chart.
538+
*/
539+
function main(workbook: ExcelScript.Workbook) {
540+
// Get the first chart on the active worksheet.
541+
const sheet = workbook.getActiveWorksheet();
542+
const chart = sheet.getCharts()[0];
543+
544+
// Set the chart title.
545+
chart.getTitle().setText("Quarterly Sales by Product");
546+
}
547+
```
530548
- name: getTop()
531549
uid: ExcelScript!ExcelScript.Chart#getTop:member(1)
532550
package: ExcelScript!
@@ -668,7 +686,25 @@ methods:
668686
type: number
669687
return:
670688
type: void
671-
description: ''
689+
description: |-
690+
691+
692+
#### Examples
693+
694+
```TypeScript
695+
/**
696+
* This sample sets the height of an existing chart.
697+
* This assumes the active worksheet has a chart.
698+
*/
699+
function main(workbook: ExcelScript.Workbook) {
700+
// Get the first chart on the active worksheet.
701+
const sheet = workbook.getActiveWorksheet();
702+
const chart = sheet.getCharts()[0];
703+
704+
// Set the chart height to 300 points.
705+
chart.setHeight(300);
706+
}
707+
```
672708
- name: setLeft(left)
673709
uid: ExcelScript!ExcelScript.Chart#setLeft:member(1)
674710
package: ExcelScript!
@@ -688,7 +724,25 @@ methods:
688724
type: number
689725
return:
690726
type: void
691-
description: ''
727+
description: |-
728+
729+
730+
#### Examples
731+
732+
```TypeScript
733+
/**
734+
* This sample sets the left position of an existing chart.
735+
* This assumes the active worksheet has a chart.
736+
*/
737+
function main(workbook: ExcelScript.Workbook) {
738+
// Get the first chart on the active worksheet.
739+
const sheet = workbook.getActiveWorksheet();
740+
const chart = sheet.getCharts()[0];
741+
742+
// Set the left position to 50 points from the left edge.
743+
chart.setLeft(50);
744+
}
745+
```
692746
- name: setName(name)
693747
uid: ExcelScript!ExcelScript.Chart#setName:member(1)
694748
package: ExcelScript!
@@ -934,7 +988,25 @@ methods:
934988
type: number
935989
return:
936990
type: void
937-
description: ''
991+
description: |-
992+
993+
994+
#### Examples
995+
996+
```TypeScript
997+
/**
998+
* This sample sets the top position of an existing chart.
999+
* This assumes the active worksheet has a chart.
1000+
*/
1001+
function main(workbook: ExcelScript.Workbook) {
1002+
// Get the first chart on the active worksheet.
1003+
const sheet = workbook.getActiveWorksheet();
1004+
const chart = sheet.getCharts()[0];
1005+
1006+
// Set the top position to 100 points from the top edge.
1007+
chart.setTop(100);
1008+
}
1009+
```
9381010
- name: setWidth(width)
9391011
uid: ExcelScript!ExcelScript.Chart#setWidth:member(1)
9401012
package: ExcelScript!
@@ -952,4 +1024,22 @@ methods:
9521024
type: number
9531025
return:
9541026
type: void
955-
description: ''
1027+
description: |-
1028+
1029+
1030+
#### Examples
1031+
1032+
```TypeScript
1033+
/**
1034+
* This sample sets the width of an existing chart.
1035+
* This assumes the active worksheet has a chart.
1036+
*/
1037+
function main(workbook: ExcelScript.Workbook) {
1038+
// Get the first chart on the active worksheet.
1039+
const sheet = workbook.getActiveWorksheet();
1040+
const chart = sheet.getCharts()[0];
1041+
1042+
// Set the chart width to 500 points.
1043+
chart.setWidth(500);
1044+
}
1045+
```

docs/docs-ref-autogen/excelscript/excelscript.chartaxes.yml

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@ uid: ExcelScript!ExcelScript.ChartAxes:interface
44
package: ExcelScript!
55
fullName: ExcelScript.ChartAxes
66
summary: Represents the chart axes.
7-
remarks: ''
7+
remarks: |-
8+
9+
10+
#### Examples
11+
12+
```TypeScript
13+
/**
14+
* This sample gets the chart axes and customizes them.
15+
* This assumes the active worksheet has a chart.
16+
*/
17+
function main(workbook: ExcelScript.Workbook) {
18+
// Get the first chart on the active worksheet.
19+
const sheet = workbook.getActiveWorksheet();
20+
const chart = sheet.getCharts()[0];
21+
22+
// Access and customize the axes.
23+
const axes = chart.getAxes();
24+
axes.getValueAxis().setDisplayUnit(ExcelScript.ChartAxisDisplayUnit.thousands);
25+
axes.getCategoryAxis().setVisible(true);
26+
}
27+
```
828
929
isPreview: false
1030
isDeprecated: false
@@ -23,7 +43,26 @@ methods:
2343
content: 'getCategoryAxis(): ChartAxis;'
2444
return:
2545
type: <xref uid="ExcelScript!ExcelScript.ChartAxis:interface" />
26-
description: ''
46+
description: |-
47+
48+
49+
#### Examples
50+
51+
```TypeScript
52+
/**
53+
* This sample gets and customizes the category axis.
54+
* This assumes the active worksheet has a chart.
55+
*/
56+
function main(workbook: ExcelScript.Workbook) {
57+
// Get the first chart on the active worksheet.
58+
const sheet = workbook.getActiveWorksheet();
59+
const chart = sheet.getCharts()[0];
60+
61+
// Get and customize the category axis.
62+
const categoryAxis = chart.getAxes().getCategoryAxis();
63+
categoryAxis.setTickLabelPosition(ExcelScript.ChartAxisTickLabelPosition.low);
64+
}
65+
```
2766
- name: getChartAxis(type, group)
2867
uid: ExcelScript!ExcelScript.ChartAxes#getChartAxis:member(1)
2968
package: ExcelScript!
@@ -76,4 +115,25 @@ methods:
76115
content: 'getValueAxis(): ChartAxis;'
77116
return:
78117
type: <xref uid="ExcelScript!ExcelScript.ChartAxis:interface" />
79-
description: ''
118+
description: |-
119+
120+
121+
#### Examples
122+
123+
```TypeScript
124+
/**
125+
* This sample gets and customizes the value axis.
126+
* This assumes the active worksheet has a chart.
127+
*/
128+
function main(workbook: ExcelScript.Workbook) {
129+
// Get the first chart on the active worksheet.
130+
const sheet = workbook.getActiveWorksheet();
131+
const chart = sheet.getCharts()[0];
132+
133+
// Get and customize the value axis.
134+
const valueAxis = chart.getAxes().getValueAxis();
135+
valueAxis.setDisplayUnit(ExcelScript.ChartAxisDisplayUnit.thousands);
136+
valueAxis.setMinimum(40000);
137+
valueAxis.setMaximum(60000);
138+
}
139+
```

0 commit comments

Comments
 (0)