[Solved] Plotting numbered data received from cloud

As of latest updation, i’m recieving data from cloud in form of numeric data, can anyone suggest me which is the best charting function for this and how to plot it.The data from cloud tends to change every day,and i’m not able to link it to the chart for auto updation. I have attached the dataset here, also the api linking to the dataset.
Do suggest me,since this is the last and important step of the whole thunkable project.
The api https://dxedi9kua3.execute-api.ap-south-1.amazonaws.com/default/db_lambda

What type of data are they?

Sorry. I see there are 4 values. How are they related?

sorry for the late reply,had PC issue. The four values from api is related to sleep pattern.
The four parameters from the api link states the highest value coming at first, followed by lower value at second and so on… in descending order. The picture i have uploaded shows an example of how the output is.
It is a manually entered data plotting using pie chart done with the help of @manyone . now the main task is depending on the data from api,the pie chart should change the values without manually entering it in thunkable design block.
this graph in pic shows delta has high value,and comments for beta (i,e) " you had a moderate sleep…"
same way when alpha wave, is high, the comments should be different. same for theta and beta.
i hope i have been specific XD

in the example i gave you, the contents of app data is shown below:
`

      ['Task', 'Hours per Day'],           ['Work',     11],           ['Eat',      2],           ['Commute',  2],           ['Watch TV', 2],           ['Sleep',    7]

so all you have to do is this: after obtaining the result of the call to webapi, create a datastring to contain what you want to chart:
maybe

['Task','Hours per day'],['Beta wave',40],['Alpha wave',15], etc.

you can use the blocks from the object category to create this, or you can probably join strings to create it.
then set app data to datastring in you “doSomething”.

in your sample data from the cloud, the returned response seems to contain an array containing 2 arrays, first array being “theta, delta,etc.”, while the 2nd seems to contain 4 arrays of of values. is that correct? how do you arrive at the single value for delta? do you add up all the values in the first subarray of values?

@manyone yeah,you’re correct, i have changed the values, and have tried it manually. my requirement was, as per data from api, and on application of a refresh buttton in app, the new data from cloud should be auto updated, so will the pie chart .
The data from api link is this ,values in descending order —>

[“Delta”, “Alpha”, “Beta”, “Theta”]

this data keep on updating every day, or manually updated, my idea was to use a refresh button, which will check the data from cloud and auto update the pie chart or any chart which best represent the discrete data, which i felt pie chart is best.

as the order delta wave has come first, we can assign a value 7 for delta, and rest 3 waves get a value of 3 each. That’s asssumed by ourselves. whichever comes first must be represented pictorially and a solution to reduce it. For example, alpha wave represent peaceful normal sleep and so on.

so it’s like, we have to define all the four waves and comments associated with it.
after which a function should be created to read the type of string appearing first in the api link, and compared to the pre defined comments, it should display the chart an the pre stored comments.

is this what you need?

below is a table of possible arrival scenarios: A=alpha,B=beta,D=delta,T=theta

  1. when your data arrives from api, create a list, say wavelist
  2. from the list join all 1st characters to form a 4 letter key, used for getting the phrase from the table.(ABDT translates to “you slept peacfully”)
  3. iterate over wavelist , and generate [wavelist[1],7].
    [wavelist[2],3]. [wavelist[3],3]. [wavelist[4],3]

using ABDT, it translates to [“alpha”,7],[“beta”,3],[“delta”,3][“theta”,3] and feed that (with the header labels) into the chart

2 Likes

@manyone ,wow i didn’t know this kinda feature can be added to thunkable,it’s exactly which i wanted. But i was trying to read the string data from api,any idea how to read string data.
And of the steps you’ve mentioned, how to do it in thunkable,i did try but no clue.

i tried to setup some blocks to process your data but your api (url) doesn’t seem to return a standard response.
when i type the url

https://dxedi9kua3.execute-api.ap-south-1.amazonaws.com/default/db_lambda

in browser i do get a response - in JSON form even.- but when i try to process it with object blocks, i get undefined for the response.

typically responses look like this:
image

but the your URL returns data with no header section.
image

which appears like this in raw data form
image
and i don’t know how to handle it.

here’s my attempt,
https://x.thunkable.com/copy/d7596aec21be461a77b5326e035215a6

(i’ve even tried get_object_properties(response) , get_property(0) of reponse, etc., each time resulting in undefined)

1 Like

oh,thanks a lot, i’m sorry. Even i have got no idea of how to resolve that undefined issue in thunkable. @jared @domhnallohanlon can you please suggest us how to get over with this issue.

Have you tried hosting your webpage and using the webviewer at all?

Imo. This is a bug. I’ve been having major issues with the Thunkable api for certain sites lately. Namely the jisho.org api. I am getting undefined even for errors on certain sites which makes no sense.

The component doesn’t even return failed to fetch when I know I’m using legitimate urls. The only thing I can think is I’m not using the correct headers but I’m not sure.

I think this should
Go to
GitHub.

1 Like