Page 1 of 1

Problem with OnGetAxisLabel event

Posted: Thu Aug 17, 2017 11:58 am
by 9342841
Hello,
I've got an issue when using the OnGetAxisLabel.
I've got a couple of TLineSeries, created at runtime, with ParentChart assigned to Chart1 for instance.

Those Series are drawn correctly in Chart1.
But when the Chart1.OnGetAxisLabel(Sender : TChartAxis; Series: TChartSeries; ValueIndex: integer; var LabelText: string) events occur, Series is not assigned and ValueIndex is always equal to -1, whatever the actual position of LabelText.
I want to custom the new LabelText with Series.XValues and ValueIndex, but I failed in connecting the runtime series with the actual Chart axis...

Thanks for any help,
Regards,
Laurent

- Delphi6 / Teechart 7.04 -

Re: Problem with OnGetAxisLabel event

Posted: Fri Aug 18, 2017 3:32 pm
by 10050769
Hello Laurent,

Maybe the problem is caused because you need set the LabelStyle as Text. The code below works fine for me using latest TeeChart Pro 707:

Code: Select all

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
if valueIndex>-1 then
Caption:= 'ValueInex'+ FloatToStr(valueIndex); //Change that for your code.
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(10);
Chart1.Axes.Bottom.LabelStyle := talText;
end;
Hoping this helps you.
Thanks in advance

Re: Problem with OnGetAxisLabel event

Posted: Mon Aug 21, 2017 10:14 am
by 9342841
Hello Sandra,
Thank you for your reply.

Actually, my problem came from the fact that the "Series" parameter of the event is not assigned when the event occurs. So calling properties of this local parameter failed.
I solve my problem by using the global Chart1.Series parameter instead of the local 'Series' parameter of the event.

But I'm interested in having information about how the "series" local parameter of the OnGetAxisLabel event works and how it is fed when several series share the same axis?

Thank you again for your help,
Regards,
Laurent

Re: Problem with OnGetAxisLabel event

Posted: Tue Aug 22, 2017 7:31 am
by yeray
Hello Laurent,
lolo1988 wrote:But I'm interested in having information about how the "series" local parameter of the OnGetAxisLabel event works and how it is fed when several series share the same axis?
The OnGetAxisLabel event should be fired with an assigned Series parameter when there are labels in that series and the Axis LabelStyle property is set to talAuto, talText or talMark.