Jfreechart setting Legends

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...????


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

View Answers

June 10, 2010 at 4:36 PM

Hi Friend,

Try the following code:

<%@page import="org.jfree.ui.*"%>
<%@page import="org.jfree.chart.*"%>
<%@page import="org.jfree.data.category.*"%>
<%@page 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









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:ADS_TO_REPLACE_1 Download JFreechart Download jfreechart-1.0.13.zip
Advertisements
ModuleNotFoundError: No module named 'apex-legends'
ModuleNotFoundError: No module named 'apex-legends'  Hi, My Python... 'apex-legends' How to remove the ModuleNotFoundError: No module named 'apex-legends' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ogc-legends'
ModuleNotFoundError: No module named 'ogc-legends'  Hi, My Python... 'ogc-legends' How to remove the ModuleNotFoundError: No module named 'ogc-legends' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'apex-legends'
ModuleNotFoundError: No module named 'apex-legends'  Hi, My Python... 'apex-legends' How to remove the ModuleNotFoundError: No module named 'apex-legends' error? Thanks   Hi, In your python
Version of jfreechart>jfreechart dependency
List of Version of jfreechart>jfreechart dependency
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... the following link and download the jfreechart api:ADS_TO_REPLACE_2 http://www.brothersoft.com/jfreechart-download-15712.html Then extract the api and put
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.*;ADS_TO_REPLACE_1 what is the reason
Maven Repository/Dependency: jfreechart | jfreechart
Maven Repository/Dependency of Group ID jfreechart and Artifact ID jfreechart. Latest version of jfreechart:jfreechart dependencies. # Version Release Date 1 0.9.18 01
jfreechart
jfreechart maven dependency
jfreechart maven dependency  Hi, I want to use jfreechart library in my Java project. My project is maven based and I am trying to find the maven dependency of jfreechart. What is jfreechart maven 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
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
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
JFreeChart Tutorial
JFreeChart Tutorials, examples and articles The JFreeChart is Java based.... In this tutorial we teach you to use popular JFreeChart api for creating various... for generating dynamic graphs from Java based applications. The JFreeChart
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart
jfreechart - jfreechart version 0.9.3 Maven dependency. How to use jfreechart version 0.9.3 in pom.xml?
jfreechart  - Version 0.9.3 of jfreechart Maven dependency? How to use  jfreechart  - Version 0.9.3 of jfreechart in pom.xml? How to use jfreechart version 0.9.3 in pom.xml? Learn to use this dependency in your project
Version of jfree>jfreechart-experimental dependency
List of Version of jfree>jfreechart-experimental dependency
Version of jfree>jfreechart-swt dependency
List of Version of jfree>jfreechart-swt dependency
Jfreechart - Java Beginners
Jfreechart  Hi Team, Am very new to Jfreechart concept. And I was tried to configure Jfreechart in my system but I cant. Can any one pls guide me how to install and configure JFreechart from the basic with the necessary files
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart. DRIVER: com.mysql.jdbc.Driver URL: jdbc:mysql
Line Graph using JFreeChart
Line Graph using JFreeChart  I need to draw a line graph of the (no. of sales made on y axis) by a shop with (dates on x axis) using data from MySQL database and JFreeChart. DRIVER: com.mysql.jdbc.Driver URL: jdbc:mysql
ModuleNotFoundError: No module named 'setting'
ModuleNotFoundError: No module named 'setting'  Hi, My Python... 'setting' How to remove the ModuleNotFoundError: No module named 'setting... to install padas library. You can install setting python with following command
JFreeChart dosn't work
JFreeChart dosn't work  Hello everybody I'm trying to make a line chart from JFreechart, but I just can't get it to work. The graph get its data...(temp, "", dateinput); } JFreeChart chart
setting web page size
setting web page size  How to set the webpage size in Java
utiliser jfreechart dans portlet struts
utiliser jfreechart dans portlet struts  Bonjour. J'ai un pfe,et mon application m'impose d'utiliser jfreechart,je trouve juste la documentation de jfreechart avec struts2 seulement,mai je l'ai besoin ds un portlet liferay. vu ke
Using JFreeChart to display recent changes in a time series
Using JFreeChart to display recent changes in a time series  Using JFreeChart to display recent changes in a time series
Jfreechart chart display problem
Jfreechart chart display problem  Using JSP and Jfreechart displays...(request.getParameter("q")); String query="select dateof,dayinprice,company from stockprice..."); dataset.executeQuery(query); JFreeChart chart = ChartFactory.createLineChart
Maven Dependency jfreechart >> 0.9.21
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version0.9.21 in your project
Maven Dependency jfreechart >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.1 in your project
Maven Dependency jfreechart >> 1.0.13
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.13 in your project
Maven Dependency jfreechart >> 1.0.4
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.4 in your project
Maven Dependency jfreechart >> 1.0.8a
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.8a in your project
Maven Dependency jfreechart >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.0 in your project
Maven Dependency jfreechart >> 1.0.0-rc1
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.0-rc1 in your project
Maven Dependency jfreechart >> 1.0.11
You should include the dependency code given in this page to add Maven Dependency of jfree >> jfreechart version1.0.11 in your project

Ads