Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 1648 - Delphi Webbroker - TeeChart return a blank image
Summary: Delphi Webbroker - TeeChart return a blank image
Status: RESOLVED NOTABUG
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Chart (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-13 17:45 EDT by caiooliveira
Modified: 2018-02-23 08:44 EST (History)
1 user (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description caiooliveira 2016-10-13 17:45:38 EDT
Hi,

I have migrating my code from Delphi 7 to Delphi XE5. Actually I keeping the Delphi 7 code only for the grafhic with TeeChart in Webbroker/Apache.

The code is work fine in Delphi 7, but when I migrate to the XE5 or major; the code allways return a blank image.

The code is:

..

Uses Winapi.windows, System.SysUtils, System.Classes, Web.HTTPApp,
  FireDAC.Stan.Intf,
  FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf,
  FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys,
  FireDAC.Phys.FBDef, FireDAC.Phys.IBBase, FireDAC.Phys.FB, FireDAC.Comp.Client,
  Data.DB, Datasnap.DBClient, FireDAC.Stan.Param, FireDAC.DatS,
  FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, Datasnap.Provider,
  System.WideStrUtils, midaslib,
  Vcl.graphics, VclTee.TeeGDIPlus, VCLTee.TeEngine, VCLTee.Chart,
  VCLTee.Series, Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.DBChart, VCLTee.EditChar,
  Vcl.StdCtrls, VCLTee.TeeConst, Vcl.imaging.pngimage;

....

var pData1, pData2 : TDatetime;
    PngImage : TPNGImage;
    MemStr : TMemoryStream;
    Chart : TDBChart;
    Vseries : TPieSeries;
    VBarSeries, vBarSeries2 : TBarSeries;
    Image : Timage;
    nWidth, nHeigh : integer;
    Estilografico : string[1];
begin
   Try

   // Trata parametros de data, periodo especificado.
   Try
          if (request.queryfields.values['data1'] = '') then
          pData1 := PrimeiroDiaGraf(now)
          else
          pData1 := StrToDatetime( request.queryfields.values['data1']);
   Except pData1 := PrimeirodiaGraf(now);
   End;
   Try
          if (request.queryfields.values['data2'] = '') then
          pData2 := now;
          pData2 := StrToDateTime( request.queryfields.values['data2']);
   Except pData2 := now;
   End;

   nWidth := 640; nHeigh := 480;
   Try
   Case StrToInt(copy( request.queryfields.values['tamanhografico'],1,4)) of
   500: begin nWidth := 495; nHeigh := 300; end;
   640: begin nWidth := 640; nHeigh := 480; end;
   800: begin nWidth := 800; nHeigh := 600; end;
   1380: begin nWidth := 1380; nHeigh := 700; end;
   else begin nWidth := 1024; nHeigh := 600; end;
   end;
   except
   end;

   // Determina estilo do Grafico:P-Pizza ou B-Barras
   Try
   EstiloGrafico := request.queryfields.values['estilodografico'];
   Except
   EstiloGrafico := 'B';
   End;

   // Simple SQL to obtained data
   FDQChart.sql.clear;
   FDQChart.Sql.Add(
   'SELECT C.numero, '+
   'case when (C.APELIDO = '''' OR C.APELIDO IS NULL) then substring( c.nome from 1 for 15) else c.apelido end AS APELIDO, '+
   'C.NOME, SUM(O.valorp) AS RECEBIDO, SUM(O.valorv) as PROGRAMADO '+
   'FROM crfa001 O '+
   'LEFT JOIN crvd001 C ON (C.numero = O.vendedor) '+
   'WHERE O.id_emp = :idEmp AND '+
   ' O.datap BETWEEN :data1 and :data2'+
   ' GROUP BY 1, 2, 3 '+
   ' ORDER BY 2 ');

   FDQChart.ParamByName('idEmp').AsInteger := FDQueryUsr.FieldByName('id_cepemp01').AsInteger;
   FDQChart.ParamByName('data1').AsDateTime := StrToDate(
request.queryfields.values['data1']);
   FDQChart.ParamByName('data2').AsDateTime := StrToDate(
request.queryfields.values['data2']);
   FDQChart.open;

   // END SQL = data in FDChart

   Chart := TDBChart.create(nil);
   Try

   Chart.width := nWidth;
   Chart.Height:= nHeigh;

   // cor de fundo
   //Chart.Gradient.StartColor := clWhite;
   //if request.queryfields.Values['cordefundo'] = '' then
   //Chart.Gradient.EndColor := clYellow;
   //else Chart.Gradient.EndColor := ConvertHtmlHexToTColor(request.queryfields.Values['cordefundo']);

   Chart.Gradient.Visible := True;

   if nWidth > 500 then
   begin
    Chart.Legend.visible := True;
    Chart.Legend.TextStyle := ltsRightValue;
   end else
    Chart.Legend.Visible := False;

   if EstiloGrafico = 'P' then
   Begin
     vSeries:= TPieSeries.create (chart);
     vSeries.ParentChart := Chart;
     vSeries.DataSource := FDQChart;
     //if nWidth <= 840 then
           vSeries.XLabelsSource := 'APELIDO';
     //else  vseries.XLabelsSource := 'NOME';

     vSeries.Marks.Style := smsLabelPercent;
     vSeries.ExplodeBiggest := 20;
     vSeries.ShowInLegend := true;
     vSeries.OtherSlice.Style := poBelowPercent;
     vSeries.OtherSlice.text  := 'Outras';
     vSeries.OtherSlice.value := 2;
     vSeries.PieValues.ValueSource := 'RECEBIDO';

     Chart.AddSeries(vSeries);

   End else
   Begin
   vBarSeries:= TBarSeries.create (chart);
   vBarSeries2:= TBarSeries.create (chart);

   if request.queryfields.values['efeito3D'] = 'ON' then
   begin
      vBarSeries.Dark3D := TRUE; vBarSeries2.Dark3D := TRUE
   end else
   begin
      vBarSeries.Dark3D := false; vBarSeries2.Dark3D := False;
   end;

   // Estilo Barras (TOTAL)
   vBarSeries.ParentChart := Chart;
   vBarSeries.DataSource := FDQChart;
   vBarSeries.BarStyle := bsCilinder;
   vBarSeries.Title := 'Recebido';

   vBarSeries.YValues.ValueSource   := 'RECEBIDO';
   vBarSeries.XLabelsSource := 'APELIDO';
   vBarSeries.ShowInLegend := True;

   vBarSeries.GetVertAxis.Labels := TRUE;
   vBarSeries.GetVertAxis.LabelsMultiLine := True;
   vBarSeries.GetHorizAxis.Labels := True;
   vBarSeries.GetHorizAxis.LabelsOnAxis := True;
   vBarSeries.GetHorizAxis.LabelsAngle := 90;
   vBarSeries.Marks.Visible := TRUE;
   VBarSeries.Marks.ZPosition := 1;
   vBarSeries.marks.Style := smsValue;

   // Barra (PROGRAMADO)
   vBarSeries2.ParentChart := Chart;
   vBarSeries2.DataSource := FDQChart;
   vBarSeries2.BarStyle := bsRectangle;
   vBarSeries2.Title := 'Programado';

   vBarSeries2.YValues.ValueSource   := 'PROGRAMADO';
   vBarSeries2.XLabelsSource := 'APELIDO';
   vBarSeries2.ShowInLegend := True;

   vBarSeries2.GetVertAxis.Labels := TRUE;
   vBarSeries2.GetHorizAxis.Labels := True;
   vBarSeries2.GetHorizAxis.LabelsOnAxis := False;
   vBarSeries2.GetHorizAxis.LabelsAngle := 90;
   vBarSeries2.Marks.Visible := False;
   VBarSeries2.Marks.Arrow.Style := psInsideFrame;
   vBarSeries2.marks.Style := smsValue;
   vBarSeries2.marks.Positions.Pack;

   Chart.AxisVisible := TRUE;
   Chart.AddSeries(vBarSeries);
   Chart.AddSeries(vBarSeries2);
   Chart.Legend.visible := True;
   //Chart.Legend.Alignment := laTop;

   End;

   Image := TImage.create (nil);
   Try
   Image.width := Chart.Width;
   Image.Height:= Chart.Height;

   // Titulo do Grafico
   Chart.Title.Text.Clear;
   if nWidth > 640 then  Chart.Title.Font.Size := 14
   else Chart.Title.Font.Size := 11;
   Chart.Title.Text.Add( 'GRÁFICO DE RECEBIMENTOS POR VENDEDOR' );
   Chart.Title.Text.Add( 'Periodo de: '+FormatDateTime( 'dd/mm/yyyy', pData1 )+
                        ' até '+FormatDateTime( 'dd/mm/yyyy', pData2 ) );

   // Desenha o Grafico
   Chart.Draw (Image.Canvas, Image.BoundsRect);

   Try
   PngImage := TPNGimage.create;
   Try
     PngImage.Assign (Image.picture.Bitmap);
     MemStr:= TMemoryStream.create;
     Try
       PngImage.SaveToStream (MemStr);
       MemStr.Position := 0;
       Response.ContentStream := MemStr;
       Response.ContentType := 'image/png';
       Response.SendResponse;

       //Response.SendStream(MemStr);
       Handled := true;
     Finally
       MemStr.free;
     End;
   Finally
     Jpeg.Free;
   End;
   Finally
     Chart.free;
     if EstiloGrafico = 'P' then
     vseries.free
     else
     begin
     vBarSeries.Free;
     vBarSeries2.Free;
     end;

   End;
   Finally
     Image.free;
   End;
   Finally
     if FDQChart.State <> dsInactive then FDQChart.close;
   End;
   except
     on e:exception do response.content := 'Erro: '+e.message;
   end;

....


Thank you very much support
Comment 1 sandra pazos 2018-02-23 08:44:10 EST
What you request are not bug fix or enhancement suggestion to the existing products but technical inquiries on how to use TeeChart. Please post this kind of questions at our technical support forums, monitored by our technical department staff at http://www.teechart.net/support/index.php