1 package org.krysalis.jcharts.demo.samples; 2 3 4 import java.awt.Color ; 5 import java.awt.Paint ; 6 7 import org.krysalis.jcharts.chartData.ChartDataException; 8 import org.krysalis.jcharts.chartData.PieChartDataSet; 9 import org.krysalis.jcharts.nonAxisChart.PieChart3D; 10 import org.krysalis.jcharts.properties.ChartProperties; 11 import org.krysalis.jcharts.properties.LegendProperties; 12 import org.krysalis.jcharts.properties.PieChart3DProperties; 13 import org.krysalis.jcharts.properties.util.ChartStroke; 14 import org.krysalis.jcharts.types.PieLabelType; 15 16 17 22 public class Pie3DSamples extends Sample 23 { 24 25 protected String getSubdir() 26 { 27 return "pie3d/"; 28 } 29 30 31 public void render() throws ChartDataException 32 { 33 double[] data = {45.00d, 90.00d, 45.00d, 180d}; 34 String [] labels = {"Equities", "Bonds", "Money Market", "Alternative Investments"}; 35 36 Paint [] paints = { new Color ( 200, 0, 0, 20 ), 37 new Color ( 0, 200, 0, 20 ), 38 new Color ( 0, 0, 200, 20 ), 39 new Color ( 200, 200, 0, 20 ) }; 40 41 42 PieChart3DProperties pieChart3DProperties = new PieChart3DProperties(); 43 pieChart3DProperties.setPieLabelType( PieLabelType.LEGEND_LABELS ); 44 pieChart3DProperties.setTickLength( 5 ); 45 46 pieChart3DProperties.setZeroDegreeOffset( 60 ); 47 48 pieChart3DProperties.setDepth( 15 ); 49 50 51 LegendProperties legendProperties = null; 52 57 58 PieChartDataSet pieChartDataSet = new PieChartDataSet( "Investment Categories", data, labels, paints, pieChart3DProperties ); 59 60 ChartProperties chartProperties = new ChartProperties(); 61 chartProperties.setBorderStroke( ChartStroke.DEFAULT_CHART_OUTLINE ); 62 63 PieChart3D pieChart = new PieChart3D( pieChartDataSet, legendProperties, chartProperties, 500, 400 ); 64 65 66 super.encode( pieChart, "pie3d" ); 67 } 68 } 69 | Popular Tags |