Skip to content

Commit 027cd97

Browse files
committed
Added samples for sunburst and treemap
1 parent c768884 commit 027cd97

File tree

8 files changed

+172
-0
lines changed

8 files changed

+172
-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-sunburst-chart", "Create-sunburst-chart\Create-sunburst-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_sunburst_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: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System.IO;
2+
using Syncfusion.DocIO;
3+
using Syncfusion.DocIO.DLS;
4+
using Syncfusion.OfficeChart;
5+
6+
namespace Create_pie_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 to the document.
16+
IWSection section = document.AddSection();
17+
//Add a paragraph to the section.
18+
IWParagraph paragraph = section.AddParagraph();
19+
//Create and append the chart to the paragraph.
20+
WChart chart = paragraph.AppendChart(446, 270);
21+
//Set chart type.
22+
chart.ChartType = OfficeChartType.Pie;
23+
//Set chart data.
24+
chart.ChartData.SetValue(2, 1, "Food");
25+
chart.ChartData.SetValue(3, 1, "Fruits");
26+
chart.ChartData.SetValue(4, 1, "Vegetables");
27+
chart.ChartData.SetValue(5, 1, "Dairy");
28+
chart.ChartData.SetValue(6, 1, "Protein");
29+
chart.ChartData.SetValue(7, 1, "Grains");
30+
chart.ChartData.SetValue(2, 2, "Percentage");
31+
chart.ChartData.SetValue(3, 2, 36);
32+
chart.ChartData.SetValue(4, 2, 14);
33+
chart.ChartData.SetValue(5, 2, 13);
34+
chart.ChartData.SetValue(6, 2, 28);
35+
chart.ChartData.SetValue(7, 2, 9);
36+
//Set region of Chart data.
37+
chart.DataRange = chart.ChartData[2, 1, 7, 2];
38+
//Set chart series in the column for assigned data region.
39+
chart.IsSeriesInRows = false;
40+
//Set a Chart Title.
41+
chart.ChartTitle = "Pie Chart";
42+
//Set Datalabels.
43+
IOfficeChartSerie serie = chart.Series[0];
44+
45+
serie.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
46+
//Set legend.
47+
chart.HasLegend = true;
48+
chart.Legend.Position = OfficeLegendPosition.Bottom;
49+
//Create a file stream.
50+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
51+
{
52+
//Save the Word document to the file stream.
53+
document.Save(outputFileStream, FormatType.Docx);
54+
}
55+
}
56+
}
57+
}
58+
}
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-treemap-chart", "Create-treemap-chart\Create-treemap-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_treemap_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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.IO;
2+
using Syncfusion.DocIO;
3+
using Syncfusion.DocIO.DLS;
4+
using Syncfusion.OfficeChart;
5+
6+
namespace Create_pie_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+
16+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
17+
{
18+
//Save the Word document to the file stream.
19+
document.Save(outputFileStream, FormatType.Docx);
20+
}
21+
}
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)