generated plot file will automatically open
This commit is contained in:
parent
d2fb17df88
commit
c388f4c7a5
@ -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)
|
||||
|
@ -17,6 +17,7 @@ main = do
|
||||
apiKey <- getWeatherKey
|
||||
|
||||
generatePlot 20 35 25 --example
|
||||
openPlot
|
||||
|
||||
putStrLn "Enter a city name: "
|
||||
city <- getLine
|
||||
|
@ -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)]
|
||||
@ -14,3 +15,10 @@ generatePlot yday tday tmrw = toFile def "plot/weather.svg" $ do
|
||||
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]
|
||||
|
||||
|
||||
openPlot :: IO ()
|
||||
openPlot = callCommand "start plot/weather.svg"
|
||||
-- start plot/weather.svg -- Windows
|
||||
-- xdg-open plot/weather.svg -- Linux
|
||||
-- open plot/weather.svg -- macOS
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user