{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Plots.Axis.Line
(
AxisLine
, HasAxisLine (..)
, AxisLineType (..)
) where
import Control.Lens hiding (( # ))
import Data.Data
import Data.Default
import Diagrams.Prelude
import Plots.Types
data AxisLineType
= BoxAxisLine
| LeftAxisLine
| MiddleAxisLine
| RightAxisLine
| NoAxisLine
deriving (Show, Eq, Typeable)
instance Default AxisLineType where
def = BoxAxisLine
data AxisLine v = AxisLine
{ alType :: AxisLineType
, alVisible :: Bool
, alStyle :: Style v Double
} deriving Typeable
type instance V (AxisLine v) = v
type instance N (AxisLine v) = Double
class HasAxisLine f a where
axisLine :: LensLike' f a (AxisLine (V a))
axisLineType :: Functor f => LensLike' f a AxisLineType
axisLineType = axisLine . lens alType (\al sty -> al {alType = sty})
axisLineStyle :: Functor f => LensLike' f a (Style (V a) Double)
axisLineStyle = axisLine . lens alStyle (\al sty -> al {alStyle = sty})
instance HasAxisLine f (AxisLine v) where
axisLine = id
instance ApplyStyle (AxisLine v)
instance HasStyle (AxisLine v) where
style = axisLineStyle
instance HasVisibility (AxisLine v) where
visible = lens alVisible (\al b -> al {alVisible = b})
instance Default (AxisLine v) where
def = AxisLine
{ alType = def
, alVisible = True
, alStyle = mempty
}