Showing the point selected in TChart in TChartGrid.

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bamboo
Newbie
Newbie
Posts: 32
Joined: Thu Jul 12, 2007 12:00 am

Showing the point selected in TChart in TChartGrid.

Post by bamboo » Thu Jun 12, 2008 7:36 am

When ever I click on a point on my series I want the row to be highlighted.
I am able to do this using the

Code: Select all

ChartGrid1.Selection := myRect;
property.

The problem is that the row is not immediately visible.
How can get this highlighted row to be visible immediately?

And is using the code above the only way of doing this or is there an easier way.

Thanks.

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

Post by Narcís » Thu Jun 12, 2008 7:42 am

Hi bamboo,

To achieve what you request you should do as in the All Features\Welcome!\Databas Charts\Locate Records example in the new features demo, available 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

bamboo
Newbie
Newbie
Posts: 32
Joined: Thu Jul 12, 2007 12:00 am

Post by bamboo » Thu Jun 12, 2008 7:59 am

Thanks, but I am using TChart and TChartGrid and my series are created at runtime.

The link you directed me to seems to be for database entries only. By the way what is the name of Table1 component in the code.

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Jun 17, 2008 3:04 pm

Hello,
Thanks, but I am using TChart and TChartGrid and my series are created at runtime.
The code used in your first post should do the trick, I've just tried it making use of the OnClickSeries event and the cell is highlighted immediately after a series point is clicked. Here is the code I've used :

Code: Select all

procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
  Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var gr : tgridrect;
begin
  gr.Left := 2;
  gr.Top := valueindex;
  gr.Bottom :=valueindex;
  gr.Right :=2;
  ChartGrid1.Selection := TGridRect(gr);
end;

procedure TForm1.FormCreate(Sender: TObject);
var points : TPointSeries;
begin
  points := TPointSeries.Create(Self);
  points.ParentChart := Chart1;
  points.FillSampleValues;
  Chart1.OnClickSeries:=Chart1ClickSeries;
  ChartGrid1.Chart := Chart1;
end;
Could you please check if it works fine for you ?
The link you directed me to seems to be for database entries only. By the way what is the name of Table1 component in the code.
You should be able to check the names of all the components used for this demo opening the TeeNew Demo (source included into the installation folder) with any Delphi and checking the dfm. If you needing help do not hesitate to let us know.

bamboo
Newbie
Newbie
Posts: 32
Joined: Thu Jul 12, 2007 12:00 am

Post by bamboo » Wed Jun 18, 2008 7:38 am

Thanks for the code. I have used similar code.
The problem is that it does not display data points towards the end of the graph unless you manually scroll to that point in ChartGrid.
If you set the ChartGrid to display 10 points at a time and your series displays 100 points and you then select point number 85 for example, then the ChartGrid will highlight point number 85 but you will not see it until you manually scroll to it.
Is there a way around this. I would like to see the point selected in ChartGrid without scrolling to it manually.

Please advise.
Thank you.

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Jun 18, 2008 10:30 am

Hi bamboo,
you can do :

Code: Select all

procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
  Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Chart1.Title.Caption := inttostr(valueindex);
  Chartgrid1.Row:=valueindex+2;
  ChartGrid1.Col:=2;
end;
This will scroll automatically to the specific row.

bamboo
Newbie
Newbie
Posts: 32
Joined: Thu Jul 12, 2007 12:00 am

Post by bamboo » Wed Jun 18, 2008 12:44 pm

Thank you.

Row and Col are the two properties I never imagined would be used for this.

Thanks again.

Post Reply