{-# 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 n = AxisLine
{ alType :: AxisLineType
, alArrowOpts :: Maybe (ArrowOpts n)
, alVisible :: Bool
, alStyle :: Style v n
} deriving Typeable
type instance V (AxisLine v n) = v
type instance N (AxisLine v n) = n
class HasAxisLine f a where
axisLine :: LensLike' f a (AxisLine (V a) (N a))
axisLineType :: Functor f => LensLike' f a AxisLineType
axisLineType = axisLine . lens alType (\al sty -> al {alType = sty})
axisLineArrowOpts :: Functor f => LensLike' f a (Maybe (ArrowOpts (N a)))
axisLineArrowOpts = axisLine . lens alArrowOpts (\al sty -> al {alArrowOpts = sty})
axisLineStyle :: Functor f => LensLike' f a (Style (V a) (N a))
axisLineStyle = axisLine . lens alStyle (\al sty -> al {alStyle = sty})
instance HasAxisLine f (AxisLine v n) where
axisLine = id
instance HasVisibility (AxisLine v n) where
visible = lens alVisible (\al b -> al {alVisible = b})
instance Typeable n => Default (AxisLine v n) where
def = AxisLine
{ alType = def
, alArrowOpts = def
, alVisible = True
, alStyle = mempty
}