document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2.  
  3. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  4. <!DOCTYPE html>
  5.  
  6. <%@page import="java.sql.ResultSet"%>
  7. <%@page import="java.sql.Statement"%>
  8. <%@ page import="java.awt.*" %>
  9. <%@ page import="java.io.*" %>
  10. <%@ page import="org.jfree.chart.*" %>
  11. <%@ page import="org.jfree.chart.axis.*" %>
  12. <%@ page import="org.jfree.chart.entity.*" %>
  13. <%@ page import="org.jfree.chart.labels.*" %>
  14. <%@ page import="org.jfree.chart.plot.*" %>
  15. <%@ page import="org.jfree.chart.renderer.category.*" %>
  16. <%@ page import="org.jfree.chart.urls.*" %>
  17. <%@ page import="org.jfree.data.category.*" %>
  18. <%@ page import="org.jfree.data.general.*" %>
  19.  
  20. <%
  21.  
  22. DefaultCategoryDataset dataset = new DefaultCategoryDataset( );
  23.  
  24.  
  25.  
  26. dataset.addValue(100 , "Today Price" , "Apple" );
  27. dataset.addValue(150 , "Tommorrow Price" , "Apple" );
  28. dataset.addValue(200 , "Today Price" , "Orange" );
  29. dataset.addValue(220 , "Tommorrow Price" , "Orange" );
  30. dataset.addValue(300 , "Today Price" , "Mango" );
  31. dataset.addValue(320 , "Tommorrow Price" , "Mango" );
  32.  
  33.  
  34. JFreeChart chart = null;
  35. BarRenderer renderer = null;
  36. CategoryPlot plot = null;
  37.  
  38.  
  39. final CategoryAxis categoryAxis = new CategoryAxis("Fruits Name");
  40. final ValueAxis valueAxis = new NumberAxis("Price");
  41. renderer = new BarRenderer();
  42.  
  43. plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
  44. renderer);
  45. plot.setOrientation(PlotOrientation.VERTICAL);
  46. chart = new JFreeChart("Commodity-wise Graph", JFreeChart.DEFAULT_TITLE_FONT,
  47. plot, true);
  48.  
  49. chart.setBackgroundPaint(new Color(249, 231, 236));
  50.  
  51. Paint p1 = new GradientPaint(
  52. 0.0f, 0.0f, new Color(16, 89, 172), 0.0f, 0.0f, new Color
  53. (201, 201, 244));
  54.  
  55. renderer.setSeriesPaint(1, p1);
  56.  
  57. Paint p2 = new GradientPaint(
  58. 0.0f, 0.0f, new Color(255, 35, 35), 0.0f, 0.0f, new Color
  59. (255, 180, 180));
  60.  
  61. renderer.setSeriesPaint(2, p2);
  62.  
  63. plot.setRenderer(renderer);
  64.  
  65. try {
  66. final ChartRenderingInfo info = new ChartRenderingInfo
  67. (new StandardEntityCollection());
  68.  
  69. ServletContext sc = this.getServletContext();
  70. String sg1=sc.getRealPath("/");
  71. String fname=sg1.substring(0,sg1.indexOf("build"));
  72. String localfilename=fname+"web/images/barchart1.png";
  73.  
  74. final File file1 = new File(localfilename);
  75. ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
  76. } catch (Exception e) {
  77. out.println(e);
  78. }
  79.  
  80. %>
  81.  
  82. <html xmlns="http://www.w3.org/1999/xhtml">
  83. <head>
  84. <meta http-equiv="Content-Type"
  85. content="text/html; charset=UTF-8" >
  86. <meta http-equiv="refresh" content="1">
  87. <title>JSP Page</title>
  88. </head>
  89.  
  90. <body>
  91. <IMG SRC="images/barchart1.png" WIDTH="600"
  92. HEIGHT="400" BORDER="0" USEMAP="#chart"></IMG>
  93. </body>
  94. </html>
');