custom values in GetAxisLabel() cause text clipping

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Saturn
Newbie
Newbie
Posts: 1
Joined: Wed Jun 05, 2013 12:00 am

custom values in GetAxisLabel() cause text clipping

Post by Saturn » Fri Jun 07, 2013 8:32 am

When I override the text that is displayed on vertical axis, through GetAxisLabel() function, only a bit of it is displayed on the actual graph.

Here's a picture to illustrate this:
a.png
a.png (24.97 KiB) Viewed 3121 times
In this project I just placed the chart on form, added two series and a custom GetAxisLabel() function that only adds a lot of brackets to labels:

Code: Select all

void __fastcall TForm3::Chart1GetAxisLabel(TChartAxis *Sender,TChartSeries *Series, int ValueIndex, AnsiString &LabelText){
	LabelText=AnsiString("[[[[[[[[[[[[[[[")+LabelText+"]]]]]]]]]]]]]]]";	
}
This happens for all label styles but Text. And Text style is not a solution for me because it only places one label per one series value on chart.

Is this a bug? Is there a workaround?

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

Re: custom values in GetAxisLabel() cause text clipping

Post by Yeray » Fri Jun 07, 2013 9:34 am

Hi,

You could try to set a left margin to the chart, setting it to be the same size (a some pixels bigger) than the largest label in the axis.
Here it is a simple example, in Delphi:

Code: Select all

uses Series, Math;

var maxLeftLabels: Integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  Chart1.AddSeries(TFastLineSeries).FillSampleValues;
end;

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  LabelText:='[[[[[[[[[[[[[[['+LabelText+']]]]]]]]]]]]]]]';
end;

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
begin
  maxLeftLabels:=-1;
  with Chart1.Axes.Left do
  begin
    Chart1.Canvas.AssignFont(LabelsFont);

    for i:=0 to Items.Count-1 do
      maxLeftLabels:=Max(maxLeftLabels, Chart1.Canvas.TextWidth(Items[i].Text));
  end;
  Chart1.MarginUnits:=muPixels;
  Chart1.MarginLeft:=maxLeftLabels;
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