Skip to main content Skip to footer

Spread Windows Forms and the Sunburst Chart

Sunburst charts are effective for showing hierarchical data visually. For example, you can use a Sunburst chart to find out what store and product have the most sales. Spread for Windows Forms and Spread for ASP.NET 10 now have the Sunburst chart. The following image displays a Sunburst chart. You can quickly spot the store with the most sales and the best-selling products. WinSunburst Sunburst Chart Use the following steps to create a Sunburst chart.

  1. Create a Sunburst series.

    FarPoint.Win.Chart.SunburstSeries series = new FarPoint.Win.Chart.SunburstSeries(); 
    
  2. Add data.

    series.Values.AddRange(new double[] { 350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220 }); 
    
  3. Set any colors.

    series.Fills.AddRange(new FarPoint.Win.Chart.Fill[] { new FarPoint.Win.Chart.SolidFill(Color.Blue), new FarPoint.Win.Chart.SolidFill(Color.Teal), new FarPoint.Win.Chart.SolidFill(Color.DarkGoldenrod), new  
    FarPoint.Win.Chart.SolidFill(Color.DarkSalmon), new FarPoint.Win.Chart.SolidFill(Color.DarkGreen), new FarPoint.Win.Chart.SolidFill(Color.Chocolate), new FarPoint.Win.Chart.SolidFill(Color.Navy), new  
    FarPoint.Win.Chart.SolidFill(Color.DarkOrange), new FarPoint.Win.Chart.SolidFill(Color.OrangeRed), new FarPoint.Win.Chart.SolidFill(Color.Tomato), new FarPoint.Win.Chart.SolidFill(Color.Firebrick), new  
    FarPoint.Win.Chart.SolidFill(Color.Gray), new FarPoint.Win.Chart.SolidFill(Color.Olive), new FarPoint.Win.Chart.SolidFill(Color.Teal) }); 
    
  4. Add text strings for the data.

    FarPoint.Win.Chart.StringCollectionItem collection1 = new FarPoint.Win.Chart.StringCollectionItem();  
    collection1.AddRange(new String[] { "Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3" });  
    FarPoint.Win.Chart.StringCollectionItem collection2 = new FarPoint.Win.Chart.StringCollectionItem();  
    collection2.AddRange(new String[] { "Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio" });  
    FarPoint.Win.Chart.StringCollectionItem collection3 = new FarPoint.Win.Chart.StringCollectionItem();  
    collection3.AddRange(new String[] { "", "", "", "", "", "", "", "", "", "", "Week1" });  
    series.CategoryNames.AddRange(new FarPoint.Win.Chart.StringCollectionItem[] { collection1, collection2, collection3 }); 
    
  5. Add any legends or labels.

    FarPoint.Win.Chart.LegendArea label = new FarPoint.Win.Chart.LegendArea();  
    label.TextFont = new System.Drawing.Font("Calibri", 10);  
    label.TextFill = new FarPoint.Win.Chart.SolidFill(System.Drawing.Color.Black); 
    
  6. Create a plot area and add the series to the plot area.

    FarPoint.Win.Chart.SunburstPlotArea plotArea = new FarPoint.Win.Chart.SunburstPlotArea();  
    plotArea.Location = new PointF(0.2f, 0.2f);  
    plotArea.Size = new SizeF(0.6f, 0.6f);  
    plotArea.Series.Add(series); 
    
  7. Create a chart model and add the plot area and legend.

    FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();  
    model.PlotAreas.Add(plotArea);  
    model.LegendAreas.Add(label); 
    
  8. Create a chart object, set the size and location, and assign the model.

    FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();  
    chart.Size = new Size(600, 700);  
    chart.Location = new System.Drawing.Point(50, 50);  
    chart.Model = model; 
    
  9. Add the chart to Spread.

    fpSpread1.Sheets[0].Charts.Add(chart); 
    

Here is the complete Spread for Windows Forms C# code:

FarPoint.Win.Chart.SunburstSeries series = new FarPoint.Win.Chart.SunburstSeries();  
series.Values.AddRange(new double[] { 350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220 });  
series.Fills.AddRange(new FarPoint.Win.Chart.Fill[] { new FarPoint.Win.Chart.SolidFill(Color.Blue), new FarPoint.Win.Chart.SolidFill(Color.Teal), new FarPoint.Win.Chart.SolidFill(Color.DarkGoldenrod), new  
FarPoint.Win.Chart.SolidFill(Color.DarkSalmon), new FarPoint.Win.Chart.SolidFill(Color.DarkGreen), new FarPoint.Win.Chart.SolidFill(Color.Chocolate), new FarPoint.Win.Chart.SolidFill(Color.Navy), new  
FarPoint.Win.Chart.SolidFill(Color.DarkOrange), new FarPoint.Win.Chart.SolidFill(Color.OrangeRed), new FarPoint.Win.Chart.SolidFill(Color.Tomato), new FarPoint.Win.Chart.SolidFill(Color.Firebrick), new  
FarPoint.Win.Chart.SolidFill(Color.Gray), new FarPoint.Win.Chart.SolidFill(Color.Olive), new FarPoint.Win.Chart.SolidFill(Color.Teal) });  
FarPoint.Win.Chart.StringCollectionItem collection1 = new FarPoint.Win.Chart.StringCollectionItem();  
collection1.AddRange(new String[] { "Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3" });  
FarPoint.Win.Chart.StringCollectionItem collection2 = new FarPoint.Win.Chart.StringCollectionItem();  
collection2.AddRange(new String[] { "Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio" });  
FarPoint.Win.Chart.StringCollectionItem collection3 = new FarPoint.Win.Chart.StringCollectionItem();  
collection3.AddRange(new String[] { "", "", "", "", "", "", "", "", "", "", "Week1" });  
series.CategoryNames.AddRange(new FarPoint.Win.Chart.StringCollectionItem[] { collection1, collection2, collection3 });  
FarPoint.Win.Chart.LegendArea label = new FarPoint.Win.Chart.LegendArea();  
label.TextFont = new System.Drawing.Font("Calibri", 10);  
label.TextFill = new FarPoint.Win.Chart.SolidFill(System.Drawing.Color.Black);  
FarPoint.Win.Chart.SunburstPlotArea plotArea = new FarPoint.Win.Chart.SunburstPlotArea();  
plotArea.Location = new PointF(0.2f, 0.2f);  
plotArea.Size = new SizeF(0.6f, 0.6f);  
plotArea.Series.Add(series);  
FarPoint.Win.Chart.ChartModel model = new FarPoint.Win.Chart.ChartModel();  
model.PlotAreas.Add(plotArea);  
model.LegendAreas.Add(label);  
FarPoint.Win.Spread.Chart.SpreadChart chart = new FarPoint.Win.Spread.Chart.SpreadChart();  
chart.Size = new Size(600, 700);  
chart.Location = new System.Drawing.Point(50, 50);  
chart.Model = model;  
fpSpread1.Sheets[0].Charts.Add(chart); 

Here is the complete Spread for Windows Forms VB code:

Dim series As New FarPoint.Win.Chart.SunburstSeries()  
series.Values.AddRange(New Double() {350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220})  
series.Fills.AddRange(New FarPoint.Win.Chart.Fill() {New FarPoint.Win.Chart.SolidFill(Color.Blue), New FarPoint.Win.Chart.SolidFill(Color.Teal), New FarPoint.Win.Chart.SolidFill(Color.DarkGoldenrod), New FarPoint.Win.Chart.SolidFill(Color.DarkSalmon), New FarPoint.Win.Chart.SolidFill(Color.DarkGreen), New FarPoint.Win.Chart.SolidFill(Color.Chocolate), New FarPoint.Win.Chart.SolidFill(Color.Navy), New FarPoint.Win.Chart.SolidFill(Color.DarkOrange), New FarPoint.Win.Chart.SolidFill(Color.OrangeRed), New FarPoint.Win.Chart.SolidFill(Color.Tomato), New FarPoint.Win.Chart.SolidFill(Color.Firebrick), New FarPoint.Win.Chart.SolidFill(Color.Gray), New FarPoint.Win.Chart.SolidFill(Color.Olive), New FarPoint.Win.Chart.SolidFill(Color.Teal)})  
Dim collection1 As New FarPoint.Win.Chart.StringCollectionItem()  
collection1.AddRange(New String() {"Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3"})  
Dim collection2 As New FarPoint.Win.Chart.StringCollectionItem()  
collection2.AddRange(New String() {"Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio"})  
Dim collection3 As New FarPoint.Win.Chart.StringCollectionItem()  
collection3.AddRange(New String() {"", "", "", "", "", "", "", "", "", "", "Week1"})  
series.CategoryNames.AddRange(New FarPoint.Win.Chart.StringCollectionItem() {collection1, collection2, collection3})  
Dim Label As New FarPoint.Win.Chart.LegendArea()  
Label.TextFont = New System.Drawing.Font("Calibri", 10)  
Label.TextFill = New FarPoint.Win.Chart.SolidFill(System.Drawing.Color.Black)  
Dim plotArea As New FarPoint.Win.Chart.SunburstPlotArea()  
plotArea.Location = New PointF(0.2F, 0.2F)  
plotArea.Size = New SizeF(0.6F, 0.6F)  
plotArea.Series.Add(series)  
Dim model As New FarPoint.Win.Chart.ChartModel()  
model.PlotAreas.Add(plotArea)  
model.LegendAreas.Add(Label)  
Dim chart As New FarPoint.Win.Spread.Chart.SpreadChart()  
chart.Size = New Size(600, 700)  
chart.Location = New System.Drawing.Point(50, 50)  
chart.Model = model  
FpSpread1.Sheets(0).Charts.Add(chart) 

Here is the complete Spread for ASP.NET C# code:

FarPoint.Web.Chart.SunburstSeries series = new FarPoint.Web.Chart.SunburstSeries();  
series.Values.AddRange(new double[] { 350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220 });  
series.Fills.AddRange(new FarPoint.Web.Chart.Fill[] { new FarPoint.Web.Chart.SolidFill(Color.Blue), new FarPoint.Web.Chart.SolidFill(Color.Teal), new FarPoint.Web.Chart.SolidFill(Color.DarkGoldenrod), new  
FarPoint.Web.Chart.SolidFill(Color.DarkSalmon), new FarPoint.Web.Chart.SolidFill(Color.DarkGreen), new FarPoint.Web.Chart.SolidFill(Color.Chocolate), new FarPoint.Web.Chart.SolidFill(Color.Navy), new  
FarPoint.Web.Chart.SolidFill(Color.DarkOrange), new FarPoint.Web.Chart.SolidFill(Color.OrangeRed), new FarPoint.Web.Chart.SolidFill(Color.Tomato), new FarPoint.Web.Chart.SolidFill(Color.Firebrick), new  
FarPoint.Web.Chart.SolidFill(Color.Gray), new FarPoint.Web.Chart.SolidFill(Color.Olive), new FarPoint.Web.Chart.SolidFill(Color.Teal) });  
FarPoint.Web.Chart.StringCollectionItem collection1 = new FarPoint.Web.Chart.StringCollectionItem();  
collection1.AddRange(new String[] { "Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3" });  
FarPoint.Web.Chart.StringCollectionItem collection2 = new FarPoint.Web.Chart.StringCollectionItem();  
collection2.AddRange(new String[] { "Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio" });  
FarPoint.Web.Chart.StringCollectionItem collection3 = new FarPoint.Web.Chart.StringCollectionItem();  
collection3.AddRange(new String[] { "", "", "", "", "", "", "", "", "", "", "Week1" });  
series.CategoryNames.AddRange(new FarPoint.Web.Chart.StringCollectionItem[] { collection1, collection2, collection3 });  
FarPoint.Web.Chart.LegendArea label = new FarPoint.Web.Chart.LegendArea();  
label.TextFont = new System.Drawing.Font("Calibri", 10);  
label.TextFill = new FarPoint.Web.Chart.SolidFill(System.Drawing.Color.Black);  
FarPoint.Web.Chart.SunburstPlotArea plotArea = new FarPoint.Web.Chart.SunburstPlotArea();  
plotArea.Location = new PointF(0.2f, 0.2f);  
plotArea.Size = new SizeF(0.6f, 0.6f);  
plotArea.Series.Add(series);  
FarPoint.Web.Chart.ChartModel model = new FarPoint.Web.Chart.ChartModel();  
model.PlotAreas.Add(plotArea);  
model.LegendAreas.Add(label);  
FarPoint.Web.Spread.Chart.SpreadChart chart = new FarPoint.Web.Spread.Chart.SpreadChart();  
chart.Width = 600;  
chart.Height = 700;  
chart.Model = model;  
FpSpread1.Sheets[0].Charts.Add(chart); 

Here is the complete Spread for ASP.NET VB code:

Dim series As New FarPoint.Web.Chart.SunburstSeries()  
series.Values.AddRange(New Double() {350, 100, 80, 85, 90, 200, 350, 450, 500, 650, 220})  
series.Fills.AddRange(New FarPoint.Web.Chart.Fill() {New FarPoint.Web.Chart.SolidFill(Color.Blue), New FarPoint.Web.Chart.SolidFill(Color.Teal), New FarPoint.Web.Chart.SolidFill(Color.DarkGoldenrod), New FarPoint.Web.Chart.SolidFill(Color.DarkSalmon), New FarPoint.Web.Chart.SolidFill(Color.DarkGreen), New FarPoint.Web.Chart.SolidFill(Color.Chocolate), New FarPoint.Web.Chart.SolidFill(Color.Navy), New FarPoint.Web.Chart.SolidFill(Color.DarkOrange), New FarPoint.Web.Chart.SolidFill(Color.OrangeRed), New FarPoint.Web.Chart.SolidFill(Color.Tomato), New FarPoint.Web.Chart.SolidFill(Color.Firebrick), New FarPoint.Web.Chart.SolidFill(Color.Gray), New FarPoint.Web.Chart.SolidFill(Color.Olive), New FarPoint.Web.Chart.SolidFill(Color.Teal)})  
Dim collection1 As New FarPoint.Web.Chart.StringCollectionItem()  
collection1.AddRange(New String() {"Store 1", "", "", "", "", "", "Store 2", "", "", "Store 3"})  
Dim collection2 As New FarPoint.Web.Chart.StringCollectionItem()  
collection2.AddRange(New String() {"Asagio", "Swiss", "Muenster", "Blue", "Cabot", "Gouda", "Feta", "Brie", "Stilton", "American", "Asagio"})  
Dim collection3 As New FarPoint.Web.Chart.StringCollectionItem()  
collection3.AddRange(New String() {"", "", "", "", "", "", "", "", "", "", "Week1"})  
series.CategoryNames.AddRange(New FarPoint.Web.Chart.StringCollectionItem() {collection1, collection2, collection3})  
Dim Label As New FarPoint.Web.Chart.LegendArea()  
Label.TextFont = New System.Drawing.Font("Calibri", 10)  
Label.TextFill = New FarPoint.Web.Chart.SolidFill(System.Drawing.Color.Black)  
Dim plotArea As New FarPoint.Web.Chart.SunburstPlotArea()  
plotArea.Location = New PointF(0.2F, 0.2F)  
plotArea.Size = New SizeF(0.6F, 0.6F)  
plotArea.Series.Add(series)  
Dim model As New FarPoint.Web.Chart.ChartModel()  
model.PlotAreas.Add(plotArea)  
model.LegendAreas.Add(Label)  
Dim chart As New FarPoint.Web.Spread.Chart.SpreadChart()  
chart.Width = 600  
chart.Height = 700  
chart.Model = model  
FpSpread1.Sheets(0).Charts.Add(chart) 

You can also add charts in the Spread Designer. Simply add the data to the designer, select the data, and then select the chart type (Insert, Create Chart dialog, and Sunburst). winsundesign1 Add and Select Data winsundesign2 Insert Sunburst Chart winsundesign3 Sunburst Chart

MESCIUS inc.

comments powered by Disqus