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 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:&nbsp;&nbsp;<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

Pls Help!!!









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 coordinate value .
JFreeChart- Display coordinate value .  How to Mark Coordinte value on top of the bar
Advertisements
Jfree chart problem - Swing AWT
Jfree chart problem  hello i have a problem related to jfree chart i have some data and i want to display data in two different chart stacked... of stacked areachart and line chart in one frame. I want to display hybrid graph
JFreechart Stacked Bar Chart
JFreechart Stacked Bar Chart JFreechart provides a way to create various... = createDataset(); final JFreeChart chart = createChart(dataset); final ChartPanel... JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart
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
How to display jfreechart at specified place in jsp
How to display jfreechart at specified place in jsp  I have a jsp page where i need to display the chart at specified position...("Inet", 20); JFreeChart chart = ChartFactory.createPieChart3D
Display Problem
Display Problem  i am creating a small window application , i want to fetch data from ms-access(db) and want to display it on tables. what options are there to show result on table. is CSS helpfull
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
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... for display frame on the screen. createCategoryDataset
How to display Jfreechart from servlet in jsp web page at specified location
to display the chart in web page. I generated the chart using Jfreechart in Servlet which is in image format.plz sir give me the code to display this chart...How to display Jfreechart from servlet in jsp web page at specified
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.... JFreeChart: JFreeChart class object is used to create new chart according
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.... setVisible(): This method is used for display frame on the screen
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... for display frame on the screen.ADS_TO_REPLACE_2 add(): This method
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
how to show x axis values of timeline chart in jfreechart with particular month.
how to show x axis values of timeline chart in jfreechart with particular month.  my x-axix timeline having day of 1 month and days shows me only differently and 1 month. I want month attached with days
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... is used for display frame on the screen.ADS_TO_REPLACE_2
display combination of a stacked area chart and line chart in one iframe using jfree - JSP-Servlet
display combination of a stacked area chart and line chart in one iframe using jfree  hello i have a problem related to jfree chart, i want to display combination of a stacked area chart and line chart in one iframe
iterator display problem - Struts
iterator display problem   in action class i store database data in arrraylist but after success how can i display those data in jsp page using... friend, Code to help in solving the problem : Iterator Tag
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
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 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 to display checkbox item
Problem to display checkbox item  Hi, Following is my code: <...; I want to display records, when i click on submit button or any dumy button... checkboxes.ADS_TO_REPLACE_5 So, from your above code, i can display selected
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
Draw Statistical chart in jsp
used  JFreeChart Library. JFreeChart is a chart library used to generate different...( query); JFreeChart chart = ChartFactory .createBarChart3D( "Test", ...) { System.out.println("Problem in creating chart."); } %> To run
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
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
JFreeChart - An Introduction
;    JFreeChart is a free open source java chart... with required JFreeChart library jar filesADS_TO_REPLACE_2 Chart and Dataset In JFreeChart project, you have to create a Dataset for creating a chart
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
JComboBox Display Problem - Java Beginners
JComboBox Display Problem  I am create one program that contain two combo boxes. If first combo box i am display all date. If i select one date from first combo box then the second combo box display some dates based on first
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
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
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)  I have created a servlet.In this,i... i have to display a graph between a student semester-marks .(semesters on x
display records with images problem - JSP-Servlet
display records with images problem  hello, i am developing HR application whereby i want to display employee records and their pictures on web... with a unique id. Also i wrote i jsp that link to servlet in order to display
Combined Category Plot Example using JFreeChart
to create a Combined Category Plot chart using JFreeChart. Code for the chart shows... Combined Category Plot Example using JFreeChart... for display frame on the screen.ADS_TO_REPLACE_2 addValue
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
Create multiple pie chart in single frame using JFreeChart
Create multiple pie chart in single frame using JFreeChart... JFreeChart. Code given below creates a simple pie charts for given values... in the middle of the screen. setVisible(): This method is used for display frame
hybrid chart(Stacked Area and Line ) - Swing AWT
hybrid chart(Stacked Area and Line )  hello i have a problem related to jfree chart i have some data and i want to display data in two... to display hybrid graph (Stacked Area and Line ).combination of stacked area chart
ChartFrame in Jfreechart - JSP-Servlet
am developing line chart in JSP and the code is: My problem is that the chart is created and also saved in the specified... the following code to display the chart: ChartPanel chartPanel = new
Version of jfreechart>jfreechart dependency
List of Version of jfreechart>jfreechart dependency
Clickable chart with Tool Tip
Clickable chart with Tool Tip  Can we generate the charts with tooltip and onclick events using jfreechart in jsps and servlets
JFreeChart Tutorial
Chart - JFreeChart provides a way to create various charts by just using....    Bar Chart Example using JFreeChart - Example create a bar chart using JFreeChart.    Pie Chart Example
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException

Ads