Example usage for org.jfree.chart.axis NumberAxis3D NumberAxis3D

List of usage examples for org.jfree.chart.axis NumberAxis3D NumberAxis3D

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis3D NumberAxis3D.

Prototype

public NumberAxis3D(String label) 

Source Link

Document

Constructs a new axis.

Usage

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

/**
 * Starting point for the demo./*from  w  w w . j  av  a2 s .  c o m*/
 *
 * @param args  ignored.
 */
public static void main(final String[] args) {

    // create a chart
    final double[][] data = new double[][] { { 56.0, -12.0, 34.0, 76.0, 56.0, 100.0, 67.0, 45.0 },
            { 37.0, 45.0, 67.0, 25.0, 34.0, 34.0, 100.0, 53.0 },
            { 43.0, 54.0, 34.0, 34.0, 87.0, 64.0, 73.0, 12.0 } };
    final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Type ", data);

    JFreeChart chart = null;
    final boolean drilldown = true;

    if (drilldown) {
        final CategoryAxis3D categoryAxis = new CategoryAxis3D("Category");
        final ValueAxis valueAxis = new NumberAxis3D("Value");
        final BarRenderer3D renderer = new BarRenderer3D();
        renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
        renderer.setItemURLGenerator(new StandardCategoryURLGenerator("bar_chart_detail.jsp"));
        final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
        plot.setOrientation(PlotOrientation.VERTICAL);
        chart = new JFreeChart("Bar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    } else {
        chart = ChartFactory.createBarChart3D("Bar Chart", // chart title
                "Category", // domain axis label
                "Value", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, true, // include legend
                true, false);
    }
    chart.setBackgroundPaint(java.awt.Color.white);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    // save it to an image
    try {
        final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
        final File file1 = new File("barchart101.png");
        ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);

        // write an HTML page incorporating the image with an image map
        final File file2 = new File("barchart101.html");
        final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2));
        final PrintWriter writer = new PrintWriter(out);
        writer.println("<HTML>");
        writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>");
        writer.println("<BODY>");
        //            ChartUtilities.writeImageMap(writer, "chart", info);
        writer.println("<IMG SRC=\"barchart100.png\" "
                + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">");
        writer.println("</BODY>");
        writer.println("</HTML>");
        writer.close();

    } catch (IOException e) {
        System.out.println(e.toString());
    }

}

From source file:com.pureinfo.srm.reports.impl.MyChartFactory.java

public static JFreeChart createBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }/*  w  w  w.j ava 2 s .  c  o m*/
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    BarRenderer3D renderer = new BarRenderer3D() {
        /**
         * @see org.jfree.chart.renderer.AbstractRenderer#getItemPaint(int, int)
         */
        public Paint getItemPaint(int _nRow, int _nColumn) {
            return getSeriesPaint(_nColumn);
        }
    };
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the 
        // right way around
        plot.setRowRenderingOrder(SortOrder.DESCENDING);
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    plot.setForegroundAlpha(0.75f);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}

From source file:soap.ui.stats.OverLaidBarChartFactory.java

public static JFreeChart createDualBarAndLineDiagram(String title, String categoryAxisLabel,
        String valueAxisLabel, CategoryDataset barDiagramDataset, LinkedList lineDiagramDatasets) {
    CategoryPlot plot = new CategoryPlot();
    int inc = 0;//  w w  w .  j a  v  a 2 s  .c  om
    BarRenderer barRenderer = null;
    if (barDiagramDataset != null) {
        plot.setDataset(barDiagramDataset);
        barRenderer = new BarRenderer3D();
        barRenderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
        plot.setRenderer(barRenderer);
        inc = 1;
        plot.setDomainAxis(new CategoryAxis3D(categoryAxisLabel));
        plot.setRangeAxis(new NumberAxis3D(valueAxisLabel));
    } else {
        plot.setDomainAxis(new CategoryAxis(categoryAxisLabel));
        plot.setRangeAxis(new NumberAxis(valueAxisLabel));
    }
    plot.mapDatasetToRangeAxis(0, 0);

    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    CategoryItemRenderer renderers[] = new LineAndShapeRenderer[lineDiagramDatasets.size()];

    for (int i = 0; i < lineDiagramDatasets.size(); i++) {
        CategoryDataset lineDiagramDataset = (CategoryDataset) lineDiagramDatasets.get(i);
        plot.setDataset(i + inc, lineDiagramDataset);
        plot.mapDatasetToRangeAxis(i + inc, 0);
        if (barDiagramDataset != null && i < barDiagramDataset.getRowCount()) {
            renderers[i] = new LineAndShapeRendererMapToBar(barRenderer, i);
        } else {
            renderers[i] = new LineAndShapeRenderer();
        }
        renderers[i].setToolTipGenerator(new StandardCategoryToolTipGenerator());
        renderers[i].setSeriesStroke(0, new BasicStroke(1.5f));
        renderers[i].setSeriesStroke(1, new BasicStroke(1.5f));
        plot.setRenderer(i + inc, renderers[i]);
    }

    CategoryDataset dataset;
    if (lineDiagramDatasets.size() > 0)
        dataset = (CategoryDataset) lineDiagramDatasets.get(0);
    else
        dataset = barDiagramDataset;
    for (int i = 0; i < dataset.getColumnCount(); i++)
        plot.getDomainAxis().addCategoryLabelToolTip(dataset.getColumnKey(i), (String) dataset.getColumnKey(i));

    plot.setRangeGridlinePaint(Color.black);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    JFreeChart chart = new JFreeChart(plot);
    chart.setTitle(title);
    chart.setLegend(new StandardLegend());

    return chart;
}

From source file:org.jfree.eastwood.GValueAxis3D.java

/**
 * Creates a new axis./*from w w  w.  j  a v a2  s  .c o  m*/
 */
public GValueAxis3D() {
    super();
    this.axisForAutoLabels = new NumberAxis3D(null);
    this.axisForAutoLabels.setRange(0.0, 100.0);
    this.axisForAutoLabels.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    this.labelAxisStart = 0.0;
    this.labelAxisEnd = 100.0;
    this.tickLabels = new java.util.ArrayList();
    this.tickLabelPositions = new java.util.ArrayList();
    setLowerMargin(0.0);
    setUpperMargin(0.0);
    // the data is normalised into the range 0.0 to 1.0, so the real axis
    // has the same range...
    setRange(0.0, 1.0);
    setTickLabelPaint(Color.darkGray);
    setTickLabelFont(new Font("Dialog", Font.PLAIN, 11));
}

From source file:DualAxisDemo4.java

/**
 * Creates a new demo instance.//www . ja  v a 2 s. c o m
 *
 * @param title  the frame title.
 */
public DualAxisDemo4(final String title) {

    super(title);

    final CategoryDataset dataset1 = createDataset1();

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart3D("Dual Axis Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset1, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, false);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(new Color(0xCC, 0xFF, 0xCC));
    //        chart.getLegend().setAnchor(Legend.SOUTH);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    final CategoryItemRenderer renderer1 = plot.getRenderer();
    renderer1.setSeriesPaint(0, Color.red);
    renderer1.setSeriesPaint(1, Color.yellow);
    renderer1.setSeriesPaint(2, Color.green);
    final CategoryDataset dataset2 = createDataset2();
    final ValueAxis axis2 = new NumberAxis3D("Secondary");
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    final CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
    renderer2.setSeriesPaint(0, Color.blue);
    plot.setRenderer(1, renderer2);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
    // OPTIONAL CUSTOMISATION COMPLETED.

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:org.gvsig.symbology.fmap.symbols.BarChart3DSymbol.java

protected Plot getOutlinePlot() {
    outlinePlot = null; // <- delete this
    if (outlinePlot == null) {
        CategoryPlot myOutlinePlot;//from   w w w  .  j  a  va2  s .  c om
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        dataset.addValue(23D, "Series 1", "London");
        // dataset.addValue(14D, "Series 1", "New York");
        // dataset.addValue(14D, "Series 1", "Istanbul");
        // dataset.addValue(14D, "Series 1", "Cairo");
        dataset.addValue(13D, "Series 2", "London");
        // dataset.addValue(19D, "Series 2", "New York");
        // dataset.addValue(19D, "Series 2", "Istanbul");
        // dataset.addValue(19D, "Series 2", "Cairo");
        dataset.addValue(7D, "Series 3", "London");
        // dataset.addValue(9D, "Series 3", "New York");
        // dataset.addValue(9D, "Series 3", "Istanbul");
        // dataset.addValue(9D, "Series 3", "Cairo");

        CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
        ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

        BarRenderer3D renderer = new BarRenderer3D();
        myOutlinePlot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
        double min = Double.POSITIVE_INFINITY;
        double max = Double.NEGATIVE_INFINITY;
        // for (int i = 0; values != null && i < values.length; i++) {
        // min = Math.min(min, values[i]);
        // max = Math.min(max, values[i]);
        // dataset.addValue(values[i], rowKeys[i], columnKeys[i]);
        // }
        myOutlinePlot.setDataset(dataset);
        myOutlinePlot.setOrientation(vertical ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL);
        outlinePlot = myOutlinePlot;

    }
    return outlinePlot;
}

From source file:action.GraphAction.java

public String drawgraph() {

    List<CustomerOrder> orderList = new ArrayList<CustomerOrder>();

    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    TransactionDao transactionDao = new TransactionDao();
    //  orderList = transactionDao.findByDate(fromdate, todate);
    orderList = (List<CustomerOrder>) request.getSession().getAttribute("orderList");
    int a = orderList.size();
    System.out.println("Size--->" + a);
    Number[] values = getValues(orderList);
    System.out.println("final values are " + Arrays.toString(values));

    final Number[][] data = new Number[][] { values, {} };

    final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("", "", data);

    JFreeChart chart = null;/*from  ww  w.  j ava  2 s  .c o  m*/
    BarRenderer renderer3D = null;
    CategoryPlot plot = null;

    final CategoryAxis3D categoryAxis = new CategoryAxis3D("Month");
    final ValueAxis valueAxis = new NumberAxis3D("Number of Transactions");
    renderer3D = new BarRenderer3D();

    plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer3D);
    plot.setOrientation(PlotOrientation.VERTICAL);
    chart = new JFreeChart("Online Transactions", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.setBackgroundPaint(new Color(152, 169, 236));

    try {
        final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());

        final File file1 = new File("D:\\3dbarchart.png");
        OutputStream out = ServletActionContext.getResponse().getOutputStream();
        ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);

        ChartUtilities.writeChartAsPNG(out, chart, 600, 400, info);

        out.close();
        //returnString = "success"; 

    } catch (Exception e) {
        System.out.println(e);
        // returnString = "error";
    }
    return SUCCESS;
}

From source file:com.ewcms.plugin.report.generate.service.chart.ChartGenerationService.java

/**
 * ?3D/*  w ww .j a v a  2  s .c o  m*/
 *
 * @param title 
 * @param titleFont 
 * @param categoryAxisLabel 
 * @param valueAxisLabel 
 * @param data ??
 * @param orientation ?
 * @param legend 
 * @param tooltips ????
 * @param urls ??URL
 * @param urlGenerator
 *
 * @return ?
 */
public static JFreeChart createBarChart3D(String title, java.awt.Font titleFont, String categoryAxisLabel,
        String valueAxisLabel, CategoryDataset data, PlotOrientation orientation, boolean legend,
        boolean tooltips, boolean urls, CategoryURLGenerator urlGenerator) {
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    BarRenderer3D renderer = new BarRenderer3D();

    // renderer.setLabelGenerator(new StandardCategoryLabelGenerator());
    if (tooltips) {
        //            renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        //            renderer.setItemURLGenerator(urlGenerator);
        renderer.setBaseItemURLGenerator(urlGenerator);
    }

    CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    plot.setForegroundAlpha(0.75f);

    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;

}

From source file:com.tonbeller.jpivot.chart.ChartFactory.java

/**
 * Creates a vertical 3D-effect bar chart with default settings.
 *
 * @param title  the chart title./* w ww.j  ava  2s . co m*/
 * @param categoryAxisLabel  the label for the category axis.
 * @param valueAxisLabel  the label for the value axis.
 * @param data  the dataset for the chart.
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return a vertical 3D-effect bar chart.
 */
public static JFreeChart createBarChart3D(String title, java.awt.Font titleFont, String categoryAxisLabel,
        String valueAxisLabel, CategoryDataset data, PlotOrientation orientation, boolean legend,
        boolean tooltips, boolean urls, CategoryURLGenerator urlGenerator) {

    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    BarRenderer3D renderer = new BarRenderer3D();

    //renderer.setLabelGenerator(new StandardCategoryLabelGenerator());
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setItemURLGenerator(urlGenerator);
    }

    CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    plot.setForegroundAlpha(0.75f);

    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;

}

From source file:com.ewcms.plugin.report.generate.service.chart.ChartGenerationService.java

/**
 * ??3D/*from w  ww .j av  a 2 s  . c o m*/
 *
 * @param title 
 * @param titleFont 
 * @param categoryAxisLabel 
 * @param valueAxisLabel 
 * @param data ??
 * @param orientation ?
 * @param legend 
 * @param tooltips ????
 * @param urls ??URL
 * @param urlGenerator
 *
 * @return ??3D
 */
public static JFreeChart createStackedBarChart3D(String title, java.awt.Font titleFont,
        String categoryAxisLabel, String valueAxisLabel, CategoryDataset data, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls, CategoryURLGenerator urlGenerator) {
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    CategoryItemRenderer renderer = new StackedBarRenderer3D();
    CategoryToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardCategoryToolTipGenerator();
    }
    if (urls) {
        //            renderer.setItemURLGenerator(urlGenerator);
        renderer.setBaseItemURLGenerator(urlGenerator);
    }
    //        renderer.setToolTipGenerator(toolTipGenerator);
    renderer.setBaseToolTipGenerator(toolTipGenerator);

    CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;

}