0

私の問題は、JFreeChart の X 軸に 00:00:00.000 のような形式で時間を割り当てる方法がわからないことです。

列が次のようになる CSV ファイルからデータを取得するアプリケーションを作成しています。

時間 加速度X 加速度Y 加速度Z

私は例を探しましたが、私を助けるものは何も見つかりませんでした。

私のコード:

public ChartService() {

        final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
        this.datasets = new TimeSeriesCollection[SUBPLOT_COUNT];

        for (int i = 0; i < SUBPLOT_COUNT; i++) {
            this.lastValue[i] = 100.0;
            final TimeSeries series = new TimeSeries(Y_AXIS_TITLES[i], Millisecond.class);
           // this.series.add(new SimpleDateFormat("hh:mm:ss.mmm"), 0.2222);

            this.datasets[i] = new TimeSeriesCollection(series);
            final NumberAxis rangeAxis = new NumberAxis(Y_AXIS_TITLES[i]);
            rangeAxis.setAutoRangeIncludesZero(false);
            final XYPlot subplot = new XYPlot(
                    this.datasets[i], null, rangeAxis, new StandardXYItemRenderer()
            );
            subplot.setBackgroundPaint(Color.lightGray);
            subplot.setDomainGridlinePaint(Color.white);
            subplot.setRangeGridlinePaint(Color.white);
            plot.add(subplot);
        }

        final JFreeChart chart = new JFreeChart("Dynamic Data Demo 3", plot);

        chart.setBorderPaint(Color.black);
        chart.setBorderVisible(true);
        chart.setBackgroundPaint(Color.white);

        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);

        final ValueAxis axis = plot.getDomainAxis();
        axis.setAutoRange(true);
        axis.setFixedAutoRange(60000.0);  // 60 seconds

        final JPanel content = new JPanel(new BorderLayout());

        final ChartPanel chartPanel = new ChartPanel(chart);
        content.add(chartPanel);

        chartPanel.setPreferredSize(new java.awt.Dimension(790, 620));
        chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        this.add(content);

    }

助けてください !!!

4

1 に答える 1

1
    String s = "10:00:00.000";
    SimpleDateFormat f = new SimpleDateFormat("HH:MM:SS.SSS");

    Date parsedDate = f.parse(s);

上記のように指定された時刻を日付に変換し、Date オブジェクトを使用して http://www.jfree.org/jfreechart/api/gjdoc/org/jfree/data/time/Millisecond.html#Millisecondを作成できます。日にち

于 2012-04-18T18:58:04.413 に答える