Jfreechart chart display problem
Using JSP and Jfreechart displays the chart fine on an internal browser in eclipse but doesnt display it on Chrome nor on Firefox.
Chart.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@page import="org.jfree.*" %>
<%@page import="org.jfree.chart.axis.CategoryAxis" %>
<%@page import="org.jfree.chart.plot.CategoryPlot" %>
<%@page import="org.jfree.chart.axis.NumberAxis" %>
<%@page import="java.awt.BasicStroke" %>
<%@page import="java.awt.Color" %>
<%@page import="java.awt.Polygon" %>
<%@page import="java.awt.Shape" %>
<%@page import="java.awt.geom.Rectangle2D" %>
<%@page import="org.jfree.chart.renderer.category.CategoryItemRenderer" %>
<%@page import="org.jfree.chart.renderer.category.LineAndShapeRenderer" %>
<%@page import="org.jfree.chart.plot.DefaultDrawingSupplier" %>
<%@page import ="org.jfree.chart.plot.DrawingSupplier" %>
<%@ page import="org.jfree.chart.ChartFactory" %>
<%@ page import="org.jfree.chart.ChartUtilities" %>
<%@ page import="org.jfree.chart.JFreeChart" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="javax.swing.JFrame" %>
<%@ page import="org.jfree.chart.plot.PlotOrientation"%>
<%@ page import="org.jfree.data.*" %>
<%@ page import="java.awt.image.*" %>
<%@ page import="org.jfree.data.jdbc.JDBCCategoryDataset"%>
<%@page import="java.awt.Paint" %>
<%@page import="org.jfree.chart.title.LegendTitle" %>
<%@page import="org.jfree.chart.block.LabelBlock" %>
<%@page import="java.awt.GradientPaint" %>
<%
int value=Integer.parseInt(request.getParameter("q"));
String query="select dateof,dayinprice,company from stockprice where stockid="+value+" ORDER BY dateof";
JDBCCategoryDataset dataset=new JDBCCategoryDataset("jdbc:odbc:login","sun.jdbc.odbc.JdbcOdbcDriver","root","root");
dataset.executeQuery(query);
JFreeChart chart = ChartFactory.createLineChart("Company","date","Day In Price",dataset,PlotOrientation.VERTICAL, true, true, false);
//chart.setBackgroundPaint(Color.black);
Paint p = new GradientPaint(0,0, Color.white, 1000,0, new Color(0,106,78));
chart.setBackgroundPaint(p);
CategoryPlot plot= chart.getCategoryPlot();
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.black);
CategoryItemRenderer cir = plot.getRenderer();
cir.setSeriesPaint(0,new Color(0,106,78));
LineAndShapeRenderer renderer = (LineAndShapeRenderer)plot.getRenderer();
renderer.setShapesVisible(true);
renderer.setUseFillPaint(false);
renderer.setFillPaint(new Color(0,106,78));
renderer.setStroke(new BasicStroke(2f, BasicStroke.JOIN_ROUND, BasicStroke.JOIN_BEVEL));
try
{
ChartUtilities.saveChartAsJPEG(new File("C:/chart.jpg"), chart, 800, 500);
out.println("<img src=\"C:\\chart.jpg \"></img>");
}
catch (IOException e)
{
System.out.println("Problem in creating chart.");
}
%>
Stock1.jsp
<%@ page language="java" import="java.sql.*" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>CHART</title>
<script type="text/javascript">
function showCustomer(str)
{
var currentTime = new Date();
var d=currentTime.getMilliseconds();
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("im").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","chart.jsp?q="+str+"&d="+d,true);
xmlhttp.send();
}
</script>
</head>
<body>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:login");
Statement st=con.createStatement();
String str="select * from stock";
ResultSet rs=st.executeQuery(str);
%>
<form>
Choose Quote: <select name="stocksel" onclick="showCustomer(this.value)">
<%while(rs.next())
{
%>
<option value="<%=rs.getString("stockid")%>"><%=rs.getString("stockname")%></option>
<%
}
rs.close();
con.close();
%>
</select>
</form>
<br />
<div id="im" ></div>
</body>
</html>
View Answers
April 17, 2012 at 10:16 PM
Ads
Related Tutorials/Questions & Answers:
Jfreechart chart display problem
Jfreechart chart display problem Using JSP and
Jfreechart displays the
chart fine on an internal browser in eclipse but doesnt
display it on Chrome...");
dataset.executeQuery(query);
JFreeChart chart = ChartFactory.createLineChart
jfreechart display from access database data.
the bar graph using
jfreechart API .This whole retrieval and
display of
chart...("
Problem in creating
chart.");
}
%>
But for above code, you need
jfreechart api...
jfreechart display from access database data. I have made a database
Advertisements
Create a polar chart using JFreeChart
Create a polar
chart using
JFreeChart
 ... a polar
chart using
JFreeChart. Code given below creates a simple
polar
chart... of the screen.
setVisible(): This method is used for
display
JFreechart multi line chart help in JSP
JFreechart multi line
chart help in JSP Hi,
I am am looking for and help in getting multi line
chart with Jfree
chart, i had manage to write...");
dataset.executeQuery(query);
//(final XYDataset dataset){
final
JFreeChart chart
jfreechart displaying chart from access database
jfreechart displaying
chart from access database I have these 2...");
JFreeChart chart = ChartFactory.createBarChart("MARKS INFORMATION... "Short description";
}// </editor-fold>
}
and a
jfreechart file
Display data in a chart
Display data in a chart I have a data in mysql table,i retrieved that data in drop down list and wen i click on particular name on the drop down, the data must
display in chat.how to do this plz help me......thank u
Display data in a chart
Display data in a chart I have a data in mysql table,i retrieved that data in drop down list and wen i click on particular name on the drop down, the data must
display in chat.how to do this plz help me......thank u
Display data in a chart
Display data in a chart I have a data in mysql table,i retrieved that data in drop down list and wen i click on particular name on the drop down, the data must
display in chat.how to do this plz help me......thank u
Stacked Bar Chart using JFreeChart
Stacked Bar
Chart using
JFreeChart
 ... bar
chart using
JFreeChart.
In the code given below we have extended class... is used for
display frame on the screen.
addValue(): This method is used for add
Stacked Bar Chart Example using JFreeChart
Stacked Bar
Chart Example using
JFreeChart... a Stacked bar
chart using
JFreeChart. Bar
chart will represent scores
of two team... for
display frame on the screen.
createCategoryDataset():
This
method is used
Category Step Chart Example using JFreeChart
Category Step
Chart Example using
JFreeChart... a category step
chart using
JFreeChart.
Code of the
chart shows you run rate... in the middle of the screen.
setVisible(): This method is used for
display
Stacked 3d Bar Chart Example using JFreeChart
Stacked 3d Bar
Chart Example using
JFreeChart... a Stacked 3d bar
chart using
JFreeChart.
Bar
chart will represent the score...(): This method is used for
display frame on the screen.
createCategoryDataset
Box And Whisker Chart Example using JFreeChart
Box And Whisker
Chart Example using
JFreeChart... to create a box and whisker
chart using
JFreeChart.
Code of the
chart given below... in the middle of the screen.
setVisible(): This method is used for
display frame
Create a pie chart in jsp page using JFreeChart
Create a pie
chart in jsp page using
JFreeChart... to create a pie
chart in jsp page using
JFreeChart. Code given below creates a simple pie
chart
for given values.
In the code given below we have extended class
Integer display problem
Integer
display problem class Bean{
int n1,n2;
public Bean(){
}
public Bean(int n1, int n2){
this.n1=n1;
this.n2=n2;
}
public...);
}
}
In above program value of n1 should
display 10. But it is displaying 8. what
Candle Stick Chart Example using JFreeChart
Candle Stick
Chart Example using
JFreeChart... a candle stick
chart using
JFreeChart. Code
of the
chart given below shows... for
display frame on the screen.
DefaultHighLowDataset(): DefaultHighLowDataset
Horizontal Bar Chart Example using JFreeChart
Horizontal Bar
Chart Example using
JFreeChart... a
Horizontal
bar
chart using
JFreeChart. This
example showing you match... of the screen.
setVisible():
This method is used for
display frame on the screen
Create a dual axis chart using JFreeChart
Create a dual axis
chart using
JFreeChart
 ... a dual axis
chart using
JFreeChart. Code given below creates a simple
dual axis
chart
for a match.
In the code given below we have extended class
Create area chart in JSP page using JFreeChart
Create area
chart in JSP page using
JFreeChart... to create a area
chart in JSP page using
JFreeChart. Code given below creates a area
chart of runs of two teams in
different matches.
In the code given below we
Create a bar chart in JSP page using JFreeChart
Create a bar
chart in JSP page using
JFreeChart... to create a bar
chart in JSP page using
JFreeChart. Code given below creates a bar
chart....
setVisible(): This method is used for
display frame on the screen
Problem with display of images in applets - Applet
Problem with
display of images in applets Hi all,
When I run... in figuring out the
problem.... Hi frined,
import java.applet.*;
import..., this);
}
}
---------------------------------------
Display image in Java Applet
Draw Statistical chart in jsp
used
JFreeChart Library.
JFreeChart is a
chart library used to generate different...;,"root");
dataset.executeQuery( query);
JFreeChart chart...
Draw Statistical
chart in jsp
 
select Query result display problem
select Query result
display problem Hi,
String SQL_QUERY ="from Cc";
Query query = session.createQuery(SQL_QUERY);
for(Iterator it=query.iterate();it.hasNext();){
Object[] row = (Object[]) it.next
Create a 3D bar chart in JSP page using JFreeChart
Create a 3D bar
chart in JSP page using
JFreeChart... to create a 3D bar
chart in jsp page using
JFreeChart. Code given below creates a bar
chart of scores of two teams in matches.
In the code given below
JFreeChart - An Introduction
;
JFreeChart is a free open source java
chart...
JFreeChart library jar files
Chart and Dataset
In
JFreeChart project, you... displays in the
chart.
JFreeChart have many Dataset objects, that are used to create
jfreechart
jfreechart i have added to libraries both of them jcommon-1.0.16.jar and jfreechart-1.0.13
But after adding the code to create bar
chart error...... i need to get a bar
chart done in my project