Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Adding marks to a Tee Chart

edited November 2001 in General
On charts in Delphi marks (cross hairs on a line plot) can be added to note
events on the chart using a draw on canvas routine. The same marks should
be drawn to the Tee Chart in RB. Can you please instruct me in how to place
marks on the Tee Chart in RB?

(D6, RB 6.01)
Thanks, code follows,
Tore Fossum
tfossum@titrate.cc


If Dest=0 then
begin // these are for the Chart in the main part of the program
ix:=Series2.CalcXPosValue(zx);
iy:=Series2.CalcYPosValue(zy);
end;
If Dest=1 then // This is for the Chart in the Report ie, ppChart
begin
ix:=LineSeries3.CalcXPosValue(zx);
iy:=LineSeries3.CalcYPosValue(zy);
end;

DrawMark(ix,iy,Dest,clBlack);


procedure TTitrData.DrawMark(AX, AY, Dest: integer; CrossHairColor: Tcolor);
begin
If Dest=0 then // mark chart plot

With DBChart2,Canvas do // Chart in main part of program
begin
Pen.Style:=psSolid;
Pen.Width:=1;
MoveTo(ax,ay-5);
LineTo(ax,ChartRect.Bottom-Height3D+6);
MoveTo(ax-5,ay);
LineTo(ax+5,ay);
end;
If Dest=1 then
With ppCHartSmall do // Chart on report
begin
Chart.Canvas.Pen.Style:=psSolid;
Chart.Canvas.Pen.Width:=1;
Chart.Canvas.MoveTo(ax,ay-5);
Chart.Canvas.LineTo(ax,Chart.ChartRect.Bottom-Chart.Height3D+6);
Chart.Canvas.MoveTo(ax-5,ay);
Chart.Canvas.LineTo(ax+5,ay);
end;

Comments

  • edited November 2001
    I have to also say that the marks work on the main chart, but not on the RB
    chart.
    The RB chart is a plain chart, not a DB chart, and it copies the points from
    the
    main RB chart. Everything on the reports looks fine, except no cross hair
    marks.
    I have attempted to draw the marks by using the event "On create preveiw" or
    the RB TeeChart "Before Print".
    Thanks again, Tore

  • edited November 2001
    What about creating TppLine objects in the report that sit on top of the
    chart component in the designer?

    If you need to create them at runtime, then create TppDrawLine draw commands
    in the Report.OnEndPage event. The measurement units are in thousandths of
    millimeters. Here's the code to create a horizontal line in the middle of
    the page:.

    lDrawLine := TppDrawLine.Create(nil);
    lDrawLine.Page := ppReport1.Engine.Page;
    lDrawLine.LinePosition := lpTop;
    lDrawLine.Left := ppReport1.PrinterSetup.PageDef.mmMarginLeft;
    lDrawLine.Top := ppReport1.PrinterSetup.PageDef.mmPrintableHeight div
    2;
    lDrawLine.Width:= ppReport1.PrinterSetup.PageDef.mmPrintableWidth;


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited November 2001
    Thank you, Jim, but figuring out exactly where to put them could be a big
    problem. Is the chart always going to be in the same place? How to figure
    out where the chart is,...hmm, it would mean doing some trials and some
    mathematics. This is possible, but it is not the most elegant way. How to
    draw on the chart?

    Many thanks, Tore Fossum
    tfossum@titrate.cc

  • edited November 2001
    You're right, we'll have to draw relative to the draw command's position on
    the page. The following demo shows how to draw on the canvas of the bitmap
    and also how to draw two lines on top of the teechart metafile with draw
    commands.

    http://www.digital-metaphors.com/tips/DrawOnTeeChartCanvas.zip
This discussion has been closed.