650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/70/F3/wKioL1XB4SWThTQuAAEODt5IRQM050.jpg "title=" D3f4f41c9d35e38e5c8bb8f6eafd0e53.jpg "alt=" Wkiol1xb4swthtquaaeodt5irqm050.jpg "/>
Import java.util.ArrayList;
Import android.content.Intent;
Import Android.os.AsyncTask;
Import Android.os.Bundle;
Import android.support.v7.app.ActionBarActivity;
Import Android.view.View;
Import Android.view.animation.AnimationUtils;
Import Com.github.mikephil.charting.charts.BarChart;
Import Com.github.mikephil.charting.data.BarData;
Import Com.github.mikephil.charting.data.BarDataSet;
Import Com.github.mikephil.charting.data.BarEntry;
Import Com.github.mikephil.charting.utils.ColorTemplate;
Import Com.github.mikephil.charting.utils.XLabels;
Import com.github.mikephil.charting.utils.XLabels.XLabelPosition;
public class Mainactivity extends Actionbaractivity {
Private Barchart Msaltchart;
public void V) {
StartActivity (New Intent (This,mainactivity.class));
Finish ();
Overridependingtransition (0, 0);
}
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Msaltchart = (barchart) Findviewbyid (R.id.chart_salt);
Initchart ();
Initanimotion ();
}
private void Initanimotion () {
Msaltchart.setanimation (Animationutils.loadanimation (This,
R.anim.in_leftright));
Msaltchart.setvisibility (view.visible);
Msaltchart.animatey (1000);
}
private void Initchart () {
TODO auto-generated Method Stub
/**
* Unit
*/
Msaltchart.setunit ("ml");
/**
* Horizontal axis
*/
Msaltchart.setdescription ("Salt content monitoring ml/h");
/**
* Number of Bar charts
*/
Msaltchart.setmaxvisiblevaluecount (12);
/**
* Set the number of digits in the chart
*/
Msaltchart.setvaluedigits (2);
/**
* 3D Effect
*/
Msaltchart.set3denabled (TRUE);
/**
* Scaling can only be done on the X and Y axes, respectively
*/
Msaltchart.setpinchzoom (FALSE);
Msaltchart.setdrawbarshadow (FALSE);
Msaltchart.setdrawverticalgrid (FALSE);
Msaltchart.setdrawhorizontalgrid (FALSE);
Msaltchart.setdrawgridbackground (FALSE);
Xlabels xlabels = Msaltchart.getxlabels ();
Xlabels.setposition (Xlabelposition.bottom);
Xlabels.setcenterxlabeltext (TRUE);
Xlabels.setspacebetweenlabels (0);
Msaltchart.setdrawylabels (TRUE);
Msaltchart.setdrawlegend (FALSE);
Msaltchart.setdrawyvalues (TRUE);
/**
* Set Animation time
*/
Msaltchart.animatey (1000);
/**
* Histogram data incoming
*/
New Charttask (). Execute (50);
}
/**
* Histogram data incoming
*/
Private class Charttask extends Asynctask<integer, Integer, bardata> {
@Override
protected void OnPreExecute () {
}
@Override
Protected BarData doinbackground (Integer ... arg0) {
TODO auto-generated Method Stub
arraylist<barentry> yVals1 = new arraylist<barentry> ();
for (int i = 0; i <; i++) {
float mult = (30 + 1);
float val1 = (float) (Math.random () * mult) + MULT/3;
Yvals1.add (New Barentry ((int) val1, i));
}
arraylist<string> xvals = new arraylist<string> ();
for (int i = 0; i <; i++) {
Xvals.add (i * 2 + "h");
}
/**
* Set Color
*/
Bardataset Set1 = new Bardataset (YVALS1, "Data Set");
Set1.setcolors (Colortemplate.createcolors (Mainactivity.this,
colortemplate.vordiplom_colors));
arraylist<bardataset> dataSets = new arraylist<bardataset> ();
Datasets.add (SET1);
BarData data = new BarData (xvals, dataSets);
return data;
}
@Override
protected void OnPostExecute (BarData result) {
TODO auto-generated Method Stub
Msaltchart.setdata (result);
Msaltchart.invalidate ();
Super.onpostexecute (result);
}
}
}
You need a friend to talk to, because there is still a rack package can not upload (702246917)
Android histogram (led drawing)