Hi,
I have a question here, how do I get the value from TColorGridSeries, ex. for a regular grid 3x3, I add data
[ 3 4 4
4 5 6
4 6 8], but how to get the data say with index (2,1) back from series.
One more question, does latest version support set one color as transparent color for TColorGridSeries and plot two colorgrid at the same time?
Thanks
Best Regards
Fang
TColorGrid read data value & transpancy question
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Fang,
Or you can use GetColumn and GetRow methods implemented in the example below.
You can use Clicked method doing something like this:I have a question here, how do I get the value from TColorGridSeries, ex. for a regular grid 3x3, I add data
[ 3 4 4
4 5 6
4 6 8], but how to get the data say with index (2,1) back from series.
Code: Select all
procedure TForm1.Series1Click(Sender: TChartSeries; ValueIndex: Integer;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var i: Integer;
begin
i:=Series1.Clicked(X,Y);
Chart1.Title.Text[0]:=FloatToStr(Series1.YValue[i]);
end;
Code: Select all
var
Form1: TForm1;
X0,Y0,X1,Y1,XIndex,YIndex: Integer;
DrawRect: Boolean;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(10);
Chart1.Zoom.Allow:=false;
end;
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Memo1.Clear;
X0:=X;
Y0:=Y;
XIndex:=Series1.Clicked(X0,Y0);
DrawRect := true;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if DrawRect then
begin
X1:=X;
Y1:=Y;
Chart1.Repaint;
end;
end;
procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
DrawRect := false;
YIndex:=Series1.Clicked(X1,Y1);
GetRectIndexes;
Chart1.Repaint;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
With Chart1.Canvas do
begin
Pen.Color:=clWhite;
Pen.Width:=2;
Brush.Style:=bsClear;
Rectangle(X0,Y0,X1,Y1);
end;
end;
procedure TForm1.GetRectIndexes;
var
Col0,Row0,Col1,Row1,x,z: Integer;
begin
Col0:=GetColumn(XIndex);
Row0:=GetRow(XIndex);
Col1:=GetColumn(YIndex);
Row1:=GetRow(YIndex);
for x:=Min(Col0,Col1) to Max(Col0,Col1) do
for z:=Min(Row0,Row1) to Max(Row0,Row1) do
Memo1.Lines.Add(FloatToStr(Series1.YValues[(x*10)+z]));
end;
function TForm1.GetColumn(ValueIndex: Integer): Integer;
begin
result:=ValueIndex div Series1.NumXValues;
end;
function TForm1.GetRow(ValueIndex: Integer): Integer;
begin
result:=ValueIndex mod Series1.NumZValues;
end;
If you want to set a TColorGridSeries cell being transparent you can set its color to clNone. And yes, two ColorGrids can be drawn at the same time, for example:One more question, does latest version support set one color as transparent color for TColorGridSeries and plot two colorgrid at the same time?
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
For i:=0 to 5 do
begin
Series1.AddXYZ(i,random,i);
Series2.AddXYZ(i+6,random,i);
end;
Chart1.View3D:=false;
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 |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Fang,
Yes, that's what I meant, you can add values to the series doing something like:
Yes, that's what I meant, you can add values to the series doing something like:
Code: Select all
Series1.AddXYZ(x,y,z,'',clNone);
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |