Page 1 of 1

Finding out the type of Series at run time

Posted: Mon Jun 09, 2014 1:19 pm
by 10050699
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

Re: Finding out the type of Series at run time

Posted: Mon Jun 09, 2014 2:02 pm
by yeray
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;
	}
  }
}