List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:org.jfree.graphics2d.demo.SVGBarChartDemo1.java
/** * Creates a sample chart./*from ww w . ja v a 2s . c om*/ * * @param dataset a dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", "Type", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setDrawBarOutline(false); renderer.setErrorIndicatorPaint(Color.black); renderer.setIncludeBaseInRange(false); plot.setRenderer(renderer); // ensure the current theme is applied to the renderer just added ChartUtilities.applyCurrentTheme(chart); renderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setDefaultItemLabelsVisible(true); renderer.setDefaultItemLabelPaint(Color.yellow); renderer.setDefaultPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER)); // set up gradient paints for series... 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)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); return chart; }
From source file:demo.BarChartDemo11.java
/** * Creates a sample chart./*from www . ja v a 2 s .co m*/ * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart("Open Source Projects By License", "License", "Percent", dataset); chart.removeLegend(); TextTitle source = new TextTitle( "Source: http://www.blackducksoftware.com/resources/data/top-20-licenses (as at 30 Aug 2013)", new Font("Dialog", Font.PLAIN, 9)); source.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(source); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setDomainGridlinesVisible(true); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.8f); // 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); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator("{1}: {2} percent", new DecimalFormat("0")); renderer.setBaseToolTipGenerator(tt); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.BLUE, 0.0f, 0.0f, new Color(0, 0, 64)); renderer.setSeriesPaint(0, gp0); return chart; }
From source file:edu.ucsd.hep.slhaviewer.view.MassGraphPanel.java
public MassGraphPanel() { this.setLayout(new BorderLayout()); dataset = new XYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart("Mass Spectrum", "", "mass [GeV]", dataset, PlotOrientation.VERTICAL, false, // no legend true, // add tooltips false // add urls );// w ww.ja v a 2 s.co m // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setTickMarksVisible(false); domainAxis.setTickLabelsVisible(false); chart.setBackgroundPaint(Color.WHITE); // 'outside' plot.setBackgroundPaint(Color.WHITE); // 'inside' plot.setRangeGridlinePaint(Color.DARK_GRAY); this.add(new ChartPanel(chart), BorderLayout.CENTER); }
From source file:uom.research.thalassemia.util.BarChartCreator.java
/** * Creates a sample chart./*ww w . j a va2s . co m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(mainTitle, xTitle, yTitle, dataset); chart.addSubtitle(new TextTitle(subTitle)); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); chart.getLegend().setFrame(BlockBorder.NONE); return chart; }
From source file:org.altusmetrum.altosuilib_2.AltosUIAxis.java
public AltosUIAxis(String label, AltosUnits units, Color color, int index, int flags) { this.label = label; this.units = units; this.index = index; this.visible = 0; this.ref = 0; setLabelPaint(color);// ww w . j a va2 s . c om setTickLabelPaint(color); setVisible(false); if ((flags & axis_integer) != 0) setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setAutoRangeIncludesZero((flags & axis_include_zero) != 0); }
From source file:no.ntnu.mmfplanner.ui.graph.SaNpvChart.java
/** * Creates the chart//from ww w . j av a 2s . co m */ private void createChart() { JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title "Period", // x axis label "Discounted Cash", // y axis label null, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setChart(chart); setMouseZoomable(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLegendLine(new Rectangle2D.Double(0.0, 0.0, 6.0, 0.0)); renderer.setUseFillPaint(true); // the x=0 line renderer.setSeriesPaint(0, Color.GRAY); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesVisibleInLegend(0, new Boolean(false)); plot.setRenderer(renderer); }
From source file:richclient.EvolutionChart.java
/** * Creates a chart./*from w w w . j a v a 2 s. c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ public JFreeChart createChart(XYDataset dataset) { // create the chart final JFreeChart chart = ChartFactory.createXYLineChart("Market evolution", // chart title "Time", // x axis label "Value", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(1, true); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createCultureTagChart() { JFreeChart chart = ChartFactory.createXYLineChart("Culture Tag Time Series", "Time", "Fraction Blue", model.culture_tag_coll, PlotOrientation.VERTICAL, true, true, false); model.culture_tag_chart = chart;// w w w . j av a2 s .c o m NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.boxcharts.SimpleBox.java
public JFreeChart createChart(DatasetMap datasetMap) { BoxAndWhiskerCategoryDataset dataset = (BoxAndWhiskerCategoryDataset) datasetMap.getDatasets().get("1"); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(name, categoryLabel, valueLabel, dataset, false); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title);/* w w w . j a v a 2 s . c om*/ if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } CategoryPlot plot = (CategoryPlot) chart.getPlot(); BoxAndWhiskerRenderer renderer = (BoxAndWhiskerRenderer) plot.getRenderer(); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(new Color(Integer.decode("#c0c0c0").intValue())); plot.setDomainGridlinePaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); renderer.setFillBox(true); renderer.setArtifactPaint(Color.BLACK); renderer.setSeriesPaint(0, new Color(Integer.decode("#0000FF").intValue())); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(min, max); return chart; }
From source file:com.pasi.pdfbox.Main.java
private static JFreeChart createBarChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(7445, "JFreeSVG", "Warm-up"); dataset.addValue(24448, "Batik", "Warm-up"); dataset.addValue(4297, "JFreeSVG", "Test"); dataset.addValue(21022, "Batik", "Test"); JFreeChart chart = ChartFactory.createBarChart("Performance: JFreeSVG vs Batik", null /* x-axis label*/, "Milliseconds" /* y-axis label */, dataset); chart.addSubtitle(/*from w ww . j av a 2 s .c o m*/ new TextTitle("Time to generate 1000 charts in SVG " + "format (lower bars = better performance)")); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); chart.getLegend().setFrame(BlockBorder.NONE); return chart; }