Skip to content

Commit 314b5db

Browse files
Merge pull request #463 from SyncfusionExamples/AdvancedChart
ES-974686-Analyze the use case of Treemap, Sunburst, Histogram, Histogram (Pareto), Box & Whisker, and Funnel charts and get the code snippet for UG documentation
2 parents aaad2d2 + 7544b8f commit 314b5db

File tree

24 files changed

+707
-0
lines changed

24 files changed

+707
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30804.86
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
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}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {404A7F36-0167-4219-AE4D-2B0626CEB7E3}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Create-box-and-whisker-chart</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Output\.gitkeep">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
</ItemGroup>
18+
19+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using System.IO;
2+
using Syncfusion.DocIO;
3+
using Syncfusion.DocIO.DLS;
4+
using Syncfusion.OfficeChart;
5+
6+
namespace Create_box_and_whisker_chart
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
using (WordDocument document = new WordDocument())
13+
{
14+
IWSection section = document.AddSection();
15+
IWParagraph paragraph = section.AddParagraph();
16+
17+
WChart chart = paragraph.AppendChart(500f, 300f);
18+
chart.ChartType = OfficeChartType.BoxAndWhisker;
19+
chart.ChartTitle = "Academic Score - Box & Whisker Chart";
20+
21+
// Set headers
22+
chart.ChartData.SetValue(1, 1, "Course");
23+
chart.ChartData.SetValue(1, 2, "School A");
24+
chart.ChartData.SetValue(1, 3, "School B");
25+
chart.ChartData.SetValue(1, 4, "School C");
26+
27+
// Add data rows
28+
string[,] data = {
29+
{"English", "63", "53", "45"},
30+
{"Physics", "61", "55", "65"},
31+
{"English", "63", "50", "65"},
32+
{"Math", "62", "51", "64"},
33+
{"English", "46", "53", "66"},
34+
{"English", "58", "56", "67"},
35+
{"Math", "60", "51", "67"},
36+
{"Math", "62", "53", "66"},
37+
{"English", "63", "54", "64"},
38+
{"English", "63", "52", "67"},
39+
{"Physics", "60", "56", "64"},
40+
{"English", "60", "56", "67"},
41+
{"Math", "61", "56", "45"},
42+
{"Math", "63", "58", "64"},
43+
{"English", "59", "54", "65"}
44+
};
45+
46+
for (int i = 0; i < data.GetLength(0); i++)
47+
{
48+
chart.ChartData.SetValue(i + 2, 1, data[i, 0]); // Course name
49+
chart.ChartData.SetValue(i + 2, 2, int.Parse(data[i, 1])); // School A
50+
chart.ChartData.SetValue(i + 2, 3, int.Parse(data[i, 2])); // School B
51+
chart.ChartData.SetValue(i + 2, 4, int.Parse(data[i, 3])); // School C
52+
}
53+
54+
// Set data range and chart properties
55+
chart.DataRange = chart.ChartData[2, 1, data.GetLength(0) + 1, 4];
56+
57+
chart.PrimaryCategoryAxis.Title = "Subjects";
58+
chart.PrimaryValueAxis.Title = "Scores";
59+
chart.PrimaryValueAxis.MinimumValue = 0;
60+
chart.PrimaryValueAxis.MaximumValue = 70;
61+
62+
IOfficeChartSerie series = chart.Series[0];
63+
series.SerieFormat.ShowOutlierPoints = true;
64+
series.SerieFormat.ShowMeanMarkers = true;
65+
66+
series = chart.Series[1];
67+
series.SerieFormat.ShowOutlierPoints = true;
68+
series.SerieFormat.ShowMeanMarkers = true;
69+
70+
series = chart.Series[2];
71+
series.SerieFormat.ShowOutlierPoints = true;
72+
series.SerieFormat.ShowMeanMarkers = true;
73+
74+
// Set legend.
75+
chart.HasLegend = true;
76+
chart.Legend.Position = OfficeLegendPosition.Bottom;
77+
78+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
79+
{
80+
document.Save(outputFileStream, FormatType.Docx);
81+
}
82+
}
83+
}
84+
}
85+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30804.86
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-funnel-chart", "Create-funnel-chart\Create-funnel-chart.csproj", "{E214E65C-980A-46F5-8207-6D02212A49F5}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {404A7F36-0167-4219-AE4D-2B0626CEB7E3}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Create_funnel_chart</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Output\.gitkeep">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
</ItemGroup>
18+
19+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System.IO;
2+
using Syncfusion.DocIO;
3+
using Syncfusion.DocIO.DLS;
4+
using Syncfusion.OfficeChart;
5+
6+
namespace Create_funnel_chart
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
// Create a new Word document.
13+
using (WordDocument document = new WordDocument())
14+
{
15+
// Add a section and a paragraph.
16+
IWSection section = document.AddSection();
17+
// Add a paragraph to the section.
18+
IWParagraph paragraph = section.AddParagraph();
19+
20+
// Create and append the chart to the paragraph.
21+
WChart chart = paragraph.AppendChart(446, 270);
22+
// Set chart type.
23+
chart.ChartType = OfficeChartType.Funnel;
24+
25+
// Set chart title.
26+
chart.ChartTitle = "Sales Stages - Funnel Chart";
27+
28+
// Set headers.
29+
chart.ChartData.SetValue(1, 1, "Stage");
30+
chart.ChartData.SetValue(1, 2, "Amount");
31+
32+
// Add data rows.
33+
string[,] data = {
34+
{"Prospects", "500"},
35+
{"Qualified prospects", "425"},
36+
{"Needs analysis", "200"},
37+
{"Price quotes", "150"},
38+
{"Negotiations", "100"},
39+
{"Closed sales", "90"}
40+
};
41+
42+
for (int i = 0; i < data.GetLength(0); i++)
43+
{
44+
chart.ChartData.SetValue(i + 2, 1, data[i, 0]);
45+
chart.ChartData.SetValue(i + 2, 2, int.Parse(data[i, 1]));
46+
}
47+
48+
// Set data range.
49+
chart.DataRange = chart.ChartData[2, 1, 7, 2];
50+
51+
IOfficeChartSerie series = chart.Series[0];
52+
series.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
53+
series.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Inside;
54+
55+
// Set legend.
56+
chart.HasLegend = true;
57+
chart.Legend.Position = OfficeLegendPosition.Bottom;
58+
59+
// Save the document.
60+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
61+
{
62+
document.Save(outputFileStream, FormatType.Docx);
63+
}
64+
}
65+
}
66+
}
67+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30804.86
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-histogram-chart", "Create-histogram-chart\Create-histogram-chart.csproj", "{E214E65C-980A-46F5-8207-6D02212A49F5}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E214E65C-980A-46F5-8207-6D02212A49F5}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {404A7F36-0167-4219-AE4D-2B0626CEB7E3}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Create_histogram_chart</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Output\.gitkeep">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
</ItemGroup>
18+
19+
</Project>

0 commit comments

Comments
 (0)