test

progging - To wander about and beg; to seek food or other supplies by low arts; to seek for advantage by mean shift or tricks.
progging - Programmer slang for writing computer code.

tirsdag 30. august 2011

Dynamically adding TQRChart at run-time on a QuickReport

Handle the BeforePrint method in the TQuickRep class to clone the TeeChart graphs...

procedure TQReport.QReportBeforePrint(Sender: TCustomQuickRep;
  var PrintReport: Boolean);
var
  i: Integer;
  LV_Height: Integer;
  LV_Top: Integer;
  LV_Chart : TChart;
  tmp: TQRChart;
begin
  // Divide height between the N charts
  LV_Height := Round(DetailBand1.Height / ChartList.Count);
  LV_Top := 0; // Starting point

  for LV_Chart in ChartList do begin
    { Create the QRChart }
    tmp:=TQRChart.Create(Self);
    { Create the QRDBChart }
    With TQRDBChart.Create(tmp) do
    begin
      Parent:=TWinControl(tmp);
      Name:=TeeGetUniqueName(Owner,'QRChart');
      Title.Text.Clear;
      Title.Text.Add(tmp.ClassName);
    end;
    { add the QRChart to the QuickReport... }
    With tmp do
    begin
      ParentReport := Self;
      Parent := DetailBand1;
      Width := DetailBand1.Width;
      Height := LV_Height;
      Left := 0;
      Top := LV_Top;
      // Move next chart down
      LV_Top := LV_Top + LV_Height;
      { Copy Series and do special formatting}
      Chart.FreeAllSeries;
      Chart.Assign(LV_Chart);
      for i:=0 to LV_Chart.SeriesCount-1 do
        CloneChartSeries(LV_Chart[i]).ParentChart := Chart;

      Chart.Color := clWhite;
      // To include all data - and not only the last 10 years
      Chart.BottomAxis.Automatic := True;
      // Remove gradient background for printing
      Chart.BackWall.Gradient.Visible := False;
    end;
  end;
end;
The QReport tips are taken from here:
http://www.steema.com/support/faq/NewVCL/FAQ_VCL_QUICKREPORT.htm

1 kommentar:

  1. Lucky 15 Casino 2021 - Games - GoPay! | Deposit Bonus
    Lucky 15 라이브바카라 Casino Review - 온라인 슬롯 머신 Enjoy our exclusive deposit bonus for your stay! Lucky 15 Casino Review – 골인벳 Up 무료 룰렛 게임 to €1600 + 배팅사이트 200 Free Spins.

    SvarSlett