TAChartTeeChart not found
lazarus / 55-TAChart
----------------------------------------------------------------------
mm7 · 2015-02-05 20:40
Hi!
Migrating Delphi project to Lazarus. There is TChart component used
with RightAxcis etc.
I am trying to add TAChartTeeChart into Uses, but getting error
"../Forms/MyChartDlg.pas(44,3) Fatal: Can't find unit TAChartTeeChart
used by ..."
The tachartteechart.pas file is there in
/usr/share/lazarus/1.2.6/components/tachart/
it is also included into tachartlazaruspkg.lpk, though wih
May be this is the cause?
How to fix?, please advise
Thanks
----------------------------------------------------------------------
wp · 2015-02-05 21:34
I had fixed this a couple of months ago, but if I remember correcty
the fix was too late for version 1.2.6, it will be in the upcoming
1.4, though. Or you use Lazarus-trunk. Or you do the modication that
you suggest and recompile your current package.
----------------------------------------------------------------------
mm7 · 2015-02-05 22:03
Quote from: wp on February 05, 2015, 10:34:32 pm.....Or you do the
modication that you suggest and recompile your current package.
By "the modication that you suggest" do you mean a change
to ?
----------------------------------------------------------------------
mm7 · 2015-02-05 23:11
Quote from: mm7 on February 05, 2015, 11:03:16 pmQuote from: wp on
February 05, 2015, 10:34:32 pm.....Or you do the modication that you
suggest and recompile your current package.
By "the modication that you suggest" do you mean a change
to ?
I've made that. The unit TAChartTeeChart is compiled and the error
"Unit cna't be found" has disappeared from my code.
Also I've rebuilt my local IDE and TAChartTeeChart is compiled in my
local .lazarus/lib/TAChartLazarusPkg/.
Now another error
The lfm file has TChart RightMargin defined, and when I try to open
the form I got error "Component Class: TChart
Error reading Chart.MarginRight: Unknown property: "MarginRight""
TAChartTeeChart has TChartTeeChart.MarginRight defined, why IDE does
not know about it?
----------------------------------------------------------------------
wp · 2015-02-05 23:49
How did you get that lfm file? How did the MarginRight get in there?
In TAChartTeeChart, MarginRight is not published, it is only public.
Only published properties are in the lfm file.
The MarginXXXX properties were added by Alexander Klenin a few years
ago, so I do not know why he did not publish them. Since this unit is
mainly for Delphi compatibility and since they are published there my
gut feeling tells me that they should be published in Lazarus as well.
Could you try to declare them as published, recompile the IDE and
check again. If it works I'll modify the unit accordingly
New interface declaration of TChartTeeChart:
Code: [Select]type
TChartTeeChart = class helper for TChart
strict private
// Workaround for issue #21809.
function GetAxisByAlign1(AIndex: TChartAxisAlignment): TChartAxis;
inline;
function GetMargin(AIndex: Integer): Integer; inline;
procedure SetMargin(AIndex: Integer; AValue: TChartDistance);
inline;
public
property RightAxis: TChartAxis index calRight read
GetAxisByAlign1;
property TopAxis: TChartAxis index calTop read GetAxisByAlign1;
published // was: public
property MarginBottom: TChartDistance index 4 read GetMargin write
SetMargin;
property MarginLeft: TChartDistance index 1 read GetMargin write
SetMargin;
property MarginRight: TChartDistance index 3 read GetMargin write
SetMargin;
property MarginTop: TChartDistance index 2 read GetMargin write
SetMargin;
end;
----------------------------------------------------------------------
mm7 · 2015-02-06 00:17
>How did you get that lfm file? How did the MarginRight get in there?
From Delphy's DFM that I've converted to text and renamed to lfm.
I will publish the MarginXXXX.
Thanks!
----------------------------------------------------------------------
wp · 2015-02-06 09:36
QuoteFrom Delphy's DFM that I've converted to text and renamed to
lfm.The "official" way to do it is to use the the Delphi converter
("Tools" / "Delphi Conversion"). But it is far from being perfect
because TAChart is too different from TeeChart. I just tried to
convert a form with an empty TeeChart and received tons of missing
property messages. Usually it is much faster to skip the chart from
importing, start with a "native" TAChart on the imported form and add
the charts properties step by step.
----------------------------------------------------------------------
wp · 2015-02-06 11:24
I tried your way of using the renamed lfm file, and now the import
seems to be much easier than with the Delphi converter. There are just
a few things to consider:
Before opening the new unit add a dependency to TAChartLazarusPkg to
your project, the fastest way to do this is to add a TChart component,
and delete it again.In the uses list of the new pas unit remove the
TeeChart-related "Chart, TeEngine, TeeGDIPlus, TeeProcs, etc". and
replace them by the TAChart units: TAGraph, TASeries plus some more
depending on your project. Feel free to ask here if you don't find the
unit.When opening the new lfm (F12) Lazarus complains about missing
properties. Allow it to "fix" the missing properties, i.e. Lazarus
removes them - you'll have to check manually what is lost, mostly they
are features not implemented by TAChart where the converter won't help
anyway.
----------------------------------------------------------------------
mm7 · 2015-02-06 17:27
I've done following:
1. Uninstalled "central" TAChartLazarusPkg package
2. Copied tachart to my home
3. Installed "my local" TAChartLazarusPkg package
4. published TAChartTeeChart MarginXXX properties as well as
AnimatedZoom boolean property that just returns False.
5. recompiled the unit and the TAChartLazarusPkg (my local) package
and the Lazarus IDE.
Result
1. IDE does not show the published properties of TAChartTeeChart for
new TChart copmponent.
2. When I load text lfm with MarginXXX and AnimatedZoom IDE raises the
error.
Does it mean that helper properties cannot be published at all?
PS/ Yes I already know the recommended migration method. Ill use that.
It is just matter of curiosity how Lazarus works with packages.
In past I wrote multiple components for Delphi, but there was not
"helper class" concept that time.
Thanks! I will fall back to the recommended migration method.
I cannot use automatic form conversion because it looks like Delphi is
more liberal for components in .DFM that are not declared in .PAS (for
example because are not used programmatically in .PAS code). It
probably just creates them dynamically during application resource
load. Lazarus removes components from .LFM if they are not declared in
.PAS. Whole components, not only properties. So whole pieces of form
can disappear. For example if TPanel was used in .DFM just for visual
purposes with no program access from code, Delphi still allows not
declare it in .PAS. Lazarus converter will remove this panel with all
controls in it, even if they are declared and used in program.
I understand, it is issue of the DFM converter, or runtime LFM loader,
and should not be reported here. I wanted to work it around with
helper class. But unfortunately this does not work either.
----------------------------------------------------------------------
mm7 · 2015-02-06 17:37
Quote from: wp on February 06, 2015, 12:24:03 pm...Allow it to "fix"
the missing properties, i.e. Lazarus removes them - you'll have to
check manually what is lost, mostly they are features not implemented
by TAChart where the converter won't help anyway.
I've described already the dangers of "autofix" when components are
not declared in .PAS will be deleted.
Another nice to have thing it would be highlighting bad things in .LFM
directly in the editor, not in the separate window where you can
either to "kill them all" or to cancel.
----------------------------------------------------------------------
wp · 2015-02-06 18:31
Quote1. Uninstalled "central" TAChartLazarusPkg package
2. Copied tachart to my home
3. Installed "my local" TAChartLazarusPkg packageI think it would be
better to modify the "central" package (after making a copy for
backup). The way you do it leaves you with two TAChart entries in the
list of known packages, and I had the experience that Lazarus may get
confused with the different versions.
But anyway, I think you are right: helper properties cannot be
published - not 100% sure, though, I'm not an expert with helper
classes.
I played around the import issue today for some time and once again
came to the conclusion that it does not make much sense to tweak the
MarginXXX properties to load correctly - there will be many others
that won't, and I only had an empty chart!
Sorry...
----------------------------------------------------------------------
mm7 · 2015-02-06 21:13
I've checked, I see only one TAChartLazarusPkg package, and it is my
local one. Compiled local IDE includes TAChartTeeChart symbol.
In my test Unit1.pas I can use helper's properties as soon as
TAChartTeeChart is specified in Uses clause.
However Register procedure that registers TChart is located in TAGraph
unit.
I am guessing, because TAChartTeeChart is not in Uses clause of
TAGraph, TChart is not assigned by TAChartTeeChart helper in that
scope. That is why IDE does not know about helper's properties.
That probably explains why the properties were not specified as
published by Alexander Klenin.
----------------------------------------------------------------------
wp · 2015-02-06 22:16
Yes, I agree.