This commit is contained in:
Szymon Szczubkowski 2024-05-26 18:51:35 +02:00
commit 16981d9d3f
4 changed files with 13 additions and 2 deletions

View File

@ -16,3 +16,4 @@ This project makes use of the following dependencies (specified in `profun.cabal
* bytestring (for ByteString type)
* utf8-string (for conversion from String to ByteString)
* time (for getting date)
* process (for opening svg file)

View File

@ -16,6 +16,7 @@ main = do
apiKey <- getWeatherKey
generatePlot 20 35 25 --example
openPlot
putStrLn "Enter a city name: "
city <- getLine

View File

@ -1,6 +1,7 @@
module Plot where
import Graphics.Rendering.Chart.Easy
import Graphics.Rendering.Chart.Backend.Diagrams
import System.Process (callCommand)
formatData :: Double -> Double -> Double -> [(Int, Double)]
@ -13,4 +14,11 @@ generatePlot yday tday tmrw = toFile def "plot/weather.svg" $ do
layout_margin .= 30
layout_y_axis . laxis_generate .= scaledAxis def (-10, 40)
layout_x_axis . laxis_generate .= autoIndexAxis ["Yesterday", "Today", "Tomorrow"]
plot $ line "Degrees Celsius" [formatData yday tday tmrw]
plot $ line "Degrees Celsius" [formatData yday tday tmrw]
openPlot :: IO ()
openPlot = callCommand "start plot/weather.svg"
-- start plot/weather.svg -- Windows
-- xdg-open plot/weather.svg -- Linux
-- open plot/weather.svg -- macOS

View File

@ -74,7 +74,8 @@ executable profun
aeson ^>=2.2.2.0,
bytestring ^>=0.12.1.0,
utf8-string ^>=1.0.2,
time ^>=1.12.2
time ^>=1.12.2,
process ^>=1.6.18.0
-- Directories containing source files.
hs-source-dirs: app