From 1516d069a87eb149677f6815a263d248b3a306c0 Mon Sep 17 00:00:00 2001 From: Sushma-SF4796 Date: Wed, 10 Sep 2025 11:28:13 +0530 Subject: [PATCH 1/5] Added sample for funnel, histogram, pareto and box and whisker --- .../.NET/Create-box-and-whisker-chart.sln | 25 ++++++ .../Create-box-and-whisker-chart.csproj | 19 +++++ .../Output/.gitkeep | 1 + .../Create-box-and-whisker-chart/Program.cs | 85 +++++++++++++++++++ .../.NET/Create-funnel-chart.sln | 25 ++++++ .../Create-funnel-chart.csproj | 19 +++++ .../.NET/Create-funnel-chart/Output/.gitkeep | 1 + .../.NET/Create-funnel-chart/Program.cs | 67 +++++++++++++++ .../.NET/Create-histogram-chart.sln | 25 ++++++ .../Create-histogram-chart.csproj | 19 +++++ .../Create-histogram-chart/Output/.gitkeep | 1 + .../.NET/Create-histogram-chart/Program.cs | 56 ++++++++++++ .../.NET/Create-pareto-chart.sln | 25 ++++++ .../Create-pareto-chart.csproj | 19 +++++ .../.NET/Create-pareto-chart/Output/.gitkeep | 1 + .../.NET/Create-pareto-chart/Program.cs | 74 ++++++++++++++++ 16 files changed, 462 insertions(+) create mode 100644 Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart.sln create mode 100644 Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Create-box-and-whisker-chart.csproj create mode 100644 Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Output/.gitkeep create mode 100644 Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Program.cs create mode 100644 Charts/Create-funnel-chart/.NET/Create-funnel-chart.sln create mode 100644 Charts/Create-funnel-chart/.NET/Create-funnel-chart/Create-funnel-chart.csproj create mode 100644 Charts/Create-funnel-chart/.NET/Create-funnel-chart/Output/.gitkeep create mode 100644 Charts/Create-funnel-chart/.NET/Create-funnel-chart/Program.cs create mode 100644 Charts/Create-histogram-chart/.NET/Create-histogram-chart.sln create mode 100644 Charts/Create-histogram-chart/.NET/Create-histogram-chart/Create-histogram-chart.csproj create mode 100644 Charts/Create-histogram-chart/.NET/Create-histogram-chart/Output/.gitkeep create mode 100644 Charts/Create-histogram-chart/.NET/Create-histogram-chart/Program.cs create mode 100644 Charts/Create-pareto-chart/.NET/Create-pareto-chart.sln create mode 100644 Charts/Create-pareto-chart/.NET/Create-pareto-chart/Create-pareto-chart.csproj create mode 100644 Charts/Create-pareto-chart/.NET/Create-pareto-chart/Output/.gitkeep create mode 100644 Charts/Create-pareto-chart/.NET/Create-pareto-chart/Program.cs diff --git a/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart.sln b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart.sln new file mode 100644 index 000000000..868859e9f --- /dev/null +++ b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-box-and-whisker-chart", "Create-box-and-whisker-chart\Create-box-and-whisker-chart.csproj", "{E214E65C-980A-46F5-8207-6D02212A49F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {404A7F36-0167-4219-AE4D-2B0626CEB7E3} + EndGlobalSection +EndGlobal diff --git a/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Create-box-and-whisker-chart.csproj b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Create-box-and-whisker-chart.csproj new file mode 100644 index 000000000..5353aad2c --- /dev/null +++ b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Create-box-and-whisker-chart.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + Create-box-and-whisker-chart + + + + + + + + + Always + + + + diff --git a/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Output/.gitkeep b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Program.cs b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Program.cs new file mode 100644 index 000000000..31ff1c7a6 --- /dev/null +++ b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Program.cs @@ -0,0 +1,85 @@ +using System.IO; +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.OfficeChart; + +namespace Create_box_and_whisker_chart +{ + class Program + { + static void Main(string[] args) + { + using (WordDocument document = new WordDocument()) + { + IWSection section = document.AddSection(); + IWParagraph paragraph = section.AddParagraph(); + + WChart chart = paragraph.AppendChart(500f, 300f); + chart.ChartType = OfficeChartType.BoxAndWhisker; + chart.ChartTitle = "Box and whisker chart"; + + // Set headers + chart.ChartData.SetValue(1, 1, "Course"); + chart.ChartData.SetValue(1, 2, "School A"); + chart.ChartData.SetValue(1, 3, "School B"); + chart.ChartData.SetValue(1, 4, "School C"); + + // Add data rows + string[,] data = { + {"English", "63", "53", "45"}, + {"Physics", "61", "55", "65"}, + {"English", "63", "50", "65"}, + {"Math", "62", "51", "64"}, + {"English", "46", "53", "66"}, + {"English", "58", "56", "67"}, + {"Math", "60", "51", "67"}, + {"Math", "62", "53", "66"}, + {"English", "63", "54", "64"}, + {"English", "63", "52", "67"}, + {"Physics", "60", "56", "64"}, + {"English", "60", "56", "67"}, + {"Math", "61", "56", "45"}, + {"Math", "63", "58", "64"}, + {"English", "59", "54", "65"} + }; + + for (int i = 0; i < data.GetLength(0); i++) + { + chart.ChartData.SetValue(i + 2, 1, data[i, 0]); // Course name + chart.ChartData.SetValue(i + 2, 2, int.Parse(data[i, 1])); // School A + chart.ChartData.SetValue(i + 2, 3, int.Parse(data[i, 2])); // School B + chart.ChartData.SetValue(i + 2, 4, int.Parse(data[i, 3])); // School C + } + + // Set data range and chart properties + chart.DataRange = chart.ChartData[2, 1, data.GetLength(0) + 1, 4]; + + chart.PrimaryCategoryAxis.Title = "Subjects"; + chart.PrimaryValueAxis.Title = "Scores"; + chart.PrimaryValueAxis.MinimumValue = 0; + chart.PrimaryValueAxis.MaximumValue = 70; + + IOfficeChartSerie series = chart.Series[0]; + series.SerieFormat.ShowOutlierPoints = true; + series.SerieFormat.ShowMeanMarkers = true; + + series = chart.Series[1]; + series.SerieFormat.ShowOutlierPoints = true; + series.SerieFormat.ShowMeanMarkers = true; + + series = chart.Series[2]; + series.SerieFormat.ShowOutlierPoints = true; + series.SerieFormat.ShowMeanMarkers = true; + + // Set legend. + chart.HasLegend = true; + chart.Legend.Position = OfficeLegendPosition.Bottom; + + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + document.Save(outputFileStream, FormatType.Docx); + } + } + } + } +} diff --git a/Charts/Create-funnel-chart/.NET/Create-funnel-chart.sln b/Charts/Create-funnel-chart/.NET/Create-funnel-chart.sln new file mode 100644 index 000000000..cadec1d7a --- /dev/null +++ b/Charts/Create-funnel-chart/.NET/Create-funnel-chart.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-funnel-chart", "Create-funnel-chart\Create-funnel-chart.csproj", "{E214E65C-980A-46F5-8207-6D02212A49F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {404A7F36-0167-4219-AE4D-2B0626CEB7E3} + EndGlobalSection +EndGlobal diff --git a/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Create-funnel-chart.csproj b/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Create-funnel-chart.csproj new file mode 100644 index 000000000..005186301 --- /dev/null +++ b/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Create-funnel-chart.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + Create_funnel_chart + + + + + + + + + Always + + + + diff --git a/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Output/.gitkeep b/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Program.cs b/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Program.cs new file mode 100644 index 000000000..feb41cfeb --- /dev/null +++ b/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Program.cs @@ -0,0 +1,67 @@ +using System.IO; +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.OfficeChart; + +namespace Create_funnel_chart +{ + class Program + { + static void Main(string[] args) + { + // Create a new Word document. + using (WordDocument document = new WordDocument()) + { + // Add a section and a paragraph. + IWSection section = document.AddSection(); + // Add a paragraph to the section. + IWParagraph paragraph = section.AddParagraph(); + + // Create and append the chart to the paragraph. + WChart chart = paragraph.AppendChart(446, 270); + // Set chart type. + chart.ChartType = OfficeChartType.Funnel; + + // Set chart title. + chart.ChartTitle = "Sales Funnel"; + + // Set headers. + chart.ChartData.SetValue(1, 1, "Stage"); + chart.ChartData.SetValue(1, 2, "Amount"); + + // Add data rows. + string[,] data = { + {"Prospects", "500"}, + {"Qualified prospects", "425"}, + {"Needs analysis", "200"}, + {"Price quotes", "150"}, + {"Negotiations", "100"}, + {"Closed sales", "90"} + }; + + for (int i = 0; i < data.GetLength(0); i++) + { + chart.ChartData.SetValue(i + 2, 1, data[i, 0]); + chart.ChartData.SetValue(i + 2, 2, int.Parse(data[i, 1])); + } + + // Set data range. + chart.DataRange = chart.ChartData[2, 1, 7, 2]; + + IOfficeChartSerie series = chart.Series[0]; + series.DataPoints.DefaultDataPoint.DataLabels.IsValue = true; + series.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Inside; + + // Set legend. + chart.HasLegend = true; + chart.Legend.Position = OfficeLegendPosition.Bottom; + + // Save the document. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + document.Save(outputFileStream, FormatType.Docx); + } + } + } + } +} diff --git a/Charts/Create-histogram-chart/.NET/Create-histogram-chart.sln b/Charts/Create-histogram-chart/.NET/Create-histogram-chart.sln new file mode 100644 index 000000000..64aae0cf5 --- /dev/null +++ b/Charts/Create-histogram-chart/.NET/Create-histogram-chart.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-histogram-chart", "Create-histogram-chart\Create-histogram-chart.csproj", "{E214E65C-980A-46F5-8207-6D02212A49F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {404A7F36-0167-4219-AE4D-2B0626CEB7E3} + EndGlobalSection +EndGlobal diff --git a/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Create-histogram-chart.csproj b/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Create-histogram-chart.csproj new file mode 100644 index 000000000..fc14c2a3a --- /dev/null +++ b/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Create-histogram-chart.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + Create_histogram_chart + + + + + + + + + Always + + + + diff --git a/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Output/.gitkeep b/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Program.cs b/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Program.cs new file mode 100644 index 000000000..65ab33a61 --- /dev/null +++ b/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Program.cs @@ -0,0 +1,56 @@ +using System.IO; +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.OfficeChart; + +namespace Create_histogram_chart +{ + class Program + { + static void Main(string[] args) + { + // Create a new Word document. + using (WordDocument document = new WordDocument()) + { + IWSection sec = document.AddSection(); + IWParagraph paragraph = sec.AddParagraph(); + + // Create and append chart + WChart chart = paragraph.AppendChart(446, 270); + chart.ChartType = OfficeChartType.Histogram; + + // Set chart title + chart.ChartTitle = "Test Scores (in Histogram)"; + chart.ChartTitleArea.FontName = "Calibri"; + chart.ChartTitleArea.Size = 14; + + // Set chart data + chart.ChartData.SetValue(1, 1, "Test Score"); + int[] scores = { 20, 35, 40, 55, 80, 60, 61, 85, 80, 64, 80, 75 }; + for (int i = 0; i < scores.Length; i++) + { + chart.ChartData.SetValue(i + 2, 1, scores[i]); + } + // Set region of chart data. + chart.DataRange = chart.ChartData[2, 1, 13, 1]; + + // Set DataLabels. + IOfficeChartSerie series = chart.Series[0]; + series.DataPoints.DefaultDataPoint.DataLabels.IsValue = true; + series.Name = "Score"; + series.SerieFormat.CommonSerieOptions.GapWidth = 3; + + // Set legend. + chart.HasLegend = true; + chart.Legend.Position = OfficeLegendPosition.Bottom; + + // Create a file stream. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + // Save the Word document to the file stream. + document.Save(outputFileStream, FormatType.Docx); + } + } + } + } +} diff --git a/Charts/Create-pareto-chart/.NET/Create-pareto-chart.sln b/Charts/Create-pareto-chart/.NET/Create-pareto-chart.sln new file mode 100644 index 000000000..40dcafab4 --- /dev/null +++ b/Charts/Create-pareto-chart/.NET/Create-pareto-chart.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-pareto-chart", "Create-pareto-chart\Create-pareto-chart.csproj", "{E214E65C-980A-46F5-8207-6D02212A49F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {404A7F36-0167-4219-AE4D-2B0626CEB7E3} + EndGlobalSection +EndGlobal diff --git a/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Create-pareto-chart.csproj b/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Create-pareto-chart.csproj new file mode 100644 index 000000000..6ccae06e6 --- /dev/null +++ b/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Create-pareto-chart.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + Create_pareto_chart + + + + + + + + + Always + + + + diff --git a/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Output/.gitkeep b/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Program.cs b/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Program.cs new file mode 100644 index 000000000..e243c5958 --- /dev/null +++ b/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Program.cs @@ -0,0 +1,74 @@ +using System.IO; +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.OfficeChart; + +namespace Create_pareto_chart +{ + class Program + { + static void Main(string[] args) + { + // Create a new Word document. + using (WordDocument document = new WordDocument()) + { + // Add a section and a paragraph. + IWSection section = document.AddSection(); + IWParagraph paragraph = section.AddParagraph(); + // Create and append a Pareto chart. + WChart chart = paragraph.AppendChart(446, 270); + chart.ChartType = OfficeChartType.Pareto; + chart.ChartTitle = "Monthly Expenses - Pareto Chart"; + chart.ChartTitleArea.FontName = "Calibri"; + chart.ChartTitleArea.Size = 14; + + // Populate chart data in the internal worksheet. + chart.ChartData.SetValue(1, 1, "Expenses"); + chart.ChartData.SetValue(1, 2, "Amount"); + + chart.ChartData.SetValue(2, 1, "Rent"); + chart.ChartData.SetValue(2, 2, 2300); + + chart.ChartData.SetValue(3, 1, "Car payment"); + chart.ChartData.SetValue(3, 2, 1200); + + chart.ChartData.SetValue(4, 1, "Groceries"); + chart.ChartData.SetValue(4, 2, 900); + + chart.ChartData.SetValue(5, 1, "Electricity"); + chart.ChartData.SetValue(5, 2, 600); + + chart.ChartData.SetValue(6, 1, "Gas"); + chart.ChartData.SetValue(6, 2, 500); + + chart.ChartData.SetValue(7, 1, "Cable"); + chart.ChartData.SetValue(7, 2, 300); + + chart.ChartData.SetValue(8, 1, "Mobile"); + chart.ChartData.SetValue(8, 2, 200); + + // Define the data range for the chart. + chart.DataRange = chart.ChartData[1, 1, 8, 2]; + + // Format the right Y-axis to show percentage. + IOfficeChartAxis rightAxis = chart.SecondaryValueAxis; + rightAxis.Title = "Cumulative Percentage"; + + // Set gap width for the first series (bars) + IOfficeChartSerie series = chart.Series[0]; + series.SerieFormat.CommonSerieOptions.GapWidth = 3; + series.DataPoints.DefaultDataPoint.DataLabels.IsValue = true; + + // Set legend. + chart.HasLegend = true; + chart.Legend.Position = OfficeLegendPosition.Bottom; + + // Save the document. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + document.Save(outputFileStream, FormatType.Docx); + } + } + } + } +} From fb86f0fe95cce0fc2a718cbbaaa6b67fde0c6f45 Mon Sep 17 00:00:00 2001 From: Sushma-SF4796 Date: Wed, 10 Sep 2025 12:30:19 +0530 Subject: [PATCH 2/5] removed the version --- .../Create-box-and-whisker-chart.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Create-box-and-whisker-chart.csproj b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Create-box-and-whisker-chart.csproj index 5353aad2c..3e13032f5 100644 --- a/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Create-box-and-whisker-chart.csproj +++ b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Create-box-and-whisker-chart.csproj @@ -7,7 +7,7 @@ - + From c768884c4f97a687efc0e38da61ff5195dabc7b9 Mon Sep 17 00:00:00 2001 From: Sushma-SF4796 Date: Thu, 11 Sep 2025 16:02:06 +0530 Subject: [PATCH 3/5] Added changes --- .../.NET/Create-box-and-whisker-chart/Program.cs | 2 +- .../Create-funnel-chart/.NET/Create-funnel-chart/Program.cs | 2 +- .../.NET/Create-histogram-chart/Program.cs | 6 +++++- .../Create-pareto-chart/.NET/Create-pareto-chart/Program.cs | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Program.cs b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Program.cs index 31ff1c7a6..a7e129ac0 100644 --- a/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Program.cs +++ b/Charts/Create-box-and-whisker-chart/.NET/Create-box-and-whisker-chart/Program.cs @@ -16,7 +16,7 @@ static void Main(string[] args) WChart chart = paragraph.AppendChart(500f, 300f); chart.ChartType = OfficeChartType.BoxAndWhisker; - chart.ChartTitle = "Box and whisker chart"; + chart.ChartTitle = "Academic Score - Box & Whisker Chart"; // Set headers chart.ChartData.SetValue(1, 1, "Course"); diff --git a/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Program.cs b/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Program.cs index feb41cfeb..e9f65627e 100644 --- a/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Program.cs +++ b/Charts/Create-funnel-chart/.NET/Create-funnel-chart/Program.cs @@ -23,7 +23,7 @@ static void Main(string[] args) chart.ChartType = OfficeChartType.Funnel; // Set chart title. - chart.ChartTitle = "Sales Funnel"; + chart.ChartTitle = "Sales Stages - Funnel Chart"; // Set headers. chart.ChartData.SetValue(1, 1, "Stage"); diff --git a/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Program.cs b/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Program.cs index 65ab33a61..52aec0344 100644 --- a/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Program.cs +++ b/Charts/Create-histogram-chart/.NET/Create-histogram-chart/Program.cs @@ -20,7 +20,7 @@ static void Main(string[] args) chart.ChartType = OfficeChartType.Histogram; // Set chart title - chart.ChartTitle = "Test Scores (in Histogram)"; + chart.ChartTitle = "Test Scores - Histogram Chart"; chart.ChartTitleArea.FontName = "Calibri"; chart.ChartTitleArea.Size = 14; @@ -44,6 +44,10 @@ static void Main(string[] args) chart.HasLegend = true; chart.Legend.Position = OfficeLegendPosition.Bottom; + //Set x-axis and y-axis title + chart.PrimaryCategoryAxis.Title = "Score Range"; + chart.PrimaryValueAxis.Title = "Number Of Candidates"; + // Create a file stream. using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite)) { diff --git a/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Program.cs b/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Program.cs index e243c5958..7b19382f0 100644 --- a/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Program.cs +++ b/Charts/Create-pareto-chart/.NET/Create-pareto-chart/Program.cs @@ -41,10 +41,10 @@ static void Main(string[] args) chart.ChartData.SetValue(6, 1, "Gas"); chart.ChartData.SetValue(6, 2, 500); - chart.ChartData.SetValue(7, 1, "Cable"); + chart.ChartData.SetValue(7, 1, "House loan"); chart.ChartData.SetValue(7, 2, 300); - chart.ChartData.SetValue(8, 1, "Mobile"); + chart.ChartData.SetValue(8, 1, "Wifi bill"); chart.ChartData.SetValue(8, 2, 200); // Define the data range for the chart. From 027cd97596df37a0c2319c6c78c41cb23c91dd97 Mon Sep 17 00:00:00 2001 From: Sushma-SF4796 Date: Fri, 12 Sep 2025 16:23:24 +0530 Subject: [PATCH 4/5] Added samples for sunburst and treemap --- .../.NET/Create-sunburst-chart.sln | 25 ++++++++ .../Create-sunburst-chart.csproj | 19 ++++++ .../Create-sunburst-chart/Output/.gitkeep | 1 + .../.NET/Create-sunburst-chart/Program.cs | 58 +++++++++++++++++++ .../.NET/Create-treemap-chart.sln | 25 ++++++++ .../Create-treemap-chart.csproj | 19 ++++++ .../.NET/Create-treemap-chart/Output/.gitkeep | 1 + .../.NET/Create-treemap-chart/Program.cs | 24 ++++++++ 8 files changed, 172 insertions(+) create mode 100644 Charts/Create-sunburst-chart/.NET/Create-sunburst-chart.sln create mode 100644 Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Create-sunburst-chart.csproj create mode 100644 Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Output/.gitkeep create mode 100644 Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Program.cs create mode 100644 Charts/Create-treemap-chart/.NET/Create-treemap-chart.sln create mode 100644 Charts/Create-treemap-chart/.NET/Create-treemap-chart/Create-treemap-chart.csproj create mode 100644 Charts/Create-treemap-chart/.NET/Create-treemap-chart/Output/.gitkeep create mode 100644 Charts/Create-treemap-chart/.NET/Create-treemap-chart/Program.cs diff --git a/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart.sln b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart.sln new file mode 100644 index 000000000..d4328a193 --- /dev/null +++ b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-sunburst-chart", "Create-sunburst-chart\Create-sunburst-chart.csproj", "{E214E65C-980A-46F5-8207-6D02212A49F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {404A7F36-0167-4219-AE4D-2B0626CEB7E3} + EndGlobalSection +EndGlobal diff --git a/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Create-sunburst-chart.csproj b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Create-sunburst-chart.csproj new file mode 100644 index 000000000..2db3ece5e --- /dev/null +++ b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Create-sunburst-chart.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + Create_sunburst_chart + + + + + + + + + Always + + + + diff --git a/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Output/.gitkeep b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Program.cs b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Program.cs new file mode 100644 index 000000000..83b6a4960 --- /dev/null +++ b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Program.cs @@ -0,0 +1,58 @@ +using System.IO; +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.OfficeChart; + +namespace Create_pie_chart +{ + class Program + { + static void Main(string[] args) + { + //Create a new Word document. + using (WordDocument document = new WordDocument()) + { + //Add a section to the document. + IWSection section = document.AddSection(); + //Add a paragraph to the section. + IWParagraph paragraph = section.AddParagraph(); + //Create and append the chart to the paragraph. + WChart chart = paragraph.AppendChart(446, 270); + //Set chart type. + chart.ChartType = OfficeChartType.Pie; + //Set chart data. + chart.ChartData.SetValue(2, 1, "Food"); + chart.ChartData.SetValue(3, 1, "Fruits"); + chart.ChartData.SetValue(4, 1, "Vegetables"); + chart.ChartData.SetValue(5, 1, "Dairy"); + chart.ChartData.SetValue(6, 1, "Protein"); + chart.ChartData.SetValue(7, 1, "Grains"); + chart.ChartData.SetValue(2, 2, "Percentage"); + chart.ChartData.SetValue(3, 2, 36); + chart.ChartData.SetValue(4, 2, 14); + chart.ChartData.SetValue(5, 2, 13); + chart.ChartData.SetValue(6, 2, 28); + chart.ChartData.SetValue(7, 2, 9); + //Set region of Chart data. + chart.DataRange = chart.ChartData[2, 1, 7, 2]; + //Set chart series in the column for assigned data region. + chart.IsSeriesInRows = false; + //Set a Chart Title. + chart.ChartTitle = "Pie Chart"; + //Set Datalabels. + IOfficeChartSerie serie = chart.Series[0]; + + serie.DataPoints.DefaultDataPoint.DataLabels.IsValue = true; + //Set legend. + chart.HasLegend = true; + chart.Legend.Position = OfficeLegendPosition.Bottom; + //Create a file stream. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the Word document to the file stream. + document.Save(outputFileStream, FormatType.Docx); + } + } + } + } +} diff --git a/Charts/Create-treemap-chart/.NET/Create-treemap-chart.sln b/Charts/Create-treemap-chart/.NET/Create-treemap-chart.sln new file mode 100644 index 000000000..bd08c9a8c --- /dev/null +++ b/Charts/Create-treemap-chart/.NET/Create-treemap-chart.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-treemap-chart", "Create-treemap-chart\Create-treemap-chart.csproj", "{E214E65C-980A-46F5-8207-6D02212A49F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {404A7F36-0167-4219-AE4D-2B0626CEB7E3} + EndGlobalSection +EndGlobal diff --git a/Charts/Create-treemap-chart/.NET/Create-treemap-chart/Create-treemap-chart.csproj b/Charts/Create-treemap-chart/.NET/Create-treemap-chart/Create-treemap-chart.csproj new file mode 100644 index 000000000..1529ea875 --- /dev/null +++ b/Charts/Create-treemap-chart/.NET/Create-treemap-chart/Create-treemap-chart.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + Create_treemap_chart + + + + + + + + + Always + + + + diff --git a/Charts/Create-treemap-chart/.NET/Create-treemap-chart/Output/.gitkeep b/Charts/Create-treemap-chart/.NET/Create-treemap-chart/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Charts/Create-treemap-chart/.NET/Create-treemap-chart/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Charts/Create-treemap-chart/.NET/Create-treemap-chart/Program.cs b/Charts/Create-treemap-chart/.NET/Create-treemap-chart/Program.cs new file mode 100644 index 000000000..84c9e0268 --- /dev/null +++ b/Charts/Create-treemap-chart/.NET/Create-treemap-chart/Program.cs @@ -0,0 +1,24 @@ +using System.IO; +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.OfficeChart; + +namespace Create_pie_chart +{ + class Program + { + static void Main(string[] args) + { + //Create a new Word document. + using (WordDocument document = new WordDocument()) + { + + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the Word document to the file stream. + document.Save(outputFileStream, FormatType.Docx); + } + } + } + } +} From f15ccaad1cf45a28c8cd01104661e6dc991cc169 Mon Sep 17 00:00:00 2001 From: Sushma-SF4796 Date: Fri, 12 Sep 2025 16:25:36 +0530 Subject: [PATCH 5/5] reverted changes of pie from sunburst sample --- .../.NET/Create-sunburst-chart/Program.cs | 35 +------------------ 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Program.cs b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Program.cs index 83b6a4960..bffc4b2bc 100644 --- a/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Program.cs +++ b/Charts/Create-sunburst-chart/.NET/Create-sunburst-chart/Program.cs @@ -12,40 +12,7 @@ static void Main(string[] args) //Create a new Word document. using (WordDocument document = new WordDocument()) { - //Add a section to the document. - IWSection section = document.AddSection(); - //Add a paragraph to the section. - IWParagraph paragraph = section.AddParagraph(); - //Create and append the chart to the paragraph. - WChart chart = paragraph.AppendChart(446, 270); - //Set chart type. - chart.ChartType = OfficeChartType.Pie; - //Set chart data. - chart.ChartData.SetValue(2, 1, "Food"); - chart.ChartData.SetValue(3, 1, "Fruits"); - chart.ChartData.SetValue(4, 1, "Vegetables"); - chart.ChartData.SetValue(5, 1, "Dairy"); - chart.ChartData.SetValue(6, 1, "Protein"); - chart.ChartData.SetValue(7, 1, "Grains"); - chart.ChartData.SetValue(2, 2, "Percentage"); - chart.ChartData.SetValue(3, 2, 36); - chart.ChartData.SetValue(4, 2, 14); - chart.ChartData.SetValue(5, 2, 13); - chart.ChartData.SetValue(6, 2, 28); - chart.ChartData.SetValue(7, 2, 9); - //Set region of Chart data. - chart.DataRange = chart.ChartData[2, 1, 7, 2]; - //Set chart series in the column for assigned data region. - chart.IsSeriesInRows = false; - //Set a Chart Title. - chart.ChartTitle = "Pie Chart"; - //Set Datalabels. - IOfficeChartSerie serie = chart.Series[0]; - - serie.DataPoints.DefaultDataPoint.DataLabels.IsValue = true; - //Set legend. - chart.HasLegend = true; - chart.Legend.Position = OfficeLegendPosition.Bottom; + //Create a file stream. using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite)) {