我有我的應用程序的屏幕顯示如下圖:如何建立與Graphview一個傳說中的Android工作室
有沒有辦法改變我的傳說,以便它可以說什麼每種顏色代表?目前我可以看到藍色方塊顯示,但不代表任何數字。以下是我在創建圖形時使用的代碼:
GraphView graph = (GraphView) findViewById(R.id.graph);
BarGraphSeries<DataPoint> series = new BarGraphSeries<DataPoint>(new DataPoint[]{
new DataPoint(1, personal),
new DataPoint(2, fun),
new DataPoint(3, work),
new DataPoint(4, food),
new DataPoint(5, commute),
new DataPoint(6,bills)
});
graph.setTitle("Expenses");
graph.addSeries(series);
graph.getLegendRenderer().setVisible(true);
graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.TOP);
series.setValueDependentColor(new ValueDependentColor<DataPoint>() {
@Override
public int get(DataPoint data) {
return Color.rgb((int) data.getX() * 255/4, (int) Math.abs(data.getY() * 255/6), 100);
}
});
series.setSpacing(50);
series.setDrawValuesOnTop(true);
series.setValuesOnTopColor(Color.RED);
backToMainMenu();
}