我在我的Android应用程序中使用jjoe64 Graph View。 我试图在图表中显示动态值,但第一次它不包含值但图表没有出现。 给我解决方案。 http://www.android-graphview.org/
答案 0 :(得分:0)
你能告诉我们你的代码吗? 你尝试过像
这样的东西吗? graph = (GraphView) findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>();
graph.addSeries(series);
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setYAxisBoundsManual(true);
graph.getViewport().setMinX(0);
graph.getViewport().setMaxX(0);
graph.getViewport().setMinY(0);
graph.getViewport().setMaxY(4);
graph.onDataChanged(true, true);
答案 1 :(得分:0)
这个问题有bug report logged,看来问题将在下一个版本(4.0.1)中得到修复。无论如何,我只是通过显示一些文字来解决问题,指示那里和那时没有数据,例如。
// If there is no data, let the user know, else blank the textBox.
TextView fragmentText = (TextView) v.findViewById(R.id.history_text);
if ( xLabels.size() < 2 ){
fragmentText.setTextSize(24);
fragmentText.setText(getString(R.string.history_graph_no_data));
} else {
// Remove the "No Data" text
fragmentText.setText("");
LinearLayout layout = (LinearLayout) v.findViewById(R.id.history_graph);
addGraphToLayout(layout);
}