zk 5.0.9 CE and bar-charts

asked 2012-01-01 17:47:48 +0800

andij62 gravatar image andij62
303 1 7


i use zk 3.6.4 with bar-charts. In ZK 5 charts are not available in CE-Version. Is it possible to use it in CE-Version? Can i include jfreechart manual in the CE-Version?

Thanks for your answer

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-01-01 19:27:15 +0800

andij62 gravatar image andij62
303 1 7
hi all, the problem is solved. Here is my code
<?page title="Auto Generated index.zul"?>
<window title="Hello World!!" border="normal" width="500px" apply="zk509.ChartCtrl">

<image id="myimage" />

package zk509;

import java.awt.image.BufferedImage;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.encoders.EncoderUtil;
import org.jfree.chart.encoders.ImageFormat;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import org.zkoss.image.AImage;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Image;

public class ChartCtrl extends GenericForwardComposer{
	private Image myimage;
	public void doAfterCompose(Component comp) throws Exception {

		DefaultPieDataset pieDataset = new DefaultPieDataset();
		pieDataset.setValue("C/C++", new Double(17.5));
		pieDataset.setValue("PHP", new Double(32.5));
		pieDataset.setValue("Java", new Double(43.2));
		pieDataset.setValue("Visual Basic", new Double(10));
		JFreeChart chart = ChartFactory.createPieChart3D("Sample Pie Chart 3D", pieDataset,true,true,true);
		PiePlot3D plot = (PiePlot3D) chart.getPlot();
		BufferedImage bi = chart.createBufferedImage(500, 300, BufferedImage.TRANSLUCENT , null);
		byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
		AImage image = new AImage("Pie Chart", bytes);

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2012-01-01 17:47:48 +0800

Seen: 196 times

Last updated: Jan 01 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More