Krysalis jCharts
 
  Font size:      
 

Bar Charts

PDF
PDF

Stacked Bar Charts

Here is some code to generate a Stacked Bar 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  }, 
                                 { 150, 15, 6, 62, 54, 10, 84  }, 
                                 { 250, 45, 36, 66, 145, 80, 55  } };
String[] legendLabels= { "Bugs", "Security Holes", "Backdoors" };
Paint[] paints= TestDataGenerator.getRandomPaints( 3 );
StackedBarChartProperties stackedBarChartProperties= 
                                           new StackedBarChartProperties();
AxisChartDataSet axisChartDataSet= new AxisChartDataSet( data, 
                                                         legendLabels, 
                                                         paints, 
                                                         ChartType.BAR_STACKED, 
                                                         stackedBarChartProperties );
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 );
			
Stacked Bar Chart


Valid HTML 4.01!Valid CSS!