Example usage for org.jfree.chart.axis AxisLocation TOP_OR_LEFT

List of usage examples for org.jfree.chart.axis AxisLocation TOP_OR_LEFT

Introduction

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

Prototype

AxisLocation TOP_OR_LEFT

To view the source code for org.jfree.chart.axis AxisLocation TOP_OR_LEFT.

Click Source Link

Document

Axis at the top or left.

Usage

From source file:com.jaspersoft.studio.components.chart.model.enums.JFreeChartAxisLocationEnum.java

public static JFreeChartAxisLocationEnum getValue(AxisLocation ha) {
    if (ha != null) {
        if (ha.equals(AxisLocation.TOP_OR_LEFT))
            return TOP_OR_LEFT;
        if (ha.equals(AxisLocation.TOP_OR_RIGHT))
            return TOP_OR_RIGHT;
        if (ha.equals(AxisLocation.BOTTOM_OR_LEFT))
            return BOTTOM_OR_LEFT;
        if (ha.equals(AxisLocation.BOTTOM_OR_RIGHT))
            return BOTTOM_OR_RIGHT;
    }/*  w  ww.  j  a  va 2s .co m*/
    return BOTTOM_OR_RIGHT;
}

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

private static JFreeChart createChart() {
    XYDataset xydataset = createDataset("March 2007", 100D, new Day(1, 3, 2007), 31);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 4", "Date", "Value",
            xydataset, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setOrientation(PlotOrientation.VERTICAL);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("d-MMM-yyyy"));
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    xyitemrenderer.setSeriesPaint(0, Color.red);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setTickLabelPaint(Color.red);
    DateAxis dateaxis1 = new DateAxis("Date");
    dateaxis1.setDateFormatOverride(new SimpleDateFormat("d-MMM-yyyy"));
    xyplot.setDomainAxis(1, dateaxis1);/*from   w  ww.ja  v  a2s .c om*/
    xyplot.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT);
    NumberAxis numberaxis1 = new NumberAxis("Value");
    numberaxis1.setAutoRangeIncludesZero(false);
    numberaxis1.setTickLabelPaint(Color.blue);
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    XYDataset xydataset1 = createDataset("July 2007", 1000D, new Day(1, 7, 2007), 31);
    xyplot.setDataset(1, xydataset1);
    xyplot.mapDatasetToDomainAxis(1, 1);
    xyplot.mapDatasetToRangeAxis(1, 1);
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.blue);
    xyplot.setRenderer(1, xylineandshaperenderer);
    return jfreechart;
}

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 ava  2  s.com
    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:net.sf.jasperreports.chartthemes.simple.handlers.AxisLocationHandler.java

@Override
public Object convertUponSet(Object value) {
    if (value == null) {
        return null;
    }// ww  w  .  ja  v  a2 s .com
    return AxisLocation.BOTTOM_OR_LEFT.toString().equals(value) ? AxisLocation.BOTTOM_OR_LEFT
            : AxisLocation.BOTTOM_OR_RIGHT.toString().equals(value) ? AxisLocation.BOTTOM_OR_RIGHT
                    : AxisLocation.TOP_OR_LEFT.toString().equals(value) ? AxisLocation.TOP_OR_LEFT
                            : AxisLocation.TOP_OR_RIGHT.toString().equals(value) ? AxisLocation.TOP_OR_RIGHT
                                    : null;
}

From source file:net.sf.fspdfs.chartthemes.simple.handlers.AxisLocationHandler.java

/**
 *
 *//*ww  w .  ja  v  a2s. c o m*/
public Object convertUponSet(Object value) {
    if (value == null) {
        return null;
    }
    return AxisLocation.BOTTOM_OR_LEFT.toString().equals(value) ? AxisLocation.BOTTOM_OR_LEFT
            : AxisLocation.BOTTOM_OR_RIGHT.toString().equals(value) ? AxisLocation.BOTTOM_OR_RIGHT
                    : AxisLocation.TOP_OR_LEFT.toString().equals(value) ? AxisLocation.TOP_OR_LEFT
                            : AxisLocation.TOP_OR_RIGHT.toString().equals(value) ? AxisLocation.TOP_OR_RIGHT
                                    : null;
}

From source file:com.jaspersoft.studio.components.chart.model.enums.JFreeChartAxisLocationEnum.java

public AxisLocation getJFreeChartValue() {
    if (value == 0)
        return AxisLocation.TOP_OR_LEFT;
    if (value == 1)
        return AxisLocation.TOP_OR_RIGHT;
    if (value == 2)
        return AxisLocation.BOTTOM_OR_LEFT;
    if (value == 3)
        return AxisLocation.BOTTOM_OR_RIGHT;
    return null;//from   ww w. j  a  v  a 2  s .co m
}

From source file:de.fub.maps.project.detector.model.inference.ui.charts.AttributeSelectionBarChart.java

/**
 * Creates new form AttributeSelectionBarChart
 *///w  w w .  ja  v a 2  s.c om
public AttributeSelectionBarChart() {
    initComponents();
    barChart = ChartFactory.createBarChart(
            NbBundle.getMessage(AttributeSelectionBarChart.class, "AttributeSelectionBarChart.CLT_Chart_Title"),
            NbBundle.getMessage(AttributeSelectionBarChart.class,
                    "AttributeSelectionBarChart.CLT_Domain_Axis_Name"),
            NbBundle.getMessage(AttributeSelectionBarChart.class,
                    "AttributeSelectionBarChart.CLT_Value_Axis_Name"),
            dataset, PlotOrientation.VERTICAL, true, true, true);
    plot = barChart.getCategoryPlot();
    Font font = new JLabel().getFont().deriveFont(Font.BOLD, 14);

    barChart.getTitle().setFont(font);
    barChart.getTitle().setPaint(new Color(153, 153, 153));

    plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);

    plot.setBackgroundPaint(Color.white);
    plot.getRangeAxis().setAutoRange(true);
    plot.getRangeAxis().setUpperMargin(.1);

    BarRenderer barRenderer = new BarRenderer();
    barRenderer.setBarPainter(new StandardBarPainter());
    barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    barRenderer.setBaseFillPaint(Color.BLUE);
    barRenderer.setBasePaint(Color.BLUE);
    barRenderer.setAutoPopulateSeriesFillPaint(false);
    barRenderer.setAutoPopulateSeriesPaint(false);
    barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat()));
    barRenderer.setBaseItemLabelsVisible(true);

    plot.setRenderer(barRenderer);
    chartPanel = new ChartPanel(barChart, false);
    chartPanel.setVerticalAxisTrace(false);
    add(chartPanel, BorderLayout.CENTER);
}

From source file:de.fub.maps.project.detector.model.inference.ui.charts.PrecisionRecallBarChartPanel.java

/**
 * Creates new form PrecisionRecallBarChartPanel
 *///from  ww w  . j a  va 2  s.c om
public PrecisionRecallBarChartPanel() {
    super();
    initComponents();
    barChart = ChartFactory.createBarChart(
            NbBundle.getMessage(PrecisionRecallBarChartPanel.class, "CLT_Chart_Precision_Recall_Name"),
            NbBundle.getMessage(PrecisionRecallBarChartPanel.class, "CLT_Doman_Axis_Name"),
            NbBundle.getMessage(PrecisionRecallBarChartPanel.class, "CLT_Value_Axis_Name"), dataset,
            PlotOrientation.VERTICAL, true, true, true);

    Font font = new JLabel().getFont().deriveFont(Font.BOLD, 14);

    barChart.getTitle().setFont(font);
    barChart.getTitle().setPaint(new Color(153, 153, 153));

    plot = barChart.getCategoryPlot();
    NumberAxis preciAxis = new NumberAxis(
            NbBundle.getMessage(PrecisionRecallBarChartPanel.class, "CLT_Value_Axis_Name"));
    preciAxis.setAutoRange(true);
    preciAxis.setUpperMargin(.20);
    plot.setRangeAxis(0, preciAxis);
    plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);
    plot.setBackgroundPaint(Color.white);

    BarRenderer barRenderer = new BarRenderer();
    barRenderer.setBarPainter(new StandardBarPainter());
    barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat()));
    barRenderer.setBaseItemLabelsVisible(true);
    barRenderer.setSeriesPaint(0, precColor);
    barRenderer.setSeriesPaint(1, recColor);

    plot.setRenderer(barRenderer);

    chartPanel = new ChartPanel(barChart, false);
    chartPanel.setVerticalAxisTrace(false);
    add(chartPanel, BorderLayout.CENTER);
}

From source file:org.sonar.server.charts.jruby.TrendsChart.java

public void initSerie(Long serieId, String legend, boolean isPercent) {
    TimeSeries series = new TimeSeries(legend);

    int index = seriesById.size();
    seriesById.put(serieId, series);/*from  w  ww  .java2  s.c  om*/

    TimeSeriesCollection timeSeriesColl = new TimeSeriesCollection();
    timeSeriesColl.addSeries(series);
    plot.setDataset(index, timeSeriesColl);

    if (isPercent) {
        if (percentAxisId == -1) {
            NumberAxis rangeAxis = new NumberAxis();
            rangeAxis.setNumberFormatOverride(new DecimalFormat("0'%'"));
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            rangeAxis.setUpperBound(100.0);
            rangeAxis.setLowerBound(0.0);
            plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_LEFT);
            plot.setRangeAxis(index, rangeAxis);
            plot.mapDatasetToRangeAxis(index, index);
            percentAxisId = index;

        } else {
            plot.mapDatasetToRangeAxis(index, percentAxisId);
        }
    } else {
        NumberAxis rangeAxis = new NumberAxis(displayLegend ? legend : null);
        rangeAxis.setAutoRangeIncludesZero(false);
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.setAutoRangeMinimumSize(2.0);
        plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_RIGHT);
        plot.setRangeAxis(index, rangeAxis);
        plot.mapDatasetToRangeAxis(index, index);
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesPaint(0, COLORS[index % COLORS.length]);
    plot.setRenderer(index, renderer);
}

From source file:DualAxisDemo4.java

/**
 * Creates a new demo instance.//  w ww  .j  a  v  a2 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);

}