Java Code Examples for org.jfree.chart.plot.PiePlot#setDirection()
The following examples show how to use
org.jfree.chart.plot.PiePlot#setDirection() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphStatsView.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * Crée le graphe JFreeChart. * * @param piedataset * : la source de données à afficher * @return le diagramme */ private JFreeChart createChart(GraphPieDataset piedataset) { JFreeChart jfreechart = ChartFactory.createPieChart3D(null, piedataset, false, true, false); jfreechart.setAntiAlias(true); jfreechart.setTextAntiAlias(true); PiePlot pieplot3d = (PiePlot) jfreechart.getPlot(); pieplot3d.setInsets(new RectangleInsets(0, 0, 0, 0)); final double angle = 290D; pieplot3d.setStartAngle(angle); pieplot3d.setDirection(Rotation.CLOCKWISE); final float foreground = 0.5F; pieplot3d.setForegroundAlpha(foreground); pieplot3d.setNoDataMessage(Messages.GraphStatsView_noDataToDisplay); pieplot3d.setCircular(true); pieplot3d.setOutlinePaint(null); pieplot3d.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); pieplot3d.setLabelGap(0.02); pieplot3d.setLabelOutlinePaint(null); pieplot3d.setLabelShadowPaint(null); pieplot3d.setLabelBackgroundPaint(Color.WHITE); pieplot3d.setBackgroundPaint(Color.WHITE); // avoid showing the percentage as an absolute number in the tooltip pieplot3d.setToolTipGenerator(new StandardPieToolTipGenerator("{0}: {2}")); pieplot3d.setInteriorGap(0.02); pieplot3d.setMaximumLabelWidth(0.20); return jfreechart; }
Example 2
Source File: StatisticsController.java From JDeSurvey with GNU Affero General Public License v3.0 | 5 votes |
@Secured({"ROLE_ADMIN","ROLE_SURVEY_ADMIN"}) private JFreeChart createChart(PieDataset pieDataset, String title) { try{ JFreeChart chart = ChartFactory.createPieChart(title, pieDataset, false,true,false); chart.setBackgroundPaint(null);//this line necessary for transparency of background final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setOpaque(false); //this line necessary for transparency of background chartPanel.setBackground(new Color(0, 0, 0, 0)); //this line necessary for transparency of background PiePlot plot = (PiePlot) chart.getPlot(); //Color[] colors = {new Color(170, 195, 217, 255),new Color(246, 140, 31, 255),new Color(204, 204, 204, 255),new Color(231, 238, 144, 255),new Color(51, 51, 51, 255),new Color(101, 125, 151, 255),new Color(0, 102, 255, 255)}; //PieRenderer renderer = new PieRenderer(colors); //renderer.setColor(plot, pieDataset); PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0}:{1}%"); plot.setLabelGenerator(generator); plot.setStartAngle(270); plot.setDirection(Rotation.CLOCKWISE); return chart; } catch (Exception e) { log.error(e.getMessage(),e); throw (new RuntimeException(e)); } }
Example 3
Source File: PieChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void configureChart( final JFreeChart chart ) { super.configureChart( chart ); final Plot plot = chart.getPlot(); final PiePlot pp = (PiePlot) plot; final PieDataset pieDS = pp.getDataset(); pp.setDirection( rotationClockwise ? Rotation.CLOCKWISE : Rotation.ANTICLOCKWISE ); if ( ( explodeSegment != null ) && ( explodePct != null ) ) { configureExplode( pp ); } if ( StringUtils.isEmpty( getTooltipFormula() ) == false ) { pp.setToolTipGenerator( new FormulaPieTooltipGenerator( getRuntime(), getTooltipFormula() ) ); } if ( StringUtils.isEmpty( getUrlFormula() ) == false ) { pp.setURLGenerator( new FormulaPieURLGenerator( getRuntime(), getUrlFormula() ) ); } pp.setIgnoreNullValues( ignoreNulls ); pp.setIgnoreZeroValues( ignoreZeros ); if ( Boolean.FALSE.equals( getItemsLabelVisible() ) ) { pp.setLabelGenerator( null ); } else { final ExpressionRuntime runtime = getRuntime(); final Locale locale = runtime.getResourceBundleFactory().getLocale(); final FastDecimalFormat fastPercent = new FastDecimalFormat( FastDecimalFormat.TYPE_PERCENT, locale, true ); final FastDecimalFormat fastInteger = new FastDecimalFormat( FastDecimalFormat.TYPE_INTEGER, locale, true ); final DecimalFormat numFormat = new DecimalFormat( fastInteger.getPattern(), new DecimalFormatSymbols( locale ) ); numFormat.setRoundingMode( RoundingMode.HALF_UP ); final DecimalFormat percentFormat = new DecimalFormat( fastPercent.getPattern(), new DecimalFormatSymbols( locale ) ); percentFormat.setRoundingMode( RoundingMode.HALF_UP ); final StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( pieLabelFormat, numFormat, percentFormat ); pp.setLabelGenerator( labelGen ); final StandardPieSectionLabelGenerator legendGen = new StandardPieSectionLabelGenerator( pieLegendLabelFormat, numFormat, percentFormat ); pp.setLegendLabelGenerator( legendGen ); } if ( StringUtils.isEmpty( getLabelFont() ) == false ) { pp.setLabelFont( Font.decode( getLabelFont() ) ); } if ( pieDS != null ) { final String[] colors = getSeriesColor(); for ( int i = 0; i < colors.length; i++ ) { if ( i < pieDS.getItemCount() ) { pp.setSectionPaint( pieDS.getKey( i ), parseColorFromString( colors[ i ] ) ); } else { break; } } } if ( shadowPaint != null ) { pp.setShadowPaint( shadowPaint ); } if ( shadowXOffset != null ) { pp.setShadowXOffset( shadowXOffset.doubleValue() ); } if ( shadowYOffset != null ) { pp.setShadowYOffset( shadowYOffset.doubleValue() ); } pp.setCircular( circular ); if ( isShowBorder() == false || isChartSectionOutline() == false ) { chart.setBorderVisible( false ); chart.getPlot().setOutlineVisible( false ); } }