Page 1 of 1

Using StackGroup with bar charts

Posted: Thu Jul 30, 2009 8:26 pm
by 9790677
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?

Re: Using StackGroup with bar charts

Posted: Fri Jul 31, 2009 11:04 am
by 10050769
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,

Re: Using StackGroup with bar charts

Posted: Fri Jul 31, 2009 4:00 pm
by 9790677
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.