cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Zirl" <alex.z...@web.de>
Subject AW: Link: Project:PDF Report with Pie chart
Date Sat, 08 Jan 2005 17:05:08 GMT
Sure there’s a way to do so, but it’s a bit complex. 
I just played around a bit with SVG, and the fo2pdf Serializer available
with cocoon.

Ok, here’s a short recipe >>

1. SVG
~~~~~~
If you generate the pie chart at runtime, I suggest using SVG graphics. For
a pie chart, simply draw as many circles as pie pieces available, and clip
their regions out (i.e. only the clipping part will be drawn, the rest will
have an alpha value of 0).

Here's a short example of how this could work. Simply save this xml-code as
a *.svg file and load it into your browser. (Use
http://www.w3.org/TR/SVG/shapes.html#PolygonElement ,
http://www.w3.org/TR/SVG/masking.html et. al. as references.) You can
generate this portion of XML via your cocoon setup (and also make the
necessary calculations for the angles, if calculated at runtime). The tricky
part will be to compute the exact locations of the polygons that clip the
regions (i.e. the pieces) of the circle (i.e. the entire pie). This works
fine for smaller pie pieces, but might not be an elegant solution for rather
large pieces. Especially for pieces >=180 degrees, this fails. Think about
it and you'll see why.... If there's a more elegant solution, let me know,
I'm always interested :) 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="1000">
<ellipse rx="100" ry="100" style="fill:red" transform="translate(500,500)"
clip-path="url(#pie1)"/>
<ellipse rx="100" ry="100" style="fill:blue" transform="translate(500,500)"
clip-path="url(#pie2)"/>
<ellipse rx="100" ry="100" style="fill:green" transform="translate(500,500)"
clip-path="url(#pie3)"/>

<clipPath id="pie1">
   <polygon points="0,0 -50,-100 50,-100" />
</clipPath>
<clipPath id="pie2">
   <polygon points="0,0 -500,-1000 0,10000" />
</clipPath>
<clipPath id="pie3">
   <polygon points="0,0 0,10000 500,-1000" />
</clipPath>
</svg>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. FO2PDF
~~~~~~~~~
Once you have generated the SVG, you can incorporate it into your PDF as
follows (See http://xml.apache.org/fop/fo/embed.fo):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

<fo:instream-foreign-object width="1000pt" height="1000pt"
content-width="500pt" content-height="500pt">
   <!-- svg code goes here -->
</fo:instream-foreign-object>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I hope this serves as a first hint for your "urgent requirement" :)

Best,
Alexander 

--- Original Message ---
________________________________________
Link: Project:PDF Report with Pie chart

I didn't find any sample project for PDF Report generation with Pie charts.
Please help me in this Regard.
I have an urgent requirement.
 
With Regards,
Rajakarthikeyan
30290586
 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message