Page 1 of 1
Quick Drawline query
Posted: Thu Jun 02, 2011 12:21 pm
by 13052926
Hi
I use a drawline tool to enable users to 'drop' a vertical line on the face of the chart. I currently use the series minimum and maximum y values to determine the top and bottom points of the drawlineitem.
Is there a way to simply draw a line from the top axis, vertically down to the bottom axes without using series values but rather the actual co-ordinates of the top/bottom axes positions?
Re: Quick Drawline query
Posted: Thu Jun 02, 2011 3:27 pm
by 10050769
Hello rossmc,
I think you do something similar as next code:
Code: Select all
Steema.TeeChart.Styles.Points points1;
Steema.TeeChart.Tools.DrawLine drawline1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Legend.Visible = false;
points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
points1.FillSampleValues();
tChart1.Dock = DockStyle.Fill;
drawline1 = new Steema.TeeChart.Tools.DrawLine(tChart1.Chart);
Steema.TeeChart.Tools.DrawLineItem I = new Steema.TeeChart.Tools.DrawLineItem(drawline1);
/* set the "Y" line positions (start and end position) */
tChart1.Draw();
I.StartPos = new Steema.TeeChart.Drawing.PointDouble(tChart1.Axes.Bottom.Minimum, tChart1.Axes.Left.Maximum);
I.EndPos = new Steema.TeeChart.Drawing.PointDouble(tChart1.Axes.Bottom.Maximum, tChart1.Axes.Left.Minimum);
drawline1.EnableDraw = false;
}
Please, could you tell us if previous code works as you expected?
I hope will helps.
Thanks,
Re: Quick Drawline query
Posted: Fri Jun 03, 2011 6:30 am
by 13052926
Hello Sandra
Thanks for response. My way - using series min/max - and your way - using axes min/max - both do basically the same thing. What I have since discovered however is a problem I had in the past (while using ActiveX control) with using the cursor tool to mimic the behaviour I want has been resolved. Resolved for my purposes anyway.
What I am doing now is simply adding a vertical cursor tool where users elects to draw the vertical line. I then set it to not follow the mouse. This additionally means if user wants to reposition the line using the mouse this is all handled by the control instead of me writing a bunch of additional code.
So for now I plan to use the cursor tool instead of the drawline tool to achieve my needs.
Re: Quick Drawline query
Posted: Mon Jun 06, 2011 8:40 am
by 13052926
Just a quick note on the above. I ran into some odd behaviour using the vertical cursor tool. When programatically adding a vertical cursor, regardless of what I set the .XValue parameter to, the cursor is always intially drawn in the center of the bottom axes. Here is the code for clarity:
Dim v As New Steema.TeeChart.Tools.CursorTool(mychart.Chart)
v.Tag = "line_Vertical"
v.Pen.Color = Color.Gray
v.FollowMouse = False
v.Style = Tools.CursorToolStyles.Vertical
v.XValue = value
The way I resolved this is a little worrying. I simply repeat the .XValue instruction twice! So after v.XValue = value in the sample above I added another line reading v.XValue = value.
Re: Quick Drawline query
Posted: Mon Jun 06, 2011 12:07 pm
by 10050769
Hello rossmc,
Next code using last version of TeeChart.Net
Code: Select all
Private Sub InitializeChart()
tChart.Aspect.View3D = False
Dim line1 As New Steema.TeeChart.Styles.Line(tChart.Chart)
cursor = New Steema.TeeChart.Tools.CursorTool(tChart.Chart)
line1.FillSampleValues()
cursor.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical
tChart.Draw()
cursor.XValue = 3.0
End Sub
Can you please, check previous code works as you expected? And also, can you tell us which version of TeeChart are you using now?
Thanks,