Jump to content

Cannot get UniCharts to work in C++ Builder 10.4


Woutero

Recommended Posts

I cannot get UniCharts to work in C++ Builder 10.4, target windows 64bit.

 

I have done the following:

 

In Main.h I have

 

class TForm1 : public TUniForm

{

__published:       // IDE-managed Components

               TUniChart *UniChart1;

               TUniButton *UniButton1;

private: // User declarations

public:                  // User declarations

               __fastcall TForm1(TComponent* Owner);

};

//---------------------------------------------------------------------------

TForm1 *Form1(void);

TUniLineSeries *LineSeries;

//---------------------------------------------------------------------------

 

In Main.cpp I have:

 

void __fastcall TForm1::UniButton1Click(TObject *Sender)

{

   int I,Val;

   String Header;

              

   TUniLineSeries *LineSeries = new TUniLineSeries(UniChart1);

   LineSeries->Parent = UniChart1;

 

  for (I=0; I<=11; I++)

  {

               Header = IntToStr(2000 + I);

 

               Val = Random(100) + 50;

               LineSeries->Add(Val, Header);

  }

 

}

 

Similar code in Delphi 10.4 worked fine, but not in C++ Builder 10.4?

Link to comment
Share on other sites

Sherzod

I got it to work half way what I need. So at least I know the UniChart component does work with C++ Builder. 

When I  manually add a LineSeries to the UniChart component, then the following code works:

 TUniChartSeries *LineSeries = UniChart1->SeriesList->Series[0] ;  
   LineSeries->Parent = UniChart1;
   LineSeries->Clear();

But I want to create Series[0] dynamically at run time. How do I do that?

 

 

 

Link to comment
Share on other sites

I figured it out, thanks to

The following C++ code works and creates a LineSeries and AreaSeries dynamically, exactly what I want:

  int I;
  TUniLineSeries *LineSeries;
  TUniAreaSeries *AreaSeries;

  LineSeries = new TUniLineSeries(UniChart1);
  LineSeries->Name = "NewLineSeries";
  LineSeries->Parent = UniChart1;
  for (I=1; I<=25; I++)
    LineSeries->Add(Random(1000), IntToStr(I));


  AreaSeries = new TUniAreaSeries(UniChart1);
  AreaSeries->Name = "NewAreaSeries";
  AreaSeries->Parent = UniChart1;
  for (I=1; I<=25; I++)
    AreaSeries->Add(Random(1000), IntToStr(I));

 

  • Like 1
Link to comment
Share on other sites

Sherzod

I spoke to soon.

When I put the code above in the UniFormCreate event, then everything works perfectly. But when I move the exact same code to a UniButton1Click event, then nothing happens on the UniChart. This is very weird?

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

// Same code don't work here

}

Link to comment
Share on other sites

This seems to be a bug. No matter what I do, the same code that works perfectly in the UniformCreate event, does not work when inside a UniButton1Click event.

I have found the following workaround:

I create 2 UniCharts, same size and on top of each other. For the first chart I manually create a LineSeries and for the second chart I manually create an AreaSeries.

Then at run time, depending on which button is pressed, I make UniChart1->Visible = true, UniChart2->Visible = false, and vice versa as needed.

Its a clumsy approach, but the only code that works with  uniGUI 1.90 Build 1535 to allow me to choose at run time between different Series types for a UniChart.

Link to comment
Share on other sites

Sherzod

Can you please confirm that setting the Title for a Bar/Line/AreaSeries during run time has been implemented or not?

e.g. BarSeries->Title = "2020";

In uniGUI 1.90 Build 1535, this is a protected member and the above line does not compile?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...