diff --git a/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart.sln b/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart.sln new file mode 100644 index 000000000..2719cde3e --- /dev/null +++ b/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31911.196 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-clustered-column-chart", "Create-clustered-column-chart\Create-clustered-column-chart.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4} + EndGlobalSection +EndGlobal diff --git a/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart/Create-clustered-column-chart.csproj b/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart/Create-clustered-column-chart.csproj new file mode 100644 index 000000000..642ba3d61 --- /dev/null +++ b/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart/Create-clustered-column-chart.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + Create-clustered-column-chart + + + + + + + + + Always + + + + diff --git a/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart/Output/.gitkeep b/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart/Program.cs b/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart/Program.cs new file mode 100644 index 000000000..ff549e704 --- /dev/null +++ b/Charts/Create-clustered-column-chart/.NET/Create-clustered-column-chart/Program.cs @@ -0,0 +1,73 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.OfficeChart; +using System.IO; + + +//Loads the template document. +WordDocument document = new WordDocument(); +// Adds section to the document. +IWSection sec = document.AddSection(); +//Adds paragraph to the section. +IWParagraph paragraph = sec.AddParagraph(); +//Creates and Appends chart to the paragraph. +WChart chart = paragraph.AppendChart(446, 270); +chart.ChartType = OfficeChartType.Column_Clustered; +//Assign data +AddChartData(chart); +chart.IsSeriesInRows = false; +//Apply chart elements +//Set chart title +chart.ChartTitle = "Sales Report in Clustered Column Chart"; +//Set Datalabels +IOfficeChartSerie serie1 = chart.Series.Add("Amount(in $)"); +//Sets the data range of chart series – start row, start column, end row, end column +serie1.Values = chart.ChartData[2, 2, 6, 2]; +IOfficeChartSerie serie2 = chart.Series.Add("Count"); +//Sets the data range of chart series start row, start column, end row, end column +serie2.Values = chart.ChartData[2, 3, 6, 3]; +//Sets the data range of the category axis +chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 6, 1]; +serie1.DataPoints.DefaultDataPoint.DataLabels.IsValue = true; +serie2.DataPoints.DefaultDataPoint.DataLabels.IsValue = true; +serie1.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside; +serie2.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside; +//Set legend +chart.HasLegend = true; +chart.Legend.Position = OfficeLegendPosition.Bottom; +//Save the Word document +document.Save(Path.GetFullPath(@"Output/Output.docx")); + + +/// +/// Set the values for the chart +/// +/// Represent the instance of the chart + +static void AddChartData(WChart chart) +{ + //Set the value for chart data + chart.ChartData.SetValue(1, 1, "Items"); + chart.ChartData.SetValue(1, 2, "Amount(in $)"); + chart.ChartData.SetValue(1, 3, "Count"); + + chart.ChartData.SetValue(2, 1, "Beverages"); + chart.ChartData.SetValue(2, 2, 2776); + chart.ChartData.SetValue(2, 3, 925); + + chart.ChartData.SetValue(3, 1, "Condiments"); + chart.ChartData.SetValue(3, 2, 1077); + chart.ChartData.SetValue(3, 3, 378); + + chart.ChartData.SetValue(4, 1, "Confections"); + chart.ChartData.SetValue(4, 2, 2287); + chart.ChartData.SetValue(4, 3, 880); + + chart.ChartData.SetValue(5, 1, "Dairy Products"); + chart.ChartData.SetValue(5, 2, 1368); + chart.ChartData.SetValue(5, 3, 581); + + chart.ChartData.SetValue(6, 1, "Grains/Cereals"); + chart.ChartData.SetValue(6, 2, 3325); + chart.ChartData.SetValue(6, 3, 189); +} \ No newline at end of file