PDA

Ver la Versión Completa : Liberar Grafico


maravert
08-01-2007, 11:27:47
Que tal, trabajo con Delphi 7 y el Tchart, me grafica perfectamente, solo que al realizar una consulta de un segundo cliente en relacion a sus ventas por mes, me suma con las del anterior y asi sucesivamente, es decir no me libera el grafico para ver solo la del siguiente cliente.

Se supone que con la instrucciòn

Series1.Clear;

Se liberaria, pero no pasa nada.

Aquì esta mi codigo, espero añguin me diga que estoy haciendo mal.

unit Unit73;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables, Buttons, ExtCtrls, TeeProcs, TeEngine,
Chart, Series, ComCtrls;
type
TForm73 = class(TForm)
Chart1: TChart;
Edit1: TEdit;
Button1: TButton;
BitBtn1: TBitBtn;
Table1: TTable;
Table2: TTable;
Label1: TLabel;
Label3: TLabel;
Series1: TBarSeries;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure Button1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form73: TForm73;
aMeses:array[1..12] of
string=('Ene' ,'Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct',
'Nov','Dic');
ventas: Array[1..12] of real;
Serie1:TLineSeries;
Serie2:TFastLineSeries;
Serie3:TBarSeries;
Serie4:TAreaSeries;
Serie5:TPieSeries;
Fecha1, Fecha2 : Tdate;
x:byte;
implementation
uses Unit80, Unit74, Unit78;
{$R *.dfm}
procedure TForm73.Button1Click(Sender: TObject);
var
FechaS, Mes : string;
X : INTEGER;
ventasT : Real;
begin
fecha1 := Datetimepicker1.DateTime;
fecha2 := Datetimepicker2.DateTime;
tABLE2.OPEN;
Table2.first;
While Not Table2.eof do
begin
If table2.fieldbyname ('Clave').asstring = edit1.text then
Label3.caption := tABLE2.Fieldbyname ('Nombre').asstring;
Table2.next;
end;
Table2.close;

Table1.open;
Table1.first;
ventasT:= 0;
While Not Table1.eof do
Begin
if Trim (Table1.fieldbyname ('iD_cLIENTE').Asstring) = Trim (edit1.text) then
Begin
if Table1.fieldbyname ('Fecha').AsDateTime >= Fecha1 then
Begin
if Table1.fieldbyname ('Fecha').asdateTime <= Fecha2 then
Begin
FechaS := DateTostr (Table1.fieldbyname ('Fecha').asdateTime);
Mes := Copy (FechaS,4,2);
ventasT := ventasT + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '01' Then ventas [1] := ventas [1] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '02' Then ventas [2] := ventas [2] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '03' Then ventas [3] := ventas [3] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '04' Then ventas [4] := ventas [4] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '05' Then ventas [5] := ventas [5] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '06' Then ventas [6] := ventas [6] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '07' Then ventas [7] := ventas [7] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '08' Then ventas [8] := ventas [8] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '09' Then ventas [9] := ventas [9] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '10' Then ventas [10] := ventas [10] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '11' Then ventas [11] := ventas [11] + Table1.fieldbyname ('Subtotal').asfloat;
If mes = '12' Then ventas [12] := ventas [12] + Table1.fieldbyname ('Subtotal').asfloat;
end;
end;
end;
Table1.next;
end;
Chart1.SeriesList.Clear;
Series1.clear;
Serie3:=TBarSeries.Create(Self);
With Serie3 do
Begin
ParentChart:=Chart1;
for x:=1 to 12 do
Add(Ventas[x],aMeses[x]);
end;
Label6.Caption := FormatFloat('###,###,###,##0.00',ventasT);
end;
procedure TForm73.BitBtn1Click(Sender: TObject);
begin
fORM73.cLOSE;
end;

procedure TForm73.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_F2: begin
Form78.show;
end;
END;
end;
end.

Casimiro Notevi
08-01-2007, 11:42:48
Así a simple vista, me parece que no "limpias" el array "ventas"

maravert
08-01-2007, 12:31:03
Gracias, eso era, en verdad estaba miope.

te lo agradesco mucho