Print Page | Close Window

I want to write a sideways text

Printed From: TMS Software
Category: VCL Components
Forum Name: VCL Chart
Forum Discription:
Printed Date: 21 Jan 2020 at 7:34am

Topic: I want to write a sideways text
Posted By: Yokoe Hideo
Subject: I want to write a sideways text
Date Posted: 29 Oct 2015 at 7:40am

I tried to find answer on your demo, but I failed. 
Could you tip me, how to rotate annotation ?
or how to write a sideways character

best regards
# Windows7(64) / Delphi10 

Posted By: Pieter Scheldeman
Date Posted: 29 Oct 2015 at 8:47am

You can achieve this with the following code (please note that the drawing is based on pointindex 4 in this sample and the text is drawn from the top of the chart to the bottom:

procedure TForm112.AdvGDIPChartView1AfterDrawSeries(Sender: TObject;
  ARect: TRect; ACanvas: TCanvas; APaneIndex: Integer);
  r: TRect;
  s: TChartSerie;
  xm, ym: Integer;
  tf: TFont;
  lf: TLogFont;
  str: string;
  tw, th: integer;
  pt: Integer;
  tf := TFont.Create;
  tf.Size := 18;
  tf.Color := clRed;
  GetObject(tf.Handle, SizeOf(lf), @lf);
  lf.lfEscapement := 900;
  lf.lfOrientation := 900;

  tf.Handle := CreateFontIndirect(lf);

  s := AdvGDIPChartView1.Panes[0].Series[0];
  r := AdvGDIPChartView1.Panes[0].Series.SeriesRectangle;

  str := 'Hello World !';
  tw := ACanvas.TextWidth(str);
  th := ACanvas.TextHeight(str);

  pt := 4;

  xm := s.GetDrawPoint(pt).X - th div 2;
  ym := r.Top + tw;

  ACanvas.Brush.Style := bsClear;
  ACanvas.TextOut(xm, ym, str);

Kind Regards, 

Print Page | Close Window