簡體   English   中英

如何在Android中在線圖上的X軸上動態添加日期

[英]How to add dates dynamically on x-axis on line graph in android

GraphView graph = (GraphView) findViewById(R.id.graph);
GridLabelRenderer gridLabel = graph.getGridLabelRenderer();
gridLabel.setHorizontalAxisTitle("Dates");
gridLabel.setVerticalAxisTitle("Status");

for (int i = 10; i >= 1; i--) {
    Calendar pastDate = Calendar.getInstance();
    pastDate.add(Calendar.DATE, -i);
    String beforedate = pastDate.get(Calendar.DATE) + "/" +(pastDate.get(Calendar.MONTH) + 1) + "/" + pastDate.get(Calendar.YEAR);

    Log.i("paste date is:", beforedate);
}

嘗試這個

gridLabel.setHorizontalLabels(new String[]{"1/1/1970", "1/2/1970", "1/3/1970"});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM