List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:com.modeln.build.ctrl.charts.CMnPatchCountChart.java
/** * Create a chart representing the number patches grouped by time interval. * The data passed in the hashtable is a list of the time intervals and * the value is the number of patch requests for each interval. * * @param data Hashtable cnotaining the time intervals and corresponding counts * @param label Count label//from w w w.j a v a 2 s.c o m * * @return Bar chart representing the interval and count information */ public static final JFreeChart getPatchesByIntervalChart(Hashtable<CMnTimeInterval, Integer> data, String label) { JFreeChart chart = null; String title = "Patches per " + label; String nameLabel = label; String valueLabel = "Patches"; // Sort the data by date Vector<CMnTimeInterval> intervals = new Vector<CMnTimeInterval>(); Enumeration intervalList = data.keys(); while (intervalList.hasMoreElements()) { intervals.add((CMnTimeInterval) intervalList.nextElement()); } Collections.sort(intervals); // Populate the dataset with data DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Iterator keyIter = intervals.iterator(); while (keyIter.hasNext()) { CMnTimeInterval interval = (CMnTimeInterval) keyIter.next(); Integer value = data.get(interval); dataset.addValue(value, valueLabel, interval.getName()); } // Create the chart chart = ChartFactory.createBarChart(title, /*title*/ nameLabel, /*categoryAxisLabel*/ valueLabel, /*valueAxisLabel*/ dataset, /*dataset*/ PlotOrientation.VERTICAL, /*orientation*/ false, /*legend*/ false, /*tooltips*/ false /*urls*/ ); // get a reference to the plot for further customization... CategoryPlot plot = (CategoryPlot) chart.getPlot(); //chartFormatter.formatMetricChart(plot, "min"); // Set the chart colors plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // 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); renderer.setShadowVisible(false); final GradientPaint gp = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue); renderer.setSeriesPaint(0, gp); // Set the label orientation CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); return chart; }
From source file:org.jfree.chart.demo.AnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart(null, "Age in Months", "Weight (kg)", xydataset, PlotOrientation.VERTICAL, true, true, false); TextTitle texttitle = new TextTitle("Growth Charts: United States", new Font("SansSerif", 1, 14)); TextTitle texttitle1 = new TextTitle("Weight-for-age percentiles: boys, birth to 36 months", new Font("SansSerif", 0, 11)); jfreechart.addSubtitle(texttitle);//from w ww .j a v a 2 s .co m jfreechart.addSubtitle(texttitle1); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setUpperMargin(0.12D); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setAutoRangeIncludesZero(false); XYTextAnnotation xytextannotation = null; Font font = new Font("SansSerif", 0, 9); xytextannotation = new XYTextAnnotation("3rd", 36.5D, 11.76D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("5th", 36.5D, 12.039999999999999D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("10th", 36.5D, 12.493D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("25th", 36.5D, 13.313000000000001D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("50th", 36.5D, 14.33D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("75th", 36.5D, 15.478D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("90th", 36.5D, 16.641999999999999D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("95th", 36.5D, 17.408000000000001D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); xytextannotation = new XYTextAnnotation("97th", 36.5D, 17.936D); xytextannotation.setFont(font); xytextannotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xyplot.addAnnotation(xytextannotation); return jfreechart; }
From source file:org.jfree.chart.demo.BarChartDemo1.java
/** * Creates a sample chart./*from w w w. java 2 s .c o m*/ * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Performance: JFreeSVG vs Batik", null /* x-axis label*/, "Milliseconds" /* y-axis label */, dataset); chart.addSubtitle( new TextTitle("Time to generate 1000 charts in SVG " + "format (lower bars = better performance)")); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // ****************************************************************** // More than 150 demo applications are included with the JFreeChart // Developer Guide...for more information, see: // // > http://www.object-refinery.com/jfreechart/guide.html // // ****************************************************************** 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:graphs.LimitsGraphs.java
/** * Creates a sample chart.//from ww w. ja v a 2s . co m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Limits ..", // chart title "Metric", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.seniorproject.augmentedreality.test.LineChartDemo6.java
/** * Creates a chart.//from w w w. j a v a2s . c o m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 6", // chart title "X", // x axis label "Y", // 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, false); renderer.setSeriesShapesVisible(1, false); 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:br.upe.ecomp.dosa.controller.chart.FileLineChartDirectorManager.java
private JFreeChart createChart(String title, String xLabel, String yLabel, CategoryDataset dataset, boolean logarithmicYAxis) { // create the chart... final JFreeChart chart = ChartFactory.createLineChart("", // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );/*from w w w . j av a2s . com*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // legend.setShapeScaleX(1.5); // legend.setShapeScaleY(1.5); // legend.setDisplaySeriesLines(true); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); return chart; }
From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java
public static JFreeChart createWhiskerChart(SuccessfulAttack sa) { BoxAndWhiskerCategoryDataset boxandwhiskercategorydataset = createDataset(sa); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setMaximumBarWidth(0.05);/*from w w w . j a va 2 s.com*/ renderer.setMeanVisible(false); renderer.setSeriesPaint(0, Color.GREEN); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesPaint(2, Color.BLUE); NumberAxis numberAxis = new NumberAxis("duration in ms"); CategoryPlot categoryplot = new CategoryPlot(boxandwhiskercategorydataset, new CategoryAxis(""), numberAxis, renderer); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangePannable(true); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart jFreeChart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 14), categoryplot, true); jFreeChart.removeLegend(); return jFreeChart; }
From source file:net.nosleep.superanalyzer.analysis.views.PlayCountView.java
private void createChart() { _chart = ChartFactory.createXYBarChart(Misc.getString("PLAY_COUNT"), Misc.getString("PLAY_COUNT"), false, Misc.getString("NUMBER_OF_SONGS"), _dataset, PlotOrientation.VERTICAL, false, true, false); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("PLAY_COUNT_SUBTITLE"))); // then customise it a little... XYPlot plot = (XYPlot) _chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); plot.setForegroundAlpha(0.75f);/*from w ww.j ava2 s.c om*/ ChartUtilities.applyCurrentTheme(_chart); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); domainAxis.setLowerMargin(0); domainAxis.setUpperMargin(0); // domainAxis.setLowerBound(0); // domainAxis.setAutoRangeIncludesZero(true); // domainAxis.setAutoRangeStickyZero(true); Misc.formatChart(plot); renderer.setSeriesPaint(0, Theme.getColorSet()[1]); }
From source file:org.jfree.experimental.chart.axis.LogAxis.java
/** * Creates a new <code>LogAxis</code> with the given label. * /*from w ww .j a v a 2 s . com*/ * @param label the axis label (<code>null</code> permitted). */ public LogAxis(String label) { super(label, NumberAxis.createIntegerTickUnits()); setDefaultAutoRange(new Range(0.01, 1.0)); this.tickUnit = new NumberTickUnit(1.0); this.minorTickCount = 10; this.setTickMarksVisible(false); }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo2.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL, false, // !legendPanelOn, true, false);/* w ww. j a v a 2 s . c o m*/ // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // setXSummary(dataset); //X is time renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }