在动态的折线图里面的时间轴是系统自带的时间.
现在我想把他改成从00:00:00开始的时间,应该怎么做?使用setMinimumDate?好像设置完之后动态图就不走了.哪位朋友指明一下,先谢了.

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【tangwei168】截止到2008-07-14 17:23:51的历史汇总数据(不包括此帖):
    发帖的总数量:3                        发帖的总分数:300                      每贴平均分数:100                      
    回帖的总数量:186                      得分贴总数量:54                       回帖的得分率:29%                      
    结贴的总数量:3                        结贴的总分数:300                      
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:100.00%                  
    无满意结贴率:0.00  %               无满意结分率:0.00  %                  
    敬礼!
      

  2.   

    动态图就是一个TimeSeriesChart,里面的数据和坐标轴实时更新就可以了。
    不明白00:00:00开始后改怎么处理。一小时后,一天后还是00:00:00吗?
      

  3.   

    给你贴段代码,看看是不是你要的。
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;import org.jfree.chart.*;
    import org.jfree.chart.axis.*;
    import org.jfree.chart.plot.*;
    import org.jfree.data.time.*;
    import org.jfree.data.xy.*;
    import org.jfree.ui.*;public class DynamicChart extends ApplicationFrame {    private static final long serialVersionUID = -1L;
        private TimeSeries        datas;
        JFreeChart jfreechart;    public DynamicChart(String s) {
            super(s);
            XYDataset xydataset = createDataset();
            jfreechart = createChart(xydataset);        ChartPanel chartpanel = new ChartPanel(jfreechart);
            chartpanel.setPreferredSize(new Dimension(500, 270));
            setContentPane(chartpanel);
            new DataGenerator(1000).start();
        }    private static JFreeChart createChart(XYDataset xydataset) {
            JFreeChart jfreechart =
                ChartFactory.createTimeSeriesChart("Dynamic Chart Example", "Time",
                                                   "Value", xydataset, false, true,
                                                   false);
            XYPlot plot = (XYPlot) jfreechart.getPlot();
            NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
            yAxis.setAutoTickUnitSelection(false);
            yAxis.setPositiveArrowVisible(true);
            // 设置y轴的单位,最大值和最小值
            NumberTickUnit ntu = new NumberTickUnit(50);
            yAxis.setTickUnit(ntu);
            yAxis.setLowerBound(0D);
            yAxis.setUpperBound(500);
            // 设置x轴的时间显示格式,显示范围,时间间隔,最大值和最小值
            DateAxis xAxis = (DateAxis) plot.getDomainAxis();
            DateFormat df = new SimpleDateFormat("HH:mm");// 显示格式
            long t = new Date().getTime()/1000L/60L;//分钟
            Date start = new Date(t*60000L);
            t += 5;
            Date end = new Date(t*60000L);
            xAxis.setRange(start, end);// 显示范围:start - end
            xAxis.setAutoTickUnitSelection(false);
            xAxis.setTickUnit(new DateTickUnit(DateTickUnit.SECOND, 60));// 单位:60秒
            xAxis.setPositiveArrowVisible(true);
            xAxis.setDateFormatOverride(df);
            return jfreechart;
        }    private XYDataset createDataset() {
            this.datas = new TimeSeries("Per Minute Data", Second.class);
            TimeSeriesCollection collection = new TimeSeriesCollection(this.datas);
            return collection;
        }    public JPanel createDemoPanel() {
            JFreeChart jfreechart = createChart(createDataset());
            return new ChartPanel(jfreechart);
        }    private void addDataObservation(double y) {
            Second s = new Second();
            try {
                this.datas.add(s, y);
            } catch ( Exception e) {
                this.datas.update(s, y);
            }
        }    private void setXAxixRange(){
            XYPlot plot = (XYPlot) jfreechart.getPlot();
            DateAxis xAxis = (DateAxis) plot.getDomainAxis();
            long t = new Date().getTime()/1000L/60L - 3;
            Date start = new Date(t*60000L);
            t += 5;
            Date end = new Date(t*60000L);
            xAxis.setRange(start, end);
        }
        
        class DataGenerator extends javax.swing.Timer implements ActionListener {        private static final long serialVersionUID = 1L;
            int count = 0;
            DataGenerator(int interval) {
                super(interval, null);
                addActionListener(this);
            }        public void actionPerformed(ActionEvent event) {
                long d = new Random().nextInt(500) + 1;
                addDataObservation(d);
                if(count > 60) {
                    setXAxixRange();
                    count = 0;
                }
                count++;
            }
        }    public static void main(String args[]) {
            DynamicChart dynamicChart = new DynamicChart("Dynamic Chart Example");
            dynamicChart.pack();
            RefineryUtilities.centerFrameOnScreen(dynamicChart);
            dynamicChart.setVisible(true);
        }
    }
      

  4.   

    LZ 试试看
    DateAxis dateAxis=new DateAxis();

    //设置时间轴相对左右边距离
    dateAxis.setLowerMargin(0.0d);
    dateAxis.setUpperMargin(0.0d);
    //设置时间轴显示格式
    dateAxis.setDateFormatOverride(new SimpleDateFormat("yy/MM/dd HH:mm:ss"));
    // dateAxis.setDateFormatOverride(new SimpleDateFormat("yy/MM/dd HH:mm"));
    dateAxis.setLabel("测试时间");
    //设置时间轴的范围
    // dateAxis.setAutoTickUnitSelection(false);
    //dateAxis.setUpperBound(1258866d);

    // dateAxis.setAutoRange(false);
    // dateAxis.setTickUnit(new DateTickUnit(DateTickUnit.MINUTE,600));
    // dateAxis.setTickUnit(new DateTickUnit(DateTickUnit.MINUTE,1000));
    plot.setDomainAxis(dateAxis);