I have a chart with an upper and a lower part, each having its own y and x-axis. Now I want to draw a ban vertically on the lower part. I can assign the band to my custom x-axis, but it will draw over the whole chart area (lower and upper part). Can I also asign a y-axis to the color band so it will only draw on the lower part of my chart?
How can I get the x-position in double if my x-axis is datetime? and how do I asign the ColorBand.Start and End as a datetime? I tried ToOADate(), but it doesnt seem precise to a millisecond.
regards
Joachim
color band on custom x-axis
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Joachim,
This can't be done using a ColorBand Tool. You can do it using something like the code below using the canvas to draw a line.
Assuming that axis1 is the lower part horizontal axis, axis2 is the lower part vertical axis, axis3 is the upper part horizontal axis and axis4 is the upper part vertical axis. This would draw a vertical line in the 5th value position.
Those positions would also work for date-time axes as they are related to the chart, not to the axis values.
This can't be done using a ColorBand Tool. You can do it using something like the code below using the canvas to draw a line.
Code: Select all
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
g.Line(axis1.CalcXPosValue(5),axis3.Position,axis1.CalcXPosValue(5),axis1.Position);
}
Those positions would also work for date-time axes as they are related to the chart, not to the axis values.
Best Regards,
Narcís Calvet / 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 |
Calling ToOADate should do the trick. The following code works fine:
Code: Select all
private DateTime start = new DateTime(2005,2,15,12,0,0,12);
private void Form1_Load(object sender, System.EventArgs e)
{
line1.Add(start,3.3);
line1.Add(start.AddMilliseconds(3),2.1);
line1.Add(start.AddMilliseconds(4),3.8);
line1.Add(start.AddMilliseconds(7),0.7);
line1.XValues.DateTime = true;
}
private void tChart2_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
g.RotateLabel(100,100,"Hello world - rotated!",45);
// Draw vertical line at starttime + 2 ms
int xpos = line1.GetHorizAxis.CalcXPosValue(start.AddMilliseconds(2).ToOADate());
g.Line(xpos,
line1.GetVertAxis.IStartPos,
xpos,
line1.GetVertAxis.IEndPos);
// Draw another vertical line at starttime + 5 ms
xpos = line1.GetHorizAxis.CalcXPosValue(start.AddMilliseconds(5).ToOADate());
g.Line(xpos,
line1.GetVertAxis.IStartPos,
xpos,
line1.GetVertAxis.IEndPos);
}
Marjan Slatinek,
http://www.steema.com
http://www.steema.com