List of usage examples for org.jfree.chart.axis NumberAxis setUpperMargin
public void setUpperMargin(double margin)
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.CoberturaTimeChartStrategy.java
public NumberAxis getRangeAxis() { NumberAxis valueaxis = new NumberAxis(); valueaxis.setLowerMargin(0.0D);//from w w w.j a v a2s . com valueaxis.setUpperMargin(0.099D); valueaxis.setRangeWithMargins(0.0D, 1.0D); valueaxis.setLabel(this.getYAxisLabel()); valueaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); return valueaxis; }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.CloverTimeChartStrategy.java
/** * //from w w w .j a va 2 s.c om */ public NumberAxis getRangeAxis() { NumberAxis valueaxis = new NumberAxis(); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.05D); valueaxis.setRangeWithMargins(0.0D, 1.0D); valueaxis.setLabel(this.getYAxisLabel()); valueaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); return valueaxis; }
From source file:org.jfree.chart.demo.BubblePlotDemo.java
/** * Creates a chart.// w ww.j a v a2 s.c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final XYZDataset dataset) { final JFreeChart chart = ChartFactory.createBubbleChart("Bubble Plot Demo", "X", "Y", dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setForegroundAlpha(0.65f); // increase the margins to account for the fact that the auto-range doesn't take into // account the bubble size... final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerMargin(0.15); domainAxis.setUpperMargin(0.15); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:com.bdb.weather.display.summary.TemperatureBinSummaryPlot.java
public TemperatureBinSummaryPlot() { plot = new CombinedDomainCategoryPlot(); JFreeChart chart = new JFreeChart(plot); setMaxHeight(10000);/*from w w w.j a va2 s . c o m*/ setMaxWidth(10000); NumberAxis countAxis = new NumberAxis("Day Count"); countAxis.setUpperMargin(.2); countPlot.setRangeAxis(countAxis); countPlot.setDataset(countDataset); BarRenderer r = new BarRenderer(); r.setBaseItemLabelsVisible(true); r.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); r.setSeriesPaint(0, Color.BLUE); r.setBasePaint(Color.BLUE); countPlot.setRenderer(r); NumberAxis durationAxis = new NumberAxis("Duration (Hours)"); durationAxis.setUpperMargin(.2); durationPlot.setRangeAxis(durationAxis); durationPlot.setDataset(durationDataset); r = new BarRenderer(); r.setBaseItemLabelsVisible(true); NumberFormat format = DecimalFormat.getNumberInstance(); format.setMaximumFractionDigits(1); format.setMinimumFractionDigits(1); r.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, format)); r.setSeriesPaint(0, Color.RED); r.setBasePaint(Color.RED); durationPlot.setRenderer(r); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); plot.add(countPlot); plot.add(durationPlot); chartViewer = new ChartViewer(chart); this.setCenter(chartViewer); }
From source file:org.sonar.plugins.buildstability.BuildStabilityChart.java
private void configureRangeAxis(CategoryPlot plot, String valueLabelSuffix, Font font) { NumberAxis numberAxis = new NumberAxis(); numberAxis.setUpperMargin(0.3); numberAxis.setTickLabelFont(font);/*from w w w. j a v a2s . c o m*/ numberAxis.setTickLabelPaint(OUTLINE_COLOR); String suffix = ""; if (valueLabelSuffix != null && !"".equals(valueLabelSuffix)) { suffix = new StringBuilder().append("'").append(valueLabelSuffix).append("'").toString(); } numberAxis.setNumberFormatOverride(new DecimalFormat("0" + suffix)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setRangeAxis(numberAxis); }
From source file:edu.ucla.stat.SOCR.chart.demo.BubbleChartDemo1.java
/** * Creates a chart.// w w w .j a v a 2 s. com * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(XYZDataset dataset) { JFreeChart chart = ChartFactory.createBubbleChart(chartTitle, domainLabel, rangeLabel, dataset, PlotOrientation.VERTICAL, !legendPanelOn, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); // SOCRBubbleRenderer renderer = new SOCRBubbleRenderer(dataset); // plot.setRenderer((XYItemRenderer)renderer); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setLegendItemLabelGenerator(new SOCRScaledBubbleSeriesLabelGenerator(zScale)); // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerMargin(0.15); domainAxis.setUpperMargin(0.15); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:org.jfree.chart.demo.ItemLabelDemo1.java
/** * Creates a sample chart.// w w w . j a v a 2s . c om * * @param dataset * the dataset. * @return the chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Item Label Demo 1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setUpperMargin(0.15); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setLabelGenerator(new LabelGenerator(50.0)); renderer.setItemLabelsVisible(true); return chart; }
From source file:org.openmrs.module.vcttrac.web.view.chart.EvolutionOfClientRegisteredPerDay.java
/** * @see org.openmrs.module.vcttrac.web.view.chart.AbstractChartView#createChart(java.util.Map, * javax.servlet.http.HttpServletRequest) *///from w ww .ja va2s.co m @Override protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) { String categoryAxisLabel = VCTTracUtil.getMessage("vcttrac.graph.evolution.yAxis.days", null); String valueAxisLabel = VCTTracUtil.getMessage("vcttrac.graph.evolution.xAxis.numberofclient", null); int numberOfDays = 7, dayFormat = 1; if (request.getParameter("graphCategory") != null) { if (request.getParameter("graphCategory").trim().compareTo("2") == 0) { Date d = new Date(); d.setDate(1); d.setMonth((new Date()).getMonth()); d.setYear((new Date()).getYear()); numberOfDays = (int) (((new Date()).getTime() - d.getTime()) / VCTTracConstant.ONE_DAY_IN_MILLISECONDS); categoryAxisLabel = VCTTracUtil.getMessage("vcttrac.month." + ((new Date()).getMonth() + 1), null); dayFormat = 2; } } String title = ""; title = VCTTracUtil.getMessage("vcttrac.graph.evolution.client.received", null); JFreeChart chart = ChartFactory.createLineChart(title, categoryAxisLabel, valueAxisLabel, createDataset(numberOfDays, dayFormat), // data PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setUpperMargin(0.15); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelsVisible(true); return chart; }
From source file:BubbleChartDemo.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { Connection conn = null;/*from www.j av a2 s. c om*/ Statement stmt = null; ResultSet rs = null; ResultSetMetaData rsm = null; OutputStream out = response.getOutputStream(); try { DefaultXYZDataset dataset = new DefaultXYZDataset(); double[] x = { 2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8 }; double[] y = { 14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25 }; double[] z = { 2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4 }; double[][] series = new double[][] { x, y, z }; dataset.addSeries("Series 1", series); JFreeChart chart = ChartFactory.createBubbleChart("Bubble Chart Demo 1", "X", "Y", dataset, PlotOrientation.HORIZONTAL, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerMargin(0.15); domainAxis.setUpperMargin(0.15); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); response.setContentType("image/png"); int width = 800; int height = 600; ChartUtilities.writeChartAsPNG(out, chart, width, height); } catch (Exception e) { throw new ServletException(e); } }
From source file:ch.zhaw.ias.dito.ui.util.BlockPlotPanel.java
public BlockPlotPanel(Matrix m, double lowerBound, double upperBound) { super(new BorderLayout()); NumberAxis xAxis = new NumberAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(1.0);//from w w w.j a v a2s. c o m xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(1.0); yAxis.setUpperMargin(0.0); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { XYZDataset xyzDataset = (XYZDataset) dataset; double x = xyzDataset.getXValue(series, item); double y = xyzDataset.getYValue(series, item); double z = xyzDataset.getZValue(series, item); return ("X=" + x + ", Y=" + y + ", Z=" + z); } }); PaintScale scale = new ColorPaintScale(lowerBound, upperBound); renderer.setPaintScale(scale); ValueAxis axis = new NumberAxis(); axis.setLowerBound(scale.getLowerBound()); axis.setUpperBound(scale.getUpperBound()); PaintScaleLegend legend = new PaintScaleLegend(scale, axis); legend.setMargin(new RectangleInsets(10, 10, 10, 10)); legend.setPosition(RectangleEdge.RIGHT); MatrixXYDataset dataset = new MatrixXYDataset(m); plot = new XYPlot(dataset, xAxis, yAxis, renderer); chart = new JFreeChart(plot); chart.removeLegend(); chart.addSubtitle(legend); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDisplayToolTips(true); this.add(chartPanel, BorderLayout.CENTER); }