134
Views
23
Comments
How do i do calculations for rest api data and display the calculated data in charts?
Question

I have consumed the rest api. However the api only has the accumulated data for the daily cases. The api does not have the actual daily cases. In order to obtain the actual daily cases, I have to take the difference between the confirmed cases for 2 days. How do i do the calculation in outsystems to obtain the actual daily cases after I have consumed the rest api? After that, I need to display that data in charts. I am doing it in traditional web. THE URL of the api: https://api.covid19api.com/country/singapore

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi Loo,

You can store the API result in an entity.

Then use aggregate(s) with the correct grouping and filters to calculate the information you need.

Regards,

Daniel

2020-01-08 08-43-00
Rahul Kumar

Hi, 

Your api is giving list of daily Covid cases in Singapore. So if you want to calculate Actual cases that is difference between the confirmed cases for 2 days . You can calculate it in expression where you want to display.

For calculation , "confirmed cases-(One days before of confirmed case)" 

For calculate one days before of confirmed case, You can use function in expression that take input parameter ( date type ) and this function have output parameter that give confirm case of one day before.In your function action flow you can use ListFilter for filter the list of covid cases by date.


Check - Sample


Hope this help.

Thanks and Regards,

Rahul

Covid19Sample.oml
UserImage.jpg
Loo Chu Jun

Hi Rahul Kumar,


Is there any way to create a chart to display actual daily cases by date?


Regards,

Chu Jun

2020-01-08 08-43-00
Rahul Kumar

Loo Chu Jun wrote:

Hi Rahul Kumar,


Is there any way to create a chart to display actual daily cases by date?


Regards,

Chu Jun

Hi,

There are different kind of chart available in outsystems , You can use them to show actual daily cases,

You can visit some link - How to create chart

                                     - Demo


 


Thanks 

UserImage.jpg
Loo Chu Jun

Hi Rahul,

I tried to create the line chart but it does not work. The chart is showing 0 cases for all the days. Is there any issue with my configuration?

URL:  http://loo-chujun.outsystemscloud.com/Covid19Sample/Entry1.aspx?_ts=637270742906305505


Regards,

Chu Jun

Covid19SampleChart.oml
2020-01-08 08-43-00
Rahul Kumar

Loo Chu Jun wrote:

Hi Rahul,

I tried to create the line chart but it does not work. The chart is showing 0 cases for all the days. Is there any issue with my configuration?

URL:  http://loo-chujun.outsystemscloud.com/Covid19Sample/Entry1.aspx?_ts=637270742906305505


Regards,

Chu Jun

Hi, 

You have done little mistake.

Look up now- Sample


Covid19SampleChart1.oml
UserImage.jpg
Loo Chu Jun

Hi Rahul,


Is there anyway to create custom names for the x-axis and y-axis labels instead of putting names by setting the label as the attributes? When i put the label as the attribute date, the x-axis shows the current day's date instead of the word "date". I want to put the x-axis label as the word "date" instead of current day's date and the y-axis label as "daily covid19 cases".

Thank you for your help.


Regards,

Chu Jun

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Chu Jun,

Please check out the documentation for Charts, and if you need a line chart, the documentation for line Charts.

2020-01-08 08-43-00
Rahul Kumar

Hi, 

In chart property you can see XAxisFormat and YAxis Format . You can set Title , label, Rotation etc for your X axis and Y axis ,

Above i already mention A Demo app for chart there is example of all kind of features.  

Check - Sample 


Thanks.

UserImage.jpg
Loo Chu Jun

Hi all,

Thank you for your help. I managed to create the charts. However, there is another issue whereby when I published the application and it gave an internal error when i went to the charts webpage. Is there any issue with my oml? How do i fix this issue?

URL:https://loo-chujun.outsystemscloud.com/covid19testdata/CoronavirusInSingapore.aspx?(Not.Licensed.For.Production)=


Regards,

Chu Jun

covid19testdata4.oml
2026-02-26 06-29-24
Rahul
 
MVP

Hi,

You are trigger many request on prepration of same action.

check service center log. Fix this issue than you are able to load page.

2020-06-09 08:53:30covid19testdata
(Independent Modules)
20429 Too Many Requests
S7S5Y-LTA782Detail

Regards

Rahul Sahu


UserImage.jpg
Loo Chu Jun

Rahul Sahu wrote:

Hi,

You are trigger many request on prepration of same action.

check service center log. Fix this issue than you are able to load page.

2020-06-09 08:53:30covid19testdata
(Independent Modules)
20429 Too Many Requests
S7S5Y-LTA782Detail

Regards

Rahul Sahu



Hi Rahul Sahu,


How do i fix this issue?


Regards,

Chu Jun

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Chu Jun,

First, check the errors in Service Center to see whether you have the same error as Rahul has - that's not a given, perhaps you have another error.

Secondly, debug your app! Put a breakpoint in the Preperation, and see where it goes wrong.

UserImage.jpg
Loo Chu Jun

Hi all,

I have the same error.

2020-06-09 09:53:50covid19testdata
(covid19testdata)
429 Too Many Requests
S7UYM-LTABTJDetail

How do i fix this error?


Regards,

Chu Jun


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Chu Jun,

Please read my instructions: "debug your app! Put a breakpoint in the Preperation, and see where it goes wrong."

UserImage.jpg
Loo Chu Jun

Hi Kilian Hekhuis,

I did the debugging but there is no error.


Regards,

Chu Jun

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Ok, so the Screen's Preperation goes fine? What if the Screen is rendered, any errors there? Because once you get to the Screen rendering, everything should be ok. (Unfortunately, my PE is currently down, so I cannot debug myself.)

2021-08-12 11-00-27
Nordin Ahdi
 
MVP

Let me jump in since Kilian is not able to debug right now. I had a quick look and your issue lies in your FilterByDate server action.

This results in too many requests which apparently the API does not allow. You can see this by viewing the Integration Log in Service Center.

Removing the FilterByDate function from the Daily cases chart results in a successfully loaded webscreen. So you need to figure out a way to display the data you want without going over the API requests threshhold.

Hope this helps!

Regards,

Nordin

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Thanks Nordin!

2021-08-12 11-00-27
Nordin Ahdi
 
MVP

Don't sweat it Kilian :)

UserImage.jpg
Loo Chu Jun

Thank you all for taking your time to help. Is there any other ways to make calculations to obtain the daily cases of covid19 in Singapore and then display it on the chart without using the FIlterByDate server action as this action is going over the API requests threshhold. I am working on traditional web.

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Loo Chu Jun,

In addition to previously mentioned solution, a small contribution from my side :)

See this implementation --> Sample Application

Please find the attachment


Hope this helps you!


Regards,

Benjith Sam

LineChartSampleApp.oml
UserImage.jpg
Loo Chu Jun

Hi all,

Thank you for the help. I have solved the issue and managed to display the data I want.


Regards,

Chu Jun

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.