SvgChartPlugin
#
I made this package to display charts in my jspwiki.
This plugin uses SVG and Batik
to render SVG to jpeg-images.
Contents:#
SvgChartPlugin.java
SvgBarChartDocument.java
SvgPieChartDocument.java
SvgChartJob.java
~Chart2File.java
Usage: #
I. Download Batik
and copy the distributions jars into your jspwiki's /WEB-INF/lib directory.
II. Unziip 'de.p8serv.KleineGeschichte.Holweide.jspwiki.plugin'-package and put it into your jspwiki's
/WEB-INF/classes directory.
III. Add the following lines to your jspwiki's /WEB-INF/web.xml
<servlet>
<servlet-name>SvgChartJob</servlet-name>
<servlet-class>
de.p8serv.KleineGeschichte.Holweide.jspwiki.plugin.SvgChartJob
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SvgChartJob</servlet-name>
<url-pattern>*.chart</url-pattern>
</servlet-mapping>
IV. Add the packages name 'de.p8serv.KleineGeschichte.Holweide.jspwiki.plugin' to the plugin-searchpath in
/WEB-INF/jspwiki.properties.
V.In case of using the attachment mode:
This Wiki is 2.1.72a, brand new, you don't have to do the following anymore. But if you run minor
versions, the following could be useful :
Edit the CheckVersionTag at the top of PageContent.jsp. Add something like - "If you are just adding a
chart or other media, everything is running fine. Please reload the page to finish !" - to the message.
VI.Edit a WikiPage. Type
code.gif
and you will get this:
How the Plugin works :
#
SvgChartPlugin.java gives the processed parameters to one of the Svg***ChartDocument.java that returns a
document, containing the dom-tree with the Svg data. If you use your own chart classes, at this point, you
make sure, the generated svg is ok with Chart2File.java. The plugin handles any Svg. Now the document is converted to a jpeg-image by Batik's Trancoder classes.
The result is stored in a bytearray, which can be given to :
- - the session as a String. In this case, the Plugin creates a link to SvgChartJob.java, that picks up the chart from the session and passes it to the outputstream. This mode is the dynamic mode.
- - the attachment manager to attach the generated jpg to the current Page. The Plugin creates a new version of the page with all the old content except the svg-plugin text, which is replaced by a wikilink to the new Attachment. This mode is the attachment mode.
If you want to display multiple dynamic charts on a wiki-page, the title parameter has to be unique,
because it is also used to store the processed chart in the session. There is no multiple attachment
processing. If you want to display multiple attached charts, you have to edit and save the page for each
chart separately.
The chart above is a working example of this plugin, running in the dynamic mode. Please do not edit the
plugin's mode parameter. Please go to SandKasten
to try out the attachment mode.
Parameter:
#
param type :
- the values of the available charts are 'bar' and 'pie' .
param mode :
- the possible values are 'dynamic' - a new chart will be generated on each request - and 'attachment' - a new page is generated, embedding the attached chart-file.
param names :
- a "|"-separated String containing the names of your items. Each token will be displayed as the name of a single bar or a single slize in the chart.
param values :
- a "|"-separated String containing the values of your items. Each token will be displayed as the value of a single bar or a single slize in the chart.
param colors :
- a "|"-separated String containing the colors you assigned to your items. Each token will be displayed as the color of a single bar or a single slize in the chart.
param bgcolor :
- the color of the background.
param textcolor :
- the color of the text.
param copy :
- place copyright here.
The number of tokens in the names-, the values-,and the colors-parameter must match each other.
If you like to style the appearence of the generated images - add a 'chart' class in jspwiki.css.
You find a working example at http://www.p8serv.de:8840/KleineGeschichteHolweide/Wiki.jsp?page=SandKasten
.
I hope you find this plugin useful.
Questions? Suggestions? Critics? Bugs? Please edit this page or mail me.
(stefan.werner@p8serv.de
)
Discussion#
The above email and website appears to have lapsed - anyone else able to help? After installation, when I try and use this plugin as follows:
[{INSERT
de.p8serv.KleineGeschichte.Holweide.jspwiki.plugin.SvgChartPlugin
type='bar' title='derek' names='Jan|Feb|Mar' values='51|22|31'
colors='#996677|#223344|#454213' mode='dynamic' bgcolor='#FaFaF6'
textcolor='#336699' copy='Derek'}]
I get the error message:
Plugin insertion failed: Could not find plugin de.p8serv.KleineGeschichte.Holweide.jspwiki.plugin.SvgChartPlugin
What could be wrong?
I added a compiled version (java 1.5, for 2.4.62). Place the attached jar to your WEB-INF/lib. This did work for me. Nice to see it working with IE7 too. -- Al
Add new attachment
List of attachments
| Kind | Attachment Name | Size | Version | Date Modified | Author | Change note |
|---|---|---|---|---|---|---|
zip |
SvgChartPlugin.zip | 36.8 kB | 1 | 19-Nov-2003 18:53 | 213.196.202.3 | |
gif |
code.gif | 6.9 kB | 1 | 19-Nov-2003 18:42 | 213.196.202.3 | |
jpg |
example.jpg | 5.7 kB | 1 | 19-Nov-2003 18:52 | 213.196.202.3 | |
jar |
extra_svg.jar | 10.8 kB | 1 | 31-Jan-2007 17:41 | 195.140.184.10 | Compiled Jar for 2.4.62 |