Page 1 of 1
Drawing and deleting lines
Posted: Mon May 16, 2005 3:42 pm
by 9525522
Hi,
I am using the DrawLine tool to draw lines and parallelograms on the chart. I found a bug where selecting the lines seems to change the angle or move the line by a fraction of pixel. This is causing me problems as I cannot delete parallelograms because I cannot identify the lines anymore.
I calculate and set the start and end coordinates of each line when drawing a parallelogram. When I select a side of the parallelogram and try to find/calculate the adjacent sides of the line I cannot find them because the line has moved and the co-ordinates no longer coincide.
Is there any way to work around this problem?
I am using the version 7.0.0.4 of TeeChart Ax.
Thanks.
Posted: Tue May 17, 2005 8:42 am
by narcis
Hi castlerigg,
Could you please send us an example we can run "as-is" to reproduce the problem here? You can post it at [url]news://
www.steema.net/steema.public.attachments[/url] newsgroup.
I found a bug where selecting the lines seems to change the angle or move the line by a fraction of pixel.
Please notice that this is not possible as pixels are integer values.
Posted: Tue May 17, 2005 4:44 pm
by 9525522
I can't seem to post to the newsgroup as suggested. I get an error saying No sender was specified (even after I subscriber to the group).
This is the code to draw a parallelogram from a newly drawn line on the chart (i'm assuming the chart already has some series data):
Private Sub cht_OnDrawLineToolNewLine()
Dim LineTool As IDrawLineTool
Dim line As IDrawLine
Set LineTool = cht.Tools.Items(0).asDrawLine
LineTool.Selected = LineTool.Lines.Count - 1
On Error Resume Next
Set line = LineTool.Lines(LineTool.Lines.Count - 1)
On Error GoTo 0
If line Is Nothing Then
Beep
Exit Sub
End If
' calculate the length and position of other 3 sides
nLenX = 2 * (line.EndPos.X - line.StartPos.X)
nLenY = (line.EndPos.Y - line.StartPos.Y) / 2
LineTool.AddLine line.EndPos.X, _
line.EndPos.Y, _
line.EndPos.X + nLenX, _
line.EndPos.Y + nLenY
LineTool.AddLine line.EndPos.X + nLenX, _
line.EndPos.Y + nLenY, _
line.StartPos.X + nLenX, _
line.StartPos.Y + nLenY
LineTool.AddLine line.StartPos.X + nLenX, _
line.StartPos.Y + nLenY, _
line.StartPos.X, _
line.StartPos.Y
End Sub
Now select any side of the parallelogram and zoom in to the corners of the line selected. You will see that either the start position or end position would have moved, making the parallelogram no longer connected.
Please let me know if you need any more information.
I'm not sure if the X, Y positions are in pixels... they seem to take floating point values.
Thanks,
Tanya
Posted: Wed May 18, 2005 8:36 am
by narcis
Hi Tanya,
Thanks for your code snippet.
I can't seem to post to the newsgroup as suggested. I get an error saying No sender was specified (even after I subscriber to the group).
You may not have set your user e-mail address. That's strange, you shouldn't have problems as settings are the default ones. Server is
http://www.steema.net, no login information is required and NNTP port number is 119.
Now select any side of the parallelogram and zoom in to the corners of the line selected. You will see that either the start position or end position would have moved, making the parallelogram no longer connected.
I'm not able to reproduce it here. It seems to work fine.
Please let me know if you need any more information.
Which TeeChart version are you using? I'm using latest release available at our customer download area which is v7.0.0.4
I'm not sure if the X, Y positions are in pixels... they seem to take floating point values.
Screen positions are in pixels and are integer values while series values take floating point values. Then you should convert from series values to screen positions and viceversa.
Posted: Wed May 18, 2005 9:23 pm
by 9525522
Hi Narcis,
I'm also using the latest version of Teecharts v7.0.0.4. I find it very suprising that you can't reproduce it because I can very easily reproduce it here. Did the code work as far as drawing the parallelogram?
I wonder if there is any way of sending you a small project with the problem example.
Screen positions are in pixels and are integer values while series values take floating point values. Then you should convert from series values to screen positions and viceversa.
That seems to make sense. But when i'm debugging through the code and I have the IDrawLine in my watch window, the X, Y positions display floating point values. Is that referring to the series values instead of screen positions?
Can you send me a snippet of code to add a line to the chart by converting the series values to screen positions?
Thanks for all your help,
Tanya
Posted: Thu May 19, 2005 7:46 am
by narcis
Hi Tanya,
I'm also using the latest version of Teecharts v7.0.0.4. I find it very suprising that you can't reproduce it because I can very easily reproduce it here. Did the code work as far as drawing the parallelogram?
Yes, it works.
I wonder if there is any way of sending you a small project with the problem example.
Yes, you could post to the newsgroups as I suggested you previously but if you are experiencing problems with them please send it directly to me.
That seems to make sense. But when i'm debugging through the code and I have the IDrawLine in my watch window, the X, Y positions display floating point values. Is that referring to the series values instead of screen positions?
Yes, it can be.
Can you send me a snippet of code to add a line to the chart by converting the series values to screen positions?
Yes, the code below does that. It's Delphi code but can easily ported to VB.
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var
IntersectIndex: Integer;
x0, y0, x1, y1: double;
begin
IntersectIndex:=10;
x0:=Series1.DateValues.Items[IntersectIndex];
y0:=Series1.HighValues.Items[IntersectIndex];
x1:=Series2.CalcXPos(IntersectIndex);
y1:=Series2.CalcYPos(IntersectIndex);
TDrawLine.CreateXY(ChartTool1.Lines, x0, y0, x1, y1);
ChartTool1.EnableDraw:=false;
end;
Posted: Thu May 19, 2005 6:34 pm
by 9525522
Hi Narcis,
Yes, you could post to the newsgroups as I suggested you previously but if you are experiencing problems with them please send it to me.
I have sent you the test project.
I forgot to mention that my Series is a Line series. So the code you sent is not that helpful. However, i've realized that i'm drawing the parallelogram correctly. Now if only I can disable the line from moving when I select it, then I am able to delete the entire parallelogram.
Thanks,
Tanya
Posted: Fri May 20, 2005 2:46 pm
by narcis
Hi Tanya,
Thank you very much for your example. I've been able to reproduce this problem here.
By now I can't think of a workaround. It seems not being easy to solve. I've added it to our deffect list to be fixed for our future releases.