Page 1 of 1

Custom labels in addition to usual ones

Posted: Mon Jul 17, 2006 12:07 pm
by 9641771
I need to label ends of all axes with their names. I can't use titles because they are drawn in the middle of axes (or maybe there is way to draw them at the end if axis?). So I tried to use custom labels. But if I use Axis.Labels.Items.Add method all other label are erased. How can I add end label without erasing the others?
One more question: is there any way to draw arrows at the end of axis that will behave like a part of this axis (rotate, elevate and zoom with it)?


Thank you.

Posted: Tue Jul 18, 2006 11:52 am
by narcis
Hi bairog,

You can try using an annotation tool positioned at the end of the axis, for example:

Code: Select all

    private void Form1_Load(object sender, EventArgs e)
    {
      line1.FillSampleValues();
      Bitmap bmp = tChart1.Bitmap;
    }

    private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      Steema.TeeChart.Tools.Annotation AnnotationBottom = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
      AnnotationBottom.Text = "My Bottom Title";
      AnnotationBottom.Left = tChart1.Axes.Bottom.IEndPos + 20;
      AnnotationBottom.Top = tChart1.Axes.Bottom.Position + 20;
    }

Posted: Thu Jul 20, 2006 7:50 am
by 9641771
I use 3D openGL chart. So there is problem with positioning depth axis annotation: annotations are drawn in the XY (front) plane, so I can't put it to the correct place (to the end of depth axis) and after rotation/elevation it appers at the wrong position. Maybe there is a way to set annotation's Z position? Or maybe you can recommend me something else to label the end of depth axis?

Thank you.

Posted: Thu Jul 20, 2006 9:10 am
by 9641771
I use non-orthogonal 3D chart so your code workes incorrectly:
Image
We've discussed this problem here

There is enother notice:
narcis wrote:Hi bairog,

You can try using an annotation tool positioned at the end of the axis, for example:
AfterDraw event does not work(no annotation appears), I use series' AfterDrawValues event instead and it worked properly (by the way it was not the first time I've discovered this). Do you have any idea why this happens?

Posted: Thu Jul 20, 2006 10:54 am
by narcis
Hi bairog,

AfterDraw event will work fine provided you use the Bitmap trick in my code example to force the event being fired.

There's no way to set a Z position for annotation tools. However drawing on TeeChart's canvas allows you setting a z position:

Code: Select all

    private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      g.Font.Color = Color.Red;
      g.Font.Size = 12;
      g.TextOut(tChart1.Axes.Bottom.IEndPos + 20, tChart1.Axes.Bottom.Position, 
                tChart1.Axes.Depth.IEndPos, "My Custom Text");
    }
Anyway, as I told you in other threads, this text will be also rotated/elevated with the chart.

Posted: Wed Feb 07, 2007 8:15 pm
by 9794096
I am trying to do something similar to what is mentioned in this issue.
I want to place a label on each of my vertical axes.

If I use the AfterDraw handler and within there I create the annotation tools to make the labels, it works except for the fact that the labels don't actually appear on my graph until the NEXT time the draw is fired.

I notice that there does not appear to be a AfterDrawValues handler any more so that seems to not be an option.

I see what you refer to as the bitmap trick but that would cause the chart to have to render twice. And with some of our larger plots, this would be a horrible performance hit.
Is there another way to get these labels to draw properly at the time the chart itself is drawn?

Thanks.

Aaron Peronto

Posted: Thu Feb 08, 2007 3:39 pm
by narcis
Hi Aaron,

You could either try using the Bitmap trick in the form constructor or Load event or try using the annotation tool creation code in BeforeDrawAxes event or BeforeDrawSeries event.

Posted: Thu Feb 08, 2007 3:44 pm
by 9794096
Excellent!

Putting the code in the BeforeDrawSeries works fine.

I was not sure when all of the information for the axes positions and visibility would be complete and available for me to determine which axes are visible and should have labels drawn and where those labels should be located based on the position of each axis.

This works perfectly.

Thanks again.