Example 39: Stacked bars (C#)
This sampe code will draw
a fancy stacked bars chart.
Steps:
1. Create a new Windows
application project (C#) and name it
Tutorial39_2D_StackedBars.
2. Add Super 2d/3d Graph
Library to the toolbox pallete, drag it
to Form1 and name it "g".
3. Copy and paste de
following code:
Form Code
using System;
using System.Windows.Forms;
using Super2d3dGraphLibrary;
namespace Tutorial39_2D_StackedBars
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// add Super2d3dGraphLibrary control to form
and name it "g"
g.LicenseeIdentifier = "PROF";
g.Style = STYLE2D3D.STYLE2D_ACUM_FIXED;
g.Thickness = 0.8F;
g.ItemsLegend = new String[]
{ "One", "Two", "Three", "Four", "Five", "Six", "Seven" };
g.SeriesLegend = new String[]
{ "Locked", "Unlocked" };
g.ShowItemsLegend = true;
g.ShowLegend = false;
g.BackStyle = STYLEBACKGROUND.STYLEBACKGROUND_GRADIENT_TUBULAR_INVERTED;
g.ShowDividersX = true;
// apply data
SeriesFactory sf = new SeriesFactory();
Random rnd = new Random(DateTime.Now.Millisecond);
int value;
for (int k = 1; k <= 7; k++)
{
value = rnd.Next(5, 10);
sf.AddValue(value);
sf.AddToolTip("Locked
item #" + k + " has a value of " + value);
}
sf.NewSerie();
for (int k = 1; k <= 7; k++)
{
value = rnd.Next(5, 10);
sf.AddValue(value);
sf.AddToolTip("Unlocked
item #" + k + " has a value of " + value);
}
sf.ApplyTo(g);
}
}
}
Result:

|