Recent

Author Topic: Can TAChart export to metafile?  (Read 16484 times)

ironphil

  • Jr. Member
  • **
  • Posts: 56
Can TAChart export to metafile?
« on: April 04, 2011, 10:00:37 pm »
Is there a way to export or copy to the clipboard a metafile (wmf or emf) of the chart when the software is run in windows?

There is only an option to save or copy to the clipboard a bitmap image of the chart. I guess this is to ensure a cross-platform compatibility. But under windows I think it is possible to create a virtual metafile canvas and redraw the chart there but I have no idea how to do that. The objective is to get a vectorized image which has no resolution instead of a bitmap image.

Considering the recent fast pace of development of TAChart, maybe something is already planned for a vectorized format.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Can TAChart export to metafile?
« Reply #1 on: April 05, 2011, 05:37:09 am »
Code: [Select]
maybe something is already planned for a vectorized format.
I have planned SVG back-end. Will it suit your purposes?
I can speed up the implementation if there is an actual user :-)

I am not sure about emf/wmf -- does Lazarus/FPC have a library for
generating this format?
I am definitely not going to implement wmf writer as part of TAChart,
but if it already exists, I can use it.



Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Can TAChart export to metafile?
« Reply #2 on: April 05, 2011, 06:42:54 am »
Code: [Select]
does Lazarus/FPC have a library for
generating this format?
Not sure, I only found this so far.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Can TAChart export to metafile?
« Reply #3 on: April 05, 2011, 08:49:53 am »
I have also found something called "FPVectorial" in FPC trunk,
but from the quick look at the source it seems like it only detects WMF,
but can not write it.



ironphil

  • Jr. Member
  • **
  • Posts: 56
Re: Can TAChart export to metafile?
« Reply #4 on: April 05, 2011, 01:37:42 pm »
SVG would be cool with me but some people on windows would not know what to do with an SVG file. If it cannot be imported straight into office...

For high quality export, maybe just being able to increase the resolution of the bitmap image would be enough. That could also be done by converting the SVG to bitmap and specifying the desired resolution. So SVG would be cool and it has the clear advantage of being cross-platform.

In fact, I am just looking for a way to export a higher quality image of the chart (with a reasonable file size).

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Can TAChart export to metafile?
« Reply #5 on: April 05, 2011, 10:31:42 pm »
I have implemented a crude SVG back-end for TAChart.

See "Save as SVG" option in the save demo since r30207.

I still lacks support for some TAChart features, but does it do what you wanted, in principle?

ironphil

  • Jr. Member
  • **
  • Posts: 56
Re: Can TAChart export to metafile?
« Reply #6 on: April 06, 2011, 12:57:06 am »
Quote
I have implemented a crude SVG back-end for TAChart.

I just updated Lazarus from SVN and it does not compile right now. The error seems to be related to the SVG back-end. That was fast by the way! The error is this:

Code: [Select]
LazarusSVN/components/tachart/tadrawersvg.pas(332,34) Error: Illegal qualifier
The line in question is the second one in this procedure:
Code: [Select]
procedure TSVGDrawer.WriteStr(const AString: String);
begin
  FStream.WriteBuffer(AString[1], Length(AString));
  FStream.WriteBuffer(LineEnding[1], Length(LineEnding));
end;

Quote
I still lacks support for some TAChart features, but does it do what you wanted, in principle?
Yes! I am quite satisfied with it. I was looking for a long time for a free alternative to the commercial teechart and this is it. And this one is cross-platform. As you said it still lacks some features but it works well and is quite stable. Your work is appreciated, thanks.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Can TAChart export to metafile?
« Reply #7 on: April 06, 2011, 02:43:55 am »
Quote
The error seems to be related to the SVG back-end.
Ugh, LineEnding apparently has different types on Windows and Unix platforms.
Please test r30218.

Quote
Yes! I am quite satisfied with it.
Thanks for your kind words, but my question was specifically about
the SVG back-end -- does it suffice for you or do you still need WMF?

ironphil

  • Jr. Member
  • **
  • Posts: 56
Re: Can TAChart export to metafile?
« Reply #8 on: April 06, 2011, 01:55:51 pm »
I tried the export to SVG and it works quite well. I opened the SVG file in inkscape and the chart is there. It is perfect in windows but in linux the mark text overflows the mark box a little bit.

It would suffice to me that is exactly what I needed.

I do not absolutely need WMF but I am sure many people would use it under windows. WMF has become the standard way to exchange images between applications in windows. If it is there I would definitely use it too.

ironphil

  • Jr. Member
  • **
  • Posts: 56
Re: Can TAChart export to metafile?
« Reply #9 on: April 07, 2011, 03:07:02 pm »
Is it safe to implement the SVG export into my project or the way to do it is expected to change? I am asking because by looking at the code of the demo it is not as straightforward as exporting to bitmap so I suspect it may get simplified in the future. Anyway, I am not in a rush for this feature, let me know when you will consider it production ready.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Can TAChart export to metafile?
« Reply #10 on: April 07, 2011, 03:50:24 pm »
Yes, I think it is reasonably safe.
Even if higher-level convenience wrapper will be added one day,
the basic interface will still work.
You can look at aggpas, nogui and opengl demos for other examples of similar interfaces.
Also note that you can omit DoChartColorToFPColor assignment if
your chart does not use system colors (like clBtnFace).

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Can TAChart export to metafile?
« Reply #11 on: April 08, 2011, 09:28:19 am »
Quote
I do not absolutely need WMF but I am sure many people would use it under windows.

After discussion with other developers it was agreed that the correct long-term plan is
to add wmf support to FPC's fpvectorial package, then add fpvectorial back-end to TAChart.
It will give cross-platform export to WMF and other vector formats, like DXF and CDR.

However, it will take a long time, so meanwhile I have implemented Windows-only
WMF back-end. See "wmf" demo in r30240.
Note that you must install a separate TAChartWMF package to use WMF drawer.
This is to avoid problems with compilation on non-Windows platforms.

Quote
in linux the mark text overflows the mark box a little bit.
Unfortunately, this problem is hard to solve -- there is no way to calculate
text dimensions in SVG, so an estimation is used by TAChart, which may be inaccurate.

Please try r30241 -- it should improve things somewhat,
but only if your SVG viewer supports textLength attribute
(Firefox does not support it, but Chrome does).

« Last Edit: April 08, 2011, 11:08:36 am by Ask »

ironphil

  • Jr. Member
  • **
  • Posts: 56
Re: Can TAChart export to metafile?
« Reply #12 on: April 21, 2011, 01:27:21 pm »
I just saw some fpvectorial stuff coming in the tachart directory. I cannot find the fpvectorial package which is required. A search for fpvectorialpkg in the lazarus or fpc directory does not return anything.

How do I install the fpvectorial package?

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Can TAChart export to metafile?
« Reply #13 on: April 22, 2011, 12:55:13 pm »
You can get fpvectorial from Lazarus CCR
https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/applications/fpvviewer/fpvectorialsrc/

Note that both fpvectorial and corresponding TAChart back-end are highly experimental.
In other words, currently they can not do anything useful.
You can see the relevant discussion at http://comments.gmane.org/gmane.comp.ide.lazarus.general/51344.
I am sure fpvectorial author will welcome your contributions ;-)

However, if you only want to write wmf under Windows, you can already
do that directly, without the need for fpvectorial -- see my previous message.

 

TinyPortal © 2005-2018