Using StackGroup with bar charts

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
MAD Developer
Newbie
Newbie
Posts: 2
Joined: Fri Mar 17, 2006 12:00 am

Using StackGroup with bar charts

Post by MAD Developer » Thu Jul 30, 2009 8:26 pm

I am trying to create a chart with 2 sets of data. Each set has 2 bars which I would like to have in front of each other but then I want the sets to be side by side. I am trying to use StackGroup but cannot get the layout I want. Here is a sample of what I have:

Code: Select all

for( int i = 1; i <= 2; i++ )
{
   Bar totalBar = new Bar( wc.Chart);
   totalBar.StackGroup = i;
   totalBar.MultiBar = MultiBars.None;

   // (Populate bar with data)
 
  Bar ngBar = new Bar( wc.Chart);
   ngBar.StackGroup = i;
   ngBar.MultiBar = MultiBars.None;

  // (Populate bar with data)
}
Is it possible to have the ngBar in front of the totalBar but then have the StackGroups side by side?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Using StackGroup with bar charts

Post by Sandra » Fri Jul 31, 2009 11:04 am

Hello MAD,
Is it possible to have the ngBar in front of the totalBar but then have the StackGroups side by side?
We made a simple example, that solve your problem. Please check that example works as you would.

Code: Select all

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            Random y = new Random();
                for (int i = 1; i <= 2; i++)
                {
                Steema.TeeChart.Styles.Bar totalBar = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
                Steema.TeeChart.Styles.Bar ngBar = new Steema.TeeChart.Styles.Bar(tChart1.Chart);

                totalBar.MultiBar = Steema.TeeChart.Styles.MultiBars.None;
                ngBar.MultiBar = Steema.TeeChart.Styles.MultiBars.None;

                totalBar.Marks.Visible = false;
                ngBar.Marks.Visible = false;

                totalBar.BarWidthPercent = 50;
                ngBar.BarWidthPercent = 50;

                for (int j = 0; j < 5; j++)
                {
                double tmp = (i == 1) ? -0.25 : 0.25;
                double x = j + tmp;
                totalBar.Add(x, y.Next());
                ngBar.Add(x, y.Next());
                }
                }

                for (int k = 0; k < tChart1.Series.Count; k++)
                {
                tChart1[k].ZOrder = k % 2;
                }
            
        }
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MAD Developer
Newbie
Newbie
Posts: 2
Joined: Fri Mar 17, 2006 12:00 am

Re: Using StackGroup with bar charts

Post by MAD Developer » Fri Jul 31, 2009 4:00 pm

Thanks for your help! My x values are dates but I was able to use this same technique by subtracting or adding 4 hours to the date.

Post Reply