Different background color for different x-axis range

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Different background color for different x-axis range

Post by pw » Fri Apr 03, 2009 5:55 am

Hi,

Is it possible to have different background color for different x-axis range? For example, my x-axis is a date & time scale, say from 1-Apr-09 00:00 to 3-Apr-09 23:30'. I want the background to have different shades for time range between 05:00 to 17:00.

Thanks.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Fri Apr 03, 2009 11:06 am

Hi pw,

I think that the easiest solution would be using ColorBand tool. Could you take a look at the demo at Welcome !\Tools\Color Band?

Note that you should set them as vertical doinf something like this:

Code: Select all

colorband1.Axis = tChart1.Axes.Bottom;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Re: Different background color for different x-axis range

Post by pw » Thu Oct 01, 2009 7:12 am

Hi,

Revisiting an old question I had. What would be the easiest way to setup the ColorBand if I want to have different color backgrounds for weekends?

I'm not sure how I can loop through the x-axis, figure out which is weekend & setup a ColorBand for each weekend.

Please advise. Thanks.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Different background color for different x-axis range

Post by Yeray » Thu Oct 01, 2009 11:07 am

Hi pw,

Here you have a simple example of how you could do it:

Code: Select all

            tChart1.Aspect.View3D = false;
            Steema.TeeChart.Styles.Candle candle1 = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
            candle1.FillSampleValues(25);

            for (int i = 0; i < candle1.Count; i++)
            {
                if (DateTime.FromOADate(candle1.DateValues[i]).DayOfWeek == DayOfWeek.Saturday)
                {
                    Steema.TeeChart.Tools.ColorBand colorband = new Steema.TeeChart.Tools.ColorBand(tChart1.Chart);
                    colorband.Start = candle1.DateValues[i];
                    colorband.End = candle1.DateValues[i] + 1;
                    colorband.Axis = tChart1.Axes.Bottom;
                    colorband.Transparency = 50;
                    colorband.Pen.Visible = false;
                }
            }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Re: Different background color for different x-axis range

Post by pw » Fri Oct 02, 2009 12:16 am

Many thanks, Yeray. You've been a great help.

Post Reply