Example usage for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero

List of usage examples for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero

Introduction

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

Prototype

public void setAutoRangeIncludesZero(boolean flag) 

Source Link

Document

Sets the flag that indicates whether or not the axis range, if automatically calculated, is forced to include zero.

Usage

From source file:se.six.jmeter.visualizer.statagg.StatAggVisualizer.java

private JFreeChart createChart() {
    setupDatasets();//from   ww  w. j  a  v  a 2s  . c  o m

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "ThroughPut", _dataSet1, true,
            true, false);
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    //axis.setFixedAutoRange(12 * 3600 * 1000);  // 12 Hours

    XYItemRenderer renderer1 = plot.getRenderer();
    renderer1.setSeriesPaint(0, Color.BLACK);

    final NumberAxis axis2 = new NumberAxis("Response Time");
    axis2.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, _dataSet2);
    plot.mapDatasetToRangeAxis(1, 1);

    StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, new Color(0, 153, 255));
    plot.setRenderer(1, renderer2);

    chart.setBackgroundPaint(Color.white);

    return chart;
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java

/**
 * @param list/*  w w w. ja  va2  s  .  c o m*/
 * @param title
 * @param xAxisTitle
 * @param yAxisTitle
 * @param isVertical
 * @param width
 * @param height
 */
public JFreeChart createLineChart(final List<Object> list, final String title, final String xAxisTitle,
        final String yAxisTitle, final boolean isVertical, final int width, final int height) {
    DefaultCategoryDataset catDataSet = new DefaultCategoryDataset();
    for (int i = 0; i < list.size(); i++) {
        Object xVal = list.get(i++);
        Object yVal = list.get(i);

        double xv = getDbl(xVal);
        numMin = Math.min(numMin, xv);
        numMax = Math.max(numMax, xv);

        catDataSet.addValue(getDbl(yVal), "X", xVal.toString());
    }

    /*XYDataset dataset = createXYDataSet(list);
    JFreeChart chart = ChartFactory.createXYLineChart( 
        title,      // chart title 
        xAxisTitle, // domain axis label 
        yAxisTitle, // range axis label 
        dataset,    // data 
        isVertical ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, 
        false,       // include legend 
        true,       // tooltips? 
        false       // URLs? 
    ); 
            
    XYPlot xyplot = chart.getXYPlot();
    NumberAxis numberAxis = (NumberAxis) xyplot.getDomainAxis();
    numberAxis.setRange(numMin, numMax);
            
    //ValueAxis axis = xyplot.getDomainAxis();
    //axis = xyplot.getRangeAxis();
    //((NumberAxis) axis).setTickUnit(new NumberTickUnit(1));
    //axis.setRange(1870,2010);*/

    /*
    JFreeChart jfreechart = ChartFactory.createLineChart3D(
        title, 
        xAxisTitle, 
        yAxisTitle, 
        catDataSet, 
        PlotOrientation.VERTICAL, 
        false, 
        true, 
        false);
    jfreechart.setBackgroundPaint(new Color(187, 187, 221));
    CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
            
    NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            
    CategoryItemRenderer renderer = categoryplot.getRenderer(); 
    renderer.setSeriesPaint(0, new Color(95, 158, 160)); 
    renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY); 
    */
    JFreeChart jfreechart = ChartFactory.createLineChart(title, xAxisTitle, yAxisTitle, catDataSet,
            PlotOrientation.VERTICAL, false, true, false);

    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setRangeGridlinePaint(Color.DARK_GRAY);
    categoryplot.setBackgroundPaint(null);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    CategoryItemRenderer renderer = categoryplot.getRenderer();
    renderer.setSeriesPaint(0, new Color(95, 158, 160));
    renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY);

    BasicStroke lineStroke = new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    renderer.setBaseStroke(lineStroke);
    renderer.setBaseOutlineStroke(lineStroke);
    renderer.setSeriesStroke(0, lineStroke);

    //renderer.setOutlineStroke(lineStroke);
    //renderer.setStroke(lineStroke);

    return jfreechart;
}

From source file:org.gvsig.remotesensing.scatterplot.gui.ChartScaterPlotPanel.java

/**
 *    Metodo que construye el grafico inicialmente. Antes de construirlo, llama a
 *    setDataChart() para cargar los datos a representar
 *
 * *///from   w  w  w.j a v  a2 s .co m
private void createChart(Color colorChart, Color colorBackground, Color colorExternal) {

    NumberAxis domainAxis = new NumberAxis(PluginServices.getText(this, "banda") + " " + (bandaX + 1));
    domainAxis.setAutoRangeIncludesZero(false);
    NumberAxis rangeAxis = new NumberAxis(PluginServices.getText(this, "banda") + " " + (bandaY + 1));
    rangeAxis.setAutoRangeIncludesZero(false);

    // Se cargan los datos antes de construir el grafico
    setDataChart(fLayer);
    plot = new ScatterPlotChart(this.data, domainAxis, rangeAxis);
    chart = new JFreeChart(PluginServices.getText(this, "diagrama_dispersion"), plot);
    data = null;
    chart.getRenderingHints().clear();
    chart.setBackgroundPaint(colorExternal);
    plot.setPaint(colorChart);
    plot.setBackgroundPaint(colorBackground);
}

From source file:be.nbb.demetra.dfm.output.FactorChart.java

private JFreeChart createMarginViewChart() {
    JFreeChart result = ChartFactory.createXYLineChart("", "", "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);

    XYPlot plot = result.getXYPlot();//from   www. j  a v a2  s  .c  o  m
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    LinesThickness linesThickness = LinesThickness.Thin;

    XYLineAndShapeRenderer factor = new LineRenderer(FACTOR_INDEX);
    plot.setRenderer(FACTOR_INDEX, factor);

    XYLineAndShapeRenderer filtered = new LineRenderer(FILTERED_INDEX);
    plot.setRenderer(FILTERED_INDEX, filtered);

    XYDifferenceRenderer difference = new XYDifferenceRenderer();
    difference.setAutoPopulateSeriesPaint(false);
    difference.setAutoPopulateSeriesStroke(false);
    difference.setBaseStroke(TsCharts.getNormalStroke(linesThickness));
    plot.setRenderer(DIFFERENCE_INDEX, difference);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setRangeAxis(rangeAxis);

    return result;
}

From source file:main.GUI.java

private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed

    areaVypis.setText("");

    int pocetRep = Integer.parseInt(txtPoceRep.getText().toString());
    int zahod = Integer.parseInt(txtZahod.getText().toString());
    carlo = new SCMC(pocetRep, zahod);
    carlo.addObserver(this);
    avgSeries = new XYSeries("AVG");
    XYSeriesCollection dataset = new XYSeriesCollection(avgSeries);

    JFreeChart lineChart = ChartFactory.createXYLineChart(null, null, null, dataset);
    final NumberAxis rangeAxis = (NumberAxis) lineChart.getXYPlot().getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    ChartPanel chartPanel = new ChartPanel(lineChart);

    panelLive.removeAll();/*from  w w w.  j ava  2 s. c om*/
    panelLive.add(chartPanel, BorderLayout.CENTER);
    panelLive.validate();

    carlo.simuluj(avgSeries);

}

From source file:org.bench4Q.console.ui.section.S_SPSSection.java

private JPanel printWIPSPic() throws IOException {
    double[][] value = sessionSmooth();
    for (int i = 0; i < value[0].length; ++i) {
        value[0][i] = i;//from ww  w  . j  av  a  2 s . c  o  m
        // value[1][i] = webInteractionThroughput[i];.
    }

    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    String series1 = "Basic";
    String series2 = "real";

    for (int i = 0; i < value[0].length; ++i) {
        defaultcategorydataset.addValue(value[1][i], series1, new Integer((int) value[0][i]));
        defaultcategorydataset.addValue(session[1][i], series2, new Integer((int) value[0][i]));
    }

    JFreeChart chart = ChartFactory.createLineChart("SPS = " + SPS, "time", "SPS", defaultcategorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setBackgroundPaint(Color.WHITE);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setAutoRangeIncludesZero(true);
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setShapesVisible(false);
    lineandshaperenderer.setSeriesStroke(0, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 1F, 1F }, 0.0F));
    lineandshaperenderer.setSeriesStroke(1,
            new BasicStroke(2.0F, 1, 0, 2.0F, new float[] { 1F, 10000F }, 0.0F));
    return new ChartPanel(chart);
}

From source file:org.gvsig.remotesensing.scatterplot.gui.ChartScaterPlotPanel.java

/**
 *    Actualizacion del grafico. Esta actualizacion se producira cuando haya variacion en la
 *  seleccion de las bandas por parte del usuario.
 *
 * */// w  w w  .j av  a  2  s.com
public void updateChart(Color colorChart, Color colorBackground, Color colorExternal) {

    NumberAxis domainAxis = new NumberAxis(PluginServices.getText(this, "banda") + (bandaX + 1));
    domainAxis.setAutoRangeIncludesZero(false);
    NumberAxis rangeAxis = new NumberAxis(PluginServices.getText(this, "banda") + (bandaY + 1));
    rangeAxis.setAutoRangeIncludesZero(false);
    chart = null;
    plot = null;

    scatterPlotProcess = new ScatterPlotProcess();
    scatterPlotProcess.addParam("layer", fLayer);
    scatterPlotProcess.addParam("bandY", new Integer(bandaY));
    scatterPlotProcess.addParam("bandX", new Integer(bandaX));
    scatterPlotProcess.addParam("backgroundColor", Color.WHITE);
    scatterPlotProcess.addParam("externalColor", Color.WHITE);
    scatterPlotProcess.addParam("chartColor", Color.BLACK);
    scatterPlotProcess.setActions(this);
    scatterPlotProcess.start();

    // Se cargan los datos correspondiesntes a las bandas seleccionadas
    /* setDataChart(fLayer);
     plot = new ScatterPlotChart(this.data, domainAxis, rangeAxis);
            
    chart = new JFreeChart(PluginServices.getText(this,"diagrama_dispersion"), plot);
    chart.getRenderingHints().clear();
    data=null;*/

    updateChartPanel(colorChart, colorBackground, colorExternal);

}

From source file:com.wsntools.iris.tools.Graph.java

private void setupChartType(JFreeChart chart) {

    chart.setBackgroundPaint(Color.white);

    // plot = chart.getCategoryPlot();
    plot = chart.getXYPlot();/*from  ww w . ja va 2 s  . co  m*/
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4));

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();

    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setAutoRange(true);
    domainAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setAutoRange(true);
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    chartPanel.setChart(chart);
}

From source file:org.tolven.graph.GraphMenuEventHandler.java

/**
 * Creates a chart based on MenuData/* w ww  .ja  va 2  s.com*/
 * @param dataset  a dataset
 * @return A chart suitable for rendering
 * @throws Exception 
 */
private JFreeChart createChart() throws Exception {
    XYDataset xyDataset = createDataset();
    Properties menuEventHandlerData = getAction().getMenuEventHandlerDataMap();
    String title = menuEventHandlerData.getProperty("title");
    String xAxisLabel = menuEventHandlerData.getProperty("xAxisLabel");
    String yAxisLabel = menuEventHandlerData.getProperty("yAxisLabel");
    JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title
            xAxisLabel, // x-axis label
            yAxisLabel, // y-axis label
            xyDataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    //CCHIT merge
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    // rangeAxis.setStandardTickUnits(NumberAxis.cr);
    NumberFormat formatter = new DecimalFormat("#0.00");
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setNumberFormatOverride(formatter);

    return chart;
}

From source file:unalcol.termites.boxplots.RoundNumber1.java

/**
 * Creates a new demo.//from   w  w w .jav a 2s  .c  om
 *
 * @param title the frame title.
 * @param pf
 */
public RoundNumber1(final String title, ArrayList<Double> pf) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);

    final CategoryAxis xAxis = new CategoryAxis("");
    //final NumberAxis yAxis = new NumberAxis("Round number");
    final NumberAxis yAxis = new NumberAxis("");
    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 16);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Round Number" + getTitle(pf), new Font("SansSerif", Font.BOLD, 18),
            plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);

    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }

    legendText.setFont(font);
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);
    chart.getLegend().setItemFont(font);

    FileOutputStream output;
    try {
        output = new FileOutputStream("roundnumber1" + pf + mazeMode + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 450, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RoundNumber1.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(RoundNumber1.class.getName()).log(Level.SEVERE, null, ex);
    }

}