DialChart (Speed-o-meter) of JfreeChart in primefaces

UI Components for JSF
Post Reply
User avatar
jomaora
Posts: 29
Joined: 05 May 2010, 16:07
Location: Bucaramanga, Colombia --> Clermont-Ferrand, France

12 May 2010, 14:36

Hi,

Well I have to say that I had worked till today with the chart-creator 1.2.0 to make my charts in my pages. I tried today with the <p:columnChart> and I have to say: "WOW". I set up the life in true and see the chart updating itself was great.

But now I have a big question. My boss wants to have the DialChart that is include un JFreeChart,
http://www.jfree.org/jfreechart/images/ ... Demo2a.png you can see it in this page.

In the Primefaces user guide, the <p:graphicImage> can be used to show images of charts created via the JFreeChart classes.

Code: Select all

<p:graphicImage value="#{backingBean.chartImage}" />
Its bean is

Code: Select all

public class BackingBean {
	 private StreamedContent chartImage;
	 public BackingBean() {
		 try {
			 JFreeChart jfreechart = ChartFactory.createPieChart("Turkish Cities", createDataset(), true, true, false);
			 File chartFile = new File("dynamichart");
			 ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 37300);
			 chartImage = new DefaultStreamedContent(new FileInputSt(chartFile), "image/png");
		 } catch (Exception e) {
			 e.printStackTrace();
		 }
	 }

	 private PieDataset createDataset() {
		 DefaultPieDataset dataset = new DefaultPieDataset();
		 dataset.setValue("Istanbul", new Double(45.0));
		 dataset.setValue("Ankara", new Double(15.0));
		 dataset.setValue("Izmir", new Double(25.2));
		 dataset.setValue("Antalya", new Double(14.8));
		 return dataset;
	 }
	 //getters and setters
}
I see that the class ChartFactory is used to created the chart and then make the image. But seeing this class and its methods, I cannot find the method that allows to create a Dial. How can I do that? Does anybody have any code of how to print a Dial in JSF 2.0?

I'm using jfreechart 1.0.13.

Thanks...

Primefaces ROCKS!!!!!!!!!!!!! :D
JSF 2.0. Primefaces 2.0.2. Apache Tomcat 6.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

12 May 2010, 17:26

Hi,

I think you can find your answer in JFreeChart forum as it is a jfreechart api.

We only provide the bridge between JSF and JFreechart using p:graphicImage.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 65 guests