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; } }
public void initialize ( ) { if ( !ready ) { chart = ChartFactory.createTimeSeriesChart( plotTitle , "Time" , verticalAxisTitle , dataCollectionForTheChart , true , true , false ); chart.setBorderVisible( true ); ready = true; logger.debug( "The Chart Virtual Sensor is ready." ); } }
public ChartHelper generateChart() { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram(null, null, yLabel, dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); setHistogramChartDefaults(chart, i18nBean); chart.setBorderVisible(false); return new ChartHelper(chart); }
private void improveChart(JFreeChart jfrechart, ChartParameters params) { Color background = Color.decode("#" + params.getValue(ChartParameters.PARAM_BACKGROUND_COLOR, "FFFFFF", false)); jfrechart.setBackgroundPaint(background); jfrechart.setBorderVisible(false); jfrechart.setAntiAlias(true); jfrechart.setTextAntiAlias(true); jfrechart.removeLegend(); }
public static ChartHelper generateTimeSeriesChart(XYDataset dataset, String chartTitle, String yLabel, String xLabel, List domainMarkers) { boolean legend = false; boolean tooltips = true; boolean urls = true; JFreeChart chart = ChartFactory.createTimeSeriesChart(null, yLabel, xLabel, dataset, legend, tooltips, urls); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); 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); } } XYDifferenceRenderer xyDifferenceRenderer = new XYDifferenceRenderer(COLOR_RED_PAINT, COLOR_GREEN_PAINT, true); xyDifferenceRenderer.setSeriesPaint(0, new Color(255, 0, 0)); xyDifferenceRenderer.setSeriesPaint(1, new Color(51, 204, 51)); xyDifferenceRenderer.setShape(new Ellipse2D.Double(-1.5, -1.5, 3.0, 3.0)); plot.setRenderer(xyDifferenceRenderer); return new ChartHelper(chart); }
legend.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0, 4, 0, 4)); chart.setBorderPaint(Color.black); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white);
legend.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0, 4, 0, 4)); chart.setBorderPaint(Color.black); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white);
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); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); 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); } } XYItemRenderer plotRenderer = plot.getRenderer(); if (plotRenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plotRenderer; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } return new ChartHelper(chart); }
/** * Generates an area chart from the incoming dataset and stores the image for viewing. * * @param dataset is a jfreechart collection containing the issues in a form that the * charting tool understands. * @param chartTitle identifies the title to be used on the generated chart. * @param yLabel identifies the label to use on the generated charts y-axis. * @param xLabel identifies the label to use on the generated charts x-axis. * @return a string containing the filename of the generated chart. */ public static ChartHelper generateAreaChart(CategoryDataset dataset, String chartTitle, String yLabel, String xLabel) { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createAreaChart(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); AreaRenderer renderer = (AreaRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, COLOR_RED_PAINT); renderer.setSeriesOutlinePaint(0, new Color(255, 0, 0)); renderer.setSeriesOutlineStroke(0, new BasicStroke(1f)); renderer.setSeriesStroke(0, new BasicStroke(3f)); return new ChartHelper(chart); }
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 void setDefaults(JFreeChart chart, final I18nHelper i18nHelper) { chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); chart.getPlot().setNoDataMessage(i18nHelper.getText("gadget.charts.no.data")); setupPlot(chart.getPlot()); ChartUtil.setupTextTitle(chart.getTitle()); ChartUtil.setupLegendTitle(chart.getLegend()); }
/** * Set up GUI components. */ private void initialize() { hoursByProjectDataset = new DefaultPieDataset(); initChartData(); final JFreeChart chart = ChartFactory.createPieChart3D(null, hoursByProjectDataset, false, true, false); chart.setBorderVisible(false); chart.setAntiAlias(true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setMouseZoomable(false); chartPanel.setEnabled(false); chartPanel.setPopupMenu(null); this.add(chartPanel, BorderLayout.CENTER); }
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.setBorderVisible(true); chart.setBorderPaint(parseColor("#cccccc"));
public static ChartHelper generatePieChart(PieDataset dataset, String chartTitle, Color[][] colorScheme) { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createPieChart(chartTitle, dataset, legend, tooltips, urls); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(false); PiePlot plot = (PiePlot) chart.getPlot(); // Make section labels in the format "<Key>" plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}")); plot.setBackgroundPaint(Color.white); plot.setOutlinePaint(null); for(int i = 0; i < colorScheme.length; i++) { setSectionColor(dataset, plot, i, colorScheme[i][0], colorScheme[i][1]); } plot.setShadowXOffset(0); plot.setShadowYOffset(0); return new ChartHelper(chart); }
/** * Generates a bar chart from the incoming data set and stores the image for viewing. * * @param dataset is a jfreechart collection containing the issues in a form that the * charting tool understands. * @param chartTitle identifies the title to be used on the generated chart. * @param yLabel identifies the label to use on the generated charts y-axis. * @param xLabel identifies the label to use on the generated charts x-axis. * @return a string containing the filename of the generated chart. */ public static ChartHelper generateBarChart(CategoryDataset dataset, String chartTitle, String yLabel, String xLabel) { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createBarChart(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(0, COLOR_GREEN_OUTLINE); plot.getRenderer().setSeriesPaint(0, COLOR_GREEN_PAINT); return new ChartHelper(chart); }
chart.setBorderVisible(getBorderVisible());
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); }
&& params.getBoolean(ChartParams.BORDER_VISIBLE).booleanValue()) jfchart.setBorderVisible(true); if (params.get(ChartParams.BORDER_COLOR) != null) { jfchart.setBorderPaint(params.getColor(ChartParams.BORDER_COLOR));
chart.setBorderVisible(false);