[英]GraphView android: strange behavior of graph
我的graphview第一次嘗試代碼有問題:
GraphView graphView;
GraphViewSeries series;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GraphViewData[] data = new GraphViewData[4];
Double[] x_values = new Double[] { 1.0, 2.0, 3.0, 4.0 };
Double[] y_values = new Double[] { 1.0, 2.0, 3.0, 4.0 };
for (int i = 0; i < data.length; i++) {
data[i] = new GraphViewData(x_values[i], y_values[i]);
}
series = new GraphViewSeries(data);
graphView = new LineGraphView(this, "Title");
graphView.addSeries(series);
graphView.setScrollable(true);
graphView.setScalable(true);
graphView.setBackgroundColor(Color.BLACK);
LinearLayout l = (LinearLayout) findViewById(R.id.linearLay);
l.addView(graphView);
}
兩個問題:-背景仍然是白色-放大后,我無法縮小-x軸上的標簽未顯示
關於白色背景,請嘗試添加:
((LineGraphView) graphView).setDrawBackground(true);
您可以這樣設置標簽顏色:
graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.BLACK);
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.BLACK);
我希望它能起作用!
Br,蒂姆
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.