2016-04-13 8 views
1

Hi ben gibi statik bu kütüphaneye ama onun girişlerle bir grafik çizmek çalışıyorum:JJOE64 Android graphview seti LineGraphSeries Dinamik

LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] { 

         new DataPoint(0, 1), 
         new DataPoint(1, 5), 
         new DataPoint(2, 3), 
         new DataPoint(3, 2), 
         new DataPoint(4, 6) 
       }); 
       graph.addSeries(series); 

Nasıl ex kabul ettiğini bu sorunu giderebilirsiniz. çalışma zamanında oluşturulmuş bir liste görünümü öğeleri?

for (int i = 0; i < list.size(); i++) { 
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] { 

         new DataPoint(i, list.getElement()), 
}); 
} 

cevap

4

böyle bir şey deneyin: o kadar çok azam sayesinde çalışıyor

DataPoint[] dataPoints = new DataPoint[list.size()]; // declare an array of DataPoint objects with the same size as your list 
for (int i = 0; i < list.size(); i++) { 
    // add new DataPoint object to the array for each of your list entries 
    dataPoints[i] = new DataPoint(i, list.getElement()); // not sure but I think the second argument should be of type double 
} 

LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(dataPoints); // This one should be obvious right? :) 
+0

Javascipt Böyle bir şey istiyorum. Bir soru daha var x ekseni i dayanmaktadır. Bunu zamanla nasıl değiştirebilirim? Bazı değer ve değer-zaman ile tamamlanmış bir listeye sahibim. Ben y ekseninin değer olduğunu (tamam) ve x ekseninin zamanı nasıl ayarlayabilirim? – mesopotamia

+0

StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter (yourGraphView); staticLabelsFormatter.setHorizontalLabels (yeni String [] { time1, time2, time3, vb}); SetLabelFormatter (staticLabelsFormatter); Örneğin bununla oynayabilir ya da buraya göz atabilirsiniz [link] (http://www.android-graphview.org/documentation/category/labels-and-label-formatter) –

+0

Eğer verileri değiştirmek isterseniz – appsthatmatter