0

Hi I am new to android and I am developing an app to display a temperature data that I get from my firebase database. I am following the following tutorial to draw the graph https://www.youtube.com/watch?v=wEFkzQY_wWI . But I am not finding many tutorials on how to connect a database to XYplot. Please help me

public class MainActivity extends AppCompatActivity {

private XYPlot plot;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    plot = (XYPlot) findViewById(R.id.plot);

    XYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "series 1", 1,3,6,4,2,6,9);

    plot.addSeries(s1, new LineAndPointFormatter(Color.GREEN, Color.GREEN, null, null));

    PanZoom.attach(plot);
}}
KENdi
  • 7,576
  • 2
  • 16
  • 31
mas
  • 29
  • 1
  • 1
  • 6

1 Answers1

0

Androidplot (or any other plotting library of which I'm aware) does not provide utilities for mapping your firebase database to an XYSeries.

Writing your own adapter is the best approach and requires only a trivial amount of code. Probably on the order of 10 lines. One simplistic approach would be to implement the XYSeries interface and have it wrap your firebase database. How exactly you map indexes in the series to your database depends on the type of database and how you've organized the data.

Nick
  • 8,181
  • 4
  • 38
  • 63
  • can you please give me such an example code? coz i don't know which code that i have to use – mas May 16 '17 at 15:41
  • I dont use the Firebase database and even if I did I don't know how your database is organized. – Nick May 16 '17 at 15:47
  • thank you for your answer about androidplot does not provide utilities for my firbase data nick, i'm really appreciate it. i need to get my diploma, and my last project is to make an app that can control and monitoring a room's temperature trough firebase database, i'm done the other system, make an XYSeries is the last thing that i need to do, and i got stuck since 3 weeks ago. – mas May 17 '17 at 00:59