package com.example.smarthome;

import org.achartengine.ChartFactory;
import org.achartengine.model.CategorySeries;
import org.achartengine.renderer.DefaultRenderer;
import org.achartengine.renderer.SimpleSeriesRenderer;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;

public class YesterDay extends Activity {

	int meter1,meter2;
	int []consumption=new int[2];
	int []colors =new int[]{Color.BLUE, Color.WHITE};
	String m1,m2;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_yester_day);
		Bundle ext=getIntent().getExtras();
		
		m1=ext.getString("str1");
		m2=ext.getString("str2");
		getInt(getBaseContext());
	}

	

	public void getInt(Context con){
	

	
	try{ 
		meter1 = Integer.parseInt(m1);
		 meter2 = Integer.parseInt(m2);
	}catch(Exception e){};
	consumption[0]= meter1;
	consumption[1]=meter2;
	
	CategorySeries series = new CategorySeries("pie");
	series.add("METER1", consumption[0]);
	series.add("METER2", consumption[1]);
	DefaultRenderer renderer = new DefaultRenderer();
	for(int color: colors){
		SimpleSeriesRenderer r =new SimpleSeriesRenderer();
		r.setColor(color);
		r.setDisplayBoundingPoints(true);
		r.setDisplayChartValuesDistance(5);
		r.setChartValuesTextSize(15);
		renderer.addSeriesRenderer(r);
	}
	renderer.isInScroll();
	renderer.setZoomButtonsVisible(true);
	renderer.setApplyBackgroundColor(true);
	renderer.setBackgroundColor(Color.BLACK);
	renderer.setChartTitle("Previous Day Consumption Of Energy");
	renderer.setChartTitleTextSize((float)30);
	renderer.setShowLabels(true);
	renderer.setLabelsTextSize(20);
	renderer.setLegendTextSize(25);
	renderer.setDisplayValues(true);
	Intent inta=ChartFactory.getPieChartIntent(con, series, renderer, "Done");
	 startActivity(inta);
}
	


}

