DragMarks tool

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

DragMarks tool

Post by JimR » Tue Nov 14, 2017 4:08 am

If I have several point series on my chart. By making the DragMarksTool active I can just drag the marks for the points in the last series. How do I make the marks for all of the series drag-able? The number of series depends on the data so it has to be done at run time.

Thanks again,

Jim

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: DragMarks tool

Post by Yeray » Tue Nov 14, 2017 7:31 am

Hello Jim,

Assigning nil to the TDragMarksTool's Series property should enable it for all the series.
An alternative is to set the TDragMarksTool's Series at OnMouseMove. Ie:

Code: Select all

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var SeriesIndex: Integer;
begin
  for SeriesIndex:=0 to Chart1.SeriesCount-1 do
  begin
    if Chart1[SeriesIndex].Marks.Clicked(X, Y) > -1 then
       (Chart1.Tools[0] as TDragMarksTool).Series:=Chart1[SeriesIndex];
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Re: DragMarks tool

Post by JimR » Tue Nov 14, 2017 4:59 pm

Thanks - that first solution of setting the series property to nil is simple and it works. I would not have guessed that. What is the procedure to restore it to normal?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: DragMarks tool

Post by Yeray » Wed Nov 15, 2017 7:28 am

Hello,
JimR wrote:Thanks - that first solution of setting the series property to nil is simple and it works. I would not have guessed that.
I'm glad to hear it works as you wish now.
JimR wrote:What is the procedure to restore it to normal?
By "normal" do you mean what you said in the opening post here?
JimR wrote:I can just drag the marks for the points in the last series
This is not the behaviour I observe by default. The TDragMarksTool works with all the series for me by default:

Code: Select all

uses Series, TeeTools;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=False;

  for i:=0 to 3 do
    with Chart1.AddSeries(TPointSeries) do
    begin
      Marks.Visible:=True;
      FillSampleValues(5);
    end;

  Chart1.Tools.Add(TDragMarksTool);
end;
What version are you using?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Re: DragMarks tool

Post by JimR » Wed Nov 15, 2017 12:12 pm

I meant your first example"
"Assigning nil to the TDragMarksTool's Series property should enable it for all the series."

How does one undo that ?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: DragMarks tool

Post by Yeray » Wed Nov 15, 2017 1:30 pm

Hello,
JimR wrote:I meant your first example"
"Assigning nil to the TDragMarksTool's Series property should enable it for all the series."

How does one undo that ?
By default, Series is nil (1). You can check it with this example:

Code: Select all

uses Series, TeeTools;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=False;

  for i:=0 to 3 do
    with Chart1.AddSeries(TPointSeries) do
    begin
      Marks.Visible:=True;
      FillSampleValues(5);
    end;

  Chart1.Tools.Add(TDragMarksTool);

  if (Chart1.Tools[0] as TDragMarksTool).Series = nil then
     Caption:='Series is nil'
  else
     Caption:='Series is assigned';
end;
If at some stage you assigned a Series to the TDragMarksTool to limit it (2), and later you set it to nil to use it in all the Series again (3), and you want to remember to what Series did you assign it at the beginning to reassign it (4), you can store the Series you assigned when setting to nil (at point 3). Ie:

Code: Select all

var mySeries: TChartSeries;
//...
  mySeries:=(Chart1.Tools[0] as TDragMarksTool).Series;
  (Chart1.Tools[0] as TDragMarksTool).Series:=nil;
And then restore that series (at point 4):

Code: Select all

  (Chart1.Tools[0] as TDragMarksTool).Series:=mySeries;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Re: DragMarks tool

Post by JimR » Wed Nov 15, 2017 7:21 pm

ok, that is clearer. Thanks again.

Post Reply