List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:net.footballpredictions.footballstats.swing.PointsGraph.java
/** * Plot points earned against number of matches played. *//*from w w w .java 2s.c o m*/ public void updateGraph(Object[] teams, LeagueSeason data) { assert teams.length > 0 : "Must be at least one team selected."; XYSeriesCollection dataSet = new XYSeriesCollection(); int max = 0; for (Object team : teams) { String teamName = (String) team; XYSeries pointsSeries = new XYSeries(teamName); int[] points = data.getTeam(teamName).getPointsData(data.getMetaData().getPointsForWin(), data.getMetaData().getPointsForDraw()); for (int i = 0; i < points.length; i++) { pointsSeries.add(i, points[i]); } max = Math.max(max, points[points.length - 1]); dataSet.addSeries(pointsSeries); } JFreeChart chart = ChartFactory.createXYLineChart(null, // Title messageResources.getString("graphs.matches"), messageResources.getString("combo.GraphType.POINTS"), dataSet, PlotOrientation.VERTICAL, true, // Legend. false, // Tooltips. false); // URLs. chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chart.getXYPlot().getRangeAxis().setRange(0, max + 1); setChart(chart); }
From source file:mediamatrix.gui.JVMMemoryProfilerPanel.java
public JVMMemoryProfilerPanel() { initComponents();/*w w w .j a va2s . c o m*/ profiler = new JVMMemoryProfiler(frequency); profiler.addListener(new JVMMemoryProfilerListener() { @Override public void addScore(long t, long f) { total.add(new Millisecond(), t); free.add(new Millisecond(), f); } }); total = new TimeSeries("Total Memory"); total.setMaximumItemCount(historyCount); free = new TimeSeries("Free Memory"); free.setMaximumItemCount(historyCount); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(total); dataset.addSeries(free); final DateAxis domain = new DateAxis("Time"); final NumberAxis range = new NumberAxis("Memory"); domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final XYItemRenderer renderer = new DefaultXYItemRenderer(); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setBaseStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); final JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12)); add(chartPanel, BorderLayout.CENTER); }
From source file:com.googlecode.logVisualizer.chart.VerticalXYBarChartBuilder.java
private JFreeChart createChart(final IntervalXYDataset dataset) { final JFreeChart chart = ChartFactory.createXYBarChart(getTitle(), xLable, false, yLable, dataset, PlotOrientation.VERTICAL, isIncludeLegend(), true, false); final XYPlot plot = (XYPlot) chart.getPlot(); final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); double lastXValue = 0; if (dataset.getSeriesCount() > 0) lastXValue = dataset.getXValue(0, dataset.getItemCount(0) - 1); plot.setDomainAxis(new FixedZoomNumberAxis(lastXValue)); plot.setNoDataMessage("No data available"); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.black); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); setBarShadowVisible(chart, false);//from w ww . j a va 2 s . com plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (dataset.getSeriesCount() > 0) plot.getDomainAxis().setUpperBound(lastXValue); plot.getDomainAxis().setLowerBound(0); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setUpperMargin(0.1); return chart; }
From source file:com.wattzap.view.graphs.DistributionGraph.java
public DistributionGraph(ArrayList<Telemetry> telemetry[], DistributionAccessor da, String domainLabel, int scale) { super();//from w w w .j a v a 2s. com 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:org.jfree.eastwood.GValueAxis.java
/** * Creates a new axis./*from w ww .j a v a 2 s. c o m*/ */ public GValueAxis() { super(); this.axisForAutoLabels = new NumberAxis(null); this.axisForAutoLabels.setRange(0.0, 100.0); this.axisForAutoLabels.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); this.labelAxisStart = 0.0; this.labelAxisEnd = 100.0; this.tickLabels = new java.util.ArrayList(); this.tickLabelPositions = new java.util.ArrayList(); setLowerMargin(0.0); setUpperMargin(0.0); // the data is normalised into the range 0.0 to 1.0, so the real axis // has the same range... setRange(0.0, 1.0); setTickLabelPaint(Color.darkGray); setTickLabelFont(new Font("Dialog", Font.PLAIN, 11)); }
From source file:org.openmrs.module.laboratorymanagement.web.chart.EvolutionOfClientRegisteredPerDay.java
/** * @see org.openmrs.module.vcttrac.web.view.chart.AbstractChartView#createChart(java.util.Map, * javax.servlet.http.HttpServletRequest) */// w w w .ja va 2 s . c om @Override protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request, String patientIdstr, String locationIdstr, int conceptId, Date startDate, Date endDate) { String categoryAxisLabel = " Year"; String valueAxisLabel = "Number of Lab tests"; String title = "EVolution of labotory test:" + Context.getConceptService().getConcept(conceptId).getDisplayString(); JFreeChart chart = ChartFactory.createLineChart(title, categoryAxisLabel, valueAxisLabel, createDataset(patientIdstr, locationIdstr, conceptId, startDate, endDate), // data PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setUpperMargin(0.15); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelsVisible(true); return chart; }
From source file:org.nbheaven.sqe.codedefects.dashboard.controlcenter.panels.Statistics.java
private static JFreeChart createOverviewPanel(DefaultCategoryDataset dataSet) { JFreeChart overview = org.jfree.chart.ChartFactory.createStackedBarChart(null, null, "CodeDefects", dataSet, PlotOrientation.HORIZONTAL, false, true, false); overview.setBorderVisible(false);//w w w .j av a 2 s . c om overview.setBackgroundPaint(Color.WHITE); overview.setAntiAlias(true); overview.setNotify(true); CategoryPlot overviewPlot = overview.getCategoryPlot(); overviewPlot.setRangeGridlinePaint(Color.BLACK); overviewPlot.setDomainGridlinePaint(Color.BLACK); overviewPlot.setBackgroundPaint(Color.WHITE); overviewPlot.setForegroundAlpha(0.7f); overviewPlot.setRangeAxisLocation(AxisLocation.getOpposite(overviewPlot.getRangeAxisLocation())); CategoryAxis domainAxis = overviewPlot.getDomainAxis(); domainAxis.setVisible(true); LogarithmicAxis rangeAxis = new LogarithmicAxis("CodeDefects"); rangeAxis.setLabel(null); rangeAxis.setStrictValuesFlag(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); overviewPlot.setRangeAxis(rangeAxis); CategoryItemRenderer categoryItemRenderer = new StackedBarRenderer(); //3D(); // categoryItemRenderers[0].setPaint(Color.RED); categoryItemRenderer.setSeriesPaint(0, Color.RED); categoryItemRenderer.setSeriesPaint(1, Color.ORANGE); categoryItemRenderer.setSeriesPaint(2, Color.YELLOW); categoryItemRenderer.setBaseItemLabelsVisible(true); overviewPlot.setRenderer(categoryItemRenderer); return overview; }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.BarChartRenderer.java
public void createChart() { CategoryDataset categorydataset = (CategoryDataset) this.datasetStrategy.getDataset(); report = ChartFactory.createBarChart(this.datasetStrategy.getTitle(), this.datasetStrategy.getYAxisLabel(), this.datasetStrategy.getXAxisLabel(), categorydataset, PlotOrientation.HORIZONTAL, true, true, false);//from w w w. ja va 2s .com // report.setBackgroundPaint( Color.lightGray ); report.setPadding(new RectangleInsets(5.0d, 5.0d, 5.0d, 5.0d)); CategoryPlot categoryplot = (CategoryPlot) report.getPlot(); categoryplot.setBackgroundPaint(Color.white); categoryplot.setRangeGridlinePaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.lightGray); categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); if (datasetStrategy instanceof CoberturaBarChartStrategy || datasetStrategy instanceof CloverBarChartStrategy || datasetStrategy instanceof MultiCloverBarChartStrategy) { numberaxis.setRange(0.0D, BarChartRenderer.NUMBER_AXIS_RANGE); numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); } else { numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } numberaxis.setLowerMargin(0.0D); CategoryAxis axis = categoryplot.getDomainAxis(); axis.setLowerMargin(0.02); // two percent axis.setCategoryMargin(0.10); // ten percent axis.setUpperMargin(0.02); // two percent BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setItemMargin(0.10); barrenderer.setDrawBarOutline(false); barrenderer.setBaseItemLabelsVisible(true); if (datasetStrategy instanceof CoberturaBarChartStrategy || datasetStrategy instanceof CloverBarChartStrategy || datasetStrategy instanceof MultiCloverBarChartStrategy) { barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", NumberFormat.getPercentInstance(Locale.getDefault()))); } else { barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); } int height = (categorydataset.getColumnCount() * ChartUtils.STANDARD_BARCHART_ENTRY_HEIGHT * categorydataset.getRowCount()); if (height > ChartUtils.MINIMUM_HEIGHT) { super.setHeight(height); } else { super.setHeight(ChartUtils.MINIMUM_HEIGHT); } Paint[] paints = this.datasetStrategy.getPaintColor(); for (int i = 0; i < categorydataset.getRowCount() && i < paints.length; i++) { barrenderer.setSeriesPaint(i, paints[i]); } }
From source file:bc.ui.swing.charts.LineChart.java
public void setModel(LineVisualModel line) { XYDataset dataset = createDataset(line); JFreeChart chart = ChartFactory.createXYLineChart(line.getTitle(), // chart title line.getDomainAxisLabel(), // x axis label line.getRangeAxisLabel(), // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );//ww w . j av a2s .c o m chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setSeriesPaint(0, new Color(153, 215, 255)); removeAll(); chartPanel = new ChartPanel(chart); add(chartPanel, BorderLayout.CENTER); }
From source file:Modelos.Grafica.java
private void configurarRangeAxis(NumberAxis rangeAxis) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setTickUnit(new NumberTickUnit(5)); rangeAxis.setRange(0, 100);/*w ww . ja v a 2 s . co m*/ }