Area Charts
|
PDF |
Here is some code to generate an Area Chart. You can send 1..n data sets through it to be plotted.
String[] xAxisLabels= { "1998", "1999", "2000", "2001",
"2002", "2003", "2004" };
String xAxisTitle= "Years";
String yAxisTitle= "Problems";
String title= "Micro$oft at Work";
DataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle,
yAxisTitle, title );
double[][] data= new double[][]{ { 250, 45, -36, 66, 145, 80, 55 },
{ 250, 45, -36, 66, 145, 80, 55 } };
String[] legendLabels= { "Bugs", "Security Holes" };
Paint[] paints= TestDataGenerator.getRandomPaints( 2 );
AreaChartProperties areaChartProperties= new AreaChartProperties();
AxisChartDataSet axisChartDataSet= new AxisChartDataSet( data,
legendLabels,
paints,
ChartType.AREA_STACKED,
areaChartProperties );
dataSeries.addIAxisPlotDataSet( axisChartDataSet );
ChartProperties chartProperties= new ChartProperties();
AxisProperties axisProperties= new AxisProperties();
LegendProperties legendProperties= new LegendProperties();
AxisChart axisChart= new AxisChart( dataSeries,
chartProperties,
axisProperties,
legendProperties,
AxisChartsGuide.width,
AxisChartsGuide.height );