I have a need from a customer to produce a bar chart that totals up the passed/failed/undetermined status for daily shipments. In the past we have used a 100% stacked bar chart that has worked well. My customer wold not like to see three bars for each date, all using the 100% stacked method. How can I display three separate bars for each date.
For example the data may look like shown below for each day:
Day-------------------- Cat1Pass Cat1Fail Cat1Und Cat2Pass Cat2Fail Cat2Und Cat3Pass Cat3Fail Cat3Und
1 May 2013---------------------5----------3--------2----------8--------2----------3---------9----------2--------9
The chart needs to look similar to the image below, but with 3 bars.
Stacked Bar Chart 100 percent with multiple bars
Re: Stacked Bar Chart 100 percent with multiple bars
Hello phil1995,
I think you can do something as next code where I use a StackGroup property:
Could you tell us if previous code works in your end?
Thanks,
I think you can do something as next code where I use a StackGroup property:
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Random rnd = new Random();
for (int i = 0; i < 4; i++)
{
Steema.TeeChart.Styles.Bar series1= new Steema.TeeChart.Styles.Bar(tChart1.Chart);
series1.BarStyle = BarStyles.RectGradient;
series1.Gradient.Direction = LinearGradientMode.Horizontal;
if (i % 2 == 0)
{
series1.StackGroup = 0;
series1.MultiBar = MultiBars.Stacked;
}
else
{
series1.StackGroup = 1;
series1.MultiBar = MultiBars.Stacked;
}
DateTime dt = DateTime.Now;
for (int j = 0; j < 10; j++)
{
series1.Add(dt, rnd.Next(100));
dt = dt.AddDays(1);
}
}
}
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Stacked Bar Chart 100 percent with multiple bars
Thanks for that. The StackGroup property did the trick. The only issue I had was that if NULL values were associated with any of the series, the stacks were added to the wrong group. I changed my data to use zeros instead on Null values, and it seems to work fine. Thanks for your help.
Re: Stacked Bar Chart 100 percent with multiple bars
Hello phil1995,
I am glad our suggestion has helped you. On the other hand, I think a good solution that allow you work with Null values and stackgroup, is use color transparent for the points you want be null. You can do something as next:
Thanks,
I am glad our suggestion has helped you. On the other hand, I think a good solution that allow you work with Null values and stackgroup, is use color transparent for the points you want be null. You can do something as next:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Random rnd = new Random();
for (int i = 0; i < 4; i++)
{
Steema.TeeChart.Styles.Bar series1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
series1.BarStyle = BarStyles.RectGradient;
series1.Gradient.Direction = LinearGradientMode.Horizontal;
//Assign group.
if (i % 2 == 0)
{
series1.StackGroup = 0;
series1.MultiBar = MultiBars.Stacked;
}
else
{
series1.StackGroup = 1;
series1.MultiBar = MultiBars.Stacked;
}
//populate seires.
DateTime dt = DateTime.Now;
for (int j = 0; j < 10; j++)
{
if (i % 2 == 0)
{
if (j == 0 || j == 1)
{
series1.Add(dt, 0,Color.Transparent);
dt = dt.AddDays(1);
}
else
{
series1.Add(dt, rnd.Next(100));
dt = dt.AddDays(1);
}
}
else
{
series1.Add(dt, rnd.Next(100));
dt = dt.AddDays(1);
}
}
}
}
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |