Example usage for org.jfree.chart ChartFrame pack

List of usage examples for org.jfree.chart ChartFrame pack

Introduction

In this page you can find the example usage for org.jfree.chart ChartFrame pack.

Prototype

@SuppressWarnings("deprecation")
public void pack() 

Source Link

Document

Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.

Usage

From source file:no.met.jtimeseries.MeteogramWrapper.java

public static void main(String[] args) {
    JFreeChart jchart;//  ww  w.  ja  v a 2  s.c o  m
    try {
        ChartPlottingInfo cpi = new ChartPlottingInfo.Builder(10.48, 59.88).altitude(0).width(800).height(300)
                .showAirTemperature(true).showDewpointTemperature(true).showPressure(true).timezone("UTC")
                .showCloudSymbol(true).showWeatherSymbol(true).showWindSymbol(true).showPrecipitation(true)
                .showWindSpeed(true).showWindDirection(true).windSpeedUnit("knop").build();

        MeteogramWrapper wrapper = new MeteogramWrapper("en");

        jchart = wrapper.createMeteogram(cpi, SHORT_TERM_HOURS);

        ChartFrame frame = new ChartFrame(jchart, new java.awt.Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
        frame.pack();
        frame.setVisible(true);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    System.out.println("Done!");
}

From source file:helpers.Plots.java

public static void plotSimpleLineXY(ArrayList<double[][]> data, ArrayList<String> seriesName, String title,
        String xname, String yname) {
    DefaultXYDataset ds = new DefaultXYDataset();

    for (int i = 0; i < data.size(); i++) {
        System.out.println(data.get(i)[0][0]);
        ds.addSeries(seriesName.get(i), data.get(i));
    }/*  w  ww  . j a  v  a2 s.c  om*/

    JFreeChart chart = ChartFactory.createXYLineChart(title, xname, yname, ds, PlotOrientation.VERTICAL, true,
            true, false);
    ChartFrame frame = new ChartFrame(title, chart);
    frame.pack();
    frame.setVisible(true);
}

From source file:frequencyassignment.charts.Charts.java

public static void displayPie(String name, HashMap<String, Double> categoryValue) {
    DefaultPieDataset data = new DefaultKeyedValuesDataset();
    for (Map.Entry<String, Double> entry : categoryValue.entrySet()) {
        data.setValue(entry.getKey(), entry.getValue());
    }/*  ww  w  .ja v  a  2s . com*/
    JFreeChart chart = ChartFactory.createPieChart("Pie Chart", data, true, true, true);
    ChartFrame frame = new ChartFrame(name, chart);
    frame.pack();
    frame.setVisible(true);
}

From source file:frequencyassignment.charts.Charts.java

public static void displayBarChart(String name, HashMap<Integer, Integer> categoryValue) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (Map.Entry<Integer, Integer> entry : categoryValue.entrySet()) {
        dataset.addValue(entry.getValue(), name, entry.getKey());
    }//from  www. ja v a 2s  .co  m
    JFreeChart chart = ChartFactory.createBarChart("Bar Chart", "Category", "Value", dataset);
    ChartFrame frame = new ChartFrame(name, chart);
    frame.pack();
    frame.setVisible(true);
}

From source file:no.met.jtimeseries.CreateChart.java

private static void show(JFreeChart chart) {
    ChartFrame frame = new ChartFrame(chart, new java.awt.Dimension(800, 300));
    frame.pack();
    frame.setVisible(true);/*from  w w w .j av  a2 s.com*/
}

From source file:frequencyassignment.charts.Charts.java

public static void displayScatterPlot(String name, HashMap<Double, Double> values) {
    XYSeries xyData = new XYSeries(name);
    for (Map.Entry<Double, Double> entry : values.entrySet()) {
        xyData.add(entry.getKey(), entry.getValue());
    }/*from   w w  w . jav a  2s.  co  m*/
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection(xyData);
    JFreeChart chart = ChartFactory.createScatterPlot(name, "X", "Y", (XYDataset) xySeriesCollection);
    ChartFrame frame = new ChartFrame(name, chart);
    frame.pack();
    frame.setVisible(true);
}

From source file:local.Statistics.LessSellCars.java

/**
 * @param args the command line arguments
 *//*from w  w w .j a va2 s .c  o  m*/
public static void carrosMenosVendidos() {
    Graficas_DAO gr = new Graficas_DAO();
    ResultSet rs = gr.getgraficaautomas();
    try {
        String nameAuto;
        int quantitySales;
        DefaultPieDataset data = new DefaultPieDataset();
        while (rs.next()) {
            nameAuto = rs.getString(3);
            quantitySales = rs.getInt(1);
            data.setValue(nameAuto, quantitySales);
        }
        JFreeChart chart = ChartFactory.createPieChart("GRAFICAS AUTOS MENOS VENDIDOS", data, true, true,
                false);
        ChartFrame frame = new ChartFrame("Autos menos vendidos", chart);
        frame.pack();
        frame.setVisible(true);
        rs.close();
        gr.close();
    } catch (SQLException ex) {
        Logger.getLogger(LessSellCars.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:local.Statistics.LessSellRepuesto.java

/**
 * @param args the command line arguments
 *///w  ww  . ja va2s.  co  m
public static void repuestosMenosVendidos() {
    Graficas_DAO gr = new Graficas_DAO();
    //obtencion de datos
    ResultSet rs = gr.getgraficarepuestomen();
    try {
        String nameAuto;
        int quantitySales;
        DefaultPieDataset data = new DefaultPieDataset();
        while (rs.next()) {
            nameAuto = rs.getString(3);
            quantitySales = rs.getInt(1);
            data.setValue(nameAuto, quantitySales);
        }
        JFreeChart chart = ChartFactory.createPieChart("GRAFICAS REPUESTO MENOS VENDIDOS", data, true, true,
                false);
        ChartFrame frame = new ChartFrame("Repuestos menos vendidos", chart);
        frame.pack();
        frame.setVisible(true);
        rs.close();
        gr.close();
    } catch (SQLException ex) {
        Logger.getLogger(LessSellRepuesto.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:local.Statistics.MostSellCars.java

/**
 * @param args the command line arguments
 *//* w  ww.j  ava 2  s .  c o m*/
public static void carrosMasVendidos() {
    Graficas_DAO gr = new Graficas_DAO();
    //obtencion de datos
    ResultSet rs = gr.getgraficaautomas();

    try {
        String nameAuto;
        int quantitySales;
        Object[] fila = new Object[3];
        DefaultPieDataset data = new DefaultPieDataset();
        while (rs.next()) {

            nameAuto = rs.getString(3);
            quantitySales = rs.getInt(1);
            data.setValue(nameAuto, quantitySales);
        }
        JFreeChart chart = ChartFactory.createPieChart("GRAFICAS AUTOS MAS VENDIDOS", data, true, true, false);
        ChartFrame frame = new ChartFrame("Autos mas vendidos", chart);
        frame.pack();
        frame.setVisible(true);

        rs.close();
        gr.close();
    } catch (SQLException ex) {
        Logger.getLogger(MostSellCars.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:graph.jfreecharts.GraphFunction.java

/**
 * Plots an xyerror graph using jfreecharts
 * @param title the title of the graph//from   ww w .  j a  va  2 s.c  o m
 * @param xlabel the x axis title
 * @param ylabel the y axis title
 * @param legend the legend
 * @param data the data values
 */
protected static void plotData(String title, String xlabel, String ylabel, String[] legend, double[][][] data) {

    DefaultIntervalXYDataset xydata = new DefaultIntervalXYDataset();

    for (int i = 0; i < legend.length; i++) {
        xydata.addSeries(legend[i], data[i]);
    }
    // create a chart...
    JFreeChart chart = GraphFunction.createXYIntervalChart(title, xlabel, ylabel, xydata,
            PlotOrientation.VERTICAL, true, true, false);
    // create and display a frame...
    ChartFrame frame = new ChartFrame("First", chart);
    frame.pack();
    frame.setVisible(true);
    frame.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
}