List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:org.jfree.chart.demo.MouseOverDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Mouseover Demo 1", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); MyBarRenderer mybarrenderer = new MyBarRenderer(); mybarrenderer.setDrawBarOutline(true); categoryplot.setRenderer(mybarrenderer); ChartUtilities.applyCurrentTheme(jfreechart); 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)); mybarrenderer.setSeriesPaint(0, gradientpaint); mybarrenderer.setSeriesPaint(1, gradientpaint1); mybarrenderer.setSeriesPaint(2, gradientpaint2); return jfreechart; }
From source file:CargarEntrenamiento.grafica2.java
private void configurarRangeAxis(NumberAxis rangeAxis) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setTickUnit(new NumberTickUnit(2)); rangeAxis.setRange(0, 100);//from w w w .j a v a2 s. com }
From source file:com.cs572.assignments.Project2.view.LineChartPanel.java
/** * Creates a chart.//from w ww . ja v a2 s . co 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("Expression Tree", // chart title "DataPoints", // x axis label "Output", // 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.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(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:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL,// ww w .j a va 2s . c om // !legendPanelOn, false, // no legend true, false); // 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()); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:org.jfree.chart.demo.selection.SelectionDemo5Category.java
private static JFreeChart createChart(CategoryDataset dataset, DatasetSelectionExtension<CategoryCursor<String, String>> ext) { // create the chart... JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 1", "Category", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainGridlinesVisible(true); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairPaint(Color.blue); // 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);/*from w w w .j a v a 2 s .co m*/ // 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)); 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); renderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); //add selection specific rendering IRSUtilities.setSelectedItemPaint(renderer, ext, Color.WHITE); //register plot as selection change listener ext.addChangeListener(plot); return chart; }
From source file:org.esa.s1tbx.insar.rcp.toolviews.insar_statistics.StatESDMeasure.java
public void update(final Product product) { try {/* ww w . j a va2 s. co m*/ if (InSARStatisticsTopComponent.isValidProduct(product) && readESDMeasure(product)) { setVisible(true); dataset.removeAllSeries(); int i = 0; for (String subswath : esdData.keySet()) { final XYSeries series = new XYSeries(subswath); final Map<Integer, Double> values = esdData.get(subswath); for (Integer burst : values.keySet()) { series.add(burst + 1, values.get(burst)); } dataset.addSeries(series); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, true); chart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ++i; } } else { setVisible(false); } } catch (Exception e) { SnapApp.getDefault().handleError("Unable to update product", e); } }
From source file:org.jfree.chart.demo.selection.SelectionDemo4.java
/** * Creates a chart.// w w w .j a v a 2 s. c o m * * @param dataset a dataset. * * @return The chart. */ private static JFreeChart createChart(IntervalXYDataset dataset, DatasetSelectionExtension<XYCursor> ext) { JFreeChart chart = ChartFactory.createHistogram("SelectionDemo4", null, null, dataset); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setForegroundAlpha(0.85f); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(true); renderer.setDefaultOutlinePaint(Color.red); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); //add selection specific rendering IRSUtilities.setSelectedItemPaint(renderer, ext, Color.white); //register plot as selection change listener ext.addChangeListener(plot); return chart; }
From source file:com.mergano.core.GraphChart.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart("Revenue", "Monthly", "Amount", dataset, PlotOrientation.VERTICAL, false, true, false); // 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.white); 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()); rangeAxis.setUpperMargin(0.15);//from w w w .j a va 2 s.co m // disable bar outlines... final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperNormalDistributionChart.java
/** * Creates a chart.//from w w w. j a va2 s . c o m * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:hudson.plugins.testlink.TestLinkGraph.java
/** * Creates TestLink trend graph.//from w w w . ja v a 2s . co m * * @return the JFreeChart graph object. */ protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, null, yLabel, categoryDataset, PlotOrientation.VERTICAL, true, true, false); final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.8f); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.darkGray); final CategoryAxis domainAxis = new ShiftedCategoryAxis(xLabel); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); plot.setDomainAxis(domainAxis); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRange(true); rangeAxis.setAutoRangeMinimumSize(5); rangeAxis.setLowerBound(0); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(0, new Color(35, 20, 89)); renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(1, new Color(0, 145, 0)); renderer.setSeriesStroke(2, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(2, new Color(207, 69, 21)); renderer.setSeriesStroke(3, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(3, Color.orange); plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }