List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.AbstractRequirementStatistics.java
protected JFreeChart buildBarChart(final String title, final String category, final String axisLabel) { final JFreeChart chart = ChartFactory.createBarChart(title, category, axisLabel, toCategoryDataset(category), PlotOrientation.VERTICAL, true, false, false); final CategoryPlot xyPlot = (CategoryPlot) chart.getPlot(); final NumberAxis range = (NumberAxis) xyPlot.getRangeAxis(); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:org.jfree.chart.demo.BarChartDemo10.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, 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); 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); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:org.jfree.chart.demo.SubCategoryAxisDemo1.java
private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("SubCategoryAxis Demo 1", "Category", "Value", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); SubCategoryAxis subCategoryAxis = new SubCategoryAxis(null); subCategoryAxis.addSubCategory("S1"); subCategoryAxis.addSubCategory("S2"); subCategoryAxis.addSubCategory("S3"); plot.setDomainAxis(subCategoryAxis); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false);//from w w w.j a v a 2 s . co m GradientPaint gradientpaint0 = 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)); renderer.setSeriesPaint(0, gradientpaint0); renderer.setSeriesPaint(1, gradientpaint1); renderer.setSeriesPaint(2, gradientpaint2); return chart; }
From source file:edu.wustl.cab2b.client.ui.visualization.charts.LineChart.java
protected JFreeChart createChart(Dataset dataset) { XYDataset xyDataset = (XYDataset) dataset; JFreeChart jfreechart = ChartFactory.createXYLineChart("Line Chart", "X", "Y", xyDataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setShapesVisible(true); xylineandshaperenderer.setShapesFilled(true); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:com.ouc.cpss.view.ProfitChartBuilder.java
public static JFreeChart createJFreeChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createLineChart("?", "", "?", dataset, PlotOrientation.VERTICAL, true, true, false); // ?/*from www . j a v a 2s . c om*/ LegendTitle legendTitle = chart.getLegend(0); // legendTitle.setItemFont(new Font("", Font.BOLD, 18)); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // ? org.jfree.chart.axis.CategoryAxis categoryAxis = plot.getDomainAxis(); // categoryAxis.setLabelFont(new Font("", Font.BOLD, 18)); // categoryAxis.setTickLabelFont(new Font("", Font.BOLD, 12)); // ? NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); // numberAxis.setLabelFont(new Font("", Font.BOLD, 14)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());// CategoryItemRenderer xylineandshaperenderer = plot.getRenderer(); xylineandshaperenderer.setBaseItemLabelsVisible(true); xylineandshaperenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE2, TextAnchor.BASELINE_RIGHT)); xylineandshaperenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); return chart; }
From source file:org.jfree.chart.demo.CrosshairDemo4.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Crosshair Demo 4", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:org.jfree.chart.demo.DeviationRendererDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart chart = ChartFactory.createXYLineChart("DeviationRenderer - Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); //A specialised subclass of the {@link XYLineAndShapeRenderer} that requires // an {@link IntervalXYDataset} and represents the y-interval by shading an // area behind the y-values on the chart. DeviationRenderer renderer = new DeviationRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); renderer.setSeriesFillPaint(0, new Color(255, 200, 200)); renderer.setSeriesFillPaint(1, new Color(200, 200, 255)); plot.setRenderer(renderer);/*w ww .j a v a 2 s . c o m*/ // NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setAutoRangeIncludesZero(false); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:org.shredzone.bullshitcharts.chart.BarChartGenerator.java
@Override public Plot generate() { LineDatasetCreator dataset = new LineDatasetCreator(); dataset.setTendency(getTendency());/* ww w.j a v a 2s.c om*/ dataset.setNumberOfValues(getResolution()); dataset.setAmplitude(getAmplitude()); CategoryAxis catAxis = new CategoryAxis(getValue("x", "Time")); // TODO: i18n catAxis.setLowerMargin(0.0d); catAxis.setUpperMargin(0.0d); catAxis.setTickMarksVisible(false); catAxis.setTickLabelsVisible(false); ValueAxis valAxis = new NumberAxis(getValue("y", "Value")); valAxis.setRange(new Range(0.0d, 1.05d)); valAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); valAxis.setTickMarksVisible(false); valAxis.setTickLabelsVisible(false); BarRenderer3D renderer = new BarRenderer3D(); CategoryPlot plot = new CategoryPlot(dataset.generate(), catAxis, valAxis, renderer); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return plot; }
From source file:userInterface.cdcRole.OverviewJPanel.java
private static JFreeChart createChart1(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Distribution of Vaccines", "Vaccine", "Quantity", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeCrosshairVisible(true); categoryplot.setRangeCrosshairPaint(Color.green); 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.green, 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.cerberus.refactor.LineChart.java
public BufferedImage bi(CategoryDataset categorydataset, String name, int count) { BufferedImage bi = null;/*from ww w .j av a 2 s . c om*/ JFreeChart jfreechart = ChartFactory.createLineChart(name, "Category", "Count", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); Shape point = ShapeUtilities.createDiagonalCross(1, 1); //TODO check this - seriesColors never used // String[] seriesColors = {"#FF0000", "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01"}; // String[] seriesColors2 = {"#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01"}; LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setBaseShapesVisible(true); lineandshaperenderer.setBaseShapesFilled(true); for (int a = 0; a < count; a++) { lineandshaperenderer.setSeriesShapesVisible(a, true); lineandshaperenderer.setSeriesLinesVisible(a, true); lineandshaperenderer.setSeriesStroke(a, new BasicStroke(1.0F)); lineandshaperenderer.setSeriesShape(a, point); } lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); //DateAxis dateaxis = (DateAxis)xyplot.getDomainAxis(); //dateaxis.setDateFormatOverride(new SimpleDateFormat("hh:mm")); bi = jfreechart.createBufferedImage(500, 270); return bi; }