color band on custom x-axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
joachim
Newbie
Newbie
Posts: 9
Joined: Thu Feb 05, 2004 5:00 am

color band on custom x-axis

Post by joachim » Mon Feb 14, 2005 7:41 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Feb 15, 2005 10:01 am

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.

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);
		}
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.
Best Regards,
Narcís Calvet / 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

joachim
Newbie
Newbie
Posts: 9
Joined: Thu Feb 05, 2004 5:00 am

Post by joachim » Thu Feb 17, 2005 9:58 pm

Thank you very much! But how do I get the XPosValue from a DateTime Value?

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Sat Feb 19, 2005 8:14 am

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

Post Reply