0
使线型图我想用我从http://www.jjoe64.com/p/graphview-library.html我的问题而采取的是我想从JSON采取数据作为波纹管Graphview库做一个线型图:如何使用Graphview库
[
{
"lji_invest": "Excellink Aggressive Fund",
"persen_hke1": 0,
"lnu_nilai": 3611.468,
"lji_id": "03",
"tanggal": "01/04/2013"
},
{
"lji_invest": "Excellink Aggressive Fund",
"persen_hke1": 0.001143302391160603,
"persen_hmin1": 0.001143302391160603,
"lnu_nilai": 3615.597,
"selisih": 4.129,
"lji_id": "03",
"tanggal": "02/04/2013"
},
{
"lji_invest": "Excellink Aggressive Fund",
"persen_hke1": 0.005411926673585367,
"persen_hmin1": 0.004263749527394784,
"lnu_nilai": 3631.013,
"selisih": 15.416,
"lji_id": "03",
"tanggal": "03/04/2013"
}]
我想显示“lnu_nilai “和”tanggal“在线图中,我试过了,但我什么都没有。这是我的源代码:
public class LineChartAsyncTask extends AsyncTask <String, String, String>{
@Override
protected void onPreExecute(){
super.onPreExecute();
Dialog=new ProgressDialog(LineChart.this);
Dialog.setMessage("Mohon Tunggu Sebentar...");
Dialog.setIndeterminate(false);
Dialog.setCancelable(true);
Dialog.show();
}
@Override
protected String doInBackground(String... params) {
String url= "http://www.sinarmaslife.co.id/E-Policy/ios/NabChart.htm?id=03&nilai=7";
try {
JSONParser jp= new JSONParser();
JSONArray ja= jp.takeJson(url);
for (int i=0; i<ja.length();i++){
JSONObject jo = ja.getJSONObject(i);
HashMap<String, String> map = new HashMap<String, String>();
if (jo.has("lnu_nilai"))
map.put("lnu_nilai", jo.get("lnu_nilai").toString());
if (jo.has("tanggal"))
map.put("tanggal", jo.get("tanggal").toString());
NabList.add(map);
}
}
catch (JSONException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String file_url) {
Dialog.dismiss();
GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[NabList.size()]);
{
for (int i=0; i<NabList.size();i++){
HashMap MapA= new HashMap();
MapA=(HashMap) NabList.get(i);
}
}
GraphView graphView;
graphView = new LineGraphView(
this // context
, "GraphViewDemo" // heading
);
graphView.addSeries(exampleSeries); // data
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
layout.addView(graphView);
};
}
}
我申请了强制关闭,和图表没有显示....我不知道哪里是我的错,我希望有人能帮助我解决这个问题,谢谢