Advertisement
infiniteblock

Untitled

Apr 14th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. -- COVID-19 Tracker for CC
  2. -- Cases Charts
  3. -- API: corona.lmao.ninja
  4. -- Source: JHUCSSE
  5. -- Program by Lemmmy - GPLv3
  6.  
  7. local util = require("covid19.util")
  8. local gfx = require("covid19.gfx")
  9. local Plot = require("covid19.plot")
  10.  
  11. local FOOTER = "By Lemmmy - Updates every 15 mins - API: corona.lmao.ninja"
  12.  
  13. local DATA_URL = "https://corona.lmao.ninja/v2/historical/all"
  14. local CACHE_FILE = ".all-historical-cache.json"
  15.  
  16. local mon, w, h = util.handleMonitorArg(...)
  17.  
  18. local function main()
  19. mon.clear()
  20.  
  21. -- prep screen
  22. gfx.drawFooter(mon, FOOTER)
  23. local centerY = gfx.drawLoading(mon)
  24.  
  25. -- fetch data
  26. local data = util.cachedJSONRequest(DATA_URL, CACHE_FILE)
  27. gfx.clearLoading(mon, centerY)
  28.  
  29. local casesPlot = Plot.new(mon, 3, 2, w - 13, 9, "Daily confirmed cases", colours.orange)
  30. local deathsPlot = Plot.new(mon, 3, 19, w - 13, 9, "Daily deaths", colours.red)
  31. local recoveriesPlot = Plot.new(mon, 3, 36, w - 13, 9, "Daily recoveries", colours.green)
  32.  
  33. casesPlot:addData(util.processCumulativeHistoricalData(data.cases))
  34. deathsPlot:addData(util.processCumulativeHistoricalData(data.deaths))
  35. recoveriesPlot:addData(util.processCumulativeHistoricalData(data.recovered))
  36.  
  37. casesPlot:draw()
  38. deathsPlot:draw()
  39. recoveriesPlot:draw()
  40. end
  41.  
  42. util.mainLoop(main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement