TeeChart VCL and Unicode?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Joschi
Newbie
Newbie
Posts: 26
Joined: Mon Oct 27, 2003 5:00 am
Location: Germany
Contact:

TeeChart VCL and Unicode?

Post by Joschi » Wed Jan 11, 2006 10:39 am

When will TeeChart finally support Unicode/WideString?

Our Delphi application is Unicode enabled for 1.5 years now, the only missing part is TeeChart. It shouldn't be too difficult, because TeeChart does all the drawing by itself.

Best regards,

Joachim Marder

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jan 11, 2006 10:58 am

Hi Joachim,

In Delphi you can access WideChars (since they are accessible from the Windows API) but you cannot display Unicode strings in native Delphi controls (at this time). TeeChart is a native Delphi control, however you can use UNICODE strings doing:

Code: Select all

// At startup, show some interesting Unicode characters
  SetLength(UnicodeString, 19);
  UnicodeString[ 1] := WideChar($0152);
  UnicodeString[ 2] := WideChar($03E0);
  UnicodeString[ 3] := WideChar($0416);
  UnicodeString[ 4] := Widechar($0539);
  UnicodeString[ 5] := WideChar($0634);
  UnicodeString[ 6] := WideChar($0950);
  UnicodeString[ 7] := WideChar($0B10);
  UnicodeString[ 8] := WideChar($0B86);
  UnicodeString[ 9] := WideChar($0C0B);
  UnicodeString[10] := WideChar($0D60);
  UnicodeString[11] := WideChar($0E12);
  UnicodeString[12] := WideChar($0EDD);
  UnicodeString[13] := WideChar($0F00);
  UnicodeString[14] := WideChar($10C5);
  UnicodeString[15] := WideChar($1124);
  UnicodeString[16] := WideChar($20A9);
  UnicodeString[17] := WideChar($2103);
  UnicodeString[18] := WideChar($3020);
  UnicodeString[19] := WideChar($FFFD);


TextOutW(Chart1.Canvas.Handle, 0, 0, pWideChar(UnicodeString),
Length(UnicodeString));
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Joschi
Newbie
Newbie
Posts: 26
Joined: Mon Oct 27, 2003 5:00 am
Location: Germany
Contact:

Post by Joschi » Wed Jan 11, 2006 11:56 am

you cannot display Unicode strings in native Delphi controls (at this time).
This is not correct, you can display Unicode in native delphi components. Just take a look at e.g. the TNT Controls.

You just need to use WideString instead of String in your methods and TextOutW() instead of TextOut() when displaying text.

So when do you intend to support Unicode in TeeChart?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jan 11, 2006 12:19 pm

Hi Joschi,

For now this is only possible using TeeChart Pro VCL with VCL.NET applications.

TNT controls are specific for converting strings to Unicode. However, I'm going to add your request to our wish-list to be considered for future releases.

In the meantime, you can use TextOutW passing TeeChart's canvas handle to it:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
Var UnicodeString : WideString;
begin
  SetLength(UnicodeString, 19);
  UnicodeString[ 1] := WideChar($0152);
  UnicodeString[ 2] := WideChar($03E0);
  UnicodeString[ 3] := WideChar($0416);
  UnicodeString[ 4] := Widechar($0539);
  UnicodeString[ 5] := WideChar($0634);
  UnicodeString[ 6] := WideChar($0950);
  UnicodeString[ 7] := WideChar($0B10);
  UnicodeString[ 8] := WideChar($0B86);
  UnicodeString[ 9] := WideChar($0C0B);
  UnicodeString[10] := WideChar($0D60);
  UnicodeString[11] := WideChar($0E12);
  UnicodeString[12] := WideChar($0EDD);
  UnicodeString[13] := WideChar($0F00);
  UnicodeString[14] := WideChar($10C5);
  UnicodeString[15] := WideChar($1124);
  UnicodeString[16] := WideChar($20A9);
  UnicodeString[17] := WideChar($2103);
  UnicodeString[18] := WideChar($3020);
  UnicodeString[19] := WideChar($FFFD);

  Windows.TextOutW(Chart1.Canvas.Handle, 10, 10, PWideChar(UnicodeString),
                   Length(UnicodeString));
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Atheling
Newbie
Newbie
Posts: 4
Joined: Thu Jan 09, 2003 5:00 am

Work-around for no unicode support

Post by Atheling » Sun Jun 03, 2007 5:46 pm

Is there a way of knowing where the e.g. chart title & axis labels are being draw at any given time (e.g. after zoom), so that one can position the unicode correctly? In other words, can I tie the unicode text to the correct position on the canvas?

From your example, that would mean knowing x & y in the code below for the relevant text that needs replacing:

Windows.TextOutW(Chart1.Canvas.Handle, x, y, PWideChar(UnicodeString), Length(UnicodeString));

The chart title seems easy using the TitleRect property, but for the vertical axes label I have no idea.

Are there any good work-arounds out there for this unicode issue?

Thank you for your kind help.

Atheling

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon Jun 04, 2007 8:30 am

Hi Atheling,

You can obtain the x any y position of axis labels using OnGetAxisLabel event. In the following example I've changed the default label text on left axis (series Y values) for the x and y position of each label.

Code: Select all

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
var x, y: Integer;
begin
  if Sender = Chart1.Axes.Left then
  begin
    x := Chart1.Axes.Left.PosLabels;
    y :=  Chart1.Axes.Left.CalcYPosValue(StrToFloat(LabelText));

    LabelText := 'X: ' + IntToStr(x) + '   Y: ' + IntToStr(y);
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply