List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:org.squale.squaleweb.util.graph.BarMaker.java
/** * @return le diagramme JFreeChart/*ww w. j a va2 s. com*/ */ protected JFreeChart getChart() { JFreeChart retChart = super.getChart(); if (null == retChart) { retChart = ChartFactory.createBarChart3D(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = retChart.getCategoryPlot(); // Les valeurs sont des entiers final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // On effectue une rotation de 90 pour afficher le titre des abscisses la verticale CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0)); super.setChart(retChart); } return retChart; }
From source file:org.webcat.grader.graphs.SubmissionCountChart.java
@Override protected JFreeChart generateChart(WCChartTheme chartTheme) { JFreeChart chart = super.generateChart(chartTheme); NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:org.mili.jmibs.jfree.JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer.java
private JFreeChart createChart(String title, CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(title, "Benchmark (Iteration/Object Loading)", "Time in ns", dataset, PlotOrientation.HORIZONTAL, true, true, false); 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);/*from w w w .j a v a 2 s . c o m*/ 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)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:org.btrg.df.betterologist.swingui.ProjectJobSchedulingPanel.java
private JFreeChart createChart(Schedule schedule) { YIntervalSeriesCollection seriesCollection = new YIntervalSeriesCollection(); Map<Project, YIntervalSeries> projectSeriesMap = new LinkedHashMap<Project, YIntervalSeries>( schedule.getProjectList().size()); YIntervalRenderer renderer = new YIntervalRenderer(); int maximumEndDate = 0; int seriesIndex = 0; for (Project project : schedule.getProjectList()) { YIntervalSeries projectSeries = new YIntervalSeries(project.getLabel()); seriesCollection.addSeries(projectSeries); projectSeriesMap.put(project, projectSeries); renderer.setSeriesShape(seriesIndex, new Rectangle()); renderer.setSeriesStroke(seriesIndex, new BasicStroke(3.0f)); seriesIndex++;/*w w w .jav a 2 s .c o m*/ } for (Allocation allocation : schedule.getAllocationList()) { int startDate = allocation.getStartDate(); int endDate = allocation.getEndDate(); YIntervalSeries projectSeries = projectSeriesMap.get(allocation.getProject()); projectSeries.add(allocation.getId(), (startDate + endDate) / 2.0, startDate, endDate); maximumEndDate = Math.max(maximumEndDate, endDate); } NumberAxis domainAxis = new NumberAxis("Job"); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-0.5, schedule.getAllocationList().size() - 0.5); domainAxis.setInverted(true); NumberAxis rangeAxis = new NumberAxis("Day (start to end date)"); rangeAxis.setRange(-0.5, maximumEndDate + 0.5); XYPlot plot = new XYPlot(seriesCollection, domainAxis, rangeAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); return new JFreeChart("Project Job Scheduling", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:sanger.team16.gui.genevar.eqtl.snp.RegionalLinePlot.java
private JFreeChart createChart(String chromosome, int position, int distance, double threshold, XYDataset dataset) {/* www . j av a2s. c om*/ JFreeChart chart = ChartFactory.createXYLineChart(null, "Position on chromosome " + chromosome + " (bp)", "-log10(P)", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); //renderer.setShapesFilled(false); //CHANGED 12/12/11 // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); /* XYItemRenderer renderer = plot.getRenderer(); int size = dataset.getSeriesCount(); for (int i=0 ; i<size ; i++) { //renderer.setSeriesPaint(i, new Color(255, 0, 0)); renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3)); renderer.setBaseSeriesVisibleInLegend(false); } */ ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold)); upperMarker.setPaint(Color.gray); float[] f = { 4, 3, 4, 3 }; upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f)); plot.addRangeMarker(upperMarker); ValueMarker marker = new ValueMarker(0.0); marker.setPaint(Color.lightGray); plot.addRangeMarker(marker); XYSeries series = new XYSeries("Range"); series.add(position - distance, -0.05); series.add(position + distance, -0.05); ((XYSeriesCollection) dataset).addSeries(series); renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false); return chart; }
From source file:logica_controladores.controlador_estadistica.java
private static void configurarDomainAxis(NumberAxis domainAxis, Inventario inventario) { domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setTickUnit(new NumberTickUnit(20)); domainAxis.setRange(inventario.getOrden_min(), inventario.getOrden_max()); }
From source file:org.jfree.chart.demo.ThumbnailDemo1.java
private static JFreeChart createChart1(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo 1", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); 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:com.mergano.core.AreaChart.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createAreaChart("Order statistic", // chart title "Days", // domain axis label "Order Average", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips false // urls );//from w ww .j a v a2 s.co m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setAnchor(StandardLegend.SOUTH); chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); CategoryPlot plot = chart.getCategoryPlot(); plot.getRenderer().setSeriesPaint(0, new Color(0, 191, 165)); plot.setForegroundAlpha(0.75f); plot.setBackgroundPaint(Color.white); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); // disable this plot.setDomainGridlinesVisible(false); plot.setDomainGridlinePaint(new Color(240, 240, 240)); plot.setRangeGridlinesVisible(false); plot.setRangeGridlinePaint(new Color(240, 240, 240)); plot.setDomainCrosshairPaint(Color.MAGENTA); plot.setRangeCrosshairPaint(Color.CYAN); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.addCategoryLabelToolTip("Type 1", "The first type."); domainAxis.addCategoryLabelToolTip("Type 2", "The second type."); domainAxis.addCategoryLabelToolTip("Type 3", "The third type."); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelAngle(0 * Math.PI / 2.0); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.BarChart.java
@Override protected JFreeChart createGraph() { CategoryDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createBarChart(graphTitle, "", "Number of failures", dataset, PlotOrientation.HORIZONTAL, false, false, false); NumberAxis domainAxis = new NumberAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeAxis(domainAxis);//from www.jav a2 s .c o m BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setMaximumBarWidth(MAX_BAR_WIDTH); return chart; }
From source file:de.aidger.view.utils.Charts.java
/** * Creates a xy area chart.// w w w.j a v a2 s . c o m * * @param title * the diagram title * @param dataset * the dataset. * @param width * the width of the chart as image * @param height * the height of the chart as image * @return the xy area chart as image */ public static ImageIcon createXYAreaChart(String title, XYDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createXYAreaChart(title, "", "", dataset, PlotOrientation.VERTICAL, false, false, false); Font titleFont = UIManager.getFont("TitledBorder.font"); chart.setBackgroundPaint(null); chart.getTitle().setFont(new Font(titleFont.getName(), titleFont.getStyle(), 14)); chart.getTitle().setPaint(UIManager.getColor("TitledBorder.titleColor")); chart.setBorderPaint(null); XYPlot plot = chart.getXYPlot(); plot.setInsets(new RectangleInsets(10, 1, 5, 1)); plot.setBackgroundPaint(null); plot.setOutlineVisible(false); plot.setNoDataMessage(_("No data to display.")); ValueAxis domainAxis = new DateAxis(); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setTickLabelFont(UIManager.getFont("RootPane.font")); ValueAxis rangeAxis = new NumberAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setDomainAxis(domainAxis); plot.setRangeAxis(rangeAxis); plot.setForegroundAlpha(0.5f); return new ImageIcon(chart.createBufferedImage(width, height)); }