Grafico na Web
Galera.
Estou precisando da ajuda de vcs, preciso colocar um grafico como pagina de internet, alguem tem algum exemplo ou dica.
Grato.
Estou precisando da ajuda de vcs, preciso colocar um grafico como pagina de internet, alguem tem algum exemplo ou dica.
Grato.
Ericfp
Curtidas 0
Respostas
Cebikyn
15/09/2003
Vc já tem o gráfico em um arquivo ou quer que o programa crie o gráfico e depois faça o Upload?
GOSTEI 0
Sam
15/09/2003
var
Formato: String;
Stream: TMemoryStream;
Chart: TDBChart;
i : integer;
begin
*** Abertura do Banco de Dados ****
try
{ Envia cabeçalho HTTP definindo ContentType }
Response.ContentType := ´image/gif´;
Response.SendResponse;
Stream := TMemoryStream.Create;
try
Chart := TDBChart.Create(nil);
try
{ Passo 3: Configurar o objeto TDBChart }
MakeBarChart(Chart, Formato,QryDolarVariacaoDiario,´Variação Dólar - Dia: ´+DateToStr(QryDolarVariacaoDiarioData.value),´Hora´,´Valor´,´DÓLAR´,´Valor´);
{ Passo 4: Escrever a imagem do gráfico em um objeto TStream }
SaveChartToStream(Chart, 700, 300, Stream);
finally
Chart.Free;
end;
{ Passo 5: Enviar o conteúdo do TStream por TWebResponse }
Response.SendStream(Stream);
finally
Stream.Free;
end;
finally
*** fechamento do banco de dados ****
procedure TWebModule1.MakeBarChart(AChart: TDBChart; const Formato: String; DB : TQuery; Titulo : string; ValorX : string; ValorY : string; serie : string; ValorYD : string);
var
Series1: TLineSeries;
begin
with AChart do
begin
BackWall.Brush.Color := clWhite;
BackWall.Brush.Style := bsClear;
BevelOuter := bvNone;
Color := clWhite;
MarginBottom := 1;
MarginLeft := 1;
MarginRight := 5;
MarginTop := 1;
Gradient.Visible := False;
Title.Visible := True;
Title.text.add(Titulo);
LeftAxis.Visible := true;
LeftAxis.Grid.Visible := true;
LeftAxis.Automatic := True;
LeftAxis.AutomaticMaximum := True;
LeftAxis.AutomaticMinimum := True;
BottomAxis.Grid.Visible := True;
BottomAxis.LabelsAngle := 90;
BottomAxis.LabelsSeparation := 5;
BottomAxis.MinorTicks.Visible := False;
BottomAxis.TicksInner.Visible := False;
BottomAxis.Title.Caption := ´Meu Gráfico´;
BottomAxis.Title.Font.Size := 12;
Chart3DPercent := 1;
Legend.visible := false;
end;
Series1 := TLineSeries.Create(AChart);
with Series1 do
begin
Pointer.HorizSize := 2;
Pointer.VertSize := 2;
Pointer.Visible := true;
ParentChart := AChart;
SeriesColor := clGreen;
Marks.Style := smsValue;
Marks.Visible := True;
DataSource := DB;
XLabelsSource := ValorX;
XValues.DateTime := False;
XValues.Name := ´X´;
XValues.Multiplier := 1;
XValues.Order := loAscending;
YValues.DateTime := False;
YValues.Name := ´Bar´;
YValues.Multiplier := 1;
YValues.Order := loNone;
if serie = ´REAIS´ then YValues.ValueSource := ValorY;
if serie = ´DÓLAR´ then YValues.ValueSource := ValorYD;
end;
end;
Formato: String;
Stream: TMemoryStream;
Chart: TDBChart;
i : integer;
begin
*** Abertura do Banco de Dados ****
try
{ Envia cabeçalho HTTP definindo ContentType }
Response.ContentType := ´image/gif´;
Response.SendResponse;
Stream := TMemoryStream.Create;
try
Chart := TDBChart.Create(nil);
try
{ Passo 3: Configurar o objeto TDBChart }
MakeBarChart(Chart, Formato,QryDolarVariacaoDiario,´Variação Dólar - Dia: ´+DateToStr(QryDolarVariacaoDiarioData.value),´Hora´,´Valor´,´DÓLAR´,´Valor´);
{ Passo 4: Escrever a imagem do gráfico em um objeto TStream }
SaveChartToStream(Chart, 700, 300, Stream);
finally
Chart.Free;
end;
{ Passo 5: Enviar o conteúdo do TStream por TWebResponse }
Response.SendStream(Stream);
finally
Stream.Free;
end;
finally
*** fechamento do banco de dados ****
procedure TWebModule1.MakeBarChart(AChart: TDBChart; const Formato: String; DB : TQuery; Titulo : string; ValorX : string; ValorY : string; serie : string; ValorYD : string);
var
Series1: TLineSeries;
begin
with AChart do
begin
BackWall.Brush.Color := clWhite;
BackWall.Brush.Style := bsClear;
BevelOuter := bvNone;
Color := clWhite;
MarginBottom := 1;
MarginLeft := 1;
MarginRight := 5;
MarginTop := 1;
Gradient.Visible := False;
Title.Visible := True;
Title.text.add(Titulo);
LeftAxis.Visible := true;
LeftAxis.Grid.Visible := true;
LeftAxis.Automatic := True;
LeftAxis.AutomaticMaximum := True;
LeftAxis.AutomaticMinimum := True;
BottomAxis.Grid.Visible := True;
BottomAxis.LabelsAngle := 90;
BottomAxis.LabelsSeparation := 5;
BottomAxis.MinorTicks.Visible := False;
BottomAxis.TicksInner.Visible := False;
BottomAxis.Title.Caption := ´Meu Gráfico´;
BottomAxis.Title.Font.Size := 12;
Chart3DPercent := 1;
Legend.visible := false;
end;
Series1 := TLineSeries.Create(AChart);
with Series1 do
begin
Pointer.HorizSize := 2;
Pointer.VertSize := 2;
Pointer.Visible := true;
ParentChart := AChart;
SeriesColor := clGreen;
Marks.Style := smsValue;
Marks.Visible := True;
DataSource := DB;
XLabelsSource := ValorX;
XValues.DateTime := False;
XValues.Name := ´X´;
XValues.Multiplier := 1;
XValues.Order := loAscending;
YValues.DateTime := False;
YValues.Name := ´Bar´;
YValues.Multiplier := 1;
YValues.Order := loNone;
if serie = ´REAIS´ then YValues.ValueSource := ValorY;
if serie = ´DÓLAR´ then YValues.ValueSource := ValorYD;
end;
end;
GOSTEI 0
Ericfp
15/09/2003
Estou seguindo o exemplo da ClubeDelphi 25, Graficos na Web; mas não estou conseguindo visualizar o grafico no IE.
Esta sendo feito uma aplicação WebServer, e foi criado uma pasta virtual no ISS, a tela com os combo para seleção de data e outros valores esta aparecendo, mas quando que clico em consultar não consegue localizar o a imagem do grafico gerado pelo programa.
Grato. :lol:
Esta sendo feito uma aplicação WebServer, e foi criado uma pasta virtual no ISS, a tela com os combo para seleção de data e outros valores esta aparecendo, mas quando que clico em consultar não consegue localizar o a imagem do grafico gerado pelo programa.
Grato. :lol:
GOSTEI 0