List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:org.ow2.clif.jenkins.ClifProjectAction.java
private JFreeChart createActionErrorGraph(ClifGraphParam params) { DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> errorsDS = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>(); List<AbstractBuild> builds = new ArrayList<AbstractBuild>(getProject().getBuilds()); Collections.sort(builds);// w ww. j av a2 s . c o m for (Run<?, ?> currentBuild : builds) { Result buildResult = currentBuild.getResult(); if (buildResult != null && buildResult.isBetterOrEqualTo(Result.SUCCESS)) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(currentBuild); ClifBuildAction clifBuildAction = currentBuild.getAction(ClifBuildAction.class); if (clifBuildAction == null) { continue; } ClifReport clifReport = clifBuildAction.getReport(); if (clifReport == null) { continue; } TestPlan tp = clifReport.getTestplan(params.getTestPlan()); if (tp == null) { continue; } if (tp.getAggregatedMeasures() != null) { Measure m = tp.getAggregatedMeasure(params.getLabel()); if (m == null) { continue; } errorsDS.add(m.errorPercent() * 100, Messages.ProjectAction_Errors(), label); } } } final CategoryAxis xAxis = new CategoryAxis(Messages.ProjectAction_BuildAxis()); xAxis.setLowerMargin(0.01); xAxis.setUpperMargin(0.01); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); xAxis.setMaximumCategoryLabelLines(3); final ValueAxis errorsAxis = new NumberAxis(Messages.ProjectAction_ErrorAxis()); errorsAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); errorsAxis.setUpperMargin(0.1); final LineAndShapeRenderer errorRenderer = new LineAndShapeRenderer(); errorRenderer.setItemMargin(0.0); final CategoryPlot plot = new CategoryPlot(errorsDS.build(), xAxis, errorsAxis, errorRenderer); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); JFreeChart chart = new JFreeChart(Messages.ProjectAction_PercentageOfErrors(), plot); chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:ac.kaist.ccs.presentation.CCSHubSelectionCost.java
/** * Creates a chart./* w ww .j a v a2s.c om*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title "Number of Hubs", // x axis label "Cost for pipeline transportation \nfrom CO2 emission source node to hubs", // 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, 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()); rangeAxis.setRange(minVal - (maxVal - minVal) * 0.05, maxVal + (maxVal - minVal) * 0.05); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:test.integ.be.fedict.performance.util.PerformanceResultDialog.java
private JFreeChart getPerformanceChart(int intervalSize, List<PerformanceData> performance, int expectedRevoked) { TimeSeries series = new TimeSeries("Success"); TimeSeries revokedSeries = new TimeSeries("Revoked"); TimeSeries failureSeries = new TimeSeries("Failures"); performance.remove(performance.size() - 1); if (performance.isEmpty()) { JOptionPane.showMessageDialog(null, "test did not run long enough"); return null; }//from w w w .j a v a2s . c om JFreeChart chart; int totalCount = 0; int totalRevoked = 0; int totalFailures = 0; for (PerformanceData performanceEntry : performance) { series.add(new Second(performanceEntry.getDate()), performanceEntry.getCount()); totalCount += performanceEntry.getCount(); revokedSeries.add(new Second(performanceEntry.getDate()), performanceEntry.getRevoked()); totalRevoked += performanceEntry.getRevoked(); failureSeries.add(new Second(performanceEntry.getDate()), performanceEntry.getFailures()); totalFailures += performanceEntry.getFailures(); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); dataset.addSeries(revokedSeries); dataset.addSeries(failureSeries); chart = ChartFactory.createTimeSeriesChart("eID Trust Service Performance History", "Time (interval size " + intervalSize + " msec)", "Number of XKMS requests", dataset, true, false, false); chart.addSubtitle(new TextTitle(performance.get(0).getDate().toString() + " - " + performance.get(performance.size() - 1).getDate().toString())); TextTitle info = new TextTitle("Total number of successful requests: " + totalCount); info.setTextAlignment(HorizontalAlignment.LEFT); info.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(info); TextTitle info2 = new TextTitle( "Total number of revoked: " + totalRevoked + " expected=" + expectedRevoked); info2.setPosition(RectangleEdge.BOTTOM); info2.setTextAlignment(HorizontalAlignment.LEFT); chart.addSubtitle(info2); TextTitle info3 = new TextTitle("Total number of failures: " + totalFailures); info3.setPosition(RectangleEdge.BOTTOM); info3.setTextAlignment(HorizontalAlignment.LEFT); chart.addSubtitle(info3); chart.setBackgroundPaint(Color.WHITE); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); ValueAxis valueAxis = plot.getRangeAxis(); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRangeGridlinePaint(Color.black); plot.setDomainGridlinePaint(Color.black); plot.setRenderer(renderer); return chart; }
From source file:com.rapidminer.gui.plotter.DistributionPlotter.java
private JFreeChart createNumericalChart() { JFreeChart chart;/* www.j a v a2s . c o m*/ XYDataset dataset = createNumericalDataSet(); // create the chart... chart = ChartFactory.createXYLineChart(null, // chart title "value", // x axis label "density", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // 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.WHITE); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); DeviationRenderer renderer = new DeviationRenderer(true, false); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); if (dataset.getSeriesCount() == 1) { renderer.setSeriesStroke(0, stroke); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesFillPaint(0, Color.RED); } else { for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, stroke); Color color = getPointColor((double) i / (double) (dataset.getSeriesCount() - 1)); renderer.setSeriesPaint(i, color); renderer.setSeriesFillPaint(i, color); } } renderer.setAlpha(0.12f); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:ReportGen.java
private void defaultPreview() throws NumberFormatException { tableModel = (DefaultTableModel) dataTable.getModel(); tableModel.getDataVector().removeAllElements(); tableModel.fireTableDataChanged();/*from w ww. jav a2 s .c o m*/ String str[] = { "X", "Y" }; tableModel.setColumnIdentifiers(str); exportcounttableexcel.setEnabled(false); exportcounttablepdf.setEnabled(false); // exportgraphtoimage.setEnabled(false); ChartPanel chartPanel; displaypane.removeAll(); displaypane.revalidate(); displaypane.repaint(); displaypane.setLayout(new BorderLayout()); //row String series1 = "Results"; //column String values[] = { "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" }; int value[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (int i = 0; i < values.length; i++) { tableModel.addRow(new Object[] { values[i], value[i] }); } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int c = 0; c < value.length; c++) { dataset.addValue(value[c], series1, values[c]); } chart = ChartFactory.createBarChart("181 North Place Residences Graph", // chart title "Default", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // 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.lightGray); 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()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); chartPanel = new ChartPanel(chart); displaypane.add(chartPanel, BorderLayout.CENTER); }
From source file:de.tsystems.mms.apm.performancesignature.PerfSigProjectAction.java
private JFreeChart createChart(final JSONObject jsonObject, final CategoryDataset dataset) throws UnsupportedEncodingException { final String measure = jsonObject.getString(Messages.PerfSigProjectAction_ReqParamMeasure()); final String chartDashlet = jsonObject.getString("chartDashlet"); final String testCase = jsonObject.getString("dashboard"); final String customMeasureName = jsonObject.getString("customName"); final String aggregation = jsonObject.getString("aggregation"); String unit = "", color = Messages.PerfSigProjectAction_DefaultColor(); for (DashboardReport dr : getLastDashboardReports()) { if (dr.getName().equals(testCase)) { final Measure m = dr.getMeasure(chartDashlet, measure); if (m != null) { unit = aggregation.equalsIgnoreCase("Count") ? "num" : m.getUnit(); color = URLDecoder.decode(m.getColor(), "UTF-8"); }//from w ww . j ava2 s . c o m break; } } String title = customMeasureName; if (StringUtils.isBlank(customMeasureName)) title = PerfSigUtils.generateTitle(measure, chartDashlet); final JFreeChart chart = ChartFactory.createBarChart(title, // title "build", // category axis label unit, // value axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend false, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); final CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); //domainAxis.setLowerMargin(0.0); //domainAxis.setUpperMargin(0.0); //domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer(); renderer.setSeriesPaint(0, Color.decode(color)); return chart; }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java
private static JFreeChart createBarChart(CategoryDataset dataset) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); BarRenderer renderer = new BarRenderer(); if (orientation == PlotOrientation.HORIZONTAL) { ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setBasePositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT); renderer.setBaseNegativeItemLabelPosition(position2); } else if (orientation == PlotOrientation.VERTICAL) { ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setBasePositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setBaseNegativeItemLabelPosition(position2); }// w w w. j ava 2s . c o m if (tooltips) { renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart("Bar Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setDrawBarOutline(false); 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); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); categoryAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:sentimentanalyzer.ChartController.java
public void postTheTimeSeriesChartOnTheGUI_words(JPanel timeSeriesChart, XYSeriesCollection dataset, String title, String y, String x, int row) { this.wordCountsChart = ChartFactory.createXYLineChart(title, x, y, dataset, PlotOrientation.VERTICAL, true, true, false);//from w w w . j a va 2 s .c om this.wordIndexesOnGraph.add(row); this.plot_counter = this.wordCountsChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); //CHECK THIS renderer.setBaseShapesVisible(true); this.plot_counter.setRenderer(renderer); this.plot_counter.setOutlinePaint(Color.orange); NumberAxis rangeAxis = (NumberAxis) this.plot_counter.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) this.plot_counter.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); this.wordCountsChart.setBackgroundPaint(Color.white); this.wordCountsChart.setBorderPaint(Color.orange); ChartPanel CP = new ChartPanel(this.wordCountsChart); timeSeriesChart.setLayout(new java.awt.BorderLayout()); timeSeriesChart.add(CP, BorderLayout.CENTER); timeSeriesChart.revalidate(); }
From source file:org.eumetsat.metop.visat.SounderInfoView.java
protected void configureSpectrumPlotXAxis(NumberAxis axis) { axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); }
From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java
private void setArtistsChart() { DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedArtists(10)); JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ARTIST_MOST_PLAYED"), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR)); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(0.6f); chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN); ((StatsDialog) frameControlled).getArtistsChart() .setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }