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



OnBeforeDrawScaleLabel


Unit:SDL_polchart
Class: TPolChart
Declaration: OnBeforeDrawScaleLabel: TpcBeforeDrawScaleLabelEvent;
{ TpcBeforeDrawScaleLabelEvent = procedure (Sender: TObject; Canvas: TCanvas; ScaleType: TpcScaleKind; var CurrentTickLabel: string; ChartX, ChartY: integer) of object;}

The events OnDataRendered and OnBeforeDrawScaleLabel provide a hook for adding user defined graphics to a PolChart. While the event OndataRendered can be used to draw special graphics or text into the chart (on top of the data and the scales, but below any crosshair), the event OnBeforeDrawScaleLabel  is triggered immediately before a label of the scale is going to be rendered and allows to modify the text of this label.

The variable parameter Canvas provides access to the canvas of the data area. The parameter ScaleType specifies the kind of scale the label belongs to (radial or angular). The variable parameter CurrentTickLabel can be adjusted according to the requirements of the program (e.g. to append a measurement unit to it). The parameters ChartX and ChartY specify the position of the label (in pixel coordinates).

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.

Hint 1: The declaration of this event has been changed with the introduction of release 10.1 of the SDL Suite. Please see the corresponding type declaration and the section How to Deal with a Canvas Reference Change for details.

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 create a radial scale showing dB as units:

procedure TFrmPolChart.PCBeforeDrawScaleLabel(Sender: TObject;
  Canvas: TCanvas; ScaleType: TpcScaleKind; var CurrentTickLabel: String;
  ChartX, ChartY: Integer);
 
begin
if ScaleType = sckRad then
  CurrentTickLabel := CurrentTickLabel + ' dB';
end;

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



Last Update: 2012-Oct-26