protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nextstatschart);
myDataset = new XYMultipleSeriesDataset ();
statsRenderer = new DefaultRenderer();
myRenderer.setLabelsColor(Color.BLUE);
myRenderer.setLabelsTextSize(12);
myRenderer.setAxesColor(Color.BLACK);
myRenderer.setBackgroundColor(Color.WHITE);
myRenderer.setAntialiasing(true);
myRenderer.setShowLabels(true);
myRenderer.setShowGrid(true);
myRenderer.setChartTitle("Next Three Months Statistical Analysis");
myRenderer.setChartTitleTextSize(16);
myRenderer.setZoomEnabled(true);
myRenderer.setChartTitle(heading);
myRenderer.setLabelsColor(Color.BLACK);
myRenderer.setXAxisMin(0);
myRenderer.setXAxisMax(100);
myRenderer.setYAxisMin(0);
myRenderer.setYAxisMax(100);
myRenderer.setYLabelsAlign(Align.RIGHT);
myRenderer.setXTitle ("Case Type");
myRenderer.setYTitle ("Count");
myRenderer.setMargins(new int[] { 30, 40, 10, 40 });
Bundle b = getIntent().getExtras();
typ = b.getStringArray("typ");
nums = b.getStringArray("counts");
percentages = b.getDoubleArray("percs");
stat_count = b.getInt("stat_count");
X_Axis = b.getDoubleArray("typp");
Y_Axis = b.getDoubleArray("contt");
}
@Override
protected void onResume() {
super.onResume();
try {
refreshChart();
if (statsChartView == null) {
LinearLayout layout = (LinearLayout) findViewById(R.id.statschart);
// statsChartView = ChartFactory.getPieChartView(getApplicationContext(), statsSeries, statsRenderer);
// statsChartView = ChartFactory.getLineChartView(getApplicationContext(), xyDataset, xyRender);
// statsChartView = ChartFactory.getBarChartView(context, dataset, renderer, type)
statsChartView = ChartFactory.getBarChartView(getApplicationContext(), myDataset, myRenderer,Type.DEFAULT);
layout.addView(statsChartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
layout.addView(statsChartView);
statsChartView.refreshDrawableState();
statsChartView.setBackgroundColor(Color.WHITE);
} else {
statsChartView.repaint();
}
// refreshChart();
}catch(Exception e){
e.printStackTrace();
}
}
void refreshChart() {
try {
mySeries = new XYSeries (series);
int[] colorpool = new int[] { 0xff000099, 0xff009900, 0xffff0000,
0xffffff00, 0xff990099, 0xffff9900, 0xff996600, 0xffcccccc,
0xff990000, 0xff66cccc, 0xff99ccff, 0xffccffcc };
int[] colors = new int[stat_count];
DecimalFormat Currency = new DecimalFormat("#0.00");
for (int i = 0; i < stat_count; i++) {
mySeries.add(Double.parseDouble(typ[i]),Double.parseDouble(nums[i]));
if (i > 11) {
colors[i] = 0xff333333;
} else {
colors[i] = colorpool[i];
}
}
myDataset.addSeries (mySeries);
for (int color : colors) {
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(color);
// statsRenderer.addSeriesRenderer(r);
xyRender.addSeriesRenderer(r);
}
mySeriesRenderer = new XYSeriesRenderer ();
if (series.equals("Weight")) {
mySeriesRenderer.setColor (0xff009900);
mySeriesRenderer.setPointStyle(PointStyle.POINT);
} else {
mySeriesRenderer.setColor (0xff990099);
}
myRenderer.addSeriesRenderer (mySeriesRenderer);
int length = myRenderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
((XYSeriesRenderer) myRenderer.getSeriesRendererAt(i)).setFillPoints(true);
}
// Draw the chart
statsChartView.repaint ();
} catch (Exception e) {
e.printStackTrace();
//Exception Code
}
}
}
E/AndroidRuntime(910): FATAL EXCEPTION: main
E/AndroidRuntime(910): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.courts.action/com.courts.action.NextStatsChart}: java.lang.NullPointerException