Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Jfreechart chart display problem
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Sujay Gandham
Jfreechart chart display problem
1 Answer(s)      2 years and 8 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>

Advertisement
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
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 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
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
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 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
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 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
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
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
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
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
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
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... for display frame on the screen. DefaultHighLowDataset(): DefaultHighLowDataset
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
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
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   
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
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
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
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
Advertisements
 

 

 

DMCA.com