#if ( __GLASGOW_HASKELL__ < 820 )
#endif
module Chart.Line
( LineOptions(..)
, oneline
, lines
, glines
, lineChart
, lineChart_
, glineChart
, glineChart_
) where
import Chart.Core
import Chart.Glyph
import Data.Default (Default(..))
import Diagrams.Prelude hiding ((<>))
import NumHask.Pair
import NumHask.Prelude
import NumHask.Rect
data LineOptions = LineOptions
{ lineSize :: Double
, lineColor :: AlphaColour Double
}
instance Default LineOptions where
def = LineOptions 0.02 ublue
lines :: (Traversable f, R2 r) => LineOptions -> f (r Double) -> Chart b
lines (LineOptions s c) xs =
case NumHask.Prelude.head xs of
Nothing -> mempty
Just p ->
trailLike (trailFromVertices (toList $ p_ <$> xs) `at` p_ p) # lcA c #
lwN s
oneline :: (R2 r) => LineOptions -> Pair (r Double) -> Chart b
oneline (LineOptions s c) (Pair x0 x1) =
stroke (trailFromVertices [p_ x0, p_ x1] `at` p_ x0) # lcA c # lwN s
lineChart ::
(Traversable f)
=> [LineOptions]
-> Aspect
-> Rect Double
-> [f (Pair Double)]
-> Chart b
lineChart optss (Aspect asp) r xyss =
mconcat $ zipWith lines optss (projectss r asp xyss)
lineChart_ ::
(Traversable f) => [LineOptions] -> Aspect -> [f (Pair Double)] -> Chart b
lineChart_ optss asp xyss = lineChart optss asp (range xyss) xyss
glines ::
(Traversable f, R2 r)
=> LineOptions
-> GlyphOptions b
-> f (r Double)
-> Chart b
glines opts gopts xs = glyphs gopts xs <> lines opts xs
glineChart ::
(Traversable f)
=> [LineOptions]
-> [GlyphOptions b]
-> Aspect
-> Rect Double
-> [f (Pair Double)]
-> Chart b
glineChart ls gs (Aspect asp) r xyss =
mconcat $
getZipList $
glines <$> ZipList ls <*> ZipList gs <*> ZipList (projectss r asp xyss)
glineChart_ ::
(Traversable f)
=> [LineOptions]
-> [GlyphOptions b]
-> Aspect
-> [f (Pair Double)]
-> Chart b
glineChart_ ls gs asp xyss = glineChart ls gs asp (range xyss) xyss