use of com.jjoe64.graphview.series.LineGraphSeries in project stillStanding by katsik.
the class GraphActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.AppTheme);
setContentView(R.layout.activity_graph);
// Get a support ActionBar corresponding to this toolbar
ActionBar ab = getSupportActionBar();
// Enable the Up button
ab.setDisplayHomeAsUpEnabled(true);
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
GraphView graph = (GraphView) findViewById(R.id.graph);
series = new LineGraphSeries<>();
series.setColor(Color.BLUE);
series.setThickness(10);
graph.addSeries(series);
series.setDrawBackground(true);
// activate horizontal zooming and scrolling
graph.getViewport().setScalable(true);
// activate horizontal scrolling
graph.getViewport().setScrollable(true);
// activate horizontal and vertical zooming and scrolling
graph.getViewport().setScalableY(true);
// activate vertical scrolling
graph.getViewport().setScrollableY(true);
// To set a fixed manual viewport use this:
// set manual X bounds
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(0.5);
graph.getViewport().setMaxX(6.5);
// set manual Y bounds
graph.getViewport().setYAxisBoundsManual(true);
graph.getViewport().setMinY(0);
graph.getViewport().setMaxY(20);
graph.setTitle(getString(R.string.graph_title));
currentX = 0;
// Start chart thread
liveChartExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(1);
if (liveChartExecutor != null)
liveChartExecutor.execute(new AccelerationChart(new AccelerationChartHandler()));
}
use of com.jjoe64.graphview.series.LineGraphSeries in project fitness-app by seemoo-lab.
the class InfoArrayAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = null;
int type = getItemViewType(position);
// Inflate the layout according to the view type
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (type == InfoListItem.TEXT_VIEW) {
// Inflate the layout with image
v = inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
TextView text = (TextView) v.findViewById(android.R.id.text1);
InfoListItem infoListItem = itemList.get(position).getItem();
Information info = (Information) infoListItem.getItem();
text.setText(Html.fromHtml(info.toString()), TextView.BufferType.SPANNABLE);
} else {
v = inflater.inflate(R.layout.listitem_dumpgraph, parent, false);
InfoListItem infoListItem = itemList.get(position);
InfoGraphDataPoints dgDataPoints = (InfoGraphDataPoints) infoListItem.getItem();
DataPoint[] dataPoints = dgDataPoints.getDatapoints();
GraphView graph = (GraphView) v.findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(dataPoints);
series.setDrawDataPoints(true);
graph.addSeries(series);
// set date label formatter
graph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(ctx));
if (dataPoints.length == 5) {
// max 3 because of the space
graph.getGridLabelRenderer().setNumHorizontalLabels(3);
} else if (dataPoints.length > 5) {
graph.getGridLabelRenderer().setNumHorizontalLabels(2);
} else {
graph.getGridLabelRenderer().setNumHorizontalLabels(dataPoints.length);
}
// set manual x bounds to have nice steps
graph.getViewport().setMinX(dataPoints[0].getX());
graph.getViewport().setMaxX(dataPoints[dataPoints.length - 1].getX());
graph.getViewport().setXAxisBoundsManual(true);
// set manual y bounds to have nice steps
graph.getViewport().setMinY(0);
graph.getViewport().setYAxisBoundsManual(true);
// as we use dates as labels, the human rounding to nice readable numbers
// is not necessary
graph.getGridLabelRenderer().setHumanRounding(false);
}
return v;
}
use of com.jjoe64.graphview.series.LineGraphSeries in project apneil by Inv4si0n.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GraphView graph = findViewById(R.id.graph);
// Titre du graph
graph.setTitle("Titre");
// Couleur du titre du graph
graph.setTitleColor(Color.BLUE);
series = new LineGraphSeries<>(generateData());
// Couleur de la courbe
series.setColor(Color.GREEN);
// Tracé les points
series.setDrawDataPoints(true);
// Radius points
series.setDataPointsRadius(10);
// Epaisseur
series.setThickness(2);
graph.addSeries(series);
Button button = findViewById(R.id.on);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
System.out.println("ta mere la chauve");
}
});
}
use of com.jjoe64.graphview.series.LineGraphSeries in project teamward-client by Neamar.
the class WinrateByTimeTipHolder method bind.
public void bind(Tip tip) {
for (Team team : tip.game.teams) {
DataPoint[] points = new DataPoint[team.winrateByGameLength.size()];
int counter = 0;
for (int i = 0; i < team.winrateByGameLength.size(); i++) {
int key = team.winrateByGameLength.keyAt(i);
points[counter] = new DataPoint(key, team.winrateByGameLength.get(key));
counter += 1;
}
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(points);
if (team.teamId == 100) {
series.setColor(graphView.getContext().getResources().getColor(R.color.blueTeam));
} else {
series.setColor(graphView.getContext().getResources().getColor(R.color.redTeam));
}
graphView.addSeries(series);
blueTeam.setText(tip.game.getPlayerOwnTeam().teamId == 100 ? R.string.your_team : R.string.their_team);
redTeam.setText(tip.game.getPlayerOwnTeam().teamId == 200 ? R.string.your_team : R.string.their_team);
}
}
Aggregations