Example usage for org.jfree.chart.axis CategoryAxis setCategoryLabelPositions

List of usage examples for org.jfree.chart.axis CategoryAxis setCategoryLabelPositions

Introduction

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

Prototype

public void setCategoryLabelPositions(CategoryLabelPositions positions) 

Source Link

Document

Sets the category label position specification for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:it.eng.spagobi.engines.chart.bo.charttypes.others.CumulativeCurveChart.java

public JFreeChart createChart(DatasetMap datasetMap) {
    CategoryDataset datasetValue = (CategoryDataset) datasetMap.getDatasets().get("1");
    CategoryDataset datasetCumulative = (CategoryDataset) datasetMap.getDatasets().get("2");

    JFreeChart chart = ChartFactory.createBarChart(name, // chart title
            xLabel, // domain axis label
            yLabel, // range axis label
            datasetValue, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, false);/*from  w  ww.  java  2s  .  co m*/

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.02);
    domainAxis.setUpperMargin(0.02);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();

    NumberAxis axis2 = new NumberAxis("Percent");
    axis2.setNumberFormatOverride(NumberFormat.getPercentInstance());
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, datasetCumulative);
    plot.setRenderer(1, renderer2);
    plot.mapDatasetToRangeAxis(1, 1);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    return chart;
}

From source file:vista.DestinosMasConsultados.java

public void iniciarGraficos(CategoryDataset dataset) {
    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Paises mas consultados", // chart title
            "Paises", // domain axis label
            "Cantidad de consultas", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//from ww  w .j a v a  2 s .  c o m

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

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    ChartPanel chartFinal = new ChartPanel(chart);
    chartFinal.setSize(new Dimension(600, 400));

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(panelDestinosMasConsultados);
    panelDestinosMasConsultados.setLayout(jPanel1Layout);
    jPanel1Layout
            .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, 0).addComponent(chartFinal)
                            .addContainerGap(0, Short.MAX_VALUE)));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, 0).addComponent(chartFinal)
                    .addContainerGap(0, Short.MAX_VALUE)));

}

From source file:info.novatec.testit.livingdoc.confluence.macros.historic.AggregationExecutionChartBuilder.java

@SuppressWarnings("deprecation")
private void customizeChart(JFreeChart chart) throws IOException {
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(settings.isBorder());

    TextTitle chartTitle = chart.getTitle();
    customizeTitle(chartTitle, DEFAULT_TITLE_FONT);

    addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT);
    addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(ldUtil.getText("livingdoc.historic.nodata"));

    StackedBarRenderer renderer = new StackedBarRenderer(true);
    plot.setRenderer(renderer);//www  .  j a v a 2 s .c o  m

    int index = 0;
    renderer.setSeriesPaint(index++, GREEN_COLOR);
    if (settings.isShowIgnored()) {
        renderer.setSeriesPaint(index++, Color.yellow);
    }
    renderer.setSeriesPaint(index, Color.red);

    renderer.setToolTipGenerator(new DefaultTooltipGenerator());
    renderer.setItemURLGenerator(new CategoryURLGenerator() {

        @Override
        public String generateURL(CategoryDataset data, int series, int category) {
            Comparable<?> valueKey = data.getColumnKey(category);
            ChartLongValue value = (ChartLongValue) valueKey;
            return "javascript:" + settings.getExecutionUID() + "_showHistoricChart('" + value.getId() + "');";
        }
    });

    CategoryAxis domainAxis = plot.getDomainAxis();
    customizeAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setCategoryMargin(0.01);

    ValueAxis rangeAxis = plot.getRangeAxis();
    customizeAxis(rangeAxis);
    rangeAxis.setLowerBound(0);
    rangeAxis.setUpperBound(1.0);

    if (rangeAxis instanceof NumberAxis) {
        NumberAxis numberAxis = (NumberAxis) rangeAxis;
        numberAxis.setTickUnit(new NumberTickUnit(.10));
        numberAxis.setNumberFormatOverride(PERCENT_FORMATTER);
    }

    plot.setForegroundAlpha(0.8f);
}

From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo7.java

/**
 * Creates a sample chart./*from ww w  .j  a  v  a 2  s. c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips?
            false // URLs?
    );

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

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    IntervalMarker target = new IntervalMarker(4.5, 7.5);
    target.setLabel("Target Range");
    target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    target.setLabelAnchor(RectangleAnchor.LEFT);
    target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    target.setPaint(new Color(222, 222, 255, 128));
    plot.addRangeMarker(target, Layer.BACKGROUND);

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setItemMargin(0.10);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    renderer.setBaseItemLabelGenerator(new CustomCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER_RIGHT,
            TextAnchor.CENTER_RIGHT, -Math.PI / 2.0);
    renderer.setBasePositiveItemLabelPosition(p);

    ItemLabelPosition p2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER_LEFT,
            TextAnchor.CENTER_LEFT, -Math.PI / 2.0);
    renderer.setPositiveItemLabelPositionFallback(p2);
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    // OPTIONAL CUSTOMISATION COMPLETED.
    setCategorySummary(dataset);
    return chart;

}

From source file:com.thalesgroup.hudson.plugins.cccc.CcccChartBuilder.java

protected JFreeChart createGraph() {

    JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, "Number of modules",
            buildDataset(action), PlotOrientation.VERTICAL, true, false, true);

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);//from   www.  j  a  v a2 s  .  c o m
    plot.setForegroundAlpha(0.8f);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    CategoryItemRenderer firstRender = new DefaultCategoryItemRenderer();
    CcccAreaRenderer renderer = new CcccAreaRenderer(action.getUrlName());
    plot.setRenderer(firstRender);

    //Second
    NumberAxis axis2 = new NumberAxis("Lines of Code");
    axis2.setLabelPaint(Color.BLUE);
    axis2.setAxisLinePaint(Color.BLUE);
    axis2.setTickLabelPaint(Color.BLUE);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    categoryPlot.setRangeAxis(1, axis2);
    //CategoryAxis categoryAxis = categoryPlot.getDomainAxis();
    categoryPlot.setDataset(1, buildDataset2(action));
    categoryPlot.mapDatasetToRangeAxis(1, 1);
    CategoryItemRenderer rendu = new DefaultCategoryItemRenderer();
    rendu.setBasePaint(Color.BLUE);
    categoryPlot.setRenderer(1, rendu);

    //Third
    NumberAxis axis3 = new NumberAxis("McCabe's Cyclomatic Number");
    axis3.setLabelPaint(Color.GREEN);
    axis3.setAxisLinePaint(Color.GREEN);
    axis3.setTickLabelPaint(Color.GREEN);
    CategoryPlot categoryPlot3 = chart.getCategoryPlot();
    categoryPlot3.setRangeAxis(2, axis3);
    categoryPlot3.setDataset(2, buildDataset3(action));
    categoryPlot3.mapDatasetToRangeAxis(2, 2);
    categoryPlot3.mapDatasetToDomainAxis(2, 0);
    CategoryItemRenderer rendu3 = new DefaultCategoryItemRenderer();
    rendu3.setBasePaint(Color.GREEN);
    categoryPlot3.setRenderer(2, rendu3);

    return chart;
}

From source file:org.psystems.dicom.browser.server.stat.StatClientRequestsChartServlet.java

public JFreeChart getChart(CategoryDataset dataset) {
    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("? ?", // chart title
            "", // domain axis label
            "? (.)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*  w  w w.j  a  va  2s. c o  m*/

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

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // final IntervalMarker target = new IntervalMarker(2000000, 3000000);
    // target.setLabel(" ");
    // target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    // target.setLabelAnchor(RectangleAnchor.LEFT);
    // target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    // target.setPaint(new Color(222, 222, 255, 128));
    // plot.addRangeMarker(target, Layer.BACKGROUND);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setItemMargin(0.10);

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    // renderer.setSeriesPaint(0, gp0);
    // renderer.setSeriesPaint(1, gp1);
    // renderer.setSeriesPaint(2, gp2);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)
    // CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
    );
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
}

From source file:biz.ixnay.pivot.charts.skin.jfree.AreaChartViewSkin.java

@Override
protected JFreeChart createChart() {
    AreaChartView chartView = (AreaChartView) getComponent();

    String title = chartView.getTitle();
    String horizontalAxisLabel = chartView.getHorizontalAxisLabel();
    String verticalAxisLabel = chartView.getVerticalAxisLabel();
    boolean showLegend = chartView.getShowLegend();

    String seriesNameKey = chartView.getSeriesNameKey();
    List<?> chartData = chartView.getChartData();

    JFreeChart chart;/*from w w w . j  a  v a2s  .c o m*/
    ChartView.CategorySequence categories = chartView.getCategories();
    if (categories.getLength() > 0) {
        CategorySeriesDataset dataset = new CategorySeriesDataset(categories, seriesNameKey, chartData);
        chart = ChartFactory.createAreaChart(title, horizontalAxisLabel, verticalAxisLabel, dataset,
                PlotOrientation.VERTICAL, showLegend, false, false);

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        CategoryAxis domainAxis = plot.getDomainAxis();
        CategoryLabelPositions categoryLabelPositions = CategoryLabelPositions
                .createUpRotationLabelPositions(categoryLabelRotation);
        domainAxis.setCategoryLabelPositions(categoryLabelPositions);
    } else {
        chart = ChartFactory.createXYAreaChart(title, horizontalAxisLabel, verticalAxisLabel,
                new XYSeriesDataset(seriesNameKey, chartData), PlotOrientation.VERTICAL, showLegend, false,
                false);
    }

    return chart;
}

From source file:com.googlecode.refit.jenkins.ReFitGraph.java

/**
 * Creates a chart from the test result data set.
 * <p>/*  ww  w.  j  a  v  a2 s  . co m*/
 * The i-th row of the data set corresponds to the results from the i-th build.
 * Each row has columns 0, 1, 2 containing the number of failed, skipped and passed tests.
 * The chart stacks these values from bottom to top, joins the values for the same columns
 * with lines and fills the areas between the lines with given colours.
 * <p> 
 * TODO Find out if Jenkins core provides any caching for the chart or the data set.
 */
@Override
protected JFreeChart createGraph() {

    final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart title
            null, // domain axis label 
            "count", // range axis label
            data, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    ChartUtil.adjustChebyshev(data, rangeAxis);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRange(true);

    StackedAreaRenderer ar = new StackedAreaRenderer2() {
        private static final long serialVersionUID = 1L;

        /**
         * Colour brush for the given data point.
         */
        @Override
        public Paint getItemPaint(int row, int column) {
            return super.getItemPaint(row, column);
        }

        /**
         * URL for the given data point, which gets opened when the user clicks on or near
         * the data point in the chart.
         */
        @Override
        public String generateURL(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            return label.getUrl();
        }

        /**
         * Tooltip to be displayed on the chart when the user hovers at or near the
         * data point.
         * <p>
         * The tooltip has the format {@code #17 : 300 Passed}, indicating the build number
         * and the number of tests with the given result.
         */
        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            TestResult result = label.getResult();
            String rowKey = (String) dataset.getRowKey(row);
            return result.getOwner().getDisplayName() + " : " + dataset.getValue(row, column) + " "
                    + rowKey.substring(1);
        }
    };
    plot.setRenderer(ar);

    // Define colours for the data points by column index
    ar.setSeriesPaint(0, ColorPalette.RED); // Failed
    ar.setSeriesPaint(1, ColorPalette.YELLOW); // Skipped
    ar.setSeriesPaint(2, ColorPalette.BLUE); // Passed

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return chart;
}

From source file:com.polivoto.vistas.acciones.Datos.java

private JFreeChart createChartBar(CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart("Votacion", "Opciones", "Total de votos", dataset,
            PlotOrientation.VERTICAL, true, true, true);
    try {/*from   ww w  . ja  va 2 s  .c  om*/

        chart.addSubtitle(new TextTitle(ac.getPreguntas().getJSONObject(pox).getString("pregunta")));
        chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.white));
        CategoryPlot plot = chart.getCategoryPlot();
        org.jfree.chart.axis.CategoryAxis axis = plot.getDomainAxis();
        axis.setCategoryLabelPositions(
                CategoryLabelPositions.createUpRotationLabelPositions(0.39269908169872414D));
        //            final CategoryItemRenderer itemRenderer = new CustomRenderer(
        //                    new Paint[] {Color.green, Color.red, Color.blue, Color.yellow, Color.magenta, Color.cyan, Color.pink, Color.lightGray}
        //            );
        ////        itemRenderer.setBaseItemLabelsVisible(true);
        ////        BarRenderer barRenderer = (BarRenderer)itemRenderer;
        ////        barRenderer.setItemMargin(0.2D);
        ////        plot.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, new java.awt.Color(147, 60, 45)));
        ////        //        StandardCategoryToolTipGenerator toolTipGenerator = new StandardCategoryToolTipGenerator("{0}: {2} %", new DecimalFormat("0"));
        //            //
        //            plot.setNoDataMessage("SIN DATOS!");
        //            
        //            
        ////        renderer.setLabelGenerator(new StandardCategoryLabelGenerator());
        //            itemRenderer.setItemLabelsVisible(true);
        //            final ItemLabelPosition p = new ItemLabelPosition(
        //                    ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0
        //            );
        //            itemRenderer.setPositiveItemLabelPosition(p);
        //            plot.setRenderer(itemRenderer);

        // change the margin at the top of the range axis...
        final ValueAxis rangeAxis = plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.setLowerMargin(0.15);
        rangeAxis.setUpperMargin(0.15);

    } catch (JSONException ex) {
        Logger.getLogger(Datos.class.getName()).log(Level.SEVERE, null, ex);
    }
    return chart;
}

From source file:hudson.model.LoadStatistics.java

/**
 * Creates a trend chart.//from  ww w.j av a2s .  c  o m
 */
public JFreeChart createChart(CategoryDataset ds) {
    final JFreeChart chart = ChartFactory.createLineChart(null, // chart title
            null, // unused
            null, // range axis label
            ds, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseStroke(new BasicStroke(3));
    configureRenderer(renderer);

    final CategoryAxis domainAxis = new NoOverlapCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return chart;
}