Better Dashboards

Working with Microsoft enterprise chart, dashboard and reporting technologies.

Stair-Stacked Pie Chart

Posted by milang on January 9, 2009

In the chart sample framework gallery, there is a very cool image of a stair-stepped pie chart that I decided to replicate.


How to Create Stair Stacked Pie Chart

Essentially, you need to create three chart areas and overlap them using manual positioning.  You have to fiddle with some chart area settings, but the steps below should help you get started.

1.    Drop chart onto web page.
2.    Copy and paste code below, substituting the name of your chart (probably Chart1) into the DoStackStairPie method.

using System.Web.UI.DataVisualization.Charting;

namespace BetterDashboards.Samples

/// Summary description for StairStackedPie.

public partial class StairStackedPie : System.Web.UI.Page

/// Page Load event handler.

protected void Page_Load(object sender, System.EventArgs e)
// Replace with the name of your chart (by default it is Chart1)

private void DoStairStackPie(Chart chart)
Random rand = new Random();

// Clear all chart areas and all series

for (int i=0; i < 3; i++) { // Create 3 new chart areas chart.ChartAreas.Add("Area" + i); // Create 3 new pie chart series chart.Series.Add("Series" + i); chart.Series[i].ChartType = SeriesChartType.Pie; // Associate each series with a different chart area chart.Series[i].ChartArea = "Area" + i; // Insert random data points for the chart for (int j = 0; j < 5; j++) chart.Series[i].Points.AddXY(j, rand.Next(0, 20)); } ChartArea chartArea1 = chart.ChartAreas[0]; ChartArea chartArea2 = chart.ChartAreas[1]; ChartArea chartArea3 = chart.ChartAreas[2]; // Chart Area 1 chartArea1.Area3DStyle.IsClustered = true; chartArea1.Area3DStyle.Enable3D = true; chartArea1.Area3DStyle.Perspective = 10; chartArea1.Area3DStyle.PointGapDepth = 900; chartArea1.Area3DStyle.IsRightAngleAxes = false; chartArea1.Area3DStyle.WallWidth = 25; chartArea1.Area3DStyle.Rotation = 65; chartArea1.Area3DStyle.Inclination = 35; chartArea1.BackColor = System.Drawing.Color.Transparent; chartArea1.BackSecondaryColor = System.Drawing.Color.Transparent; chartArea1.InnerPlotPosition.Auto = false; chartArea1.InnerPlotPosition.Height = 95F; chartArea1.InnerPlotPosition.Width = 85F; chartArea1.Position.Auto = false; chartArea1.Position.Height = 70F; chartArea1.Position.Width = 52F; chartArea1.Position.X = 48F; chartArea1.Position.Y = 30F; // Chart Area 2 chartArea2.Area3DStyle.IsClustered = true; chartArea2.Area3DStyle.Enable3D = true; chartArea2.Area3DStyle.Perspective = 10; chartArea2.Area3DStyle.PointGapDepth = 900; chartArea2.Area3DStyle.IsRightAngleAxes = false; chartArea2.Area3DStyle.WallWidth = 25; chartArea2.Area3DStyle.Rotation = 65; chartArea2.Area3DStyle.Inclination = 35; chartArea2.BackColor = System.Drawing.Color.Transparent; chartArea2.BackSecondaryColor = System.Drawing.Color.Transparent; chartArea2.InnerPlotPosition.Auto = false; chartArea2.InnerPlotPosition.Height = 95F; chartArea2.InnerPlotPosition.Width = 85F; chartArea2.Position.Auto = false; chartArea2.Position.Height = 70F; chartArea2.Position.Width = 52F; chartArea2.Position.X = 26.5F; chartArea2.Position.Y = 15F; // Chart Area 3 chartArea3.Area3DStyle.IsClustered = true; chartArea3.Area3DStyle.Enable3D = true; chartArea3.Area3DStyle.Perspective = 10; chartArea3.Area3DStyle.PointGapDepth = 900; chartArea3.Area3DStyle.IsRightAngleAxes = false; chartArea3.Area3DStyle.WallWidth = 25; chartArea3.Area3DStyle.Rotation = 65; chartArea3.Area3DStyle.Inclination = 35; chartArea3.BackColor = System.Drawing.Color.Transparent; chartArea3.BackSecondaryColor = System.Drawing.Color.Transparent; chartArea3.InnerPlotPosition.Auto = false; chartArea3.InnerPlotPosition.Height = 95F; chartArea3.InnerPlotPosition.Width = 85F; chartArea3.Position.Auto = false; chartArea3.Position.Height = 70F; chartArea3.Position.Width = 52F; chartArea3.Position.X = 5F; } } } [/sourcecode] (Sidebar: The design-time experience with the Microsoft chart control is nowhere near as clean or as valuable as the Dundas experience.  As a result, I suspect there will be a lot of Microsoft charts that replicate the look and feel of the charts in the sample framework; developers are not known for their graphical prowess, and graphic designers will be scared to death to try to create anything decent-looking using Visual Studio.  Hopefully the Silverlight chart will make it easier to bring graphic artists into the fold.)


6 Responses to “Stair-Stacked Pie Chart”

  1. venkat said

    Hi milang,

    This is very good example for stair-stacked pie chart.Do u’ve any 2d grouped pie chart implementation like in MS 2D grouped pie chart control?I’ve tried from MSDN chart samples.But they are showing grouped pie chart in gallery (in image view) only.Not providing any implementation.I’m new to this chart control implementation.Plz help me..!!


    • milang said

      Hi Venkat,
      I don’t have any details about the grouped pie chart in the gallery, but I would strongly advise against using such a chart. The data will almost surely not line up the way it is shown in this chart, and it will create confusion in understanding the meaning behind the visualization. This is just my take 🙂


  2. bin said

    Hi milang,
    Thanks for your sample,But i can’t use the legends like The Ms Chart web samples (in 3D Stair-Stacked Pie)
    can you help me!
    thanks again
    china bin

    • milang said

      You’ll need to enable the legend (chart1.Legends[0].Enabled = true) and then re-position the chart areas to fit around the legend. It’s not the most elegant solution but it’s the best that the chart can do at this time. 🙂

  3. Aditya said

    Hey. can u please help me for the 3D Stacked Pie chart.
    Thanks in advance.

  4. android|application android|android firmware|android game|android os|android upgrade…

    […]Stair-Stacked Pie Chart « Better Dashboards[…]…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: