Page 1 of 1

TeeChart VCL and Unicode?

Posted: Wed Jan 11, 2006 10:39 am
by 8441509
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

Posted: Wed Jan 11, 2006 10:58 am
by narcis
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));

Posted: Wed Jan 11, 2006 11:56 am
by 8441509
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?

Posted: Wed Jan 11, 2006 12:19 pm
by narcis
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;

Work-around for no unicode support

Posted: Sun Jun 03, 2007 5:46 pm
by 8440834
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

Posted: Mon Jun 04, 2007 8:30 am
by yeray
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;