Page 1 of 1
Showing the point selected in TChart in TChartGrid.
Posted: Thu Jun 12, 2008 7:36 am
by 10546084
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
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.
Posted: Thu Jun 12, 2008 7:42 am
by narcis
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.
Posted: Thu Jun 12, 2008 7:59 am
by 10546084
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.
Posted: Tue Jun 17, 2008 3:04 pm
by Pep
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.
Posted: Wed Jun 18, 2008 7:38 am
by 10546084
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.
Posted: Wed Jun 18, 2008 10:30 am
by Pep
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.
Posted: Wed Jun 18, 2008 12:44 pm
by 10546084
Thank you.
Row and Col are the two properties I never imagined would be used for this.
Thanks again.