how to make this work

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Harry

how to make this work

Post by Harry » Tue Apr 23, 2002 8:49 am

package cy.com.netinfo.util;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import cy.com.netinfo.html.*;
import java.util.Date;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import java.text.SimpleDateFormat;
import cy.com.netinfo.customs.bonded.*;

public class JChart extends HttpServlet {
static ResourceBundle bundle = null;

/**
*This method gets the request
*/
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
processRequest(req,resp);
}

/**
*This method posts the request
*/

public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
processRequest(req,resp);
}


public void processRequest(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
HttpSession session = req.getSession();
resp.setContentType("text/html");
PrintWriter out = new PrintWriter(resp.getOutputStream());
if (action.equals("Find")){
String XNumber = req.getParameter("x_number");
String YNumber = req.getParameter("y_number");
}

page.print(out);
out.flush();

}//process
public HtmlForm enterDataForm (HttpServletRequest req,HttpServletResponse resp){
String action = req.getParameter("submit");
HtmlForm form = new HtmlForm("EnterData",req.getRequestURI(),HtmlForm.GET,"Find Authorization","");
form.addBR();
HtmlTable table = new HtmlTable();
table.setBorder(0);
HtmlTableCell c;
HtmlTableRow row1 = new HtmlTableRow();
c = new HtmlTableCell();
c.addText("X-Axis","blue");
c.setHorizontalAlign(HtmlTableCell.LEFT);
c.setVerticalAlign(HtmlTableCell.TOP);
row1.add(c);
c = new HtmlTableCell();
HtmlInput rn = new HtmlInput("x_number",XNumber,3);
rn.setFormat("num");
rn.setMaxSize(3);
rn.setMandatory(true);
c.add(rn);
c.setHorizontalAlign(HtmlTableCell.CENTER);
c.setVerticalAlign(HtmlTableCell.TOP);
row1.add(c);
table.add(row1);
row1 = new HtmlTableRow();
c = new HtmlTableCell();
c.addText("Y-Axis","blue");
c.setHorizontalAlign(HtmlTableCell.LEFT);
c.setVerticalAlign(HtmlTableCell.TOP);
row1.add(c);
c = new HtmlTableCell();
HtmlInput in = new HtmlInput("y_number",YNumber,3);
in.setFormat("num");
in.setMaxSize(3);
c.add(in);
c.setHorizontalAlign(HtmlTableCell.LEFT);
c.setVerticalAlign(HtmlTableCell.TOP);
row1.add(c);
table.add(row1);
form.add(table);
form.addBR();
form.add(new HtmlButton("submit","Find"));

return form;

}//enterRefNumForm ends here
}//class

and here is my class,for some peculiar reason when i try and implemet a draw pie chart i get 60 errors,so i have put the code for the draw pie chart in a seperate class.Another question i have is how do i put the information from my two text boxes into the program,for example say i have 3 text boxes with values 20,30,50 and want to draw a pie chart,how do i do this?
here is the code for my class,i would be very gratefull if you can help me out here and try and get this servlet to work.

package com.jrefinery.chart.demo;
import com.jrefinery.chart.demo;
import com.jrefinery.chart.ChartFactory;
import com.jrefinery.chart.JFreeChart;
import com.jrefinery.chart.JFreeChartFrame;

public class First {
public static void main(String[] args) {
// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Category 1", new Double(43.2));
data.setValue("Category 2", new Double(27.9));
data.setValue("Category 3", new Double(79.5));
// create a chart...
JFreeChart chart = ChartFactory.createPieChart("Sample Pie Chart", data, true);
// create and display a frame...
JFreeChartFrame frame = new JFreeChartFrame("Test", chart);
frame.pack();
frame.setVisible(true);
}
}

Harry

Re: how to make this work

Post by Harry » Wed Apr 24, 2002 3:03 pm

ignore the above please,discard this question!!!!

Locked