From 728dadc84571ce3e4a3f1a48545bae495486ed17 Mon Sep 17 00:00:00 2001 From: K4RP4T Date: Sat, 25 May 2024 16:03:03 +0200 Subject: [PATCH 1/3] added gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..82fdd79 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/dist-newstyle \ No newline at end of file From 0b21b7db40ccc5880101a893bee6336085afd900 Mon Sep 17 00:00:00 2001 From: K4RP4T Date: Sat, 25 May 2024 20:00:14 +0200 Subject: [PATCH 2/3] added simple plot generator in svg format --- app/Main.hs | 6 +++++- app/Plot.hs | 15 +++++++++++++++ plot/weather.svg | 3 +++ profun.cabal | 6 ++++-- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 app/Plot.hs create mode 100644 plot/weather.svg 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 From be65a9bfd4362d2184de28349b388bf09abe403d Mon Sep 17 00:00:00 2001 From: K4RP4T Date: Sat, 25 May 2024 20:01:50 +0200 Subject: [PATCH 3/3] updated README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d4c7d0f..9580c2f 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,6 @@ to get the needed dependencies. This project makes use of the following dependencies (specified in `profun.cabal`): * http-client * http-client-tls -* http-conduit \ No newline at end of file +* http-conduit +* Chart +* Chart-diagrams \ No newline at end of file