Skepsis IT Posted May 16, 2019 Share Posted May 16, 2019 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 16, 2019 Share Posted May 16, 2019 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; Quote Link to comment Share on other sites More sharing options...
Skepsis IT Posted May 16, 2019 Author Share Posted May 16, 2019 Hi, did it by nothing happened. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 16, 2019 Share Posted May 16, 2019 4 minutes ago, Skepsis IT said: did it by nothing happened. Which build are you using? Can you make a simple testcase for this? Quote Link to comment Share on other sites More sharing options...
Skepsis IT Posted May 16, 2019 Author Share Posted May 16, 2019 Build 1436 You already posted the testcase above It is similar to yours.... Does the above code works on your pc? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 16, 2019 Share Posted May 16, 2019 21 minutes ago, Skepsis IT said: Does the above code works on your pc? Yes Quote Link to comment Share on other sites More sharing options...
Skepsis IT Posted May 16, 2019 Author Share Posted May 16, 2019 Unichart1 on my occasion is on an inherited uniframe. Is that related? Or is an issue of that specific build? Quote Link to comment Share on other sites More sharing options...
Skepsis IT Posted May 16, 2019 Author Share Posted May 16, 2019 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! Quote Link to comment Share on other sites More sharing options...
NizamUlMulk Posted September 13, 2019 Share Posted September 13, 2019 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? Quote Link to comment Share on other sites More sharing options...
RobertoLopes Posted October 21, 2019 Share Posted October 21, 2019 So the final answer is NO ? Unigui does not allow you to create runtime series on the chart component ? That's it ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 21, 2019 Share Posted October 21, 2019 3 minutes ago, RobertoLopes said: So the final answer is NO ? Unigui does not allow you to create runtime series on the chart component ? That's it ? Sorry which build are you using? Quote Link to comment Share on other sites More sharing options...
RobertoLopes Posted October 21, 2019 Share Posted October 21, 2019 1 minute ago, Sherzod said: Sorry which build are you using? I'm using 1.90.0.1510. Quote Link to comment Share on other sites More sharing options...
JamesC Posted August 8, 2020 Share Posted August 8, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
jrp Posted April 29, 2022 Share Posted April 29, 2022 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; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.