Hi Currently I am trying to plot data from CSV, I have the code but it is not able to take HH:mm:ss MM-dd-yy, the code I have is just for float but not timestamp. I need to plot it, it is current value against time like: "2016-05-15 00:00:00" "20" "2016-05-15 00:00:01" "22" and the data is in my local drive, and the code is as following:
file reader:
public XYSeriesCollection createDataset() throws NumberFormatException,
IOException {
dataset = new XYSeriesCollection();
try {
reader = new CSVReader(new FileReader("/usr/csv_dump.csv"),'\t');
// Read the header and chuck it away
readNextLine = reader.readNext();
import data:
// Set up series
final XYSeries seriesX = new XYSeries("X");
while ((readNextLine = reader.readNext()) != null) {
// add values to dataset
double Time = Double.valueOf(readNextLine[0]);
double X = Long.valueOf(readNextLine[1]);
seriesX.add(Time, X);
}
System.out.println(seriesX.getMaxX() + "; " + seriesX.getMaxY());
dataset.addSeries(seriesX);
} catch (FileNotFoundException e) {
System.out.println("File not found!");
}
return dataset;
}
public JFreeChart createChart(XYDataset dataset)
throws NumberFormatException, IOException {
chart = ChartFactory.createXYLineChart("Acceleration vs Time", // chart
// title
"Time", // domain axis label
"Acceleration", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // the plot orientation
true, // legend
true, // tooltips
false); // urls
return chart;
}
as you can see it can only read double but not the time, if I want to import the time (HH:mm:ss MM-dd-yy), how can I do it?