私は会社の株価履歴がDB列に保存されているデータベースから株式日付を取得しています。毎日のデータは{date、stock_value}の形式で存在し、他の日付から "\ n"で区切られています。Android GraphViewはX軸に1つの日付しかレンダリングしません
String[] allStocks = history.split("\n");
String[] singleStock;
ArrayList<DataPoint> points = new ArrayList<>();
GraphView graph = (GraphView) findViewById(R.id.graph);
for(int i=0; i<3; i++)
{
singleStock = allStocks[i].split(",");
Date date = new Date(Long.parseLong(singleStock[0]));
System.out.println(date);
points.add(new DataPoint(new Date(Long.parseLong(singleStock[0])), Float.parseFloat(singleStock[1])));
}
DataPoint[] dbPoint = points.toArray(new DataPoint[points.size()]);
System.out.println(points);
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(dbPoint);
graph.addSeries(series);
graph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(this));
graph.getGridLabelRenderer().setNumHorizontalLabels(2);
// set manual x bounds to have nice steps
graph.getViewport().setXAxisBoundsManual(true);
// as we use dates as labels, the human rounding to nice readable numbers
// is not necessary
graph.getGridLabelRenderer().setHumanRounding(false);
次の変数ポイントのコンテンツである: [1.4887386E12/117.55000305175781]、[1.4881338E12/118.62000274658203]、[1.4876154E12/118.79000091552734]
グラフとして表示されます The graph appears only for one date
これは私のグラフのxmlです:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.jjoe64.graphview.GraphView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/graph" />
</LinearLayout>
つだけ日付が表示されますでグラフ。日付のための 'GraphView'からサンプルコードを試してみると、すべてが期待通りに機能します。私のコードに欠陥があるかどうか教えてください。
'機能しません。同じ問題が続く。 –