diff --git a/app/Main.hs b/app/Main.hs index 4f66864..de17eb9 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,8 +1,12 @@ {-# LANGUAGE OverloadedStrings #-} --needed for string arguments import Network.HTTP.Simple +import Plot + main :: IO () main = do apiResponse <- httpLBS "POST http://httpbin.org/get" - putStrLn $ "Status code: " ++ show (getResponseStatusCode apiResponse) \ No newline at end of file + putStrLn $ "Status code: " ++ show (getResponseStatusCode apiResponse) + + generatePlot 20 30 25 --example \ No newline at end of file diff --git a/app/Plot.hs b/app/Plot.hs new file mode 100644 index 0000000..f3304a8 --- /dev/null +++ b/app/Plot.hs @@ -0,0 +1,15 @@ +module Plot where +import Graphics.Rendering.Chart.Easy +import Graphics.Rendering.Chart.Backend.Diagrams + + +formatData :: Double -> Double -> Double -> [(Int, Double)] +formatData yday tday tmrw = [(0, yday), (1, tday), (2, tmrw)] + + +generatePlot :: Double -> Double -> Double -> IO () +generatePlot yday tday tmrw = toFile def "plot/weather.svg" $ do + layout_title .= "Yesterday, Today, and Tomorrow's Temperatures" + layout_margin .= 30 + layout_x_axis . laxis_generate .= autoIndexAxis ["Yesterday", "Today", "Tomorrow"] + plot $ line "Degrees Celsius" [formatData yday tday tmrw] \ No newline at end of file diff --git a/plot/weather.svg b/plot/weather.svg new file mode 100644 index 0000000..b526933 --- /dev/null +++ b/plot/weather.svg @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/profun.cabal b/profun.cabal index 60c2f15..ac5c648 100644 --- a/profun.cabal +++ b/profun.cabal @@ -58,7 +58,7 @@ executable profun main-is: Main.hs -- Modules included in this executable, other than Main. - -- other-modules: + other-modules: Plot -- LANGUAGE extensions used by modules in this package. -- other-extensions: @@ -67,7 +67,9 @@ executable profun build-depends: base ^>=4.17.2.1, http-client ^>=0.7.17, http-client-tls ^>=0.3.6.3, - http-conduit ^>=2.3.8.3 + http-conduit ^>=2.3.8.3, + Chart ^>=1.9.5, + Chart-diagrams ^>=1.9.5 -- Directories containing source files. hs-source-dirs: app