Graphical Interaction with Graphs

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Karen99
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am

Graphical Interaction with Graphs

Post by Karen99 » Mon Jun 26, 2006 12:36 pm

Hi!

Is there a function available within your charts to have like two line dividers that can be moved accross the graph on the horizontal axis. The graph then must report on the starting value as well as the ending value. I'd like to develop a graphical delete function. All data between these two dividers will then be deleted in the original dataset.

Regards

Jaco Pretorius

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

Post by Narcís » Mon Jun 26, 2006 12:57 pm

Hi Jaco,

Yes, TColorBandTool exactly does what you request. For examples on how to use it you can have a look at the features demo at TeeChart's program group.
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

Karen99
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am

Post by Karen99 » Tue Jun 27, 2006 8:31 am

Hi again

I had no demo as you suggested, but I came accross the TColorLine tool which has an extra function than the TColorBand tool and that is to be able to move the lines.

I am using a Chart that displays data over a time period. It should be possible to delete data between two date time values. The TColorLine tool gives you a double value as you move the line, but how on earth do I convert this double value to the exact date time on which the line is.

Have any suggestions/help?

Regards

Jaco

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 Jun 27, 2006 9:31 am

Hi Jaco,

TColorBandTool also supports line dragging. You can do something like this using a TColorBandTool:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  Series1.XValues.DateTime:=true;
  Series1.FillSampleValues(50);

  With ChartTool1 do
  begin
    Axis:=Chart1.Axes.Bottom;
    ResizeEnd:=true;
    ResizeStart:=true;
    StartValue:=Series1.XValue[5];
    EndValue:=Series1.XValue[15];
  end;

end;

procedure TForm1.Button1Click(Sender: TObject);
var i1, i2: integer;
begin
  i1:=Series1.XValues.Locate(Round(ChartTool1.StartValue));
  i2:=Series1.XValues.Locate(Round(ChartTool1.EndValue));

  if CheckBox1.Checked then
  begin
    Series1.Delete(i1,i2-i1, true);
    ChartTool1.StartValue:=Series1.XValue[i1];
    ChartTool1.EndValue:=Series1.XValue[i2];
  end
  else
    Series1.Delete(i1,i2-i1);
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

Karen99
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am

Post by Karen99 » Tue Jun 27, 2006 9:36 am

Thanks!

Will try it soon.

Regards

Jaco

Karen99
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am

Post by Karen99 » Tue Jun 27, 2006 2:50 pm

Hi Again

How can I actually get the date/time value on which this ColorLine is? I have decided to use the Color Lines and not the Color Bands. My graph is not connected to a dataset, but I have to delete data in a dataset according to this selecteion of the lines.

Regards

Jaco - Thanks for the help so far. It is good.

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 Jun 27, 2006 2:59 pm

Hi Jaco,

Have you tried using the Locate method and Series.XValue[index] as in the code snippet I posted before?
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

Karen99
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am

Post by Karen99 » Wed Jun 28, 2006 6:37 am

Hi

Yes I did. It returns a double that I convert to a TDateTime value. That value is wrong.

Regards

Jaco

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 Jun 28, 2006 9:09 am

Hi Jaco,

It works fine for me here doing something like this:

Code: Select all

uses Math;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  Series1.XValues.DateTime:=true;
  Series1.FillSampleValues(50);

  SetRoundMode(rmUP);
end;

procedure TForm1.ChartTool1DragLine(Sender: TColorLineTool);
var
  i1,i2: Integer;
  y,m,d: Word;
begin
  i1:=Series1.XValues.Locate(Trunc(ChartTool1.Value));
  i2:=Series1.XValues.Locate(Round(ChartTool1.Value));

  DecodeDate(Series1.XValue[i1],y,m,d);
  Memo1.Lines.Add(IntToStr(d)+'/'+IntToStr(m)+'/'+IntToStr(y));

  DecodeDate(Series1.XValue[i2],y,m,d);
  Memo1.Lines.Add(IntToStr(d)+'/'+IntToStr(m)+'/'+IntToStr(y));
end;
Could you please check if this works at your end and if the problem persists send us an example we can run "as-is" to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.
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

achristouio
Newbie
Newbie
Posts: 26
Joined: Tue Apr 02, 2002 5:00 am
Location: University of Oslo
Contact:

Post by achristouio » Tue Jul 04, 2006 7:54 pm

narcis wrote:Hi Jaco,

TColorBandTool also supports line dragging. You can do something like this using a TColorBandTool:
I thought tOlorBandTool are lacking an important event for that, an event that tell the program that a line has been dragged?

Maybe somethng for next version?

Would also be interesting if the area also could be moved around, I have a use here where the area should change dependent on data it covers.

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 Jul 05, 2006 7:30 am

Hi achristouio,
I thought tOlorBandTool are lacking an important event for that, an event that tell the program that a line has been dragged?

Maybe somethng for next version?
Yes, I added your request to our wish-list to be considered for inclusion in future releases.
Would also be interesting if the area also could be moved around, I have a use here where the area should change dependent on data it covers.
Could you please give us more specific information on that request?
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