construct a graph from data stored in TinyDB

749 views
Skip to first unread message

Nicola C.

unread,
Oct 19, 2016, 6:34:29 AM10/19/16
to MIT App Inventor Forum
Good morning,

I ask if it is possible to construct a graph starting from some data stored through the TinyDB. The data to be stored in TinyDB arrive via bluetooth.
If possible you could use some guidance consult with examples.

Thank you

Nicola 

Tim Carter

unread,
Oct 19, 2016, 7:52:46 AM10/19/16
to MIT App Inventor Forum
Yes, this is possible, but can be complicated.

If constructing a simple bar/column chart you could set up a row/column of buttons and change their heights/colours based upon the data.

More complicated (to create) charts can be drawn on a canvas.

Nicola C.

unread,
Oct 19, 2016, 8:01:48 AM10/19/16
to MIT App Inventor Forum
Thanks,
you know if there are any examples here on the forum?

Ghica

unread,
Oct 19, 2016, 8:02:42 AM10/19/16
to MIT App Inventor Forum
Do this in steps. Fist make sure that you can receive data via Bluetooth. Search this forum for examples.
Then make sure you can store it in a suitable way in a TinyDB. Search this forum.
Finally, there are several charting examples in this forum.
But maybe start with a tutorial?

Nicola C.

unread,
Oct 19, 2016, 8:41:27 AM10/19/16
to MIT App Inventor Forum
Hello,

Therefore the first two phases are already ok. Remember? Some time ago we talked about it, thoroughly. At the time through a circuit if it is based on Arduino I built a small central weather and can not send via Bluetooth the following data:

temperature
humidity
pressure

and then calculate

HI, dewpoint, maximum and minimum temperature of 24 h.

Now I would like to draw a graph of the maximum temperature and the minimum one.

If the project concerns, I can condididere all: sketch, design, pcb and work in teams to make a better app.

Greetings

Nicola

Abraham Getzler

unread,
Oct 19, 2016, 11:46:01 AM10/19/16
to MIT App Inventor Forum

Nicola C.

unread,
Oct 19, 2016, 2:27:36 PM10/19/16
to MIT App Inventor Forum
Hello, I opened the faq indicated. The example of Ferguson's fine. I have tested by inserting more data, I noticed that the y-axis shows the values below zero. For the type of value that I have to handle (temperature) I could also have values close to -15. How can you handle this? Also how you can tie the insertion of the x / y values to a value stored in TinyDB?

Nicola 

Abraham Getzler

unread,
Oct 19, 2016, 2:46:14 PM10/19/16
to MIT App Inventor Forum
There are several Ferguson examples.
What's the URL of the one you are using?
ABG

Nicola C.

unread,
Oct 19, 2016, 3:30:00 PM10/19/16
to MIT App Inventor Forum

Abraham Getzler

unread,
Oct 19, 2016, 6:37:46 PM10/19/16
to MIT App Inventor Forum
could also have values close to -15. How can you handle this?

This will require knowing both the maximum and minimum of the Y data values, to know how to scale that range against the available graph height (Canvas height - 30?)

I added a minimum collection section to the plot routine, near the max section.

It also requires shifting the y origin to raise up the graph.  (I did not do this, supper bell is sounding.)
It also requires changing the drawing of the axis lines and their markers to reflect the new graph origin.

Look in the blocks for magix numbers like 30 that need to be changed to new variables for this.

 
Also how you can tie the insertion of the x / y values to a value stored in TinyDB?


This routine is set to show only one list at  time.
Store your list of temperature y values in TinyDB  under tag TempY, 
Store your list of temperature x (time/reading?) values in TinyDB  under tag TempX.
etc.

ABG


2016-10-19 18_27_40-5554__build_.png
blocks-V2.png
Plot_Line_Graph_Res_V2.aia

Nicola C.

unread,
Oct 20, 2016, 3:05:08 AM10/20/16
to MIT App Inventor Forum
Hello,
for the Y-axis was thinking to a range + 45 / -15. As for the X-axis thought to 30/31 readings, equal to about one month.
thank you

Abraham Getzler

unread,
Oct 20, 2016, 12:19:06 PM10/20/16
to MIT App Inventor Forum
That's the problem with the graph examples I have been finding.
Every one hard wires limits into their blocks to fit their own data,
leaving a tangled mess for any one else to try and re-fit their code.

I suggest looking in the AI2 Gallery and the AI2 App of the Month section
in case something more general can be found.

Untangling and generalizing one of the existing samples will take some drudgery.

ABG

Reply all
Reply to author
Forward
0 new messages