Refine search
/** * Builds and returns JFreeChart. * * @return */ public JFreeChart build() { XYSeriesCollection collection = new XYSeriesCollection(); for (XYSeries s : seriesMap.values()) { collection.addSeries(s); } JFreeChart chart = ChartFactory.createXYLineChart(chartName, xDomain, yDomain, collection, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); 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());
public JFreeChart getChart(JSONObject jsonData, boolean legendBit, boolean tooltipBit) { DefaultPieDataset dataset = new DefaultPieDataset(); Iterator iter = jsonData.keys(); while (iter.hasNext()) { String keyData = (String)iter.next(); Float value = Float.parseFloat(jsonData.getString(keyData)); dataset.setValue(keyData, value); } boolean legend = legendBit; boolean tooltips = tooltipBit; boolean urls = false; JFreeChart chart = ChartFactory.createPieChart("Loklak Visualizes - PieChart", dataset, legend, tooltips, urls); chart.setBorderPaint(Color.BLACK); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); return chart; } }
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());
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 );
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());
JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.7f); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.darkGray); domain.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setCategoryMargin(0.0); plot.setDomainAxis(domain); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setAutoRange(true); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
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); } }
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 = ChartFactory.createXYLineChart("", 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]));
/** * Creates a chart. * * @param dataset * a dataset. * * @return A chart. */ private JFreeChart createChart(SimpleHistogramDataset dataset) { chart = ChartFactory.createHistogram(null, engl("Value"), engl("Histogram"), dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.getRenderer().setSeriesPaint(0, new Color(0x7f9f51)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); return chart; }
/** * 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; }
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); }
@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; }
/** * Creates a stacked area graph from the specified data set. * * @param dataset * the values to display * @return the created graph */ public JFreeChart createAreaChart(final CategoryDataset dataset) { JFreeChart chart = ChartFactory.createStackedAreaChart( null, // chart title null, // unused "count", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); setCategoryPlotProperties(chart.getCategoryPlot()); chart.getCategoryPlot().getDomainAxis().setCategoryMargin(0.0); return chart; }
public static ChartHelper generateMultiLineChart(XYDataset dataset, String chartTitle, String yLabel, String xLabel, List domainMarkers) { boolean legend = true; boolean tooltips = true; boolean urls = true; JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, yLabel, xLabel, dataset, legend, tooltips, urls); XYPlot plot = chart.getXYPlot(); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); TickUnitSource units = NumberAxis.createIntegerTickUnits(); yAxis.setStandardTickUnits(units); if (domainMarkers != null && !domainMarkers.isEmpty()) { for (Iterator iterator = domainMarkers.iterator(); iterator.hasNext();) { ValueMarker valueMarker = (ValueMarker) iterator.next(); valueMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); valueMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(valueMarker); } } return new ChartHelper(chart); }
public static JFreeChart createStackedBarChart(String title, List<List<Double>> bars, List<String> zoneLabels, String xLabel, String yLabel, ColorTheme theme) { DefaultCategoryDataset ds = new DefaultCategoryDataset(); Integer barId = 0; int maxStack = 0; for (List<Double> bar : bars) { int i = 0; maxStack = Math.max(maxStack, bar.size()); for (double value : bar) { ds.addValue(value, zoneLabels.get(i), barId); i++; } barId++; } JFreeChart chart = ChartFactory.createStackedBarChart(title, xLabel, yLabel, ds, PlotOrientation.VERTICAL, true, false, false); formatColorTheme(chart, theme); formatBars(chart); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setCategoryMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setUpperMargin(0); Color[] colors = generateJetSpectrum(maxStack); for (int i = 0; i < maxStack; i++) { plot.getRenderer().setSeriesPaint(i, colors[i]); plot.getRenderer().setSeriesOutlinePaint(i, Color.white); } return chart; }
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart( null, null, null, dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot localCategoryPlot = (CategoryPlot)chart.getPlot(); localCategoryPlot.setDomainGridlinesVisible(true); CustomBarRenderer localCustomBarRenderer = new CustomBarRenderer(arrayOfPaint); localCustomBarRenderer.setBarPainter(new StandardBarPainter()); localCustomBarRenderer.setDrawBarOutline(true); localCustomBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); localCustomBarRenderer.setBaseItemLabelsVisible(true); localCategoryPlot.setRenderer(localCustomBarRenderer); chart.addChangeListener(new UpdateChartChangeListener()); return chart; }
protected JFreeChart createChart(XYDataset dataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart( null, "time", "# of issues", dataset, true, false, false); jfreechart.setBackgroundPaint(Color.WHITE); XYPlot plot = (XYPlot)jfreechart.getPlot(); XYStepAreaRenderer renderer = new XYStepAreaRenderer(); plot.setRenderer(renderer); renderer.setSeriesPaint(0,ColorPalette.RED); renderer.setSeriesPaint(1,ColorPalette.GREEN); return jfreechart; } }
private ChartInfo createPlot(String labelX, String labelY, double maxX, double maxY) { ChartInfo ret = new ChartInfo(); JFreeChart chart = ChartFactory.createScatterPlot( null, labelX, labelY, ret.dataset, PlotOrientation.VERTICAL, false,false,false); NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis(); domainAxis.setRange(0,maxX); NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); rangeAxis.setRange(0,maxY); ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new Dimension(250, 250)); panel.setMinimumSize(getPreferredSize()); panel.setMaximumSize(getPreferredSize()); ret.chart = chart; ret.panel = panel; return ret; }