List of usage examples for org.jfree.chart.axis ValueAxis setStandardTickUnits
public void setStandardTickUnits(TickUnitSource source)
From source file:org.jfree.chart.demo.StackedBarChart3DDemo5.java
private static JFreeChart createChart(int i, CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedBarChart3D("Chart " + (i + 1), "Category", "Value", categorydataset, PlotOrientation.VERTICAL, false, false, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.getDomainAxis().setMaximumCategoryLabelLines(2); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = categoryplot.getRangeAxis(); valueaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:org.jfree.chart.demo.PlotOrientationDemo1.java
private static JFreeChart createChart(int i, XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Chart " + (i + 1), "X", "Y", xydataset, PlotOrientation.VERTICAL, false, false, 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); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ValueAxis valueaxis1 = xyplot.getRangeAxis(); valueaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:eu.kprod.gui.chart.MwChartFactory.java
public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) { final JFreeChart chart; chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true); chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); chart.setBorderVisible(false);/*w w w. j a va 2 s .com*/ final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final DateAxis axis = (DateAxis) plot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS")); axis.setAxisLineVisible(false); axis.setTickLabelsVisible(false); axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // force integer display final ValueAxis va = plot.getRangeAxis(); va.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // va.setRange(-280,280); // va.setFixedAutoRange(560); // va.setLowerBound(-280); // va.setUpperBound(280); // va.setAutoRange(false); va.setRangeWithMargins(-280, 280); final MwChartPanel chartPanel = new MwChartPanel(chart, conf); chartPanel.setMouseWheelEnabled(false); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); return chartPanel; }
From source file:org.multiwii.swingui.gui.chart.MwChartFactory.java
public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) { final JFreeChart chart; chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true); chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); chart.setBorderVisible(false);/*from ww w .j a v a 2 s . c o m*/ final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final DateAxis axis = (DateAxis) plot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS")); axis.setAxisLineVisible(false); axis.setTickLabelsVisible(false); axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // force integer display final ValueAxis va = plot.getRangeAxis(); va.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // va.setRange(-280,280); // va.setFixedAutoRange(560); // va.setLowerBound(-280); // va.setUpperBound(280); // va.setAutoRange(false); va.setRangeWithMargins(-280, 280); final MwChartPanel chartPanel = new MwChartPanel(chart, conf); chartPanel.setMouseWheelEnabled(false); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); return chartPanel; }
From source file:de.aidger.view.utils.Charts.java
/** * Creates a xy area chart./*from ww w . ja v a 2 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)); }
From source file:org.gephi.statistics.plugin.ChartUtils.java
public static void scaleChart(JFreeChart chart, XYSeries dSeries, boolean normalized) { XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(1.0);// w w w. j ava2 s . c o m domainAxis.setUpperMargin(1.0); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (normalized) { domainAxis.setRange(-0.05, 1.05); } else { domainAxis.setRange(dSeries.getMinX() - 1, dSeries.getMaxX() + 1); } NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(-0.1 * Math.sqrt(dSeries.getMaxY()), dSeries.getMaxY() + 0.1 * Math.sqrt(dSeries.getMaxY())); }
From source file:org.jfree.chart.demo.WaterfallChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createWaterfallChart("Product Cost Breakdown", "Expense Category", "Cost Per Unit", categorydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); categoryplot.setRangeGridlinesVisible(true); categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); ValueAxis valueaxis = categoryplot.getRangeAxis(); DecimalFormat decimalformat = new DecimalFormat("##,###"); decimalformat.setNegativePrefix("("); decimalformat.setNegativeSuffix(")"); TickUnits tickunits = new TickUnits(); tickunits.add(new NumberTickUnit(5D, decimalformat)); tickunits.add(new NumberTickUnit(10D, decimalformat)); tickunits.add(new NumberTickUnit(20D, decimalformat)); tickunits.add(new NumberTickUnit(50D, decimalformat)); tickunits.add(new NumberTickUnit(100D, decimalformat)); tickunits.add(new NumberTickUnit(200D, decimalformat)); tickunits.add(new NumberTickUnit(500D, decimalformat)); tickunits.add(new NumberTickUnit(1000D, decimalformat)); tickunits.add(new NumberTickUnit(2000D, decimalformat)); tickunits.add(new NumberTickUnit(5000D, decimalformat)); valueaxis.setStandardTickUnits(tickunits); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); barrenderer.setBase(5D);//from w w w . j a v a 2 s .c om DecimalFormat decimalformat1 = new DecimalFormat("$##,###.00"); decimalformat1.setNegativePrefix("("); decimalformat1.setNegativeSuffix(")"); barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat1)); barrenderer.setBaseItemLabelsVisible(true); return jfreechart; }
From source file:com.crunchify.jsp.servlet.BarServlet.java
public JFreeChart getChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(15, "1", "451"); dataset.addValue(12, "1", "851"); dataset.addValue(10, "2", "362"); dataset.addValue(5, "2", "142"); JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 3", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation false, // include legend true, false);//from w w w . j av a 2 s .c o m chart.setBackgroundPaint(Color.lightGray); // get a reference to the plot for further customisation... CategoryPlot plot = chart.getCategoryPlot(); plot.setNoDataMessage("NO DATA!"); CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }); renderer.setItemLabelsVisible(true); ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0); renderer.setPositiveItemLabelPosition(p); plot.setRenderer(renderer); // change the margin at the top of the range axis... ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:subterranean.crimson.server.graphics.graphs.LineChart.java
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createTimeSeriesChart("", "", "", dataset, false, false, false); XYPlot plot = result.getXYPlot();// ww w. j av a 2 s . c om plot.setDataset(1, new TimeSeriesCollection(s2)); plot.setBackgroundPaint(new Color(0x000000)); plot.setDomainGridlinesVisible(false); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinesVisible(false); plot.setRangeGridlinePaint(Color.lightGray); ValueAxis xaxis = plot.getDomainAxis(); xaxis.setAutoRange(true); xaxis.setFixedAutoRange(160000.0); // 160 seconds xaxis.setVerticalTickLabels(false); ValueAxis yaxis = plot.getRangeAxis(); yaxis.setAutoRange(true); yaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return result; }
From source file:org.evosuite.jenkins.plot.Plot.java
@Override protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, "Build Number #", this.yLabel, this.dataset, PlotOrientation.VERTICAL, true, true, true); chart.setBackgroundPaint(Color.WHITE); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0);/*from w w w . j a va2 s . c o m*/ domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); plot.setDomainAxis(domainAxis); plot.setBackgroundPaint(Color.WHITE); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //yAxis.setRange(0.0, 100.0); URLAndTooltipRenderer urlRenderer = new URLAndTooltipRenderer(this.project.getProject()); ColorPalette.apply(urlRenderer); plot.setRenderer(urlRenderer); return chart; }