Page 1 of 1
Different background color for different x-axis range
Posted: Fri Apr 03, 2009 5:55 am
by 6923298
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.
Posted: Fri Apr 03, 2009 11:06 am
by yeray
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;
Re: Different background color for different x-axis range
Posted: Thu Oct 01, 2009 7:12 am
by 6923298
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.
Re: Different background color for different x-axis range
Posted: Thu Oct 01, 2009 11:07 am
by yeray
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;
}
}
Re: Different background color for different x-axis range
Posted: Fri Oct 02, 2009 12:16 am
by 6923298
Many thanks, Yeray. You've been a great help.