Page 1 of 1
A label next to one single point
Posted: Mon Mar 06, 2006 3:23 pm
by 9637396
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
Lars Iversen
Posted: Mon Mar 06, 2006 3:54 pm
by narcis
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";
}
Posted: Tue Mar 07, 2006 9:25 am
by 9637396
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
Posted: Tue Mar 07, 2006 9:37 am
by narcis
Hi Lars,
Ok, then instead of TextOut you should use RotateLabel which also lets you specifing the rotation angle you want for the label.
Posted: Tue Mar 07, 2006 9:43 am
by 9637396
You guys are cool !!
Thanks
...and just one more thing (I think):
Is it also possible to control font size, color etc. ?
Br Lars Iversen
Posted: Tue Mar 07, 2006 10:05 am
by narcis
You're very welcome Lars
.
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);
}
Posted: Tue Mar 07, 2006 10:11 am
by 9637396
Perfect !
Thanks for great en fast support.
Teechart rules !
/Lars
Posted: Tue Mar 07, 2006 10:50 am
by 9637396
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
Posted: Tue Mar 07, 2006 10:54 am
by narcis
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.
Posted: Tue Mar 07, 2006 12:24 pm
by 9637396
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
Posted: Tue Mar 07, 2006 1:01 pm
by narcis
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.
Posted: Tue Mar 07, 2006 1:44 pm
by 9637396
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