1 2 35 36 package org.krysalis.jcharts.demo.userGuide; 37 38 39 import java.awt.BasicStroke ; 40 import java.awt.Color ; 41 import java.awt.Paint ; 42 43 import org.krysalis.jcharts.chartData.ChartDataException; 44 import org.krysalis.jcharts.chartData.PieChartDataSet; 45 import org.krysalis.jcharts.nonAxisChart.PieChart3D; 46 import org.krysalis.jcharts.properties.ChartProperties; 47 import org.krysalis.jcharts.properties.LegendProperties; 48 import org.krysalis.jcharts.properties.PieChart3DProperties; 49 import org.krysalis.jcharts.properties.util.ChartStroke; 50 import org.krysalis.jcharts.types.PieLabelType; 51 52 53 58 public class PieChart3DGuide extends UserGuideBase 59 { 60 61 66 public void run() throws Throwable 67 { 68 this.basicChart(); 69 this.zeroDegreeOffsetChart(); 70 this.depth(); 71 this.borderStroke(); 72 this.borderPaint(); 73 74 this.pieValueLabels(); 75 this.pieLegendLabels(); 76 } 77 78 79 80 private void outputChart( PieChart3DProperties pieChart3DProperties, String name ) throws ChartDataException 81 { 82 double[] data= { 81d, 55d, 39d, 20.6d }; 83 String [] labels= { "BMW M5", "BMW M3", "Viper GTS-R", "Corvette Z06" }; 84 Paint [] paints= { Color.lightGray, Color.green, Color.blue, Color.red }; 85 86 PieChartDataSet pieChartDataSet= new PieChartDataSet( "Cars That Own", data, labels, paints, pieChart3DProperties ); 87 88 PieChart3D pieChart3D= new PieChart3D( pieChartDataSet, new LegendProperties(), new ChartProperties(), 600, 350 ); 89 super.exportImage( pieChart3D, name ); 90 } 91 92 93 94 private void basicChart() throws Throwable 95 { 96 PieChart3DProperties pieChart3DProperties= new PieChart3DProperties(); 97 this.outputChart( pieChart3DProperties, "pieChart3DBasic" ); 98 } 99 100 101 102 private void zeroDegreeOffsetChart() throws Throwable 103 { 104 PieChart3DProperties pieChart3DProperties= new PieChart3DProperties(); 105 pieChart3DProperties.setZeroDegreeOffset( 45f ); 106 this.outputChart( pieChart3DProperties, "pieChart3DZeroOffset" ); 107 } 108 109 110 111 private void depth() throws Throwable 112 { 113 PieChart3DProperties pieChart3DProperties= new PieChart3DProperties(); 114 pieChart3DProperties.setDepth( 50 ); 115 this.outputChart( pieChart3DProperties, "pieChart3DDepth" ); 116 } 117 118 119 120 private void borderStroke() throws Throwable 121 { 122 PieChart3DProperties pieChart3DProperties= new PieChart3DProperties(); 123 pieChart3DProperties.setBorderChartStroke( new ChartStroke( new BasicStroke ( 4f ), Color.black ) ); 124 this.outputChart( pieChart3DProperties, "pieChart3DBorderStroke" ); 125 } 126 127 128 129 private void borderPaint() throws Throwable 130 { 131 136 } 137 138 139 private void pieValueLabels() throws ChartDataException 140 { 141 PieChart3DProperties pieChart3DProperties= new PieChart3DProperties(); 142 pieChart3DProperties.setPieLabelType( PieLabelType.VALUE_LABELS ); 143 this.outputChart( pieChart3DProperties, "pieChart3DValueLabels" ); 144 } 145 146 private void pieLegendLabels() throws ChartDataException 147 { 148 PieChart3DProperties pieChart3DProperties= new PieChart3DProperties(); 149 pieChart3DProperties.setPieLabelType( PieLabelType.LEGEND_LABELS ); 150 151 double[] data= { 81d, 55d, 39d, 20.6d }; 152 String [] labels= { "BMW M5", "BMW M3", "Viper GTS-R", "Audi S6" }; 153 Paint [] paints= { Color.lightGray, Color.green, Color.blue, Color.red }; 154 155 PieChartDataSet pieChartDataSet= new PieChartDataSet( "Cars That Own", data, labels, paints, pieChart3DProperties ); 156 PieChart3D pieChart3D= new PieChart3D( pieChartDataSet, null, new ChartProperties(), 400, 350 ); 157 super.exportImage( pieChart3D, "pieChart3DLegendLabels" ); 158 } 159 } 160 161 162 163 164 165 | Popular Tags |