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

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

Introduction

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

Prototype

public NumberAxis(String label) 

Source Link

Document

Constructs a number axis, using default values where necessary.

Usage

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

private static JFreeChart createChart(BoxAndWhiskerXYDataset boxandwhiskerxydataset) {
    DateAxis dateaxis = new DateAxis("Day");
    NumberAxis numberaxis = new NumberAxis("Value");
    XYBoxAndWhiskerRenderer xyboxandwhiskerrenderer = new XYBoxAndWhiskerRenderer();
    XYPlot xyplot = new XYPlot(boxandwhiskerxydataset, dateaxis, numberaxis, xyboxandwhiskerrenderer);
    xyplot.setOrientation(PlotOrientation.HORIZONTAL);
    JFreeChart jfreechart = new JFreeChart("Box-and-Whisker Chart Demo 2", xyplot);
    jfreechart.setBackgroundPaint(Color.white);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setDomainGridlinesVisible(true);
    xyplot.setRangeGridlinePaint(Color.white);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return jfreechart;
}

From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java

public static JFreeChart createDumyChart() {
    final BoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    final CategoryAxis xAxis = new CategoryAxis("Type");
    final NumberAxis yAxis = new NumberAxis("Value");
    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(true);//from ww w .  ja  v a 2s . co m
    renderer.setMeanVisible(false);
    renderer.setMedianVisible(false);
    // renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    return new JFreeChart(plot);
}

From source file:jesse.GA_ANN.DataVis.java

JFreeChart createChart()//Here Input MillSecond
{
    total = new XYSeries[10];
    XYSeriescollection = new XYSeriesCollection();
    for (int i = 0; i < 10; i++) {
        total[i] = new XYSeries(i);
        XYSeriescollection.addSeries(total[i]);
    }//from w  ww  . ja va 2  s  . c om

    dateaxis = new NumberAxis("Time");
    NumberAxis Conaxis = new NumberAxis("z??");
    dateaxis.setAutoRange(true);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.green);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1F, 0, 2));
    xylineandshaperenderer.setFillPaint(new Color(30, 30, 220), true);

    Conaxis.setRange(-1, 1);
    Conaxis.setAutoRange(true);
    Conaxis.setAutoRangeIncludesZero(false);

    XYPlot xyplot = new XYPlot(XYSeriescollection, dateaxis, Conaxis, xylineandshaperenderer);
    JFreeChart jfreechart = new JFreeChart("time-z", new Font("Arial", 1, 24), xyplot, true);
    ChartUtilities.applyCurrentTheme(jfreechart);
    ChartPanel chartpanel = new ChartPanel(jfreechart, true);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    return jfreechart;
}

From source file:userinterface.CyberSecurity.ChartFactory.java

public static ChartPanel createChart(UserAccount account) {
    Map<String, LoginDetails> loginDetails = account.getLoginDetails();
    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();

    Collection<LoginDetails> values = loginDetails.values();

    for (LoginDetails details : values) {
        dataset1.addValue(TimeUnit.MILLISECONDS.toHours(details.getLogoutTime() - details.getLoginTime()),
                HOURS_WORKED_BY_USER, details.getLoginDate());
        dataset2.addValue(2.5, MINIMUM_WORKING_HOURS, details.getLoginDate());
    }/*  www . ja v a  2 s .  c o m*/

    dataset1.addValue(2, HOURS_WORKED_BY_USER, "4-19-2016");
    dataset1.addValue(3, HOURS_WORKED_BY_USER, "4-20-2016");
    dataset2.addValue(2.5, MINIMUM_WORKING_HOURS, "4-19-2016");
    dataset2.addValue(2.5, MINIMUM_WORKING_HOURS, "4-20-2016");

    final CategoryItemRenderer renderer = new BarRenderer();

    final CategoryPlot plot = new CategoryPlot();
    plot.setDataset(dataset1);
    plot.setRenderer(renderer);

    plot.setDomainAxis(new CategoryAxis("Date"));
    plot.setRangeAxis(new NumberAxis("Hours"));

    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);

    // now create the second dataset and renderer...
    final CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
    plot.setDataset(1, dataset2);
    plot.setRenderer(1, renderer2);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    final JFreeChart chart = new JFreeChart(plot);
    chart.setTitle("Employee work hours");

    chart.setBackgroundPaint(Color.WHITE);
    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    return chartPanel;
}

From source file:org.csml.tommo.sugar.heatmap.MeanQualityMatrixChart.java

public static MeanQualityMatrixChart createNiceChart(MeanQualityMatrixDataset dataset, PaintScale paintScale) {

    Rectangle range = dataset.getMeanQualityMatrix().getRange();
    String xLabel = "X from " + range.x + " to " + (range.x + range.width);
    String yLabel = "Y from " + range.y + " to " + (range.y + range.height);

    NumberAxis xAxis = new NumberAxis(xLabel);
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setTickLabelsVisible(true);/*from ww  w  .j a v  a 2s  . c  om*/
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    NumberAxis yAxis = new NumberAxis(yLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setTickLabelsVisible(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);

    MeanQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale);

    // draw paint scale legend
    chart.setPaintScaleLegend(paintScale);

    return chart;
}

From source file:bigdataproject.ScatterPlot.java

/**
 * Creates a new fast scatter plot.//www .  j  a  v a2s  .  c  om
 *
 * @param title the frame title.
 * @param samples the 2D matrix to plot.
 */
public ScatterPlot(final String title, double[][] samples, List<Cluster<DoublePoint>> list) {

    super(title);
    this.list = list;
    convertToFloat(samples);
    listToHashMap();
    HashMap<Integer, float[][]> clusterData = HashMapDoubleToFloat();
    final NumberAxis domainAxis = new NumberAxis("X1");
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis("X2");
    rangeAxis.setAutoRangeIncludesZero(false);
    final CustomFastScatterPlot plot = new CustomFastScatterPlot(this.data, domainAxis, rangeAxis, clusterData);
    final JFreeChart chart = new JFreeChart(title, plot);
    //chart.setLegend(null);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(1000, 540));
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(2000);
    setContentPane(panel);

}

From source file:org.csml.tommo.sugar.heatmap.MappingQualityMatrixChart.java

public static MappingQualityMatrixChart createNiceChart(MappingQualityMatrixDataset dataset,
        PaintScale paintScale) {//from   www  . ja va2s. c  o  m

    Rectangle range = dataset.getMappingQualityMatrix().getRange();
    String xLabel = "X from " + range.x + " to " + (range.x + range.width);
    String yLabel = "Y from " + range.y + " to " + (range.y + range.height);

    NumberAxis xAxis = new NumberAxis(xLabel);
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setTickLabelsVisible(true);
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    NumberAxis yAxis = new NumberAxis(yLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setTickLabelsVisible(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);

    MappingQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale);

    // draw paint scale legend
    chart.setPaintScaleLegend(paintScale);

    return chart;
}

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

public static JFreeChart createChart(CategoryDataset acategorydataset[]) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Freshmeat Software Projects", "Language", "Projects",
            acategorydataset[0], PlotOrientation.VERTICAL, true, true, false);
    jfreechart.addSubtitle(new TextTitle("By Programming Language"));
    jfreechart.addSubtitle(new TextTitle("As at 5 March 2003"));
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setLowerMargin(0.02D);/* w w w . j  av a 2s.c o  m*/
    categoryaxis.setUpperMargin(0.02D);
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
    NumberAxis numberaxis1 = new NumberAxis("Percent");
    numberaxis1.setNumberFormatOverride(NumberFormat.getPercentInstance());
    categoryplot.setRangeAxis(1, numberaxis1);
    categoryplot.setDataset(1, acategorydataset[1]);
    categoryplot.setRenderer(1, lineandshaperenderer);
    categoryplot.mapDatasetToRangeAxis(1, 1);
    categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    return jfreechart;
}

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

private static JFreeChart createChart(TableXYDataset tablexydataset) {
    DateAxis dateaxis = new DateAxis("Year");
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateaxis.setLowerMargin(0.01D);//from  w  w w  .  java2  s .  c  o m
    dateaxis.setUpperMargin(0.01D);
    NumberAxis numberaxis = new NumberAxis("Tonnes");
    numberaxis.setNumberFormatOverride(new DecimalFormat("0.0%"));
    StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.29999999999999999D);
    stackedxybarrenderer.setRenderAsPercentages(true);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, new Color(64, 0, 0), 0.0F, 0.0F, Color.red);
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, new Color(0, 64, 0), 0.0F, 0.0F, Color.green);
    stackedxybarrenderer.setSeriesPaint(0, gradientpaint);
    stackedxybarrenderer.setSeriesPaint(1, gradientpaint1);
    stackedxybarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
    stackedxybarrenderer.setDrawBarOutline(false);
    stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2} tonnes",
            new SimpleDateFormat("yyyy"), new DecimalFormat("#,##0")));
    XYPlot xyplot = new XYPlot(tablexydataset, dateaxis, numberaxis, stackedxybarrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    JFreeChart jfreechart = new JFreeChart("Waste Management", xyplot);
    jfreechart.setBackgroundPaint(Color.white);
    jfreechart.addSubtitle(new TextTitle("St Albans City and District Council"));
    return jfreechart;
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.XYAreaChartExpression.java

public static JFreeChart createTimeSeriesChart(final String title, final String timeAxisLabel,
        final String valueAxisLabel, final XYDataset dataset, final boolean legend, final boolean tooltips,
        final boolean urls, final boolean stacked) {
    final ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);// w ww  . j a  v a2  s.c  o  m
    final NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    final XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    final XYAreaRenderer2 renderer;
    if (stacked) {
        renderer = new StackedXYAreaRenderer2();
    } else {
        renderer = new XYAreaRenderer2();
    }
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
}