List of usage examples for org.jfree.chart JFreeChart getPlot
public Plot getPlot()
From source file:fr.paris.lutece.plugins.form.business.GraphTypePieChart.java
/** * return the PieChartGraph JFreeChart graph * @param listStatistic listStatistic/*from w ww . j ava 2s . c o m*/ * @param strGraphTitle graph title * @param nGraphThreeDimension true if the graph must be in three dimension * @param nGraphLabelValue true if the labels must appear in the graph * @return the JFreeChart graph associate to the graph type */ public static JFreeChart createPieChartGraph(List<StatisticEntrySubmit> listStatistic, String strGraphTitle, boolean nGraphThreeDimension, boolean nGraphLabelValue) { PieDataset pieDataset = createPieDataset(listStatistic); JFreeChart chart; if (nGraphThreeDimension) { chart = ChartFactory.createPieChart3D(strGraphTitle, pieDataset, true, true, false); } else { chart = ChartFactory.createPieChart(strGraphTitle, pieDataset, true, true, false); } PiePlot plot = (PiePlot) chart.getPlot(); if (nGraphLabelValue) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}")); } else { plot.setLabelGenerator(null); } return chart; }
From source file:com.griddynamics.jagger.reporting.chart.ChartHelper.java
private static void formatBars(JFreeChart chart) { if (chart != null) { Plot p = chart.getPlot(); if (p instanceof CategoryPlot) { CategoryPlot cp = (CategoryPlot) p; CategoryItemRenderer cir = cp.getRenderer(); if (cir instanceof BarRenderer) { BarRenderer br = (BarRenderer) cir; br.setShadowVisible(false); br.setBarPainter(new StandardBarPainter()); br.setDrawBarOutline(true); }// ww w . java2s .c o m } } }
From source file:plugins.tutorial.chart.ChartTutorial2.java
/** * Creates a sample chart./*from www. ja v a 2 s. c o m*/ * * @param dataset * the dataset. * @return The chart. */ private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Projected Values - Test", "Date", "Index Projection", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D)); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); DeviationRenderer deviationrenderer = new DeviationRenderer(true, false); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); deviationrenderer.setSeriesFillPaint(0, new Color(255, 200, 200)); deviationrenderer.setSeriesFillPaint(1, new Color(200, 200, 255)); xyplot.setRenderer(deviationrenderer); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:UserInterface.EmployeeViewArea.ViewIssuesStatisticsJPanel.java
private static JFreeChart createPieChart(PieDataset dataset) { // chart title // data // include legend JFreeChart chart = ChartFactory.createPieChart("Reported Child Issues", dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection tempChrData, boolean showlables) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesVisibleInLegend(0, showlables); renderer.setSeriesVisibleInLegend(1, showlables); //renderer.setBaseShape(new Ellipse2D.Float(0, 0, 2,2), false); if (combinedPlot.getSubplots().isEmpty()) { LogAxis rangeAxis = new LogAxis("P value"); rangeAxis.setBase(10);/*from w w w . java 2 s.co m*/ rangeAxis.setInverted(true); rangeAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickCount(2); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setAxisLineVisible(true); rangeAxis.setAutoRangeMinimumSize(0.0000005); rangeAxis.setLowerBound(1d); //rangeAxis.setAutoRangeIncludesZero(false); combinedPlot.setRangeAxis(0, rangeAxis); } JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", tempChrData, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); final Marker thresholdLine = new ValueMarker(0.0000005); thresholdLine.setPaint(Color.red); if (showlables) { thresholdLine.setLabel("P = 510??"); } thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT); thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); subplot.addRangeMarker(thresholdLine); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(false); chrAxis.setTickLabelsVisible(false); chrAxis.setTickMarksVisible(false); chrAxis.setAutoRangeIncludesZero(false); //combinedPlot.setGap(0); combinedPlot.add(subplot, 1); }
From source file:com.ouc.cpss.view.EmpSaleChartBuilder.java
private static JFreeChart createJFreeChart(CategoryDataset dataset) { /**//w w w. java 2s .c om * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //? JFreeChart jfreeChart = ChartFactory.createBarChart3D("", "", "?", dataset, PlotOrientation.VERTICAL, true, false, false); /** * JFreeChart */ jfreeChart.setTitle(new TextTitle("", new Font("", Font.BOLD + Font.ITALIC, 20))); CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12)); return jfreeChart; }
From source file:com.griddynamics.jagger.reporting.chart.ChartHelper.java
private static void formatColorTheme(JFreeChart chart, ColorTheme theme) { Plot rawPlot = chart.getPlot(); Paint background = Color.BLACK; Paint foregroung = Color.WHITE; if (theme == ColorTheme.LIGHT) { background = Color.WHITE; foregroung = Color.BLACK; }//from ww w. j a va 2 s .c o m chart.setBackgroundPaint(background); chart.getLegend().setBackgroundPaint(background); chart.getLegend().setItemPaint(foregroung); if (rawPlot instanceof XYPlot) { XYPlot plot = (XYPlot) rawPlot; plot.getDomainAxis().setLabelPaint(foregroung); plot.getRangeAxis().setLabelPaint(foregroung); plot.getDomainAxis().setTickLabelPaint(foregroung); plot.getDomainAxis().setTickMarkPaint(foregroung); plot.getRangeAxis().setTickLabelPaint(foregroung); plot.getRangeAxis().setTickMarkPaint(foregroung); plot.setBackgroundPaint(background); plot.setDomainGridlinePaint(foregroung); plot.setRangeGridlinePaint(foregroung); } if (rawPlot instanceof CategoryPlot) { CategoryPlot plot = (CategoryPlot) rawPlot; plot.getDomainAxis().setLabelPaint(foregroung); plot.getRangeAxis().setLabelPaint(foregroung); plot.getDomainAxis().setTickLabelPaint(foregroung); plot.getDomainAxis().setTickMarkPaint(foregroung); plot.getRangeAxis().setTickLabelPaint(foregroung); plot.getRangeAxis().setTickMarkPaint(foregroung); plot.setBackgroundPaint(background); plot.setDomainGridlinePaint(foregroung); plot.setRangeGridlinePaint(foregroung); } }
From source file:edu.wpi.cs.wpisuitetng.modules.requirementmanager.view.requirements.NewPieChartPanel.java
/** * @param dataset//from w ww . j a v a2 s . com * the data to be displayed by the pie chart * @param title * the title of the chart @return the pie chart to be displayed */ private static JFreeChart createChart(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart3D(title, // chart title dataset, // data true, // include legend true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot();// 3D pie chart. the cats // are going to love // this. plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0.02); plot.setStartAngle(270); plot.setDirection(Rotation.ANTICLOCKWISE); //Rotator rotator = new Rotator(plot); //rotator.start(); return chart; }
From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java
public static void setXYSeriesColors(JFreeChart chart, ChartData chartData) { if (chart.getPlot() instanceof XYPlot && chartData.getColors() != null) { XYPlot plot = (XYPlot) chart.getPlot(); String[] colors = chartData.getColors().split(","); for (int i = 0; i < colors.length; i++) { plot.getRenderer().setSeriesPaint(i, ChartUtils.getColor(colors[i].trim())); }//w ww.j av a 2 s . c om } }
From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java
/** * Series coloring//ww w. ja v a 2 s.c o m * Plot has no getRenderer so two methods for each plot type(categoryplot and xyplot) */ public static void setCategorySeriesColors(JFreeChart chart, ChartData chartData) { if (chart.getPlot() instanceof CategoryPlot) { CategoryPlot plot = (CategoryPlot) chart.getPlot(); if (chartData.getColors() != null) { String[] colors = chartData.getColors().split(","); for (int i = 0; i < colors.length; i++) { plot.getRenderer().setSeriesPaint(i, ChartUtils.getColor(colors[i].trim())); } } } }