Paul, your code works... its showing labels! However, its showing 'php 
sucks1!' and 'php sucks 2!' in the label. Whereas, I want to display the 
actual value of each bar, which in your example would be 1,5,3,2,3,2. What 
shall I change in this code?


Regards,
Arsalan

--------------------------------------------------
From: "Paul Hastings" <p...@sustainablegis.com>
Sent: Monday, April 05, 2010 10:42 PM
To: "cf-talk" <cf-talk@houseoffusion.com>
Subject: Re: JFreeChart with CF [spamtrap bayes][spamtrap heur]

>
> On 4/5/2010 8:01 PM, Arsalan Tariq Keen wrote:
>> How can I do that?
>
> what ver of jfreechart are you using? this works with the latest (1.0.13):
>
> <cfscript>
> color=createObject("java","java.awt.Color");
> plotOrientation=createObject("java","org.jfree.chart.plot.PlotOrientation");
> nf=createObject("java","java.text.NumberFormat").getInstance();
> /*
> pay attention: label format, format where format is either some instance 
> of
> NumberFormat or DateFormat
> leave you to fiddle w/placement,formatting, etc.
> */
> itemLabelGenerator=createObject("java","org.jfree.chart.labels.StandardCategoryItemLabelGenerator").init(
> "php sucks {0}!",nf);
> dataset=createObject("java","org.jfree.data.category.DefaultCategoryDataset").init();
> dataset.addValue(1.0, "1", "Column 1");
> dataset.addValue(5.0, "1", "Column 2");
> dataset.addValue(3.0, "1", "Column 3");
> dataset.addValue(2.0, "2", "Column 1");
> dataset.addValue(3.0, "2", "Column 2");
> dataset.addValue(2.0, "2", "Column 3");
> chart=createObject("java","org.jfree.chart.ChartFactory").createBarChart3D(
> "it's a bar chart stupid", // title
> "category", // domain axis label
> "value", // range axis label
> dataset, // which data
> plotOrientation.VERTICAL, // direction
> false, // legend
> false, // tooltips
> false // urls
> );
> chart.setBackgroundPaint(Color.white);
> // plot
> plot=chart.getCategoryPlot();
> plot.setBackgroundPaint(Color.lightGray);
> plot.setRangeGridlinePaint(Color.white);
> // renderer
> renderer=plot.getRenderer();
> renderer.setSeriesPaint(0,color.gray);
> renderer.setSeriesPaint(1,color.orange);
> renderer.setDrawBarOutline(false);
> renderer.setItemMargin(0.0);
> renderer.setItemLabelPaint(color.red);
> renderer.setItemLabelsVisible(javacast("boolean","true"));
> renderer.setItemLabelGenerator(itemLabelGenerator);
> // axis
> categoryAxis = plot.getDomainAxis();
> categoryAxis.setCategoryMargin(0.0);
> // wrap it up
> chartImage=chart.createBufferedImage(650,450);
> imageIO=createObject("java","javax.imageio.ImageIO");
> outFile=createObject("java","java.io.File");
> // some write accessible path
> outFile.init("path_to_image_file\labels.png");
> imageIO.write(chartImage,"png",outFile);
> </cfscript>
>
> <img src="labels.png">
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332609
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to