From c8f0e8be795e644635e5a71ed632a414400a326b Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 17 Aug 2023 19:51:24 +0400 Subject: [PATCH] remove chart-sample2.lua --- samples/chart-sample2.lua | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 samples/chart-sample2.lua diff --git a/samples/chart-sample2.lua b/samples/chart-sample2.lua deleted file mode 100644 index 3a3da1f..0000000 --- a/samples/chart-sample2.lua +++ /dev/null @@ -1,39 +0,0 @@ -local api_url = "https://api.covid19api.com/country/ru?from=2021-07-01T00:00:00Z&to=2021-07-31T00:00:00Z" - -local tab = {} - -function on_alarm() - http:get(api_url) -end - -function on_network_result(result) - tab = get_tab_ajson(result) - ui:show_chart(tab, "x:date y:number") -end - -function totime(str) - local y,m,d = str:match("(%d+)-(%d+)-(%d+)") - return os.time{year=y, month=m, day=d}*1000 -end - -function get_tab_ajson(result) - local tab = {} - local dat = ajson:get_value(result, "array object:0 string:Date") - local conf = ajson:get_value(result, "array object:0 int:Confirmed") - local prev_conf = conf - local new = conf - prev_conf - tab[1] = {totime(dat), new} - local i = 1 - while true do - dat = ajson:get_value(result, "array object:"..i.." string:Date") - if dat:match("Error") == "Error" then - break - end - conf = ajson:get_value(result, "array object:"..i.." int:Confirmed") - new = conf - prev_conf - prev_conf = conf - tab[i] = {totime(dat), new} - i = i+1 - end - return tab -end