⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xybarchartdemo2.java

📁 很好的制作统计图表的代码
💻 JAVA
字号:
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 7/18/2005 5:14:02 PM
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 

package org.jfree.chart.demo;

import java.awt.Dimension;
import javax.swing.JPanel;
import org.jfree.chart.*;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.ClusteredXYBarRenderer;
import org.jfree.data.time.*;
import org.jfree.data.xy.IntervalXYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

public class XYBarChartDemo2 extends ApplicationFrame
{

    public XYBarChartDemo2(String s)
    {
        super(s);
        IntervalXYDataset intervalxydataset = createDataset();
        JFreeChart jfreechart = createChart(intervalxydataset);
        ChartPanel chartpanel = new ChartPanel(jfreechart);
        chartpanel.setPreferredSize(new Dimension(500, 300));
        setContentPane(chartpanel);
    }

    private static IntervalXYDataset createDataset()
    {
        TimeSeries timeseries = new TimeSeries("Series 1", org.jfree.data.time.Day.class);
        timeseries.add(new Day(1, 1, 2003), 54.299999999999997D);
        timeseries.add(new Day(2, 1, 2003), 20.300000000000001D);
        timeseries.add(new Day(3, 1, 2003), 43.399999999999999D);
        timeseries.add(new Day(4, 1, 2003), -12D);
        TimeSeries timeseries1 = new TimeSeries("Series 2", org.jfree.data.time.Day.class);
        timeseries1.add(new Day(1, 1, 2003), 8D);
        timeseries1.add(new Day(2, 1, 2003), 16D);
        timeseries1.add(new Day(3, 1, 2003), 21D);
        timeseries1.add(new Day(4, 1, 2003), 5D);
        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
        timeseriescollection.setDomainIsPointsInTime(false);
        timeseriescollection.addSeries(timeseries);
        timeseriescollection.addSeries(timeseries1);
        return timeseriescollection;
    }

    private static JFreeChart createChart(IntervalXYDataset intervalxydataset)
    {
        JFreeChart jfreechart = ChartFactory.createXYBarChart("XY Bar Chart Demo 2", "Date", true, "Y", intervalxydataset, PlotOrientation.HORIZONTAL, true, true, false);
        XYPlot xyplot = jfreechart.getXYPlot();
        xyplot.setRenderer(new ClusteredXYBarRenderer());
        return jfreechart;
    }

    public static JPanel createDemoPanel()
    {
        return new ChartPanel(createChart(createDataset()));
    }

    public static void main(String args[])
    {
        XYBarChartDemo2 xybarchartdemo2 = new XYBarChartDemo2("XY Bar Chart Demo 2");
        xybarchartdemo2.pack();
        RefineryUtilities.centerFrameOnScreen(xybarchartdemo2);
        xybarchartdemo2.setVisible(true);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -