델파이 초보생입니다.
CHART에서 PIE를 이용하여 변수값을 그래프로 나타내고 싶습니다...Value1값과 Value2값을 파란색과 빨간색으로 구분하여 나타내고 싶은데, 고정적인 값을 써야 나타낼 수 있는지요?
답변부탁드립니다..
unit Ar2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBTables, DB, TeEngine, Series, TeeProcs, Chart, ExtCtrls,
Buttons, StdCtrls;
type
TFrmAr = class(TForm)
Btn_Close: TSpeedButton;
Panel1: TPanel;
Pan_Theme: TPanel;
Chart1: TChart;
// Series1: TPieSeries;
QryMain: TQuery;
UpdateSQL1: TUpdateSQL;
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Btn_CloseClick(Sender: TObject);
//procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmAr: TFrmAr;
implementation
{$R *.dfm}
uses grpcon, main, map, dbconnect;
procedure TFrmAr.FormClose(Sender: TObject; var Action: TCloseAction);
begin
QryMain.Free;
Action := caFree;
end;
procedure TFrmAr.FormDestroy(Sender: TObject);
begin
FrmAr := nil;
end;
procedure TFrmAr.FormCreate(Sender: TObject);
var
SqlStr, jStr,SqlStr1, SqlStr2: String;
Value1, Value2 : String;
begin
//전체 자료 검색
if FrmGrpCon.CheckBox1.Checked = True then
begin
//PJ_N 테이블의 면적 합계
With QryMain do
begin
if Active then Close;
Sql.Clear;
Sql.Add('SELECT SUM(U_A) AS AREA ');
Sql.Add('FROM PJ_N ');
Open;
if EOF then
begin
MessageDlg('등록된 자료가 없습니다!', mtInformation, [mbOk], 0);
DlgShow := False;
Exit;
end;
Value1 := FieldByName('AREA').AsString;
end;
//PJ_P 테이블의 면적 합계
With QryMain do
begin
if Active then Close;
Sql.Clear;
Sql.Add('SELECT SUM(U_A) AS AREA ');
Sql.Add('FROM PJ_P ');
Open;
if EOF then
begin
MessageDlg('등록된 자료가 없습니다!', mtInformation, [mbOk], 0);
DlgShow := False;
Exit;
end;
Value2 := FieldByName('AREA').AsString;
end;
ShowMessage('전체지역 PJ_N : ' + Value1 + ' PJ_P : ' + Value2);
end else
//부분 자료 검색
if FrmGrpCon.CheckBox2.Checked = True then
begin
//PJ_N 테이블의 면적 합계
With QryMain do
begin
if Active then Close;
Sql.Clear;
Sql.Add('SELECT SUM(U_A) AS AREA ');
Sql.Add('FROM PJ_N ');
if FrmGrpCon.Cmb_SD.Text <> '' then
Sql.Add('WHERE SD LIKE ''' + Copy(FRmGrpCon.Cmb_SD.Text, 2, 2) + ''' ');
if FrmGrpCon.Cmb_GG.Text <> '' then
Sql.Add('AND SG LIKE ''' + Copy(FrmGrpCon.Cmb_GG.Text, 2, 3) + ''' ');
if FrmGrpCon.Cmb_YM.Text <> '' then
Sql.Add('AND MY LIKE ''' + Copy(FrmGrpCon.Cmb_YM.Text, 2, 3) + ''' ');
Open;
if EOF then
begin
MessageDlg('등록된 자료가 없습니다!', mtInformation, [mbOk], 0);
DlgShow := False;
Exit;
end;
Value1 := FieldByName('AREA').AsString;
end;
//PJ_P 테이블의 면적 합계
With QryMain do
begin
if Active then Close;
Sql.Clear;
Sql.Add('SELECT SUM(U_A) AS AREA ');
Sql.Add('FROM PJ_P ');
if FrmGrpCon.Cmb_SD.Text <> '' then
Sql.Add('WHERE SD LIKE ''' + Copy(FRmGrpCon.Cmb_SD.Text, 2, 2) + ''' ');
if FrmGrpCon.Cmb_GG.Text <> '' then
Sql.Add('AND SG LIKE ''' + Copy(FrmGrpCon.Cmb_GG.Text, 2, 3) + ''' ');
if FrmGrpCon.Cmb_YM.Text <> '' then
Sql.Add('AND MY LIKE ''' + Copy(FrmGrpCon.Cmb_YM.Text, 2, 3) + ''' ');
Open;
if EOF then
begin
MessageDlg('등록된 자료가 없습니다!', mtInformation, [mbOk], 0);
DlgShow := False;
Exit;
end;
Value2 := FieldByName('AREA').AsString;
end;
ShowMessage('지역별 PJ_N : ' + Value1 + ' PJ_P : ' + Value2);
//* Chart1.Series[1].Add(Value1, 'K', clRed);
//* Chart2.Series[2].Add(Value2,'P',clBlue);
end;
end;
procedure TFrmAr.Btn_CloseClick(Sender: TObject);
begin
Close;
end;
end.