Forum OpenACS Development: Response to ploting service

Collapse
Posted by Dan Wickstrom on
Rafael,

I tried using jchart with nsjava and it seems to work okay. I ran a couple of demo programs as follows:

package require nsjava

# import the demo classes
nsjava::import -package com.jrefinery.chart.demo ImageMapDemo1 ImageMapDemo2

# main routines expect a string array arg - but it is not used so pass 0-length
# array
set args [nsjava::new {String[]} 0]

# call the two image demo routines
nsjava::call ImageMapDemo1 {main String[]} $args
nsjava::call ImageMapDemo2 {main String[]} $args


Which resulted in the following two .png images being created:

Barchart

Piechart

To enable nsjava to use the jchart software, it was only necessary to include the appropriate .jar files in the class path:


ns_section "ns/server/${server}/module/nsjava"
        ns_param   ClassPath  "/export/local/aolserver/bin/nsjava.jar:/home/unix/wickstrom/web/jchart/jfreechart-0.9.2/jars/jcommon-0.6.4.jar:/home/unix/wickstrom/web/jchart/jfreechart-0.9.2/jars/jfreechart-0.9.2.jar:/home/unix/wickstrom/web/jchart/jfreechart-0.9.2/jars/jfreechart-0.9.2-demo.jar"


If you try this, you should note that the demo programs don't give an absolute path for writing the .png files, so they will be created in the aolserver start directory. For actual use, you could pass in a tmpfile name and the data that you want plotted.