You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by ra...@wipro.com on 2005/01/08 06:26:35 UTC

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





Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

AW: Link: Project:PDF Report with Pie chart

Posted by Alexander Zirl <al...@web.de>.
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