Deleting mouse selected data ?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Deleting mouse selected data ?

Post by moelski » Tue Nov 13, 2007 1:16 pm

Hi support,

a customer asked me the following and I can´t find an answer ...

Is it possible to select an x-area of the chart with the mouse and then delete the data I´ve selected?

Example ...
I have a chart with 2 fastline series. The X axis has values from 0 to 50.
I select the data from X value 0 to 20 and delete it.
After this procedure the X axis shows only the vales from 20 to 50. And the data from the both fastlines only have 30 x/y values.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Nov 13, 2007 2:46 pm

Hi Dominik,

Yes, you could use a TColorBandTool for selecting the values as some code like this:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues(50);
  Series2.FillSampleValues(50);

  ChartTool1.Axis:=Series1.GetHorizAxis;
  ChartTool1.StartLine.AllowDrag:=true;
  ChartTool1.StartLine.Active:=true;
  ChartTool1.EndLine.AllowDrag:=true;
  ChartTool1.EndLine.Active:=true;

  ChartTool1.StartValue:=5;
  ChartTool1.EndValue:=25;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
    tmp: double;
begin
  for i:=Series1.Count-1 downto 0 do
  begin
    tmp:=Series1.XValue[i];

    if ((tmp>=ChartTool1.StartValue) and (tmp<=ChartTool1.EndValue)) then
    begin
      Series1.Delete(i);
      Series2.Delete(i);
    end;
  end;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Wed Nov 14, 2007 8:18 am

Hi Narcis,

I did a test today and it works nearly perfect.

I have only one problem left ...
Is it possible to recalculate the X Axis?

Example:
If I delete the data from XValue 0 - 20 the x axis starts from 21 after deleting. But it would be better if the Axis starts from 0 again.

Same problem if I delete values from 10-20 for example. Only the Y data is deleted and not the x values.

I can make two pictures is necessary.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 14, 2007 9:26 am

Hi Dominik,

Ok, then the solution is pretty easy. You can force sequential values in series using FillSequence as shown here:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
    tmp: double;
begin
  for i:=Series1.Count-1 downto 0 do
  begin
    tmp:=Series1.XValue[i];

    if ((tmp>=ChartTool1.StartValue) and (tmp<=ChartTool1.EndValue)) then
    begin
      Series1.Delete(i);
      Series2.Delete(i);
    end;
  end;

  Series1.XValues.FillSequence;
  Series2.XValues.FillSequence;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Wed Nov 14, 2007 9:32 am

Hi Narcis,

I´m speechless, really !

There is actually no day (until we bought TChart) where I don´t found any amazing feature in TChart.

Thx alot for your help !!!

Image

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 14, 2007 9:48 am

Hi Dominik,

You're very welcome! I'm glad to hear that.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply