Page 1 of 3

TColorLineTool problem

Posted: Wed Jun 30, 2004 12:40 am
by 9336236
I'm trying to use the TColorLineTool to display vertical lines (markers in my terms) on a chart. I create a line at the cursor position when the user selects "drop marker" from a context menu. These markers are used to mark points of interest in the data being displayed, and are saved in a database table so they persist across application runs. This all works fine.

The problem I'm having is that when the chart is scrolled, the marker line move with the data as expected until it runs into the right or left edge of the chart. It then drags along the chart edge until the scrolling stops, and its initial position is lost.

If I set the NoDragLimit property to true, the line stays with the data, but doesn't vanish at the right or left chart axes - instead it is displayed over the right or left axis.

I want the line to travel with the data, and vanish when the associated data point is no longer visible on the chart.

How can I make this happen?

I am using BCB6 patch level 4 and TeeChartPro version 7.

Posted: Wed Jun 30, 2004 3:59 pm
by 9336236
One more thing. When the line I'm dragging hits the left or right edge of the chart, I'd like the chart to scroll so the user doesn't have to drag the marker to an edge, drop it, scroll the chart manually, then drag again.

Posted: Mon Jul 05, 2004 4:15 pm
by Pep
Hi Leroy,
I want the line to travel with the data, and vanish when the associated data point is no longer visible on the chart.

How can I make this happen?
you can solve this using the following code, also seting the NoDragLimit property to true :

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
if (Charttool1.Value > Chart1.Axes.Bottom.Maximum) or (Charttool1.Value < Chart1.Axes.Bottom.Minimum) then
   Charttool1.Visible := false
else
   Charttool1.Visible := true;
end;
One more thing. When the line I'm dragging hits the left or right edge of the chart, I'd like the chart to scroll so the user doesn't have to drag the marker to an edge, drop it, scroll the chart manually, then drag again.
This can be simulated by using the following code :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(1000);
Chart1.MaxPointsPerPage := 100;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
if (Charttool1.Value > Chart1.Axes.Bottom.Maximum) or (Charttool1.Value < Chart1.Axes.Bottom.Minimum) then
   Charttool1.Visible := false
else
   Charttool1.Visible := true;
end;

procedure TForm1.ChartTool1DragLine(Sender: TColorLineTool);
begin
if charttool1.Value < Chart1.Axes.Bottom.Minimum +10 then
    Chart1.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum-10,Chart1.Axes.bottom.Maximum-10)
else
  if charttool1.Value > Chart1.Axes.Bottom.Maximum - 10 then
     Chart1.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum+10,Chart1.Axes.bottom.Maximum+10);
end;

Posted: Mon Jul 05, 2004 4:17 pm
by 9336236
Marjan or David, could you please help me out here?

Posted: Mon Jul 05, 2004 4:23 pm
by Pep
Hi Leroy,
have you seen my post ?

Posted: Mon Jul 05, 2004 4:30 pm
by 9336236
Pep wrote:Hi Leroy,
have you seen my post ?
We must have been posting at the same time. Your answer wasn't visible when I posted my latest message.

I realize that I can do this manually as you have pointed out. I was hoping that the TColorLineTool could handle this on its own. As it apparently can't, could you please add this behavior to the wish-list?

Thanks!

-Leroy

Posted: Mon Jul 05, 2004 8:05 pm
by 9336236
I have one more question on the TColorLineTool. I need to display a hint where the cursor passes over or is held over the line.

I see that since I have drag enabled for the line, the cursor changes to a drag cursor when it is over the line and changes back to the default cursor when it is moved away. If I could get the line to fire events when the cursor changes I could show/hide my hints at that time.

Is there a way to display a hint or fire events when the cursor changes?

Posted: Tue Jul 06, 2004 9:10 am
by Pep
Hi Leroy,
I realize that I can do this manually as you have pointed out. I was hoping that the TColorLineTool could handle this on its own. As it apparently can't, could you please add this behavior to the wish-list?
Ok, I've added on our wish list to be considered for the next releases.
Is there a way to display a hint or fire events when the cursor changes?
You could use similar code that in the example I've posted into the steema.public.attachments newsgroup.

Posted: Thu Jul 08, 2004 6:20 pm
by 9336236
Pep wrote:Hi Leroy,
I want the line to travel with the data, and vanish when the associated data point is no longer visible on the chart.

How can I make this happen?
you can solve this using the following code, also seting the NoDragLimit property to true :

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
if (Charttool1.Value > Chart1.Axes.Bottom.Maximum) or (Charttool1.Value < Chart1.Axes.Bottom.Minimum) then
   Charttool1.Visible := false
else
   Charttool1.Visible := true;
end;
This works fine.
One more thing. When the line I'm dragging hits the left or right edge of the chart, I'd like the chart to scroll so the user doesn't have to drag the marker to an edge, drop it, scroll the chart manually, then drag again.
This can be simulated by using the following code :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(1000);
Chart1.MaxPointsPerPage := 100;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
if (Charttool1.Value > Chart1.Axes.Bottom.Maximum) or (Charttool1.Value < Chart1.Axes.Bottom.Minimum) then
   Charttool1.Visible := false
else
   Charttool1.Visible := true;
end;

procedure TForm1.ChartTool1DragLine(Sender: TColorLineTool);
begin
if charttool1.Value < Chart1.Axes.Bottom.Minimum +10 then
    Chart1.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum-10,Chart1.Axes.bottom.Maximum-10)
else
  if charttool1.Value > Chart1.Axes.Bottom.Maximum - 10 then
     Chart1.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum+10,Chart1.Axes.bottom.Maximum+10);
end;
But this doesn't.

As the line I am dragging approaches within 10 units of either side of the chart, the chart scrolls as expected. The line I am dragging also scrolls, but the Drag Cursor does not travel with the line - it stays where the line was before the scroll.

Posted: Thu Jul 08, 2004 6:51 pm
by Pep
Hi Leroy,
As the line I am dragging approaches within 10 units of either side of the chart, the chart scrolls as expected. The line I am dragging also scrolls, but the Drag Cursor does not travel with the line - it stays where the line was before the scroll.
I'm sorry, I'm not quite sure what you refer here when you says "Drag Cursor". Is that you're using one more Tool (Cursor Tool) ? Could you please be more specific ?

Posted: Thu Jul 08, 2004 6:57 pm
by 9336236
Pep wrote:Hi Leroy,
As the line I am dragging approaches within 10 units of either side of the chart, the chart scrolls as expected. The line I am dragging also scrolls, but the Drag Cursor does not travel with the line - it stays where the line was before the scroll.
I'm sorry, I'm not quite sure what you refer here when you says "Drag Cursor". Is that you're using one more Tool (Cursor Tool) ? Could you please be more specific ?
When I move the cursor over the line, it changes to indicate that you can drag the line. This is what I was calling a Drag Cursor. The proper name for it is crHSplit.

Posted: Fri Jul 09, 2004 8:39 am
by Pep
Hi Leroy,

ok, I understand now. But here works fine using the TeeChart Pro v7 with BCB6 (the mouse cursor travels with the Line when drag). I've attached one example to the steema.public.attachments newsgroup. Could you please get it and test if it works fine for you ?

Posted: Fri Jul 09, 2004 9:50 pm
by 9336236
Pep wrote:Hi Leroy,

ok, I understand now. But here works fine using the TeeChart Pro v7 with BCB6 (the mouse cursor travels with the Line when drag). I've attached one example to the steema.public.attachments newsgroup. Could you please get it and test if it works fine for you ?
Thanks, Pep. I built your project and am still having the problem. I don't think I explained it well - the cursor tracks the line OK until the line reaches either edge of the chart, then the chart scrolls and the line scrolls with it, but the cursor does not.

I've uploaded a zip file containing an AVI which shows the problem to the steema.public.attachments newsgroup.

Posted: Wed Jul 14, 2004 3:37 pm
by 9336236
Pep, have you had a chance to look at this yet?

Posted: Thu Jul 15, 2004 7:02 am
by Pep
Hi Leroy,

sorry for delay. I'm not able to open the AVI files here. Could you please send them again directly to my mail account (pep@steema.com) ?