Recent

Author Topic: TChart - what happened to OnCreate  (Read 2871 times)

slj2021

  • Newbie
  • Posts: 2
TChart - what happened to OnCreate
« on: March 20, 2021, 09:36:12 pm »
Hi All, first post, new user to FPC/Lazarus

System:
macOS 10.13.6 (HighSierra)
Xcode 10.1
Command Line Tools 10.1 (for High Sierra)
FPC 3.2.0
Lazarus 2.0.12 (macOS 64-bit)

I was experimenting with TChart and went through the "Getting Started" tutorial (LineSeries) and the 2nd tutorial (FuncSeries).  All went well and I could duplicate the graphs in the tutorials.  To be noted:  when using LineSeries , there was a OnCreate option under the Events tab (more on that later).

Next I tried to use PolarSeries and things changed.  Under Events tab, there was no OnCreate or similar option.  There was however a Source option with 2 choices:  "Chart1PolarSeries1.Builtin" and "(none)".  Neither of these options allowed me to add code in the Source Editor to generate a series.  Double-clicking on the "...Builtin" option just brought up the Data Point Editor.  At this point I gave up on the PolarSeries, closed the Project, and created a new project.

In this new project I added a Tchart and then a LineSeries.  I went to the Events tab and there was no OnCreate option now.  But there was the Source option with the same setup as before.  Where before trying PolarSeries I could use LineSeries/OnCreate to generate a data series, now I can't.

I uninstalled/deleted Lazarus, including the hidden user folder. I reinstalled Lazarus and tried again.  Same result:  OnCreate is gone from LineSeries/Events.

What happened to OnCreate?  I am stuck at this time because I need to be able to write the code to generate the data series for LineSeries. 
Any comments, suggestions, recommendations, etc. will be greatly appreciated.

Sterling

wp

  • Hero Member
  • *****
  • Posts: 8583
Re: TChart - what happened to OnCreate
« Reply #1 on: March 20, 2021, 10:54:57 pm »
Maybe I am wrong, but I guess that you are assuming that there should be an OnCreate event of TLineSeries or TPolarSeries? No, there is none. Please read the "Getting started" tutorial carefully: "we write a handler for the forms's OnCreate event". This means: You must use the OnCreate event of the form. What you see in the Lazarus object inspector (the two-column table usually at the left of your screen) depends on what is selected in the form designer window. Click anywhere on the form at a place which is not covered by another control, and the object inspector will show the properties and events of the form; click on a chart and you will see the properties of the chart, etc. Some components are hard to select. In this case it is helpful to use the tree above the table in the object inspector; it shows the hierarchy of the components on the form. Whatever you click here will be selected in the form designer, and its properties and events will be brought into the object inspector.

So, after you selected the form go to the "Events" tab and you'll see all events of the form. A bit down the list you will find the OnCreate event. Double-click on this line, or click on the '...' at the event line, and the code editor will create the skeleton of a handler for the OnCreate event. Now you can add the code that you want to be executed when the form is created. Here is the place where you can enter the code mentioned in the getting started tutorial.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

slj2021

  • Newbie
  • Posts: 2
Re: TChart - what happened to OnCreate
« Reply #2 on: March 21, 2021, 10:03:53 pm »
wp,

Thanks for the detailed reply and great explanation.  I was indeed doing it wrong.  Following your "workflow" I retested LineSeries and PolarSeries and both now had the OnCreate and everything worked fine.  For me, just another "don't leave out the small steps".
Thanks again.

 

TinyPortal © 2005-2018