TDBChart in VCL

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
pcs_user
Newbie
Newbie
Posts: 4
Joined: Tue Nov 08, 2016 12:00 am

TDBChart in VCL

Post by pcs_user » Mon Jun 26, 2017 6:01 pm

When using TDBChart in VCL I’m not getting the expected output. I get two separate X’s for the two series.
Works ok in FMX.

How to I resolve this?
Thanks, Alan

Code: Select all

// VCL
//---------------------------------------------------------------------------
void __fastcall TfMain::bChartClick(TObject *Sender)
{
 int i ;

 FDMemTable->EmptyDataSet() ;
 FDMemTable->Append() ;
 FDMemTable->FieldValues["ID"]     = 1 ;
 FDMemTable->FieldValues["Input"]  = 10 ;
 FDMemTable->FieldValues["Output"] = 20 ;

 FDMemTable->Append() ;
 FDMemTable->FieldValues["ID"]     = 2 ;
 FDMemTable->FieldValues["Input"]  = 20 ;
 FDMemTable->FieldValues["Output"] = 40 ;
 FDMemTable->Post() ;

 Series1->Clear() ;
 Series2->Clear() ;
 FDMemTable->First() ;

 do
  {
   Series1->AddXY(FDMemTable->FieldByName("ID")->AsInteger, FDMemTable->FieldByName("Input")->AsInteger, "", clBlack) ;
   Series2->AddXY(FDMemTable->FieldByName("ID")->AsInteger, FDMemTable->FieldByName("Output")->AsInteger, "", clBlack) ;

   FDMemTable->Next() ;
  }while(!FDMemTable->Eof) ;

}
//---------------------------------------------------------------------------
void __fastcall TfMain::bConnectClick(TObject *Sender)
{
 Series3->DataSource = FDMemTable ;
 Series4->DataSource = FDMemTable ;

 Series3->XLabelsSource = "ID" ;
 Series4->XLabelsSource = "ID" ;

 Series3->YValues->ValueSource = "Input" ;
 Series4->YValues->ValueSource = "Output" ;
}
//--------------------------------------------------------------------------

// FMX
//---------------------------------------------------------------------------
void __fastcall TfMain::bChartClick(TObject *Sender)
{
 int i ;

 BindSourceDB1->DataSource = 0 ;
 FDMemTable->EmptyDataSet() ;
 FDMemTable->Append() ;
 FDMemTable->FieldValues["ID"]     = 1 ;
 FDMemTable->FieldValues["Input"]  = 10 ;
 FDMemTable->FieldValues["Output"] = 20 ;

 FDMemTable->Append() ;
 FDMemTable->FieldValues["ID"]     = 2 ;
 FDMemTable->FieldValues["Input"]  = 20 ;
 FDMemTable->FieldValues["Output"] = 40 ;
 FDMemTable->Post() ;
 BindSourceDB1->DataSource = dsFDMemTable ;

 Series1->Clear() ;
 Series2->Clear() ;
 FDMemTable->First() ;

 do
  {
   Series1->AddXY(FDMemTable->FieldByName("ID")->AsInteger, FDMemTable->FieldByName("Input")->AsInteger, "", TAlphaColor(claBlack)) ;
   Series2->AddXY(FDMemTable->FieldByName("ID")->AsInteger, FDMemTable->FieldByName("Output")->AsInteger, "", TAlphaColor(claBlack)) ;

   FDMemTable->Next() ;
  }while(!FDMemTable->Eof) ;
}
//--------------------------------------------------------------------------
void __fastcall TfMain::bConnectClick(TObject *Sender)
{
 Series3->DataSource = FDMemTable ;
 Series4->DataSource = FDMemTable ;

 Series3->XLabelsSource = "ID" ;
 Series4->XLabelsSource = "ID" ;

 Series3->YValues->ValueSource = "Input" ;
 Series4->YValues->ValueSource = "Output" ;
}
//---------------------------------------------------------------------------
Attachments
charVCL.jpg
charVCL.jpg (50.95 KiB) Viewed 11118 times
charFMX.jpg
charFMX.jpg (50.24 KiB) Viewed 11120 times

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

Re: TDBChart in VCL

Post by Yeray » Fri Jun 30, 2017 9:25 am

Hello,

It sounds as a bug.
Could you please attach the projects so we can take a look at them?
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

pcs_user
Newbie
Newbie
Posts: 4
Joined: Tue Nov 08, 2016 12:00 am

Re: TDBChart in VCL

Post by pcs_user » Fri Jun 30, 2017 2:03 pm

Here's the projects.
Attachments
TestApp1_FMX.zip
FMX Project
(97.91 KiB) Downloaded 560 times
TestApp1.zip
VCL Project
(99.56 KiB) Downloaded 570 times

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

Re: TDBChart in VCL

Post by Yeray » Tue Jul 04, 2017 8:34 am

Hello,

I haven't looked at the FMX version yet, but I see in the VCL version, this seems to fix the problem:

Code: Select all

 Series3->XValues->ValueSource = "ID";
 Series4->XValues->ValueSource = "ID";
Note you assigned the Labels and the YValues source of the series in the TDBChart, but not the XValues source.
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

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

Re: TDBChart in VCL

Post by Yeray » Tue Jul 04, 2017 9:20 am

Hello,

I see in the dfm in your VCL project Series3 has XLabelSource and YValues.ValueSource defined.

Code: Select all

    object Series3: TLineSeries
      ...
      XLabelsSource = 'ID'
      ...
      YValues.ValueSource = 'Input'
Removing those 2 lines from the dfm the problem disappears.
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

pcs_user
Newbie
Newbie
Posts: 4
Joined: Tue Nov 08, 2016 12:00 am

Re: TDBChart in VCL

Post by pcs_user » Thu Jul 06, 2017 8:47 pm

That works,

Thanks

Post Reply