Jump to content

Create unilineseries dynamically


Skepsis IT

Recommended Posts

Hi everybody,

is there a way finally to create series dynamically to a tunichart.

I've tried solutions by setting the parent e.g. alineseries.Parent:=unichart1;

also using SeriesList e.g. unichart1.SeriesList.Add(alineseries);

but nothing work, black chart all the time.

Does anyone has a solution?

Regards

Link to comment
Share on other sites

28 minutes ago, Skepsis IT said:

is there a way finally to create series dynamically to a tunichart.

Hi,

Can you try this?:

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  I: Integer;
  LineSeries: TUniLineSeries;
begin
  LineSeries := TUniLineSeries.Create(UniChart1);
  LineSeries.Name:= 'NewLineSeries1';
  LineSeries.Parent := UniChart1;
  for I := 1 to 25 do
    LineSeries.Add(Random(1000), IntToStr(I));


  LineSeries := TUniLineSeries.Create(UniChart1);
  LineSeries.Name:= 'NewLineSeries2';
  LineSeries.Parent := UniChart1;
  for I := 1 to 25 do
    LineSeries.Add(Random(1000), IntToStr(I));

end;

 

Link to comment
Share on other sites

I've created a new application and your code works fine.

However at my app that opens a frame to a tab at mainform does not work.

Works only if I created unilineseries at designtime, and have Unichart1.SeriesList.Clear; at the start of your code.

And you have to create the number of series that you want at design time.... Perhaps it is a bug!

Link to comment
Share on other sites

  • 3 months later...
On 5/16/2019 at 6:00 PM, Skepsis IT said:

I've created a new application and your code works fine.

However at my app that opens a frame to a tab at mainform does not work.

Works only if I created unilineseries at designtime, and have Unichart1.SeriesList.Clear; at the start of your code.

And you have to create the number of series that you want at design time.... Perhaps it is a bug!

I see only works on FormCreate event.
Normally want to create series at runtime, by clicking a button, for example.  It doesn't work there.

I found that the only way to do it is to create the chart also at runtime which is extremely laborious, crazy.

Is there any method that makes the graph "refresh" the series that are created at runtime, such as a reInit, or Init, or destroy and init ... what would be the solution?

Link to comment
Share on other sites

  • 1 month later...
  • 9 months later...

I have the same issue for TUnimLineSeries.

Create LineSeries in FormCreate event as below.

procedure TMainmForm.UnimFormCreate(Sender: TObject);
var
  k: Integer;
begin
  with chtV006Group.SeriesList do
  for k := 0 to (Length(aryCouriers) - 1) do begin
    Insert(k, TUnimLineSeries.Create(chtV006Group));
    TUnimLineSeries(Items[k]).Title := aryCouriers[k].FullName;
  end;
end;

And get error message:

Project Project1.exe raised exception classs $C0000005 with message 'access violation at 0x0074af8c: read of address 0x00000444'.

program pointer is pointed to this line when error happens:

procedure TUniChartSeries.LoadCompleted;
begin
  FID := (FParent as TUniCustomChart).GetNewId;
end;

version 1.90.0.1530.

 

<update>

Sherzod's codes works in my program. That must be something wrong with my codes.

Can anyone give me advice?

Found the issue: Parent property needs to be assigned.

  with chtV006Group.SeriesList do
  for k := 0 to (nCount - 1) do begin
    Insert(k, TUnimLineSeries.Create(chtV006Group));
    TUnimLineSeries(Items[k]).Parent := chtV006Group;
    TUnimLineSeries(Items[k]).Title := aryCouriers[k].FullName;
  end;

Thanks.

  • Upvote 1
Link to comment
Share on other sites

  • 1 year later...

Hello,

Sorry to revive this post from 2019.

But the code to create chart series at runtime still only work in OnCreate event. It does not work in OnClick event of UniButton.

How to make it work in UniButton.OnClick?

I use UniGUI 1.90.0.1557.

Thank you

 

On 5/17/2019 at 4:43 AM, Sherzod said:

Hi,

Can you try this?:

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  I: Integer;
  LineSeries: TUniLineSeries;
begin
  LineSeries := TUniLineSeries.Create(UniChart1);
  LineSeries.Name:= 'NewLineSeries1';
  LineSeries.Parent := UniChart1;
  for I := 1 to 25 do
    LineSeries.Add(Random(1000), IntToStr(I));


  LineSeries := TUniLineSeries.Create(UniChart1);
  LineSeries.Name:= 'NewLineSeries2';
  LineSeries.Parent := UniChart1;
  for I := 1 to 25 do
    LineSeries.Add(Random(1000), IntToStr(I));

end;

 

 

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...