Label TLineSeries series by series name?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Tink
Newbie
Newbie
Posts: 3
Joined: Fri Feb 07, 2003 5:00 am
Location: University of Calgary
Contact:

Label TLineSeries series by series name?

Post by Tink » Mon Dec 01, 2003 6:15 pm

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

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon Dec 01, 2003 9:20 pm

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.

Tink
Newbie
Newbie
Posts: 3
Joined: Fri Feb 07, 2003 5:00 am
Location: University of Calgary
Contact:

Post by Tink » Mon Dec 01, 2003 10:04 pm

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

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Dec 02, 2003 1:12 am

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

Tink
Newbie
Newbie
Posts: 3
Joined: Fri Feb 07, 2003 5:00 am
Location: University of Calgary
Contact:

Post by Tink » Tue Dec 02, 2003 4:46 pm

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.

Post Reply