Open dharmen1901 opened 7 years ago
GraphView graph = (GraphView) findViewById(R.id.graph);
ArrayList<DataPoint> data = new ArrayList<DataPoint>();
//data.add(new DataPoint(0,0));
for(String str : historyArray)
{
String value[] = str.split(",");
Date date=new Date(Long.parseLong(value[0]));
Timber.d("Symbol clicked: %s", date);
data.add(new DataPoint(date,Double.parseDouble(value[1])));
}
DataPoint araay[] = new DataPoint[data.size()];
int i=0;
for(DataPoint x : data)
{
araay[i] = x;
i++;
}
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(araay);
graph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(this));
Calendar now = Calendar.getInstance();
now.add(Calendar.YEAR, -1);
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMaxX(System.currentTimeMillis());
graph.getViewport().setMinX(now.getTimeInMillis());
graph.getViewport().setScalable(true);
graph.getViewport().setScrollable(true);
graph.getGridLabelRenderer().setNumHorizontalLabels(12);
graph.getGridLabelRenderer().setHumanRounding(false);
graph.addSeries(series);
setNumHorizontalLabel(12) for 12 months shows all horizontal labels on one screen which is hard to read. And the graph is viewed only on scalling.
![Uploading Screenshot_2017-03-19-10-39-42-203_com.udacity.stockhawk.png…]() ![Uploading Screenshot_2017-03-19-10-39-48-603_com.udacity.stockhawk.png…]()