List of usage examples for org.jfree.chart.axis NumberAxis setStandardTickUnits
public void setStandardTickUnits(TickUnitSource source)
From source file:com.wattzap.view.graphs.DistributionGraph.java
public DistributionGraph(ArrayList<Telemetry> telemetry[], DistributionAccessor da, String domainLabel, int scale) { super();/* w w w . java 2 s . co m*/ this.telemetry = telemetry; this.da = da; // create the chart... JFreeChart chart = ChartFactory.createBarChart("", domainLabel, // domain // axis // label "Time %", // range axis label null, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? ); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... plot = (CategoryPlot) chart.getPlot(); // 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); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.gray, 0.0f, 0.0f, new Color(0, 0, 64)); renderer.setSeriesPaint(0, gp0); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. chartPanel = new ChartPanel(chart); chartPanel.setSize(100, 800); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); setLayout(new BorderLayout()); add(chartPanel, BorderLayout.CENTER); BucketPanel bucketPanel = new BucketPanel(this, scale); add(bucketPanel, BorderLayout.SOUTH); setBackground(Color.black); chartPanel.revalidate(); setVisible(true); }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo4.java
/** * Creates a sample chart./* w w w .j a v a 2 s. c o m*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(new Color(0xBBBBDD)); // get a reference to the plot for further customisation... CategoryPlot plot = chart.getCategoryPlot(); // 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.setMaximumBarWidth(0.10); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); // OPTIONAL CUSTOMISATION COMPLETED. renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); setCategorySummary(dataset); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.ScatterChartDemo1.java
/** * Creates a chart.// w w w . j a v a2s .co m * * @param dataset the data for the chart. * * @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); renderer.setBaseLinesVisible(false); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0); // OPTIONAL CUSTOMISATION COMPLETED. setXSummary(dataset); return chart; }
From source file:org.esa.beam.smos.visat.GridPointBtDataFlagmatrixToolView.java
private NumberAxis createRangeAxis(String[] flagNames) { final NumberAxis axis = new SymbolAxis(null, flagNames); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setAutoRangeIncludesZero(false); axis.setLowerMargin(0.0);//from ww w .j av a 2 s . c o m axis.setUpperMargin(0.0); axis.setInverted(true); return axis; }
From source file:wm.edu.cs420.Data.ChartBuilder.java
/** * Creates a chart.// ww w . jav a 2s .c o m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart generateChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend false, // 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.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); Shape shape = new Ellipse2D.Double(0, 0, 3, 3); renderer.setSeriesShape(0, shape); 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:org.ow2.clif.jenkins.chart.CallChart.java
@Override protected JFreeChart createChart() { XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(this.eventSerie); JFreeChart chart;//from w w w . j av a2 s . c o m if (this.scatterPlot) { chart = ChartFactory.createScatterPlot(getBasicTitle(), // chart title Messages.CallChart_Time(), // x axis label Messages.CallChart_ResponseTime(), // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); } else { chart = ChartFactory.createXYLineChart(getBasicTitle(), // chart title Messages.CallChart_Time(), // x axis label this.chartId.getEvent(), // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); } 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); Shape cross = ShapeUtilities.createDiamond(3); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShape(cross); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShape(0, cross); plot.setRenderer(renderer); // Force the 0 on vertical axis NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Force the 0 on horizontal axis NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(true); return chart; }
From source file:edu.turtlekit2.tools.chart.ChartWindow.java
/** * Creates a chart. Local use./*from w w w . j a v a 2 s .c o m*/ * @param dataset - the data for the chart. * @param title - the name of the chart * @param xName - the name of the x-axis. * @param yName - the name of the y-axis. * @return a chart. */ private JFreeChart createChart(final XYDataset dataset, String title, String xName, String yName) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xName, // x axis label yName, // 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); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // final XYAreaRenderer2 renderer = new XYAreaRenderer2(); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesShapesVisible(2, false); plot.setRenderer(renderer); // renderer.setSeriesStroke( // 0, new BasicStroke( // 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, // 1.0f, new float[] {1.0f, 6.0f}, 0.0f // ) // ); // renderer.setSeriesStroke( // 1, new BasicStroke( // 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, // 1.0f, new float[] {1.0f, 6.0f}, 0.0f // ) // ); // renderer.setSeriesStroke( // 2, new BasicStroke( // 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, // 1.0f, new float[] {1.0f, 6.0f}, 0.0f // ) // ); // // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo6.java
/** * Creates a chart.//from www.j a v a 2 s. c o m * * @param dataset the data for the chart. * * @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 ); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = chart.getXYPlot(); 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 = new XYLineAndShapeRenderer(); // renderer.setSeriesLinesVisible(0, false); // renderer.setSeriesShapesVisible(1, false); renderer.setBaseLinesVisible(false); plot.setRenderer(renderer); // 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:Visuals.BarChart.java
public ChartPanel drawBarChart() { DefaultCategoryDataset bardataset = new DefaultCategoryDataset(); bardataset.addValue(new Double(low), "Low (" + low + ")", lowValue); bardataset.addValue(new Double(medium), "Medium (" + medium + ")", mediumValue); bardataset.addValue(new Double(high), "High (" + high + ")", highValue); bardataset.addValue(new Double(critical), "Critical (" + critical + ")", criticalValue); JFreeChart barchart = ChartFactory.createBarChart(title, // Title riskCategory, riskCountTitle, bardataset // Dataset );// w ww . ja va 2 s. c o m final CategoryPlot plot = barchart.getCategoryPlot(); CategoryItemRenderer renderer = new CustomRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator(riskCountTitle, NumberFormat.getInstance())); DecimalFormat df = new DecimalFormat("##"); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", df)); Font m1Font; m1Font = new Font("Cambria", Font.BOLD, 16); renderer.setItemLabelFont(m1Font); renderer.setItemLabelPaint(null); //barchart.removeLegend(); plot.setRenderer(renderer); //renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE5, TextAnchor.CENTER)); //renderer.setItemLabelsVisible(true); barchart.getCategoryPlot().setRenderer(renderer); LegendItemCollection chartLegend = new LegendItemCollection(); Shape shape = new Rectangle(10, 10); chartLegend.add(new LegendItem("Low (" + low + ")", null, null, null, shape, new Color(230, 219, 27))); chartLegend .add(new LegendItem("Medium (" + medium + ")", null, null, null, shape, new Color(85, 144, 176))); chartLegend.add(new LegendItem("High (" + high + ")", null, null, null, shape, new Color(230, 90, 27))); chartLegend.add( new LegendItem("Critical (" + critical + ")", null, null, null, shape, new Color(230, 27, 27))); plot.setFixedLegendItems(chartLegend); plot.setBackgroundPaint(new Color(210, 234, 243)); ChartPanel chartPanel = new ChartPanel(barchart); return chartPanel; }
From source file:net.nosleep.superanalyzer.analysis.views.GenreView.java
public void createChart() { _chart = ChartFactory.createBarChart3D(Misc.getString("GENRES"), // chart // title Misc.getString("GENRE"), // domain axis label Misc.getString("SONG_COUNT"), // range axis label _dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? );//ww w . j ava2 s . co m _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("GENRES_SUBTITLE"))); CategoryPlot plot = (CategoryPlot) _chart.getPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(_chart); Misc.formatChart(plot); CategoryItemRenderer renderer = plot.getRenderer(); BarRenderer3D barRenderer = (BarRenderer3D) renderer; barRenderer.setWallPaint(Color.white); barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]); }