Example usage for org.jfree.chart.plot PlotOrientation VERTICAL

List of usage examples for org.jfree.chart.plot PlotOrientation VERTICAL

Introduction

In this page you can find the example usage for org.jfree.chart.plot PlotOrientation VERTICAL.

Prototype

PlotOrientation VERTICAL

To view the source code for org.jfree.chart.plot PlotOrientation VERTICAL.

Click Source Link

Document

For a plot where the range axis is vertical.

Usage

From source file:Diagramas.BarChart_AWT.java

public BarChart_AWT(String applicationTitle, String chartTitle) throws IOException {
    super(applicationTitle);
    JFreeChart barChart = ChartFactory.createBarChart(chartTitle, "Category", "Score", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    int width = 640; /* Width of the image */
    int height = 480; /* Height of the image */
    File BarChart = new File("BarChart.png");
    ChartUtilities.saveChartAsPNG(BarChart, barChart, width, height);

    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);/*from   w w w .  j ava2 s.  c  o m*/
}

From source file:exemploJFreeChart.TelaGrafico.java

public TelaGrafico() {
    janela = new ApplicationFrame("Exemplo JFreeChart");
    janela.setDefaultCloseOperation(ApplicationFrame.EXIT_ON_CLOSE);

    JFreeChart graficoLinha = ChartFactory.createLineChart("Titulo do Grafico", "Nome do eixo X",
            "Nome do eixo Y", criarDataset(), // mtodo que cria os dados do grfico
            PlotOrientation.VERTICAL, true, true, false); // legenda, tooltips, urls

    ChartPanel painelGrafico = new ChartPanel(graficoLinha);
    painelGrafico.setPreferredSize(new Dimension(600, 400));

    janela.setContentPane(painelGrafico);
    janela.pack();//from   w w w.  j  a  v  a2s .  c  o  m
    RefineryUtilities.centerFrameOnScreen(janela);
}

From source file:org.jfree.chart.demo.MouseListenerDemo4.java

public MouseListenerDemo4(String s) {
    super(s);/* www . java 2s.  c om*/
    String s1 = "Mouse Listener Demo 4";
    XYDataset xydataset = createDataset();
    chart = ChartFactory.createXYLineChart(s1, "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true,
            false);
    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    chartPanel.addChartMouseListener(this);
    setContentPane(chartPanel);
}

From source file:graph.jfreecharts.GraphFunction.java

/**
 * Plots an xyerror graph using jfreecharts
 * @param title the title of the graph/* ww w .  ja v  a2 s.co 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);
}

From source file:org.jfree.chart.demo.StackedBarChartDemo5.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 5", "Category", "Value",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    GroupedStackedBarRenderer groupedstackedbarrenderer = new GroupedStackedBarRenderer();
    KeyToGroupMap keytogroupmap = new KeyToGroupMap("G1");
    keytogroupmap.mapKeyToGroup("S1", "G1");
    keytogroupmap.mapKeyToGroup("S2", "G1");
    keytogroupmap.mapKeyToGroup("S3", "G2");
    keytogroupmap.mapKeyToGroup("S4", "G3");
    groupedstackedbarrenderer.setSeriesToGroupMap(keytogroupmap);
    groupedstackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    groupedstackedbarrenderer.setBaseItemLabelsVisible(true);
    groupedstackedbarrenderer.setPositiveItemLabelPositionFallback(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));
    groupedstackedbarrenderer.setItemMargin(0.10000000000000001D);
    SubCategoryAxis subcategoryaxis = new SubCategoryAxis("Category / Group");
    subcategoryaxis.setCategoryMargin(0.050000000000000003D);
    subcategoryaxis.addSubCategory("G1");
    subcategoryaxis.addSubCategory("G2");
    subcategoryaxis.addSubCategory("G3");
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setDomainAxis(subcategoryaxis);
    categoryplot.setRenderer(groupedstackedbarrenderer);
    return jfreechart;
}

From source file:signalanalysis.Graphs.java

public Graphs(final String title, ArrayList<Float> lags, String x, String y, String name) {

    super(title);
    final XYSeries series = new XYSeries(name);
    for (int i = 0; i < lags.size(); i++) {
        series.add(i, lags.get(i));//from   ww  w .j a  v  a 2 s.  c  o m
    }

    final XYSeriesCollection data = new XYSeriesCollection(series);
    final JFreeChart chart = ChartFactory.createXYLineChart(title, x, y, data, PlotOrientation.VERTICAL, true,
            true, false);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
}

From source file:simcommunity.XYChart.java

public XYChart(String applicationTitle, String chartTitle, ArrayList<Float> dSet) {
    super(applicationTitle);

    // based on the dataset we create the chart
    JFreeChart pieChart = ChartFactory.createXYLineChart(chartTitle, "ERA", "OMOGENEITA'", createDataset(dSet),
            PlotOrientation.VERTICAL, true, true, false);

    // Adding chart into a chart panel
    ChartPanel chartPanel = new ChartPanel(pieChart);

    // settind default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    // add to contentPane
    setContentPane(chartPanel);//ww  w  .j a v a  2s.  c om

    this.pack();
    this.setVisible(true);
}

From source file:Similaridade.GraficosSimilaridade.java

public static JFreeChart criaGrafico2LinhasComDeslocada(CapturaAtual onda1, CapturaAtual onda2,
        int deslocamento, double correlacao, Paint cor1, Paint cor2) {
    String eixoy = new String("Current ");
    // verifica se  fase ou fuga
    if (onda1.getCodEvento().getCodEvento() == 1) { // evento 1  de fuga
        eixoy = eixoy.concat("(mA)");
    } else {/*w  w  w . j a  v  a  2s. c  o m*/
        eixoy = eixoy.concat("(A)");
    }
    XYDataset dataset = newDataset2OndasComDeslocada(onda1, onda2, deslocamento, correlacao);

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            "Time (ms)", // x axis label
            eixoy, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            false, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    // Definindo valores no eixo y
    double min = (double) DatasetUtilities.findMinimumRangeValue(dataset);
    double max = (double) DatasetUtilities.findMaximumRangeValue(dataset);

    plot.getRangeAxis().setRange(min - min * 0.005, //min
            max + min * 0.005);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setBaseStroke(new BasicStroke(1.0f));
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesShapesVisible(i, false);
    }
    // Ajustar para todas as cores padro, pelo menos 10
    renderer.setSeriesPaint(0, cor1);
    renderer.setSeriesPaint(1, cor2);

    /* Cdigo para ter linhas tracejadas 
    renderer.setSeriesStroke(1, 
        new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND,
                        20.0f, new float[] {5.0f}, 0.0f) );
               
    renderer.setDrawSeriesLineAsPath(true); 
    /* Final do Codigo para tracejadas */

    plot.setRenderer(renderer);

    return chart;
}

From source file:src.Barchart.java

public Barchart(String windowTitle, String chartTitle, String nombreChart, String nombreMetrica,
        ArrayList<String> barras, ArrayList<Double> valorBarras, String tiposValor) {
    super(windowTitle);
    JFreeChart barChart = ChartFactory.createBarChart(chartTitle, nombreChart, nombreMetrica,
            createDataset(barras, valorBarras, tiposValor), PlotOrientation.VERTICAL, true, true, false);
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);/*from   ww  w.  j a v a2  s.  c  o m*/
}

From source file:iad_2_gg.gui.ChartDialog.java

public ChartDialog(java.awt.Frame parent, boolean modal, String chartTitle, String xLabel, String yLabel,
        List<Double> values, String name, int interval) {
    super(parent, modal);

    JFreeChart lineChart = ChartFactory.createXYLineChart(chartTitle, xLabel, yLabel,
            createDataset(values, name, interval), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new Dimension(1200, 600));
    setContentPane(chartPanel);/* w w w . ja v a 2  s  .  co  m*/
    initComponents();
}