Super 2d/3d Graph Library

Enhance your .NET application adding nice charts within minutes! Save time and money!


Example 12: 3D Pie Chart Demo (C#)


In previous tutorial, I used SeriesFactory helper class to assign values to the chart. This time I will use the Series property to assign values to the pie chart. You can use series property or SeriesFactory class, the result is the same.

1. Create a new Windows application project (VB.NET)

2. Add Super 2d/3d Graph Library to the toolbox pallete and drag it to Form1

3. Copy and paste de following code:


Form Code

using System;
using
Super2d3dGraphLibrary;
using
System.Collections;
using
System.Drawing;
using
System.IO;
using
System.Drawing.Imaging;

namespace TheCodeProject_3dPie
{

  public partial class PieChart : System.Web.UI.Page
  {

    protected void Page_Load(object sender, EventArgs e)
    {

        // Chart control:
        Super2D3dGraph oGraph = new Super2D3dGraph();

        // Data variable:
        ArrayList[] numbers = new ArrayList[1];

        // Explode flags (one per sector; if flag[i]<> "", sector[i] will be exploded)
        String[] explode = new String[6];

        // Add random data...
        Random rnd = new Random();
        numbers[0] = new ArrayList();
        for (int i = 0; i < 6; i++)
        {
           numbers[0].Add(rnd.Next(500));
           if (i == 2) // Only explode one sector (example)
           {
              explode[i] = "1";
           }
        }

        // Legend texts...
        string[] legend = { "January", "February", "March", "April", "June", "July" };

        // Customize chart:
        oGraph.LicenseeIdentifier = "STAND";
        oGraph.Title = "3D Pie Chart";
        oGraph.Style = STYLE2D3D.STYLE3D_PIE ;

        oGraph.Series = numbers;
        oGraph.ValuesLocationStyle =
STYLECAPTIONLOCATION.STYLECAPTIONLOCATION_INSIDE;
        oGraph.ValuesFormat = "0"; // No decimals

        oGraph.ItemsHighlight = explode;
        oGraph.ItemsLegend = legend;
        oGraph.ShowItemsLegend =
true;
        oGraph.ShowLegend = false;
        oGraph.ShowDataTable = true;
        oGraph.ShowLegendInDataTable = false;

        oGraph.BackColor = Color.LightYellow;
        oGraph.BackStyle = STYLEBACKGROUND.STYLEBACKGROUND_GRADIENT_TUBULAR_INVERTED;

        oGraph.Width = 500;
        oGraph.Height = 500;

        oGraph.RefreshChart();

        // Save image in a temporary buffer (PNG format for best quality)
        MemoryStream io = new MemoryStream();
        oGraph.Image.Save(io, ImageFormat.Png);

        // Output the content of the buffer to the browser
        Response.Clear();
        Response.ContentType = "image/png";
        Response.BinaryWrite(io.GetBuffer());

     }
   }
}

 

Result:


 

 

License & Purchase Info


Current version: 14

Super 2d/3d Graph Library is available as:
-Standard License (99€)
-Premium License (149€)
-Enterprise License (299€)

Click here for more details & purchase

Contact Info


Feel free to contact us
for questions related to any of our products or custom .Net development. We usually respond in the same labor day.

Software Siglo XXI

Main support service: support@softwaresigloxxi.com

Sales and other enquiries: contact@softwaresigloxxi.com