Skip to content

Commit 93cd25c

Browse files
committed
minor refactor
1 parent ba728d4 commit 93cd25c

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

chart-tests/tests/Test15.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Test15 where
1+
module Test15 where
22

33
import Graphics.Rendering.Chart
44
import Data.Colour
@@ -10,14 +10,14 @@ import Utils
1010

1111
chart lo lp = layoutToRenderable layout
1212
where
13-
layout =
13+
layout =
1414
layout_title .~ "Legend Test"
1515
$ layout_title_style . font_size .~ 10
1616
$ layout_x_axis . laxis_generate .~ autoIndexAxis alabels
1717
$ layout_y_axis . laxis_override .~ axisGridHide
1818
$ layout_left_axis_visibility . axis_show_ticks .~ False
1919
$ layout_plots .~ [ plotBars bars2 ]
20-
$ layout_legend .~ Just lstyle
20+
$ layout_legend ?~ lstyle
2121
$ def :: Layout PlotIndex Double
2222

2323
bars2 = plot_bars_titles .~ ["A","B","C","D","E","F","G","H","I","J"]

chart/Graphics/Rendering/Chart/Easy.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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
@@ -17,10 +17,10 @@
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

4848
import Control.Lens
49-
import Control.Monad(when)
49+
import Control.Monad(unless)
5050
import Data.Default.Class
5151
import Data.Colour hiding (over) -- overlaps with lens over function
5252
import 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

9292
isFilled :: PointShape -> Bool
9393
isFilled PointShapeCircle = True
9494
isFilled PointShapePolygon{} = True
9595
isFilled _ = False
96-
96+
9797
-- | Construct a bar chart with the given titles and data, using the
98-
-- next available colors
98+
-- next available colors
9999
bars :: (PlotValue x, BarsPlotValue y) => [String] -> [(x,[y])] -> EC l (PlotBars x y)
100100
bars titles vals = liftEC $ do
101101
styles <- sequence [fmap mkStyle takeColor | _ <- titles]

0 commit comments

Comments
 (0)