Results 1 to 2 of 2
- 03-23-2009, 09:18 AM #1
How to add a second series in jfreechart
Hi people,
Am using jfreechart to plot values that i that i read from a jtable.With the first series, my program is working ok but when i try to add a second series i get an error.
Java Code:Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
Anyone with an idea why am getting this kind of an error?
Below is a copy of the method that am using
your help will be highly appreciatedJava Code:public void plotGraph() { final XYSeries series1 = new XYSeries("Poisoning"); final XYSeries series2 = new XYSeries("Concentration"); int i,num,num2; double axis; double values; //Poisoning Profile num = Xenon.getRowCount(); for (i = 0; i < num; i++){ String time; time = (String) Xenon.getValueAt(i, 0); if (time == null) { break; } axis = Double.parseDouble(time); String tmp = (String) Xenon.getValueAt(i, 1); values =Double.parseDouble(tmp); series1.add(axis,values); } //Concentration profile num2 = Temp.getRowCount(); for (int k = 0; k<num2; k++) { String time2 = (String)Temp.getValueAt(k, 0); if (time2 == null){ break; } double axis2 = Double.parseDouble(time2); String concentration = (String)Temp.getValueAt(k,3); double xen =Double.parseDouble(concentration); series2.add(axis2, xen); // series2.add(15, 0.5); // series2.add(25, 0.6); // series2.add(40, 0.8); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); //final XYSeriesCollection dataset1 = new XYSeriesCollection(series2); //JFreeChart chart = null; chart = ChartFactory.createXYLineChart("Xenon Concentration and Poisoning", "Time(Hrs)", "Xenon",(XYSeriesCollection) dataset, PlotOrientation.VERTICAL, true, true, false); ChartPanel frame = new ChartPanel(chart); GraphPanel.add(frame,BorderLayout.CENTER); GraphPanel.validate(); }
thanks
- 03-23-2009, 11:16 AM #2
Senior Member
- Join Date
- Dec 2008
- Location
- Hong Kong
- Posts
- 473
- Rep Power
- 5
not related to jFreeChart
use Double.toString() instead of (String)Java Code:String tmp = (String) Xenon.getValueAt(i, 1);
Similar Threads
-
Getting ExceptionInInitializer exception when i am trying to code a time series chart
By neeraj.singh in forum AWT / SwingReplies: 2Last Post: 02-17-2009, 03:20 PM -
JFreeChart 1.0.8
By JavaBean in forum Java SoftwareReplies: 0Last Post: 11-27-2007, 08:27 PM -
JFreeChart 1.0.7
By JavaBean in forum Java SoftwareReplies: 0Last Post: 11-17-2007, 02:13 PM -
JFreeChart 1.0.5
By levent in forum Java SoftwareReplies: 0Last Post: 05-10-2007, 05:36 PM -
No Fluff Just Stuff Software Symposium Series 2007,
By orchid in forum Reviews / AdvertisingReplies: 0Last Post: 04-08-2007, 08:13 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks