ChartFrame in Jfreechart

Ads

 
 

Share on Google+Share on Google+

Ragavendran
ChartFrame in Jfreechart
1 Answer(s)      7 years ago
Posted in : JSP-Servlet
Dear roseindia team,

I am Ragavendran.R.. I am under the project where i need to develop some charting application.. I am developing line chart in JSP and the code is:


<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="org.jfree.chart.*"%>
<%@page import="org.jfree.chart.ChartFrame"%>
<%@page import="org.jfree.chart.plot.PlotOrientation"%>
<%@page import="org.jfree.data.category.DefaultCategoryDataset"%>
<%@ page import="org.jfree.data.general.DefaultPieDataset" %>
<%@ page import="org.jfree.data.xy.*" %>
<%@ page import="org.jfree.data.*" %>
<%@ page import="org.jfree.chart.renderer.category.*"%>
<%@ page import="java.awt.*" %>
<%@ page import="javax.swing.JFrame" %>
<%@ page import="javax.swing.JScrollPane" %>
<%@ page import="javax.swing.WindowConstants" %>
<%
XYSeries series1 = new XYSeries("Branch");
XYSeries series2 = new XYSeries("Franchisee");
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@142.1.0.14:1550:bosaix","report","tcs123");
Statement st=con.createStatement();
Statement state=con.createStatement();
ResultSet rs=st.executeQuery("select to_char(PB_DATE,'DD') dt, PB_BROK from ascilmis.projs_bf t WHERE PB_TYPE = 'B'");
ResultSet rs1=state.executeQuery("select to_char(PB_DATE,'DD') dt, PB_BROK from ascilmis.projs_bf t WHERE PB_TYPE = 'F'");
while(rs.next()){
series1.add(Double.parseDouble(rs.getString(1)), Double.parseDouble(rs.getString(2)));
}
while(rs1.next()){
series2.add(Double.parseDouble(rs1.getString(1)), Double.parseDouble(rs1.getString(2)));
}
XYSeriesCollection xyDataset = new XYSeriesCollection();
xyDataset.addSeries(series1);
xyDataset.addSeries(series2);
JFreeChart chart = ChartFactory.createXYLineChart("XYLine Chart using JFreeChart", "Date", "Value",xyDataset, PlotOrientation.VERTICAL, true, true, false);
ChartFrame frame1=new ChartFrame("XYLine Chart",chart);
frame1.pack();
frame1.setVisible(true);
frame1.setSize(300,300);
String f="C:/chart.jpg";
ChartUtilities.saveChartAsJPEG(new File(f), chart, 600, 300);
}
catch(Exception e){}
%>

My problem is that the chart is created and also saved in the specified location.. But its not displaying on the page i.e chartframe portion is not executing.. What could be the problem? I know that this problem can be solved using html <img src>.. But I dont need this to be done.. I need this chartframe to be executed.. Please reply ASAP...

Regards,
Ragav..
Ads
View Answers

June 3, 2010 at 1:33 PM


Hi Friend,

You can use the following code to display the 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:
ChartFrame in Jfreechart - JSP-Servlet
ChartFrame in Jfreechart  Dear roseindia team, I am... location.. But its not displaying on the page i.e chartframe portion... html .. But I dont need this to be done.. I need this chartframe to be executed
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
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
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.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.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 >> 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
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.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.8
You should include the dependency code given in this page to add Maven Dependency of jfreechart >> jfreechart version0.9.8 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
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
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
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
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
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 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
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

Ads

 
Advertisement null

Ads