Page 1 of 1

How to create MultiChart application for C++Builder?

Posted: Fri May 31, 2024 8:30 am
by 16597583
The example exists for Delphi - Spark_series.pas, but for C++ this is more complicated.
What is better - AddSeries to Grid->Items[...][...] or to add chart and then AddSeries?
I need to refresh series data for at least 16 charts as fast as possible.

Re: How to create MultiChart application for C++Builder?

Posted: Mon Jun 03, 2024 1:41 pm
by yeray
Hello,

Here the example translated to C++Builder:

Code: Select all

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  TChart *Chart1 = new TChart(this);
  Chart1->Parent = this;
  Chart1->Align = alClient;
  Chart1->View3D = false;

  Grid = new TChartLayoutTool(this);
  Chart1->Tools->Add(Grid);

  // We want 10x4 = 40 charts
  Grid->SetSize(10,4);

  // Set custom columns sizes. Automatic=0
  Grid->Columns->Item[0]->Size = 60;
  Grid->Columns->Item[0]->SizeUnits = muPixels;

  Grid->Columns->Item[1]->Size = 60;
  Grid->Columns->Item[1]->SizeUnits = muPercent;

  Grid->Columns->Item[2]->Size = 110;
  Grid->Columns->Item[2]->SizeUnits = muPixels;

  // First row, custom size
  Grid->Rows->Item[0]->Size = 90;
  Grid->Rows->Item[0]->SizeUnits = muPixels;

  // Add Series to all charts
  for (int Row = 0; Row < Grid->Rows->Count; Row++) {
	TAnnotationTool *Annotation = new TAnnotationTool(this);
	Grid->Items[Row][0]->Tools->Add(Annotation);

	Annotation->Text = "Row "+IntToStr(Row);

	TFastLineSeries *FastLine = new TFastLineSeries(this);
	Grid->Items[Row][1]->AddSeries(FastLine);
	FastLine->Marks->Hide();
	FastLine->FillSampleValues(100);
	//FastLine->ParentChart->Color=RGB(250,240,230);

	TPieSeries *Pie = new TPieSeries(this);
	Grid->Items[Row][2]->AddSeries(Pie);
	Pie->Marks->Hide();
	Pie->FillSampleValues(6);
	Pie->ParentChart->MarginTop = 10;

	TBarSeries *Bar = new TBarSeries(this);
	Grid->Items[Row][3]->AddSeries(Bar);
	Bar->Marks->Hide();
	Bar->FillSampleValues(6);
	Bar->ColorEachPoint=True;
	Bar->Marks->Show();
	Bar->Marks->Transparent=True;
  }

Re: How to create MultiChart application for C++Builder?

Posted: Thu Jun 06, 2024 7:00 am
by 16597583
Thank you!