2017년 4월 16일 일요일

construct a graph from data stored in TinyDB

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.

--
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.

--
Thanks,
you know if there are any examples here on the 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.

--
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.

--
There is a Charts and Graphs section in this FAQ:
FAQ for Charts and Graphs

--
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?

--
There are several Ferguson examples.
What's the URL of the one you are using?

--
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.

--
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.

--
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.

--