List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:org.jfree.chart.demo.CombinedCategoryPlotDemo1.java
/** * Creates a chart./*from w w w . jav a 2 s . c o m*/ * * @return A chart. */ private JFreeChart createChart() { final CategoryDataset dataset1 = createDataset1(); final NumberAxis rangeAxis1 = new NumberAxis("Value"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); final CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1); subplot1.setDomainGridlinesVisible(true); final CategoryDataset dataset2 = createDataset2(); final NumberAxis rangeAxis2 = new NumberAxis("Value"); rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final BarRenderer renderer2 = new BarRenderer(); renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); final CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2); subplot2.setDomainGridlinesVisible(true); final CategoryAxis domainAxis = new CategoryAxis("Category"); final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis); plot.add(subplot1, 2); plot.add(subplot2, 1); final JFreeChart result = new JFreeChart("Combined Domain Category Plot Demo", new Font("SansSerif", Font.BOLD, 12), plot, true); // result.getLegend().setAnchor(Legend.SOUTH); return result; }
From source file:com.argeloji.server.BarChartDemo4.java
/** * Creates a sample chart./*from w w w . j a va 2s . com*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Cevap Dalm", // chart title "Seenekler", // domain axis label "renci Says", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(new Color(0xFFFFFF)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); // 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.setMaxBarWidth(0.10); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.GREEN, 0.0f, 0.0f, Color.GREEN); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.RED, 0.0f, 0.0f, Color.RED); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.RED, 0.0f, 0.0f, Color.RED); final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.RED, 0.0f, 0.0f, Color.RED); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); renderer.setSeriesPaint(3, gp3); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo2.java
/** * Creates a sample chart./*from ww w.j a v a2 s. c om*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(BoxAndWhiskerCategoryDataset dataset) { CategoryAxis domainAxis = new CategoryAxis(null); NumberAxis rangeAxis = new NumberAxis(rangeLabel); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart(chartTitle, plot); plot.setOrientation(PlotOrientation.HORIZONTAL); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator( new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); //columnCount -- category count //RowCount -- serie count domainAxis.setLowerMargin(0.44); domainAxis.setUpperMargin(0.44); if (dataset.getColumnCount() == 1) renderer.setItemMargin(0.5); // domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2); /* System.out.println("1lowerMargin="+domainAxis.getLowerMargin()); System.out.println("ItemMargin="+renderer.getItemMargin()); System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/ renderer.setItemMargin(renderer.getItemMargin() * 2); /*System.out.println("2lowerMargin="+domainAxis.getLowerMargin()); System.out.println("ItemMargin="+renderer.getItemMargin()); System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/ return chart; }
From source file:org.esa.beam.smos.visat.GridPointBtDataFlagmatrixToolView.java
private NumberAxis createRangeAxis(String[] flagNames) { final NumberAxis axis = new SymbolAxis(null, flagNames); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setAutoRangeIncludesZero(false); axis.setLowerMargin(0.0);/* w w w .j a v a 2 s . c o m*/ axis.setUpperMargin(0.0); axis.setInverted(true); return axis; }
From source file:regression.gui.RegressionChart.java
/** * Creates a chart./*w ww .ja v a 2s . c om*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createScatterPlot("Wykres funkcji regresji", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShape(0, ShapeUtilities.createRegularCross(3, 3)); renderer.setSeriesShape(2, ShapeUtilities.createRegularCross(3, 3)); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(2, false); plot.setRenderer(renderer); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:test.integ.be.fedict.performance.util.PerformanceResultDialog.java
private JFreeChart getMemoryChart(int intervalSize, List<MemoryData> memory) { if (null == memory || memory.isEmpty()) { return null; }/*from w w w .j av a 2 s . c o m*/ JFreeChart chart; TimeSeries freeSeries = new TimeSeries("Free"); TimeSeries maxSeries = new TimeSeries("Max"); TimeSeries totalSeries = new TimeSeries("Total"); memory.remove(memory.size() - 1); for (MemoryData memoryEntry : memory) { freeSeries.add(new Second(memoryEntry.getDate()), memoryEntry.getFreeMemory()); maxSeries.add(new Second(memoryEntry.getDate()), memoryEntry.getMaxMemory()); totalSeries.add(new Second(memoryEntry.getDate()), memoryEntry.getTotalMemory()); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(freeSeries); dataset.addSeries(maxSeries); dataset.addSeries(totalSeries); chart = ChartFactory.createTimeSeriesChart("eID Trust Service Memory Usage History", "Time (interval size " + intervalSize + " msec)", "Memory", dataset, true, false, false); chart.addSubtitle(new TextTitle( memory.get(0).getDate().toString() + " - " + memory.get(memory.size() - 1).getDate().toString())); chart.setBackgroundPaint(Color.WHITE); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); ValueAxis valueAxis = plot.getRangeAxis(); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRangeGridlinePaint(Color.black); plot.setDomainGridlinePaint(Color.black); plot.setRenderer(renderer); return chart; }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.MatrixChart.java
private void buildMainChart(String title, String subTitle, String xAxisLabel, String yAxisLabel, String fileName) {//from www .j a v a 2 s. c o m final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.createMatrixDataSet()); final JFreeChart chart = ChartFactory.createBubbleChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); chart.addSubtitle(new TextTitle(subTitle)); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.WHITE)); chart.removeLegend(); // Perform customizations starts here ... final XYPlot plot1 = chart.getXYPlot(); plot1.setDomainGridlinesVisible(false); plot1.setRangeGridlinesVisible(false); plot1.setForegroundAlpha(0.5f); plot1.setDomainAxis(new CustomAxis(plot1.getDomainAxis().getLabel())); plot1.setRangeAxis(new CustomAxis(plot1.getRangeAxis().getLabel())); // Custumize the domain axis ( y ) final NumberAxis domainAxis = (NumberAxis) plot1.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-1, this.array.length); // Custumize the range axis ( y ) final NumberAxis rangeAxis = (NumberAxis) plot1.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(-1, this.array.length); // Create custom renderer StandardXYItemRenderer ren = new CustomRenderer(false); ren.setSeriesItemLabelPaint(0, Color.BLACK); plot1.setRenderer(ren); this.mainChart = chart; }
From source file:com.seniorproject.augmentedreality.test.AreaChartDemo.java
/** * Creates a chart./*from ww w . j a v a2s . c om*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setAnchor(StandardLegend.SOUTH); chart.setBackgroundPaint(Color.white); final TextTitle subtitle = new TextTitle("An area chart demonstration. We use this " + "subtitle as an example of what happens when you get a really long title or " + "subtitle."); subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12)); subtitle.setPosition(RectangleEdge.TOP); // subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05)); subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM); chart.addSubtitle(subtitle); final CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(0.5f); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.addCategoryLabelToolTip("Type 1", "The first type."); domainAxis.addCategoryLabelToolTip("Type 2", "The second type."); domainAxis.addCategoryLabelToolTip("Type 3", "The third type."); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelAngle(0 * Math.PI / 2.0); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.hello2morrow.sonargraph.jenkinsplugin.model.AbstractPlot.java
/** * Configure the Y-axis: Adjust the range and specify tick units. *//*from www . j a v a 2 s . c o m*/ protected void setRangeAxis(boolean hideDecimals, XYPlot plot) { if (hideDecimals) { plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } if (getDatasetSize() == 0) { plot.getRangeAxis().setRange(0.0, 1.0); } else { plot.getRangeAxis().setRange(getMinimumValue() - 1, getMaximumValue() + 1); } }
From source file:com.opensourcestrategies.crmsfa.reports.JFreeCrmsfaCharts.java
/** * Opportunities by stage. Description at * http://www.opentaps.org/docs/index.php/CRMSFA_Dashboard * Note that this counts all the opportunities in the system for now. *//*from w w w. ja v a 2s . c o m*/ public static String createOpportunitiesbyStageChart(Delegator delegator, Locale locale) throws GenericEntityException, IOException { Map uiLabelMap = UtilMessage.getUiLabels(locale); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String currency = UtilConfig.getPropertyValue("crmsfa", "defaultCurrencyUomId"); // get all sales opportunity stages that are not closed, or lost List<GenericValue> salesOpportunityStages = ReportHelper .findSalesOpportunityStagesForDashboardReporting(delegator); // report number of leads for each status for (GenericValue stage : salesOpportunityStages) { String opportunityStageId = stage.getString("opportunityStageId"); EntityCondition conditions = EntityCondition.makeCondition(EntityOperator.AND, EntityCondition.makeCondition("opportunityStageId", EntityOperator.EQUALS, opportunityStageId), EntityCondition.makeCondition("currencyUomId", EntityOperator.EQUALS, currency)); List<GenericValue> salesOpportunityEstimatedAmountTotals = delegator .findByConditionCache("SalesOpportunityEstimatedAmountTotalByStage", conditions, null, null); if (salesOpportunityEstimatedAmountTotals != null && !salesOpportunityEstimatedAmountTotals.isEmpty()) { GenericValue salesOpportunityEstimatedAmountTotal = salesOpportunityEstimatedAmountTotals.get(0); dataset.addValue(salesOpportunityEstimatedAmountTotal.getDouble("estimatedAmountTotal"), "", (String) stage.get("description", locale)); } else { dataset.addValue(0, "", (String) stage.get("description", locale)); } } // set up the chart JFreeChart chart = ChartFactory.createBarChart( (String) UtilMessage.expandLabel("CrmOpportunitiesbyStage", locale, UtilMisc.toMap("currency", currency)), null, null, dataset, PlotOrientation.HORIZONTAL, false, true, false); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setPadding(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // get the bar renderer to put effects on the bars final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // disable bar outlines // set up gradient paint on bar final GradientPaint gp = new GradientPaint(0.0f, 0.0f, new Color(206, 246, 245), 0.0f, 0.0f, new Color(51, 204, 204)); renderer.setSeriesPaint(0, gp); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // save as a png and return the file name return ServletUtilities.saveChartAsPNG(chart, 360, 200, null); }