List of usage examples for org.jfree.chart.axis NumberAxis setLowerMargin
public void setLowerMargin(double margin)
From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java
private static JFreeChart createTsChart() { XYPlot plot = new XYPlot(); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); DateAxis domainAxis = new DateAxis(); domainAxis.setTickLabelsVisible(false); domainAxis.setLowerMargin(0.02);//from www . j a v a2 s .c o m domainAxis.setUpperMargin(0.02); plot.setDomainAxis(domainAxis); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setTickLabelsVisible(false); rangeAxis.setLowerMargin(0.02); rangeAxis.setUpperMargin(0.02); plot.setRangeAxis(rangeAxis); JFreeChart result = new JFreeChart("", null, plot, true); result.setPadding(new RectangleInsets(5, 5, 5, 5)); result.getLegend().setFrame(BlockBorder.NONE); result.getLegend().setBackgroundPaint(null); return result; }
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
/** * DOC xqliu Comment method "createStackedBarChart". * /*from w w w .ja va 2 s . com*/ * @param title * @param domainAxisLabel * @param rangeAxisLabel * @param dataset * @param orientation * @param legend * @param tooltips * @param urls * @return */ public static JFreeChart createStackedBarChart(String title, String domainAxisLabel, String rangeAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { // ADD msjian TDQ-5112 2012-4-10: after upgrate to jfreechart-1.0.12.jar, change the default chart wallPaint ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); // TDQ-5112~ final JFreeChart chart = ChartFactory.createStackedBarChart(title, domainAxisLabel, rangeAxisLabel, dataset, orientation, legend, tooltips, urls); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeGridlinesVisible(true); StackedBarRenderer sbr = (StackedBarRenderer) plot.getRenderer(); sbr.setBaseItemLabelsVisible(true); sbr.setRenderAsPercentages(true); sbr.setBaseItemLabelGenerator(new DQRuleItemLabelGenerator("{3}", NumberFormat.getIntegerInstance())); //$NON-NLS-1$ sbr.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); // ADD xqliu 2010-03-10 feature 10834 // sbr.setBaseToolTipGenerator(new DQRuleToolTipGenerator(ChartDecorator.NEW_TOOL_TIP_FORMAT_STRING, // NumberFormat // .getInstance())); // ~10834 // ADD TDQ-5251 msjian 2012-7-31: do not display the shadow sbr.setShadowVisible(false); // TDQ-5251~ NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setNumberFormatOverride(NumberFormat.getPercentInstance()); axis.setUpperMargin(0.05f); axis.setLowerMargin(0.01f); return chart; }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.CoberturaTimeChartStrategy.java
public NumberAxis getRangeAxis() { NumberAxis valueaxis = new NumberAxis(); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.099D);/*from ww w . j a v a 2 s . c om*/ 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
/** * /*w w w . ja v a2 s.c o m*/ */ 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 w w .ja v a 2 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:edu.ucla.stat.SOCR.chart.demo.BubbleChartDemo1.java
/** * Creates a chart./*from w ww .j a v a2s . c o m*/ * * @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:BubbleChartDemo.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { Connection conn = null;//from www . jav a2 s . c o m 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); xAxis.setUpperMargin(0.0);//from w ww . j av a 2 s .c o m 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); }
From source file:org.jfree.chart.demo.WaterfallChartDemo2.java
/** * Returns the chart.// www .j a va 2s .c om * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final CategoryAxis xAxis = new CategoryAxis("Category"); final NumberAxis yAxis = new NumberAxis("$ in Thousands"); yAxis.setLowerMargin(0.10); yAxis.setUpperMargin(0.10); // create a custom tick unit collection... final DecimalFormat formatter = new DecimalFormat("##,###"); formatter.setNegativePrefix("("); formatter.setNegativeSuffix(")"); final TickUnits standardUnits = new TickUnits(); standardUnits.add(new NumberTickUnit(200, formatter)); standardUnits.add(new NumberTickUnit(500, formatter)); standardUnits.add(new NumberTickUnit(1000, formatter)); standardUnits.add(new NumberTickUnit(2000, formatter)); standardUnits.add(new NumberTickUnit(5000, formatter)); yAxis.setStandardTickUnits(standardUnits); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** final DecimalFormat labelFormatter = new DecimalFormat("##,###"); labelFormatter.setNegativePrefix("("); labelFormatter.setNegativeSuffix(")"); final WaterfallBarRenderer renderer = new WaterfallBarRenderer(); // renderer.setLabelGenerator( // new StandardCategoryLabelGenerator("{2}", labelFormatter) // ); renderer.setItemLabelsVisible(Boolean.TRUE); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); final ValueMarker baseline = new ValueMarker(0.0); baseline.setPaint(Color.blue); baseline.setStroke(new BasicStroke(1.1f)); plot.addRangeMarker(baseline, Layer.FOREGROUND); final JFreeChart chart = new JFreeChart("OM WaterFall Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(Color.white); return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperBubbleChart.java
/** * Creates a chart./*from w w w . jav a 2 s . co m*/ * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(XYZDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBubbleChart(chartTitle, // chart titl rangeLabel, // y axis label domainLabel, // x axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setLegendItemLabelGenerator(new SOCRXYZSeriesLabelGenerator()); // 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; }