Page 1 of 1

color band on custom x-axis

Posted: Mon Feb 14, 2005 7:41 pm
by 8725765
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

Posted: Tue Feb 15, 2005 10:01 am
by narcis
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.

Posted: Thu Feb 17, 2005 9:58 pm
by 8725765
Thank you very much! But how do I get the XPosValue from a DateTime Value?

Posted: Sat Feb 19, 2005 8:14 am
by Marjan
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);
  }