Skip to content

Commit 1238f56

Browse files
Update chart-data.md
1 parent fd36beb commit 1238f56

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

libraries/radspreadprocessing/features/charts/chart-data.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,27 @@ The **FormulaChartData** type is abstract and it is implemented by the **Workboo
2929
#### [C#] Example 1: Using IChartData
3030
{{region radspreadprocessing-features-charts-chart-data_0}}
3131

32-
BarSeriesGroup barSeriesGroup = new BarSeriesGroup();
33-
34-
StringChartData barCategoryData = new StringChartData(new List<string> { "category 1", "category 2", "category 3" });
35-
NumericChartData barValueData = new NumericChartData(new List<double> { 1, 2, 3 });
36-
FormulaChartData barSeriesTitle = new WorkbookFormulaChartData(workbook, "Sheet1!A1");
37-
38-
barSeriesGroup.Series.Add(barCategoryData, barValueData, new FormulaTitle(barSeriesTitle));
39-
40-
DocumentChart chart = new DocumentChart();
41-
chart.SeriesGroups.Add(barSeriesGroup);
42-
43-
// Add the chart to the worksheet
44-
Worksheet worksheet = workbook.ActiveWorksheet;
45-
FloatingChartShape chartShape = new FloatingChartShape(worksheet, new CellIndex(6, 4), new CellRange(1, 1, 5, 2), ChartType.Column)
46-
{
47-
Width = 460,
48-
Height = 250
49-
};
50-
51-
worksheet.Charts.Add(chartShape);
32+
Workbook workbook = new Workbook();
33+
Worksheet worksheet = workbook.Worksheets.Add();
34+
FloatingChartShape chartShape = new FloatingChartShape(worksheet, new CellIndex(1, 1), new CellRange(1, 1, 1, 1), ChartType.Column)
35+
{
36+
Width = 400,
37+
Height = 200
38+
};
39+
40+
DocumentChart chart = chartShape.Chart;
41+
BarSeriesGroup barSeriesGroup = chart.SeriesGroups.First() as BarSeriesGroup;
42+
barSeriesGroup.BarDirection = BarDirection.Column;
43+
44+
StringChartData barCategoryData = new StringChartData(new List<string> { "New", "In Progress", "Ready for Test", "Done", "Declined" });
45+
NumericChartData barValueScore1Data = new NumericChartData(new List<double> { 75.31, 66.3, 62.78, 61.72, 63.9 });
46+
NumericChartData barValueScore2Data = new NumericChartData(new List<double> { 78.56, 70.7, 67.63, 66.71, 63.9 });
47+
barSeriesGroup.Series.Remove(barSeriesGroup.Series.First());
48+
barSeriesGroup.Series.Add(barCategoryData, barValueScore1Data);
49+
barSeriesGroup.Series.Add(barCategoryData, barValueScore2Data);
50+
worksheet.Charts.Add(chartShape);
51+
52+
worksheet.Charts[0].Chart.SeriesGroups.First().Series.First().Title = new TextTitle("Team 1");
53+
worksheet.Charts[0].Chart.SeriesGroups.First().Series.Last().Title = new TextTitle("Team 2");
54+
5255
{{endregion}}

0 commit comments

Comments
 (0)