Page 1 of 1

Label TLineSeries series by series name?

Posted: Mon Dec 01, 2003 6:15 pm
by 8576017
This should be easy to do, but I cannot figure it out.

Using TeeChartPro v6 under BCB6.

I have several line series on Chart1, and I want lebels on the chart, where the label text is the series name (so 1 label for each series). Is there a built-in method to add a label to each series specifying the series name?


Thanks,
Doug

Posted: Mon Dec 01, 2003 9:20 pm
by Marjan
Hi, Dough.

Try setting the TChartSeries.Title property.

Code: Select all

Series1.Title := 'Series1Title';
Series2.Title := 'Series2Title';
Please not the difference between series Title and Name properties-The Title property is used in the Legend to draw the series descriptions. If set, it will be displayed instead of Series.Name in the Chart Editor and/or TChartListBox. Series.Title can be multi-worded whereas as Series.Name is a Delphi component name.

Posted: Mon Dec 01, 2003 10:04 pm
by 8576017
Hi Marjan,

Thanks for your reply, I will use ->Title for the legend. However, I would really like to have a Label directly on the Chart also, on top of or next to the actually plotted Series. This is similar to Series 'Marks', but instead of labelling an actual point in the Series (as the Marks is used for), I simply want to label the line, with for example the series Title, or some other text if I want.

Is there a built in method for that? If not, can you point me in the right place for manually building and placing these labels?

Thanks,
Doug

Posted: Tue Dec 02, 2003 1:12 am
by Pep
Hi Doug,

to do this you could use the OnGetMarkText event as in the following example :

Code: Select all

void __fastcall TForm1::FormCreate(TObject *Sender)
{
Series1->FillSampleValues(10);
Series2->FillSampleValues(10);
Series1->Marks->Visible = true;
Series2->Marks->Visible = true;
Series1->Name = "Name1";
Series2->Name = "Name2";
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Series1GetMarkText(TChartSeries *Sender,
      int ValueIndex, AnsiString &MarkText)
{
if (ValueIndex == 4) MarkText = Sender->Name;
else MarkText = "";
}
Josep Lluis Jorge
http://support.steema.com

Posted: Tue Dec 02, 2003 4:46 pm
by 8576017
Perfect, Thanks Pep.

That also shows me how I can customize the placement of the label; I can place it on any datapoint in my series I want.

Thanks so much.