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
TeeChart VCL and Unicode?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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:
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 |
Instructions - How to post in this forum |
This is not correct, you can display Unicode in native delphi components. Just take a look at e.g. the TNT Controls.you cannot display Unicode strings in native Delphi controls (at this time).
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?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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:
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 |
Instructions - How to post in this forum |
Work-around for no unicode support
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
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
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.
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |