A label next to one single point

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

A label next to one single point

Post by Lars Iversen » Mon Mar 06, 2006 3:23 pm

Hi I have a graph with a lot of point on a linegraph

Is it possible to add some text next to one of the points in the graph?
How?

Thanks in advance :D

Lars Iversen

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

Post by Narcís » Mon Mar 06, 2006 3:54 pm

Hi Lars,

Yes, you have several options here:

1. Custom drawing on TeeChart's canvas in the AfterDraw event:

Code: Select all

		private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			g.TextOut(line1.CalcXPos(5),line1.CalcYPos(5),"My Custom Text");
		}
This code draws the text at the 5th point in the series.

2. Using an Annotation tool. For examples have a look at All Features\Welcome !\Tools\Annotation example in TeeChart's features demo which can be found at its program group.

3. Make series marks visible and use the series GetMarkText event:

Code: Select all

		private void line1_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e)
		{
			if (e.ValueIndex!=5) e.MarkText="";
			else e.MarkText="My Custom Text";
		}
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

Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Post by Lars Iversen » Tue Mar 07, 2006 9:25 am

Hi Narcis

Thanks for your quick reply. option 1 with TextOut looks like the one I'm looking for. One problem though:
I would like the text to be rotated 90 degrees so that it starts from the bottom.

Can that be done?

Thanks in advance
Lars Iversen

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 Mar 07, 2006 9:37 am

Hi Lars,

Ok, then instead of TextOut you should use RotateLabel which also lets you specifing the rotation angle you want for the label.
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

Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Post by Lars Iversen » Tue Mar 07, 2006 9:43 am

You guys are cool !!
Thanks :lol:

...and just one more thing (I think):

Is it also possible to control font size, color etc. ?

Br Lars Iversen

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 Mar 07, 2006 10:05 am

You're very welcome Lars :wink: .

Yes, this is also possible. You need to use:

Code: Select all

		private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			g.Font.Color = Color.Blue;
			g.Font.Size=14;
			g.Font.Name="Times New Roman";
			g.RotateLabel(100,100,"Rotated Label", 45);
		}
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

Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Post by Lars Iversen » Tue Mar 07, 2006 10:11 am

Perfect !

Thanks for great en fast support.

Teechart rules !

/Lars

Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Post by Lars Iversen » Tue Mar 07, 2006 10:50 am

OK. Now I got it to work with this point label, but now if I zoom my graph the series are disappering !?!?
If I undo zoom, my series appear again!?
(During zomm I update some series as they are a dynamic average that averages the poins that are visible. I don't know if that interfers with the functionality)


If you have an email address I can try to create a small isolated example of the problem.

Br
Lars Iversen

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 Mar 07, 2006 10:54 am

Hi Lars,

Yes please, could you post an example we can run "as-is" to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.
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

Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Post by Lars Iversen » Tue Mar 07, 2006 12:24 pm

Hi Thanks again

While trying to create the example I found out what the problem was:

When I have created my series
I set the left axis to autoscale
I Refresh the graph
then I store the MaxY and MinY values in two variables
Heres some of my code:

call CreateSeries()

TChart1.Axes.Left.Automatic = True
TChart1.Refresh()

m_dblYMax = TChart1.Axes.Left.Maximum
m_dblYMin = TChart1.Axes.Left.Minimum

I use the two variables m_dblYMax and Min in this way:
When the user zooms or scrolls i set the left axis minimum and maximum to the saved values. this way the user can only zoom the x-axis (That is what I want in this case)

This works fine when I have no code in the AfterDraw Event.
If I add this code in after draw:

For _i As Integer = 0 To TChart1.Series(0).Count - 1
If TChart1.Series(0).Item(_i).Label <> "" Then
g.RotateLabel(TChart1.Series(0).CalcXPos(_i), TChart1.Series(0).CalcYPos(_i), TChart1.Series(0).Item(_i).Label, 90)
End If

Next _i

Then My two variables ( m_dblYMax and m_dblYMin) are always zero. So in my zoom event i accidentially set min and max on the left axis to zero.

Is there a way to make it work so I can use:
m_dblYMax = TChart1.Axes.Left.Maximum
m_dblYMin = TChart1.Axes.Left.Minimum


Thanks

Lars Iversen

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 Mar 07, 2006 1:01 pm

Hi Lars,
When the user zooms or scrolls i set the left axis minimum and maximum to the saved values. this way the user can only zoom the x-axis (That is what I want in this case)
Have you tried setting the zoom direction?

Code: Select all

tChart1.Zoom.Direction=Steema.TeeChart.ZoomDirections.Horizontal;
Then My two variables ( m_dblYMax and m_dblYMin) are always zero. So in my zoom event i accidentially set min and max on the left axis to zero.

Is there a way to make it work so I can use:
m_dblYMax = TChart1.Axes.Left.Maximum
m_dblYMin = TChart1.Axes.Left.Minimum
You need to make that assignment in a place where the axes are already drawn so that they have valid values. You may want to try using the line below before executing those statements.

Code: Select all

Bitmap bmp=tChart1.Bitmap;
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

Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Post by Lars Iversen » Tue Mar 07, 2006 1:44 pm

Yes sir that thing about setting horizontal zoom only helps a lot and now I set the max and min from trhe series(0).MaxYValue and series(0).MinYValue.
That seems to work perfectly.

Thanks again

Lars Iversen

Post Reply