Подскажите пожалуйсто как пользоваться графиком Chart.
И возможно ли связать StringGrid с этим графиком.
Если можно то напишите хотябы примерно как это зделать!
function AddXY(Const AXValue, AYValue: Double; Const AXLabel: String; AColor: TColor) : Longint;
for i := 0 to 10 do
begin
Chart1.Series[0].AddXY(i,i*2,'Text',clRed);
end;
Form1.StringGrid1.Cells[8,1]
for k:=1 to 10 do
Chart1.Series[0].AddXY(k,StrToFloat(Form1.StringGrid1.Cells[8,1]),' ',clREd);
Form1.StringGrid1.Cells[8,1]
for k:=1 to 10 do
Chart1.Series[0].AddXY(k,StrToFloat(Form1.StringGrid1.Cells[8,1]),' ',clREd);
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, Series, StdCtrls, ExtCtrls, TeeProcs, Chart, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Chart1: TChart;
Button1: TButton;
Series1: TLineSeries;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
k : Integer;
begin
for k := 1 to 7 do
Chart1.Series[0].AddXY(k,StrToFloat(Form1.StringGrid1.Cells[k,1]),' ',clREd);
end;
end.
for i := 1 to StringGrid1.RowCount-1 do
begin
bez := 0;
bez := bez + StrToInt(StringGrid1.Cells[7,i]); // это я так понимаю сумма элементов нужного столбца
Chart1.Series[0].AddXY(i,bez,'',clRed);
end;
bez := bez + StrToFloat(StringGrid1.Cells[7,i]);
Chart1.Series[0].Clear;
bez := 0;
for j := 1 to StringGrid1.RowCount-1 do
begin
bez := bez + StrToFloat(StringGrid1.Cells[7,j]);//подсчитываем сумму элементов
end;
Chart1.Series[0].AddXY(1,bez,' ',clRed);//Выводим один столбец с суммой
for j := 1 to StringGrid1.RowCount-1 do
begin
bez := bez + StrToFloat(
StringReplace(
StringReplace(StringGrid1.Cells[7, j], '.', DecimalSeparator, [rfReplaceAll]),
',', DecimalSeparator, [rfReplaceAll]
) // подсчитываем сумму элементов
); // Независимо от того, точка или запятая стоит в StringGrid
end;
Project Project1.exe raised exeption Class EconvertError With Message "' is not a valid Floating value Process stoped
.Use Step or run to continue
Form6.Show;Хотя отрисовку графика навешал на Create
procedure CreateУдали ее!
var
Bez:Real;
j:integer;
begin
Chart1.Visible := true;
Chart1.Series[0].Clear;
bez := 0;
for j := 1 to Form1.StringGrid1.RowCount-1 do
begin
if not(Length(Form1.StringGrid1.Cells[7,j]) = 0) then //Если ячейка не пуста
bez := bez + StrToFloat(Form1.StringGrid1.Cells[7,j]);//подсчитываем сумму элементов
end;
Chart1.Series[0].AddXY(1,bez,' ',clRed);//Выводим один столбец с суммой
stoimost:integerКак Ты хочеш занести в нее дорби???
procedure TForm2.LabeledEdit3KeyPress(Sender: TObject; var Key: Char);
var
Not_DESIMAL : string;
begin
if DecimalSeparator = ',' then
Not_DESIMAL := '.'
else
Not_DESIMAL := ',';
if Key = Not_DESIMAL then
Key := DecimalSeparator;
if ((Key in ['0' .. '9']))OR(Key = DecimalSeparator) then begin
if (Key = DecimalSeparator) AND (Pos(DecimalSeparator,(Sender AS TLabeledEdit).Text) > 0) then begin
Key := Chr(0);
end;
end else if (Key=Chr(VK_RETURN))OR (Key=Chr(VK_BACK)) then begin
end
else Key := Chr(0);
end;
begin
if not(Key in ['0' .. '9']) then begin
Key := Chr(0);
end;
end else if (Key=Chr(VK_RETURN))OR (Key=Chr(VK_BACK)) then begin
end
else Key := Chr(0);
end;