Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Jfreechart setting Legends

Ads

 
 

Share on Google+Share on Google+

santosh
Jfreechart setting Legends
1 Answer(s)      7 years ago
Posted in : Java Beginners
Hi...
i am using JfreeChart in my web app. for creating charts.I am trying to make the legends as vertical in Stacked bar chart. Does anybody know How to set the legends in any graph as vertical...????


please reply me if you know it...thanks in advance.....

Ads
View Answers

June 10, 2010 at 4:36 PM


Hi Friend,

Try the following code:

<[email protected] import="org.jfree.ui.*"%>
<[email protected] import="org.jfree.chart.*"%>
<[email protected] import="org.jfree.data.category.*"%>
<[email protected] import="org.jfree.chart.plot.PlotOrientation"%>
<%
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(10, "Girls","Chess");
dataset.addValue(15, "Boys", "Chess");
dataset.addValue(17, "Girls","Cricket");
dataset.addValue(23, "Boys","Cricket");
dataset.addValue(25, "Girls","FootBall");
dataset.addValue(20, "Boys","FootBall");
dataset.addValue(40, "Girls","Badminton");
dataset.addValue(30, "Boys","Badminton");
dataset.addValue(35, "Girls","Hockey");
dataset.addValue(32, "Boys","Hockey");

final JFreeChart chart = ChartFactory.createStackedBarChart(
"Stacked Bar Chart Demo 1",
"Category",
"Value",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
try
{
ChartUtilities.saveChartAsJPEG(new File("C:/chart.jpg"), chart, 400, 300);
}
catch (IOException e)
{
System.out.println("Problem in creating chart.");
}
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
ApplicationFrame f=new ApplicationFrame("Chart");
f.setContentPane(chartPanel);
f.pack();
f.setVisible(true);

%>

Thanks

Ads









Related Tutorials/Questions & Answers:
Jfreechart setting Legends - Java Beginners
Jfreechart setting Legends  Hi... i am using JfreeChart in my web app. for creating charts.I am trying to make the legends as vertical in Stacked bar chart. Does anybody know How to set the legends in any graph as vertical
jfreechart
jfreechart  hi how install jfreechart? and how free download jcommon? plz insert link for this? thanks   Hi Friend, Please visit the following link: Download JFreechart Download jfreechart-1.0.13.zip from the given
Advertisements
Version of jfreechart>jfreechart dependency
List of Version of jfreechart>jfreechart dependency
setting keys
setting keys  Hi Sir\Mam,At present we are doing Payroll Project .I would like to set some special keys for my forms and i want the coding to do the same .Pls Provide me source code for setting keys as soon as possible
JFreechart & JCommon
JFreechart & JCommon   hi........... thanks a lot. The code is running successfully and able to get the output. Thanks once again
Artifacts of jfreechart
List of Artifacts of jfreechart maven depenency
Error in JfreeChart
Error in JfreeChart  I am getting an error when i am using jfreechart for graph generation, that is: D:\my\linechart.java:5: package org.jfree.chart... and download the jfreechart api: http://www.brothersoft.com/jfreechart
Error in JfreeChart
Error in JfreeChart  I am getting an error when i am using jfreechart for graph generation, that is: D:\my\linechart.java:5: package org.jfree.chart does not exist import org.jfree.chart.*; what is the reason and possible
setting web page size
setting web page size  How to set the webpage size in Java
Version of jfree>jfreechart dependency
List of Version of jfree>jfreechart dependency
Maven Dependency jfreechart >> 0.9.16
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.16 in your project
Maven Dependency jfreechart >> 0.9.17
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.17 in your project
Maven Dependency jfreechart >> 0.9.18
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.18 in your project
Maven Dependency jfreechart >> 0.9.19
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.19 in your project
Maven Dependency jfreechart >> 0.9.2
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.2 in your project
Maven Dependency jfreechart >> 0.9.20
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.20 in your project
Maven Dependency jfreechart >> 0.9.3
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.3 in your project
Maven Dependency jfreechart >> 0.9.8
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.8 in your project
Maven Dependency jfreechart >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version1.0.0 in your project
JFreeChart- Display coordinate value .
JFreeChart- Display coordinate value .  How to Mark Coordinte value on top of the bar
Setting file extension
Setting file extension  Hi, I have used FileChooser to save a file. When I was trying to save it, the extension of the file is showing 'File'. How can I save that file to .xls ? Thanks
JFreeChart - An Introduction
JFreeChart - An Introduction       JFreeChart is a free open source java chart library. David Gilbert founded the JFreeChart project in February 2000. Now a days
how to install jfreechart in netbeans.
how to install jfreechart in netbeans.  I have successfully installed jfreechart in eclipse IDE.but I am unable to install the same in netbeansIDE 6.7.1 .There is some error regarding the ant folder.Please tell the step by step
Jfreechart zoomin and zoomout - Framework
Jfreechart zoomin and zoomout  how to zoomin and zoom out chart using button plus and minus or slide bar in jFree chart
Setting Cookie
Setting Cookie  setcookie function is used for setting up a cookie. In the following example, if you use $_COOKIE command, you will view one cookie value, and if you see print_r ($_COOKIE), you will view all cookie value. We have
Setting File Attributes
Setting File Attributes  I would be glad if anyone could help me set file attributes in java I would like to know how to set the hidden file attribute or the read only file attribute. Thank you
Setting File Attributes
Setting File Attributes  I would be glad if anyone could help me set file attributes in java I would like to know how to set the hidden file attribute or the read only file attribute. Thank you
Setting environment variables
Setting environment variables  Hi, I have a java web application running on jboss AS. 1)How do I set the environment variable in jboss? 2)How do I get the environment variable from jboss
setting RGB for a circle
setting RGB for a circle  how can i change the color of the circle(not through filling it) and i want to use RGB (not regular colors such as black or red..) i should include RGB numbers (for example 240, 150, 19) but i am
problem in setting path - Ant
problem in setting path  hi friends i am getting a problem in setting but i followed the procedure same as like in http://www.roseindia.net... Do some changes setting the path : 1)ANT_HOME=D:\installations\apache