Показать сообщение отдельно
  #1  
Старый 28.06.2013, 20:09
cezer cezer вне форума
Прохожий
 
Регистрация: 01.06.2012
Сообщения: 44
Репутация: 10
Вопрос График на основе Brush.Canvas

Добрый вечер Ув. Программисты.
Делаю свой график вот код:

Код:
var
  Form1: TForm1;
  arPxl: array [0..7]  of TPoint;
  i, j, max, a, b: Integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  max := StrToInt(StringGrid1.Cells[0, 0]);
  for i:= 0 to 5 do
    for j:=0 to 0 do
      if StrToInt(StringGrid1.Cells[i, j]) > max then
        max := StrToInt(StringGrid1.Cells[i, j]);
  Label1.Caption := IntToStr(max);



image7.Refresh;
image7.Repaint;
image1.Visible:=false;
image2.Visible:=false;
image3.Visible:=false;
image4.Visible:=false;
image5.Visible:=false;
image6.Visible:=false;
Canvas.Brush.Color:=clred;

arPxl[0].X:=50;
arPxl[0].Y:=200;

arPxl[1].X:=50;
a:=round(((strtoint(StringGrid1.Cells[0, 0])/max))*100);
b:=(100-a)+100;
arPxl[1].Y:=b;
image1.Left:=arPxl[1].X-5;
image1.Top:=arPxl[1].Y-5;

arPxl[2].X:=100;
a:=round(((strtoint(StringGrid1.Cells[1, 0])/max))*100);
b:=(100-a)+100;
arPxl[2].Y:=b;
image2.Left:=arPxl[2].X-5;
image2.Top:=arPxl[2].Y-5;

arPxl[3].X:=150;
a:=round(((strtoint(StringGrid1.Cells[2, 0])/max))*100);
b:=(100-a)+100;
arPxl[3].y:=b;
image3.Left:=arPxl[3].X-5;
image3.Top:=arPxl[3].Y-5;

arPxl[4].X:=200;
a:=round(((strtoint(StringGrid1.Cells[3, 0])/max))*100);
b:=(100-a)+100;
arPxl[4].y:=b;
image4.Left:=arPxl[4].X-5;
image4.Top:=arPxl[4].Y-5;

arPxl[5].X:=250;
a:=round(((strtoint(StringGrid1.Cells[4, 0])/max))*100);
b:=(100-a)+100;
arPxl[5].y:=b;
image5.Left:=arPxl[5].X-5;
image5.Top:=arPxl[5].Y-5;

arPxl[6].X:=300;
//arPxl[6].y:=145;
a:=round(((strtoint(StringGrid1.Cells[5, 0])/max))*100);
b:=(100-a)+100;
arPxl[6].y:=b;
image6.Left:=arPxl[6].X-5;
image6.Top:=arPxl[6].Y-5;

arPxl[7].X:=300;
arPxl[7].y:=200;

image1.Hint:=(StringGrid1.Cells[0, 0]);
image2.Hint:=(StringGrid1.Cells[1, 0]);
image3.Hint:=(StringGrid1.Cells[2, 0]);
image4.Hint:=(StringGrid1.Cells[3, 0]);
image5.Hint:=(StringGrid1.Cells[4, 0]);
image6.Hint:=(StringGrid1.Cells[5, 0]);

Canvas.Polygon(arPxl);
image1.Visible:=true;
image2.Visible:=true;
image3.Visible:=true;
image4.Visible:=true;
image5.Visible:=true;
image6.Visible:=true;
Canvas.Polygon(arPxl);

end;

Вот исходники: График.rar

подскажите как сделать этот график универсальным.
А именно... Добавление сколько угодно в стринг грид данных, сколько угодно вспомогательных точек(image1 и тд). Ну вообщем чтоб он был универсальным для входных данных. За ранее спасибо.

С Уваженияем: Я.
Ответить с цитированием