List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:org.jfree.chart.demo.BoxAndWhiskerChartDemo2.java
private static JFreeChart createChart(BoxAndWhiskerXYDataset boxandwhiskerxydataset) { DateAxis dateaxis = new DateAxis("Day"); NumberAxis numberaxis = new NumberAxis("Value"); XYBoxAndWhiskerRenderer xyboxandwhiskerrenderer = new XYBoxAndWhiskerRenderer(); XYPlot xyplot = new XYPlot(boxandwhiskerxydataset, dateaxis, numberaxis, xyboxandwhiskerrenderer); xyplot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart jfreechart = new JFreeChart("Box-and-Whisker Chart Demo 2", xyplot); jfreechart.setBackgroundPaint(Color.white); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setDomainGridlinesVisible(true); xyplot.setRangeGridlinePaint(Color.white); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:org.jfree.chart.demo.BarChartDemo11.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Open Source Projects By Licence", "Licence", "Project Count", categorydataset, PlotOrientation.HORIZONTAL, false, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeGridlinePaint(Color.white); categoryplot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.4F); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); barrenderer.setSeriesPaint(0, gradientpaint); return jfreechart; }
From source file:org.matsim.contrib.util.timeprofile.TimeProfileCharts.java
public static JFreeChart chartProfile(DefaultTableXYDataset dataset, ChartType type) { JFreeChart chart;/*w w w . j a v a2 s . co m*/ switch (type) { case Line: chart = ChartFactory.createXYLineChart("TimeProfile", "Time [h]", "Values", dataset, PlotOrientation.VERTICAL, true, false, false); break; case StackedArea: chart = ChartFactory.createStackedXYAreaChart("TimeProfile", "Time [h]", "Values", dataset, PlotOrientation.VERTICAL, true, false, false); break; default: throw new IllegalArgumentException(); } XYPlot plot = chart.getXYPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setBackgroundPaint(Color.white); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRange(true); XYItemRenderer renderer = plot.getRenderer(); for (int s = 0; s < dataset.getSeriesCount(); s++) { renderer.setSeriesStroke(s, new BasicStroke(2)); } return chart; }
From source file:org.jfree.chart.demo.AxisOffsetsDemo1.java
private static JFreeChart createChart(String s, CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart(s, "Category", "Value", categorydataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); return jfreechart; }
From source file:no.imr.sea2data.guibase.chart.XYBarChart.java
public XYBarChart() { dataset = new XYSeriesCollection(new XYSeries("Series 1")); JFreeChart chart = ChartFactory.createXYBarChart("", "X axis", false, "Y axis", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); chart.getTitle().setPaint(Color.black); chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, 12)); chart.addSubtitle(trendLegend);/* w ww .j a va2s.co m*/ chart.addSubtitle(trendLegend2); trendLegend.setPosition(RectangleEdge.TOP); trendLegend2.setPosition(RectangleEdge.TOP); plot = (XYPlot) chart.getPlot(); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setShadowVisible(false); chartPanel = new ChartPanel(chart); plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); }
From source file:playground.thibautd.utils.charts.XYChartUtils.java
/** * Sets the X axis of an XYPlot chart to a {@link NumberAxis} * with integer values.//from www .j a v a 2 s. c o m */ public static void integerYAxis(final JFreeChart chart) { ValueAxis axis = (chart.getXYPlot()).getRangeAxis(); NumberAxis numberAxis; if (axis instanceof NumberAxis) { numberAxis = (NumberAxis) axis; } else { numberAxis = new NumberAxis(); (chart.getXYPlot()).setRangeAxis(numberAxis); } numberAxis.setTickUnit((NumberTickUnit) NumberAxis.createIntegerTickUnits().getCeilingTickUnit(1d)); numberAxis.setAutoRangeIncludesZero(false); }
From source file:com.hello2morrow.sonargraph.jenkinsplugin.model.XYLineAndShapePlot.java
@Override protected void applyRendering(XYPlot plot) { NumberAxis axis = (NumberAxis) plot.getDomainAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesPaint(0, DATA_COLOR); //Unfortunately, the tooltips are not visible, when the graph gets rendered as a PNG StandardXYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator() { private static final long serialVersionUID = -5803780142385784897L; @Override/*from w w w.j a v a 2s . com*/ public String generateToolTip(XYDataset dataset, int series, int item) { return new StringBuilder(BUILD).append(dataset.getXValue(series, item)).append(COLON) .append(dataset.getYValue(series, item)).toString(); } }; renderer.setBaseToolTipGenerator(toolTipGenerator); }
From source file:org.jfree.chart.demo.CategoryStepChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { CategoryStepRenderer categorysteprenderer = new CategoryStepRenderer(true); categorysteprenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); CategoryAxis categoryaxis = new CategoryAxis("Category"); NumberAxis numberaxis = new NumberAxis("Value"); CategoryPlot categoryplot = new CategoryPlot(categorydataset, categoryaxis, numberaxis, categorysteprenderer);/*www.ja v a 2 s. c o m*/ JFreeChart jfreechart = new JFreeChart("Category Step Chart", categoryplot); jfreechart.setBackgroundPaint(Color.white); categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinesVisible(true); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinesVisible(true); categoryplot.setRangeGridlinePaint(Color.white); categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); categoryaxis.setLowerMargin(0.0D); categoryaxis.setUpperMargin(0.0D); categoryaxis.addCategoryLabelToolTip("Type 1", "The first type."); categoryaxis.addCategoryLabelToolTip("Type 2", "The second type."); categoryaxis.addCategoryLabelToolTip("Type 3", "The third type."); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setLabelAngle(0.0D); return jfreechart; }
From source file:gui.MainForm.java
private static JFreeChart create_AMS_DATA_Chart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("AMS??", "", "??", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeCrosshairVisible(true); categoryplot.setRangeCrosshairPaint(Color.blue); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:org.sonar.plugins.core.charts.DistributionAreaChart.java
@Override protected Plot getPlot(ChartParameters params) { DefaultCategoryDataset dataset = createDataset(params); CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setCategoryMargin(0.0);//w w w . ja v a 2s . co m domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setNumberFormatOverride(NumberFormat.getIntegerInstance(params.getLocale())); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); AreaRenderer renderer = new AreaRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); plot.setForegroundAlpha(0.5f); plot.setDomainGridlinesVisible(true); configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); return plot; }