Home Answers Viewqa JSP-Servlet Jfreechart chart display problem

 
 


Sujay Gandham
Jfreechart chart display problem
1 Answer(s)      a year and 2 months ago
Posted in : JSP-Servlet

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 Pages:
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
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
JFreechart Stacked Bar Chart
JFreechart Stacked Bar Chart JFreechart provides a way to create various... JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new... createChart(final CategoryDataset 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
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
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
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
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
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
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
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
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
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   
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
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 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
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
JFreeChart- Display coordinate value .
JFreeChart- Display coordinate value .  How to Mark Coordinte value on top of the bar
how to show value and percentage in piechart sections from database using jfreechart
(query); JFreeChart chart = ChartFactory.createPieChart("Call... (IOException e) { System.out.println("Problem in creating chart... jfreechart  Hii Sir, I made a pie chart from database using
graph generation using jfreechart and retrieving values from the database
jfreechart API .This whole retrieval and display of chart is to be done in a servlet...", "sun.jdbc.odbc.JdbcOdbcDriver","root","root"); dataset.executeQuery(query); JFreeChart chart...("Problem in creating chart."); } %> please reply its very urgent..how to do
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 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
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
Combined Category Plot Example using JFreeChart
to create a Combined Category Plot chart using JFreeChart. Code for the chart shows.... JFreeChart: JFreeChart class object is used to create new chart according CategoryPlot... Combined Category Plot Example using JFreeChart
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
Error in JfreeChart
Error in JfreeChart  I am getting an error when i am using jfreechart... solution to the problem.   Hello Friend, Please visit the following link and download the jfreechart api: http://www.brothersoft.com/jfreechart
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
XYArea Chart
object in the dataset.     JFreeChart chart...",chart); After this we create the object of ChartFrame. It used to display a chart...;ChartFactory.createXYAreaChart   ("XY Chart using JFreeChart", 
Chart - Java Beginners
"); ChartUtilities.saveChartAsJPEG(image, chart, 400, 300); pw.println(" Display Chart"); Dis.html The problem is ,its working fine in my system.when i running some other system with help of URL.The chart is not coming.Its display empty page
JFREE chart - Java Beginners
..thanks,i want my chart to display dynamically from my database  Hi Friend, Try the following code to display the dynamic data from the MySQL database on your chart
Pie Chart
by invoking the method setValue(). Like        JFreeChart chart... this we create the object of ChartFrame. It used to display a chart. Here is code... Pie Chart      
Bar Chart
some more interactive features of JFreechart like set the background color of chart...; JFreeChart chart = ChartFactory.createBarChart("BarChart using JFreeChart...); After this we create the object of ChartFrame. It used to display a chart. Here
XYLine Chart
the XYSeries object in the dataset.     JFreeChart chart... the object of ChartFrame. It used to display a chart. Here is the code... XYLine Chart      
Bar Chart Example using JFreeChart
Bar Chart Example using JFreeChart   ... chart using JFreeChart. Code given below creates a bar chart of scores of two teams.... setVisible(): This method is used for display frame on the screen
WaterFall Chart
.   JFreeChart chart = ChartFactory.createWaterfallChart("Comparison between... Chart. GetCategoryPlot() is method of the JFreeChart class and it returns the object... this we create the object of ChartFrame. It used to display a chart. Here is a code
Polar Chart
the collection of XYSeries objects, which is used as a dataset.   JFreeChart chart.... It is used to display a chart. Here is a code of the Program... Polar Chart      
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... solution to the problem.   Hi Friend, Please go through the following
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
Area Chart
more interactive features of JFreeChart like set the background color of chart...;   JFreeChart chart = ChartFactory.createAreaChart("Comparison between.... It used to display a chart.   Here is a code of the Program
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
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
Dynamin Jfree chart in jsp---error
); JFreeChart chart = ChartFactory .createBarChart3D( "Stock Update", "runs...("Problem in creating chart."); } %> Generated error: <...Dynamin Jfree chart in jsp---error   While compiling this CODE
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
3D Pie Chart
; setValue(?one?, new Integer(10));     JFreeChart chart... to display a chart. Here is the code the of Program... 3D Pie Chart      
3D Bar Chart
what will appear in the legend to the meaning of the bar.   JFreeChart chart... to display a chart. Here is code of Program : import ... 3D Bar Chart