Skip to content

Instantly share code, notes, and snippets.

@jddeep
Created June 24, 2019 10:34
Show Gist options
  • Save jddeep/8b578c45c589d7aafd85cc9b9ebe9583 to your computer and use it in GitHub Desktop.
Save jddeep/8b578c45c589d7aafd85cc9b9ebe9583 to your computer and use it in GitHub Desktop.
private void addEntry() {
LineData data = graph.getData();
if (data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
if (set == null) {
set = createSet();
data.addDataSet(set);
}
data.addEntry(new Entry(set.getEntryCount(), (float) (Math.random() * 40) + 30f), 0);
data.notifyDataChanged();
// let the graph know it's data has changed
graph.notifyDataSetChanged();
// limit the number of visible entries
graph.setVisibleXRangeMaximum(120);
// graph.setVisibleYRange(30, AxisDependency.LEFT);
// move to the latest entry
graph.moveViewToX(data.getEntryCount());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment