Page 1 of 1

Example code using groups

Posted: Wed Jan 21, 2009 9:18 pm
by 10551545
Hi,

Is there an example code of how to use chart groups? While easy enough to create from within the chart editor, getting them to display at runtime seems elusive.

nsm

Posted: Thu Jan 22, 2009 8:38 am
by narcis
Hi nile,

You can use series groups like this:

Code: Select all

Chart1.SeriesGroups.Add;
Chart1.SeriesGroups.Items[0].Add(point1);
Chart1.SeriesGroups.Clear;

Posted: Fri Jan 23, 2009 1:31 am
by 10551545
Hi Narcis,

Thanks for your reply. However, this isn't quite what i had in mind. The interface I'm designing is zero code based, as all data is processed via dbchart from a virtual table. As such, using the charteditor, lets say i've got 3 groups. All, Std, Financial. Let's now add a combo box with these choices. Then ideally, if the user chooses Std, I would like my ChartListBox to display only the charts contained by the Financial group (and in order).

For this i was expecting something like:

ChartListBox->SeriesGroup = Chart->SeriesGroups->Items[0];

But when i do this, my ChartListBox is empty.

Cheers, Nile.

Posted: Fri Jan 23, 2009 8:29 am
by narcis
Hi Nile,

Currently TChartListBox component doesn't support series groups. I added your request to the wish-list. In the meantime, you'll have to add all series in a group to TChartListBox.

Posted: Fri Jan 23, 2009 9:30 pm
by 10551545
Ah, okay. Would have thought this to be a natural extension of having groups with the listbox. Meanwhile is there an alternative you can suggest?

If I can cycle through the list of series available in a specific group, then I should be able to turn off the visibility that are not in the all group - or something similar?

Thanks, nile.

Posted: Mon Jan 26, 2009 9:22 am
by narcis
Hi nile,

Yes, you can do something like this:

Code: Select all

void __fastcall TForm4::FormCreate(TObject *Sender)
{
	Chart1->SeriesGroups->Add();
	Chart1->SeriesGroups->Items[0]->Add(Series1);
	Chart1->SeriesGroups->Items[0]->Add(Series2);

	Chart1->SeriesGroups->Add();
	Chart1->SeriesGroups->Items[1]->Add(Series3);
	Chart1->SeriesGroups->Items[1]->Add(Series4);

	for (int i = 0; i < Chart1->SeriesGroups->Items[0]->Series->Count; i++) {
		ChartListBox1->AddItem(Chart1->SeriesGroups->Items[0]->Series->Items[i]->Name,
								Chart1->SeriesGroups->Items[0]->Series->Items[i]);
	}
}
Hope this helps!

Posted: Mon Jan 26, 2009 8:52 pm
by 10551545
Got it - looks like this will do just fine.

Many thanks,
Nile.