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....


Class: TContourPlot
Declaration: OnScaleTickDrawn: TScaleTickDrawnEvent;
{ TScaleTickDrawnEvent = procedure (Sender: TObject; 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 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 1: Graphic elements outside the scales area are cut automatically.

Hint 2: In order to avoid unwanted size effects regarding characters displayed on canvases of different resolution (i.e. the screen and a printer) you should never directly assign the font size within the event. Use SetCanvasFontSizeScaled instead. So, for example, the statement Canvas.Font.Size := 12; should be replaced by SetCanvasFontSizeScaled (Canvas, 12);

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 properties ScaleX.LabelTypeand ScaleY.LabelType have to be set to ftNoFigs in order to prevent the standard labels from being displayed. The function hex is part of unit math1.
procedure TForm2.Cplot1ScaleTickDrawn (Sender: TObject; Canvas: TCanvas;
                               ScaleType: TScaleType; CurrentTickPos: double;
                               ChartX, ChartY: integer);

  astr   : string;
  tw, th : integer;

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

Last Update: 2023-Dec-13