ChartFactory.createLineChart( chartTitle, // chart title BaseMessages.getString( PKG, "StepPerformanceSnapShotDialog.TimeInSeconds.Label", Integer true, // tooltips false ); // urls chart.setBackgroundPaint( Color.white ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint( Color.white ); plot.setForegroundAlpha( 0.5f ); plot.setRangeGridlinesVisible( true ); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelsVisible( false ); renderer.setSeriesShape( 0, new Ellipse2D.Double( -3.0, -3.0, 6.0, 6.0 ) ); BufferedImage bufferedImage = chart.createBufferedImage( bounds.width, bounds.height ); ImageData imageData = ImageUtil.convertToSWT( bufferedImage );
final JFreeChart result = ChartFactory.createTimeSeriesChart( TITLE, "hh:mm:ss", "milliVolts", dataset, true, true, false); final XYPlot plot = result.getXYPlot(); ValueAxis domain = plot.getDomainAxis(); domain.setAutoRange(true); ValueAxis range = plot.getRangeAxis(); range.setRange(-MINMAX, MINMAX); return result;
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { Locale locale = benchmarkReport.getLocale(); NumberAxis xAxis = new NumberAxis("Time spent"); xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale)); NumberAxis yAxis = new NumberAxis("Score calculation speed per second"); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setOrientation(PlotOrientation.VERTICAL); int seriesIndex = 0; for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) { plot.setDataset(seriesIndex, new XYSeriesCollection(series)); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); plot.setRenderer(seriesIndex, renderer); seriesIndex++; JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " score calculation speed statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "ScoreCalculationSpeedStatistic");
/** * Draws a chart into {@link JFreeChart}. */ public JFreeChart createChart() { final JFreeChart chart = ChartFactory.createLineChart(null, // chart title null, // unused null, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); chart.getLegend().setItemFont(CHART_FONT); final CategoryPlot plot = chart.getCategoryPlot(); configurePlot(plot); configureRangeAxis((NumberAxis) plot.getRangeAxis()); crop(plot); return chart; }
final JFreeChart chart = ChartFactory.createLineChart(null, // chart title ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); 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());
private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) { String w = req.getParameter("width"); if(w==null) w=String.valueOf(defaultW); String h = req.getParameter("height"); if(h==null) h=String.valueOf(defaultH); Color graphBg = stringToColor(req.getParameter("graphBg")); Color plotBg = stringToColor(req.getParameter("plotBg")); if (graph==null) graph = createGraph(); graph.setBackgroundPaint(graphBg); Plot p = graph.getPlot(); p.setBackgroundPaint(plotBg); return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info); }
final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); 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(); ChartUtil.adjustChebyshev(dataset, rangeAxis); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
private JFreeChart createChart(final BuildStatConfiguration config, List<AbstractBuildStatChartDimension> dimensions, String title) { final JFreeChart chart = ChartFactory.createStackedAreaChart(title, null, "", new DataSetBuilder<String, DateRange>().build(), PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setForegroundAlpha(0.85F); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.darkGray); 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());
private byte[] generateBoxAndWhiskerChart (BoxAndWhiskerCategoryDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createBoxAndWhiskerChart (null, null, null, dataset, false); // set background chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ())); // set chart border chart.setPadding (new RectangleInsets (10, 5, 5, 5)); chart.setBorderVisible (true); chart.setBorderPaint (parseColor ("#cccccc")); // set anti alias chart.setAntiAlias (true); CategoryPlot plot = (CategoryPlot) chart.getPlot (); plot.setDomainGridlinePaint (Color.white); plot.setDomainGridlinesVisible (true); plot.setRangeGridlinePaint (Color.white); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis (); rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ()); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis (); domainAxis.setLowerMargin (0.0); domainAxis.setUpperMargin (0.0); BufferedImage img = chart.createBufferedImage (width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try{ ImageIO.write(img, "png", out); }catch(IOException e){ log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
chart = ChartFactory.createXYAreaChart("", labelX, labelY, ds, PlotOrientation.VERTICAL, showLegend, false, false); ((XYAreaRenderer) chart.getXYPlot().getRenderer()).setOutline(true); chart = ChartFactory.createStackedXYAreaChart("", labelX, labelY, ds, PlotOrientation.VERTICAL, showLegend, false, false); chart.getXYPlot().setRenderer(renderer); chart.setAntiAlias(true); chart.setBackgroundPaint(new Color(backgroundColor)); for (int i = 0; i < seriesMaxCount; i++) { if (seriesColor[i] >= 0) { chart.getXYPlot().getRenderer().setSeriesPaint(i, new Color(seriesColor[i])); chart.getXYPlot().getRenderer().setSeriesOutlinePaint(i, new Color(seriesOutlineColor[i])); chart.getXYPlot().setDomainGridlinePaint(new Color(gridColor)); chart.getXYPlot().setRangeGridlinePaint(new Color(gridColor)); chart.getXYPlot().setDomainAxis(0, new DateAxis()); chart.getXYPlot().setDomainAxis(1, new DateAxis()); chart.getXYPlot().setInsets(new RectangleInsets(-15, 0, 0, 10)); .write(ChartUtilities.encodeAsPNG(chart.createBufferedImage(width, height)));
public ChartHelper generateChart() { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createStackedBarChart(null, null, yLabel, dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); setStackedBarChartDefaults(chart, i18nBean); CategoryPlot plot = chart.getCategoryPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); TickUnitSource units = NumberAxis.createIntegerTickUnits(); axis.setStandardTickUnits(units); CategoryAxis catAxis = plot.getDomainAxis(); catAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.getRenderer().setSeriesOutlinePaint(1, ChartDefaults.GREEN_DIFF); plot.getRenderer().setSeriesPaint(1, ChartDefaults.GREEN_DIFF); plot.getRenderer().setSeriesOutlinePaint(0, ChartDefaults.RED_DIFF); plot.getRenderer().setSeriesPaint(0, ChartDefaults.RED_DIFF); return new ChartHelper(chart); }
@Override public void write(OutputStream aStream) throws IOException { JFreeChart chart = ChartFactory.createXYLineChart(null, "Recall", "Precision", dataset, PlotOrientation.VERTICAL, false, false, false); chart.getXYPlot().setRenderer(new XYSplineRenderer()); chart.getXYPlot().getRangeAxis().setRange(0.0, 1.0); chart.getXYPlot().getDomainAxis().setRange(0.0, 1.0); ChartUtil.writeChartAsSVG(aStream, chart, 400, 400); } }
title, "X", "Y", createSampleData(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setRange(0.00, 1.00); domain.setTickUnit(new NumberTickUnit(0.1)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) xyPlot.getRangeAxis(); range.setRange(0.0, 1.0);
NumberAxis numberAxis = new NumberAxis("count"); numberAxis.setAutoRange(true); numberAxis.setAutoRangeIncludesZero(false); CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setCategoryMargin(0.0); CategoryPlot plot = new CategoryPlot(dataSet, domainAxis, numberAxis, new LineAndShapeRenderer(true, false)); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, hasLegend); if (hasLegend) { chart.getLegend().setItemFont(LEGEND_FONT); chart.setBackgroundPaint(Color.white);
public ChartPanel getOutputPanel() { //we return a copy of the chart because we only want to show the //legend in the larger view of the graph //not the small runtime graph block view JFreeChart newChart = new JFreeChart(chart.getPlot()); newChart.getLegend().setPosition(RectangleEdge.TOP); newChart.getLegend().setPadding(5, 5, 5, 5); newChart.setBackgroundPaint(background); output = new ChartPanel(newChart); return output; }
public static void setDefaults(JFreeChart chart) { chart.setBackgroundPaint(ChartDefaults.transparent); chart.setBorderVisible(false); chart.getPlot().setNoDataMessage("No Data Available"); setupPlot(chart.getPlot()); ChartUtil.setupTextTitle(chart.getTitle()); ChartUtil.setupLegendTitle(chart.getLegend()); }
public static ChartHelper generateStackedBarChart(CategoryDataset dataset, String chartTitle, String yLabel, String xLabel, List domainMarkers) { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createStackedBarChart(chartTitle, yLabel, xLabel, dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); CategoryPlot plot = chart.getCategoryPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); TickUnitSource units = NumberAxis.createIntegerTickUnits(); axis.setStandardTickUnits(units); plot.getRenderer().setSeriesOutlinePaint(1, COLOR_YELLOW_OUTLINE); plot.getRenderer().setSeriesPaint(1, COLOR_YELLOW_PAINT); plot.getRenderer().setSeriesOutlinePaint(0, COLOR_CYAN_OUTLINE); plot.getRenderer().setSeriesPaint(0, COLOR_CYAN_PAINT); return new ChartHelper(chart); }
maximumEndDate = Math.max(maximumEndDate, endDate); NumberAxis domainAxis = new NumberAxis("Job"); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-0.5, schedule.getAllocationList().size() - 0.5); domainAxis.setInverted(true); NumberAxis rangeAxis = new NumberAxis("Day (start to end date)"); rangeAxis.setRange(-0.5, maximumEndDate + 0.5); XYPlot plot = new XYPlot(seriesCollection, domainAxis, rangeAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); return new JFreeChart("Project Job Scheduling", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
@Override protected JFreeChart createGraph() { CategoryDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createBarChart(graphTitle, "", "Number of failures", dataset, PlotOrientation.HORIZONTAL, false, false, false); NumberAxis domainAxis = new NumberAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryPlot plot = (CategoryPlot)chart.getPlot(); plot.setRangeAxis(domainAxis); BarRenderer renderer = (BarRenderer)plot.getRenderer(); renderer.setMaximumBarWidth(MAX_BAR_WIDTH); return chart; }
private JFreeChart createChart(String title, XYDataset magDataset, String freqUnits, String magnitudeUnits) { XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis("Magnitude " + magnitudeUnits); XYPlot subplot1 = new XYPlot(magDataset, new LogarithmicAxis("Frequency " + freqUnits), rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer1.setSeriesVisibleInLegend(0, false); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, subplot1, true); } }