List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:org.tap4j.plugin.util.GraphHelper.java
public static JFreeChart createChart(StaplerRequest req, CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedAreaChart("TAP Tests", // chart title null, // unused "TAP Tests Count", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );/*from w w w . j av a 2s. com*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); 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(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); StackedAreaRenderer ar = new StackedAreaRenderer2() { private static final long serialVersionUID = 331915263367089058L; @Override public String generateURL(CategoryDataset dataset, int row, int column) { NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column); return label.build.getNumber() + "/" + AbstractTapProjectAction.URL_NAME + "/"; } @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column); TapBuildAction build = label.build.getAction(TapBuildAction.class); TapResult report = build.getResult(); report.tally(); switch (row) { case 0: return String.valueOf(report.getFailed()) + " Failure(s)"; case 1: return String.valueOf(report.getPassed()) + " Pass"; case 2: return String.valueOf(report.getSkipped()) + " Skip(s)"; default: return ""; } } }; plot.setRenderer(ar); ar.setSeriesPaint(0, ColorPalette.RED); // Failures ar.setSeriesPaint(1, ColorPalette.BLUE); // Pass ar.setSeriesPaint(2, ColorPalette.YELLOW); // Skips // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }
From source file:graficarordenamiento.Graficador.java
public void crearGrafico() { // Creando el Grafico chart = ChartFactory.createBarChart("Grfico de barras", null, null, dataset, PlotOrientation.VERTICAL, false, false, false);//from w w w . ja va 2s. c o m chart.setBackgroundPaint(new GradientPaint(0, 0, Color.WHITE, 700, 0, Color.BLACK.brighter(), false)); chart.setBackgroundImageAlpha(0.5f); final CategoryPlot plot = chart.getCategoryPlot(); plot.setNoDataMessage("NO DATA!"); plot.setRangeGridlinePaint(Color.red); plot.setBackgroundPaint(new GradientPaint(0, 0, Color.LIGHT_GRAY, 0, 100, Color.darkGray)); plot.setBackgroundImageAlpha(0.5f); //plot.setDomainGridlinesVisible(true); BarRenderer rend = (BarRenderer) plot.getRenderer(); final ItemLabelPosition e = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0); GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); rend.setSeriesPaint(0, gp0); rend.setSeriesPaint(1, gp1); rend.setSeriesPaint(2, gp2); plot.setRenderer(rend); // 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); // set up gradient paints for series... }
From source file:com.googlecode.logVisualizer.chart.HorizontalBarChartBuilder.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart(getTitle(), xLable, yLable, dataset, PlotOrientation.HORIZONTAL, isIncludeLegend(), true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); final CategoryAxis categoryAxis = plot.getDomainAxis(); final NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); plot.setNoDataMessage("No data available"); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.black); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); setBarShadowVisible(chart, false);// w w w. j av a 2s . co m renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{1}, {2}", NumberFormat.getInstance())); categoryAxis.setCategoryMargin(0.02); categoryAxis.setUpperMargin(0.02); categoryAxis.setLowerMargin(0.02); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberAxis.setUpperMargin(0.1); return chart; }
From source file:org.jfree.chart.swt.demo.SWTBarChartDemo1.java
/** * Creates a sample chart.// w ww. jav a2s . c om * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart("SWTBarChartDemo1", // chart title "Category", // domain axis label "Value", // range axis label dataset); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); // 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); // the SWTGraphics2D class doesn't handle GradientPaint well, so // replace the gradient painter from the default theme with a // standard painter... renderer.setBarPainter(new StandardBarPainter()); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.opensourcestrategies.crmsfa.reports.JFreeCrmsfaCharts.java
/** * Lead pipeline. Description at http://www.opentaps.org/docs/index.php/CRMSFA_Dashboard * Note that this counts all the leads in the system for now. *//*from ww w . j a v a 2s. c o m*/ public static String createLeadPipelineChart(Delegator delegator, Locale locale) throws GenericEntityException, IOException { Map uiLabelMap = UtilMessage.getUiLabels(locale); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // get all LEAD statuses that are not CONVERTED, or DEAD List<GenericValue> leadStatuses = ReportHelper.findLeadStatusesForDashboardReporting(delegator); // report number of leads for each status for (GenericValue status : leadStatuses) { String statusId = status.getString("statusId"); long count = delegator.findCountByCondition("PartyAndStatus", EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, statusId), null); dataset.addValue(count, "", (String) status.get("description", locale)); } // set up the chart JFreeChart chart = ChartFactory.createBarChart((String) uiLabelMap.get("CrmLeadPipeline"), 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(227, 246, 206), 0.0f, 0.0f, new Color(153, 204, 102)); 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); }
From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java
static XYPlot newPlot(XYDataset dataset, String label, boolean forceIncludeZero) { StandardXYItemRenderer standardxyitemrenderer = new StandardXYItemRenderer(); NumberAxis numberaxis = new NumberAxis(label); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setAutoRangeIncludesZero(forceIncludeZero); return new XYPlot(dataset, null, numberaxis, standardxyitemrenderer); }
From source file:subterranean.crimson.server.graphics.graphs.LineChart.java
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createTimeSeriesChart("", "", "", dataset, false, false, false); XYPlot plot = result.getXYPlot();/*w w w. j ava 2 s . c om*/ plot.setDataset(1, new TimeSeriesCollection(s2)); plot.setBackgroundPaint(new Color(0x000000)); plot.setDomainGridlinesVisible(false); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinesVisible(false); plot.setRangeGridlinePaint(Color.lightGray); ValueAxis xaxis = plot.getDomainAxis(); xaxis.setAutoRange(true); xaxis.setFixedAutoRange(160000.0); // 160 seconds xaxis.setVerticalTickLabels(false); ValueAxis yaxis = plot.getRangeAxis(); yaxis.setAutoRange(true); yaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return result; }
From source file:com.googlecode.logVisualizer.chart.perDayConsumption.ConsumptionBarChartBuilder.java
private JFreeChart createChart(final ConsumptionDataset dataset) { final JFreeChart chart = ChartFactory.createStackedBarChart(getTitle(), xLable, yLable, dataset, PlotOrientation.VERTICAL, isIncludeLegend(), true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); final CategoryAxis categoryAxis = plot.getDomainAxis(); final NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); plot.setNoDataMessage("No data available"); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.black); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); setBarShadowVisible(chart, false);/*from ww w.j av a 2s .c o m*/ setStackColors(dataset, renderer); renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new ConsumptionLableGenerator()); renderer.setBaseToolTipGenerator(new ConsumptionToolTipGenerator()); categoryAxis.setCategoryMargin(0.07); categoryAxis.setUpperMargin(0.01); categoryAxis.setLowerMargin(0.01); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberAxis.setUpperMargin(0.1); return chart; }
From source file:org.ow2.clif.jenkins.chart.MovingStatChart.java
@Override protected JFreeChart createChart() { XYSeriesCollection coreDataset = new XYSeriesCollection(); coreDataset.addSeries(this.eventSerie); long periodMs = this.chartConfiguration.getStatisticalPeriod() * 1000L; XYSeriesCollection movingDataset = calculateMovingDataset(coreDataset, periodMs); XYSeriesCollection throughputDataset = calculateThroughputDataset(coreDataset, periodMs); JFreeChart chart;//from w ww.ja va 2s . c o m chart = ChartFactory .createXYLineChart( getBasicTitle() + " " + Messages.MovingChart_StatisticalPeriod( this.chartConfiguration.getStatisticalPeriod()), // chart title Messages.MovingChart_Time(), // x axis label Messages.MovingChart_ResponseTime(), // y axis label movingDataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); configureBasicPlotProperties(plot); // Force the 0 on vertical axis NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Force the 0 on horizontal axis NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(true); attachThroughputDatasetToDedicatedAxis(throughputDataset, plot); // Global renderer for moving stats plot.setRenderer(getGlobalRenderer()); // Dedicated Throughput renderer plot.setRenderer(1, getThroughputRenderer()); return chart; }
From source file:sturesy.votinganalysis.TimeChart.java
/** * Creates an XYSeries-ChartPanel//from w w w. ja v a 2s. co m * * @param votes * votes to use * @return ChartPanel */ private ChartPanel getXYSeriesChart(Set<Vote> votes) { final XYSeries series = new XYSeries(Localize.getString("label.votes.over.time")); if (votes.size() != 0) { double[] dubble = createArrayOfVotes(votes); for (int i = 0; i < dubble.length; i++) { series.add(i, dubble[i]); } } final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart(Localize.getString("label.votes.over.time"), Localize.getString("label.time.seconds"), Localize.getString("label.amount.votes"), data, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(_background); chart.getPlot().setNoDataMessage("NO DATA"); chart.getXYPlot().getRenderer().setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f)); chart.getXYPlot().getRenderer().setSeriesPaint(0, new Color(255, 140, 0)); chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel chartpanel = new ChartPanel(chart); return chartpanel; }