Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jfreechart TimeSeriesDemo10

 
Pedro Neves
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, does anybody knows if, and how can i use Jfreechart TimeSeriesDemo10 but replacing minutes by seconds?


This is the code (per minute)




import java.awt.Color;
import java.util.Date;

import javax.swing.JPanel;
import javax.swing.border.LineBorder;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.time.Hour;
import org.jfree.data.time.Minute;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

/**
* A demo showing a time series with per minute data.
*
*/
public class TimeSeriesDemo10 extends ApplicationFrame {

private JPanel jp;

public TimeSeriesDemo10(final String title,JPanel j) {

super(title);

jp = new JPanel();
jp.setBounds(j.getBounds());

final TimeSeries series = new TimeSeries("Per Minute Data", Minute.class);
final Hour hour = new Hour();

Date date =new Date();

int min = date.getMinutes();

series.add(new Minute(min, hour), 10.2);
series.add(new Minute(min + 1, hour), 17.3);
series.add(new Minute(min + 2, hour), 14.6);
series.add(new Minute(min + 3, hour), 11.9);
series.add(new Minute(min + 4, hour), 13.5);
series.add(new Minute(min + 5, hour), 10.9);
final TimeSeriesCollection dataset = new TimeSeriesCollection(series);
final JFreeChart chart = ChartFactory.createTimeSeriesChart("Time Series Demo 10", "Time", "Value", dataset,true, true, false );


final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(250, 200));

j.add(chartPanel);
j.setBorder(new LineBorder(Color.GRAY));

}

public JPanel GetPanel(){return jp;}



}


thanks in advance
 
Tim Moores
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that a class "org.jfree.data.time.Second" exists, have you tried a search-and-replace of "Minute" with "Second"?
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved from Swing / AWT / SWT / JFace
 
Pedro Neves
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:Assuming that a class "org.jfree.data.time.Second" exists, have you tried a search-and-replace of "Minute" with "Second"?


I tried but i havent succeed.. well.. I realise i need another graphic.. a windowing graphic, like the preformance tab in windws task manager.. :-/ well i got to search for a while.. thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic