Finding out the type of Series at run time

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Maria
Newbie
Newbie
Posts: 6
Joined: Thu Oct 30, 2008 12:00 am

Finding out the type of Series at run time

Post by Maria » Mon Jun 09, 2014 1:19 pm

Hello,

We have been using TeeChart for over a decade now but have just found a problem that we are unable to solve.

In our application we use 3 different types of series (TLineSeries, THighLowSeries and TPointSeries) on the same chart. In principle thre can be any number of series of each type with no predefined order, and we do not have control over when a type of series is added to a chart.

Our problem is that we need to find out what kind of series is each of the series from the Series property of the chart. For instance using the HighValues and LowValues properties only makes sense for the series that are THighLowSeries.

Ideally we would like to have a property 'type' associated with the series that we could use act on each series . Is there a way to find this in run time?

We use both BCB 6.0 and C++ Builder 2010. TeeChart Pro 8.08

Thanks,

Rafael Collantes

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

Re: Finding out the type of Series at run time

Post by Yeray » Mon Jun 09, 2014 2:02 pm

Hi Rafael,

You could try with a dynamic cast as explained here.
Ie:

Code: Select all

void __fastcall TForm1::FormCreate(TObject *Sender)
{

  Chart1->AddSeries(new TLineSeries(this));
  Chart1->AddSeries(new THighLowSeries(this));
  Chart1->AddSeries(new TPointSeries(this));

  for (int i=0; i<Chart1->SeriesCount(); i++) {
	Chart1->Series[i]->FillSampleValues();
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  for (int i=0; i<Chart1->SeriesCount(); i++) {
	TLineSeries *line1 = dynamic_cast<TLineSeries *>(Chart1->Series[i]);
	if (line1) {
	  line1->Pointer->Visible=true;
	}

	THighLowSeries *highlow1 = dynamic_cast<THighLowSeries *>(Chart1->Series[i]);
	if (highlow1) {
	  highlow1->HighBrush->Style=bsSolid;
	}
  }
}
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