diff --git a/README.md b/README.md index 9a1665c..bd0a9c1 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/app/Main.hs b/app/Main.hs index 52987b6..d4c1fd8 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -16,6 +16,7 @@ main = do apiKey <- getWeatherKey generatePlot 20 35 25 --example + openPlot putStrLn "Enter a city name: " city <- getLine diff --git a/app/Plot.hs b/app/Plot.hs index c6f291b..9ea4f46 100644 --- a/app/Plot.hs +++ b/app/Plot.hs @@ -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] \ No newline at end of file + 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 \ No newline at end of file diff --git a/profun.cabal b/profun.cabal index 7a046e4..40943b0 100644 --- a/profun.cabal +++ b/profun.cabal @@ -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