1- {-# LANGUAGE ScopedTypeVariables, TemplateHaskell, TypeSynonymInstances, FlexibleInstances #-}
1+ {-# LANGUAGE ScopedTypeVariables, FlexibleInstances #-}
22----------------------------------------------------------------------------
33-- |
44-- Module : Graphics.Rendering.Chart.Easy
55-- Copyright : (c) Tim Docker 2014
66-- License : BSD-style (see chart/COPYRIGHT)
77--
88-- A high level API for generating a plot quickly.
9- --
9+ --
1010-- Importing the Easy module brings into scope all core functions and types required
1111-- for working with the chart library. This includes key external dependencies such as
1212-- Control.Lens and Data.Colour. The module also provides several helper functions for
1717--
1818-- > import Graphics.Rendering.Chart.Easy
1919-- > import Graphics.Rendering.Chart.Backend.Cairo
20- -- >
20+ -- >
2121-- > signal :: [Double] -> [(Double,Double)]
2222-- > signal xs = [ (x,(sin (x*3.14159/45) + 1) / 2 * (sin (x*3.14159/5))) | x <- xs ]
23- -- >
23+ -- >
2424-- > main = toFile def "example.png" $ do
2525-- > layout_title .= "Amplitude Modulation"
2626-- > plot (line "am" [signal [0,(0.5)..400]])
@@ -46,7 +46,7 @@ module Graphics.Rendering.Chart.Easy(
4646 ) where
4747
4848import Control.Lens
49- import Control.Monad (when )
49+ import Control.Monad (unless )
5050import Data.Default.Class
5151import Data.Colour hiding (over ) -- overlaps with lens over function
5252import Data.Colour.Names
@@ -83,19 +83,19 @@ points title values = liftEC $ do
8383 plot_points_style . point_color .= color
8484 plot_points_style . point_shape .= shape
8585 plot_points_style . point_radius .= 2
86-
86+
8787 -- Show borders for unfilled shapes
88- when ( not ( isFilled shape) ) $ do
88+ unless ( isFilled shape) $ do
8989 plot_points_style . point_border_color .= color
9090 plot_points_style . point_border_width .= 1
9191
9292isFilled :: PointShape -> Bool
9393isFilled PointShapeCircle = True
9494isFilled PointShapePolygon {} = True
9595isFilled _ = False
96-
96+
9797-- | Construct a bar chart with the given titles and data, using the
98- -- next available colors
98+ -- next available colors
9999bars :: (PlotValue x , BarsPlotValue y ) => [String ] -> [(x ,[y ])] -> EC l (PlotBars x y )
100100bars titles vals = liftEC $ do
101101 styles <- sequence [fmap mkStyle takeColor | _ <- titles]
0 commit comments