The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



OnScaleTickDrawn


Unit:SDL_rchart
Class: TRChart
Declaration: OnScaleTickDrawn: TScaleTickDrawnEvent;
{ TScaleTickDrawnEvent = procedure (Sender: TObject; var Canvas: TCanvas; ScaleType: TScaleType; CurrentTickPos: double; ChartX, ChartY: integer) of object; }

The OnScaleTickDrawn event provides a hook for adding or modifying individual scale ticks. The event OnScaleTickDrawn occurs whenever a tick mark on a scale has been drawn. The variable parameter Canvas provides access to the canvas of the data area. Please note that the state of the canvas (e.g. the color of its pen, or the fill mode of the brush) depends on the graphics elements drawn before. The parameter ScaleType specifies to which type of scale the tick mark belongs to; the ScaleType parameter is controlled by the properties ScalePropsX[].ScaleLocation and ScalePropsY[].ScaleLocation. The parameter CurrentTickPos holds the numeric value which corresponds to the tick mark, and the parameters ChartX and ChartY contain the position of the tick mark on the canvas.

Hint: Graphic elements outside the scales area are cut automatically.

Example: Following is an example on how to draw user defined labels on the left y-axis. The left y-axis is labeled by hexadecimal numbers instead of the standard decimal numbers. Please note that the property ScalePropsY[].LabelType has to be set to ftNoFigs in order to prevent the standard labels from being displayed. The function hex is part of unit math1. A full example how to use the OnScaleTickDrawn event is included in the programming examples (USERSPEC.DPR in directory "exmpl-rchart-9").

procedure TForm2.RChart1ScaleTickDrawn (Sender: TObject; var Canvas: TCanvas;
                               ScaleType: TScaleType; CurrentTickPos: double;
                               ChartX, ChartY: integer);

var
  astr   : string;
  tw, th : integer;

begin
if ScaleType = sctYL then
  begin
  astr := hex(round(CurrentTickPos),8);
  tw := canvas.TextWidth(astr);
  th := canvas.TextHeight(astr);
  Canvas.TextOut (ChartX-tw-8, ChartY-(th div 2), astr);
  end;
end;

Example: This event is used in the following example program (see http://www.lohninger.com/examples.html for downloading the code): userspec



Last Update: 2008-Okt-29