Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 29th, 2012, 05:41 AM
priti priti is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 1 priti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 21 sec
Reputation Power: 0
How to plot line graph using jfreechart by reading from text file

hello,
how to plot graph using jfreechart by extracting date format i.e yyyy-mm-dd hh:mm:ss:SS (in x-axis) and kilobyte(in y-axis) from text file.

the following code contains code for plotting graph for double values.but how to do for date formats versus kilobyte which is mentioned above.am in trouble in this please help us .
Thanks in advance

import java.io.*;
import java.util.*;//Scanner is included
import org.jfree.chart.*;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.xy.*;
import org.jfree.data.*;
public class Plot_1
{
static Scanner scanner;
static XYSeries series;
//static File file;
public static void main(String[] args)
{
plotResult();



}//end of main





//**********



//Method that reads in an external file with numbers (doubles)

//and plots the content in a line chart using JFreeChart





public static void plotResult() {



//Read in the file "calculation.txt" using Scanner and call hasNextDouble on it



try {

int index = 0;



File file = new File("data.txt");

series = new XYSeries("Pk");

scanner = new Scanner(file);

// Scanner scanner = new Scanner(file);

while (scanner.hasNextDouble()) {

series.add(index++,scanner.nextDouble());

}

scanner.close();

}

catch (FileNotFoundException e) {
e.printStackTrace();

}





//Round off the doubles to two decimals - not done yet







//Plot the line chart







/*

XYSeries series = new XYSeries("Pk");

series.add(1, 0.8201791789916324 );

series.add(2, 0.9727097916233601 );

series.add(3, 0.9949972829175494);

*/



XYDataset xyDataset = new XYSeriesCollection(series);





JFreeChart chart = ChartFactory.createXYLineChart

("Temp = 85", "k", "Pk",xyDataset, PlotOrientation.VERTICAL, true, true, false);

ChartFrame frame1=new ChartFrame("XYLine Chart",chart);

frame1.setVisible(true);

frame1.setSize(600,400);







}//End of method





//***************





}//end of class

in data.txt has following values
0.0 0.8201791789916324 0.9727097916233601 0.9949972829175494 0.9930928370666989 0.9757838836701933 0.9610936247552858 0.9085823680551047 0.6555671891250983

this works fine for the above values but how to plot for below values
2012-02-13 15:14:43:038 234,567,123

Reply With Quote
  #2  
Old March 31st, 2012, 08:03 PM
John1477 John1477 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 4 John1477 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 26 sec
Reputation Power: 0
I have been working with some basic SMS, and I can tell that it all depends on what network you are developing for...URLURLURL

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > How to plot line graph using jfreechart by reading from text file


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap