hello
I have plotted graph from database using jfreechart.it works fine for different x-axis values but how to plot for same x-axis values
values in database(test) are
tim(x-axis) mem(y-axis)
2012-02-13 15:12:43.508 408889999
2012-02-13 15:12:43.508 800000567
2012-02-13 16:12:43.508 96345678
here is my code
import java.text.ParseException;
import org.jfree.ui.*;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.jdbc.JDBCCategoryDataset;
import org.jfree.data.xy.XYDataset;
public class Chart
{
public static void main(String[] args) throws Exception
{
//Calendar cal = Calendar.getInstance();
String query = "SELECT * from chart";
//cal.set(year, month, date, hourOfDay, minute);
JDBCCategoryDataset dataset = new JDBCCategoryDataset("jdbc:mysql://localhost:3306/test", "com.mysql.jdbc.Driver","root", "root");
dataset.executeQuery(query);
JFreeChart chart = ChartFactory.createLineChart("Test", "Id", "Score",dataset, PlotOrientation.VERTICAL, true,true,true);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
ApplicationFrame f = new ApplicationFrame("Chart");
f.setContentPane(chartPanel);
f.pack();
f.setVisible(true);
//JFreeChart chart1 = ChartFactory.createLineChart("Test", "Id", "Score", dataset, PlotOrientation.VERTICAL, true,true,true);
//ChartPanel chartPane2 = new ChartPanel(chart1);
}
}
what changes we have to make in above code inorder to get plot for same x-axis values.
please help me.