{-# LANGUAGE DeriveDataTypeable    #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE RankNTypes            #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE UndecidableInstances  #-}
{-# LANGUAGE ViewPatterns          #-}

-- Orphan Mainable Axis instance.
{-# OPTIONS_GHC -fno-warn-orphans #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  Plots.Axis.Render
-- Copyright   :  (C) 2016 Christopher Chalmers
-- License     :  BSD-style (see the file LICENSE)
-- Maintainer  :  Christopher Chalmers
-- Stability   :  experimental
-- Portability :  non-portable
--
-- Low level module containing functions for rendering different types
-- of axis.
--
----------------------------------------------------------------------------
module Plots.Axis.Render
  ( -- * Rendering axes
    RenderAxis (..)
  , r2AxisMain

    -- * Low level
  , buildPlots
  )where

import           Data.Bool
import           Data.Foldable              as F
import           Data.List                  (sort)
import           Data.Typeable

import           Diagrams.BoundingBox
import           Diagrams.Prelude
import           Diagrams.TwoD.Text
import           Linear                     hiding (rotate, translation)

import           Diagrams.Backend.CmdLine
import           Diagrams.Coordinates.Polar

import           Plots.Axis
import           Plots.Axis.ColourBar
import           Plots.Axis.Grid
import           Plots.Axis.Labels
import           Plots.Axis.Line
import           Plots.Axis.Scale
import           Plots.Axis.Ticks
import           Plots.Axis.Title
import           Plots.Legend
import           Plots.Style
import           Plots.Types
import           Plots.Util

import           Prelude

------------------------------------------------------------------------
-- Mainable instances
------------------------------------------------------------------------

instance (TypeableFloat n,
          Renderable (Path V2 n) b,
          Mainable (QDiagram b V2 n Any))
       => Mainable (Axis b Polar n) where
  type MainOpts (Axis b Polar n) = MainOpts (QDiagram b V2 n Any)

  mainRender :: MainOpts (Axis b Polar n) -> Axis b Polar n -> IO ()
mainRender MainOpts (Axis b Polar n)
opts = MainOpts (QDiagram b V2 n Any) -> QDiagram b V2 n Any -> IO ()
forall d. Mainable d => MainOpts d -> d -> IO ()
mainRender MainOpts (QDiagram b V2 n Any)
MainOpts (Axis b Polar n)
opts (QDiagram b V2 n Any -> IO ())
-> (Axis b Polar n -> QDiagram b V2 n Any)
-> Axis b Polar n
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Axis b Polar n -> QDiagram b V2 n Any
forall b (v :: * -> *) n.
RenderAxis b v n =>
Axis b v n -> QDiagram b (BaseSpace v) n Any
renderAxis

instance (TypeableFloat n,
          Renderable (Path V2 n) b,
          Mainable (QDiagram b V2 n Any))
       => Mainable (Axis b V2 n) where
  type MainOpts (Axis b V2 n) = MainOpts (QDiagram b V2 n Any)

  mainRender :: MainOpts (Axis b V2 n) -> Axis b V2 n -> IO ()
mainRender MainOpts (Axis b V2 n)
opts = MainOpts (QDiagram b V2 n Any) -> QDiagram b V2 n Any -> IO ()
forall d. Mainable d => MainOpts d -> d -> IO ()
mainRender MainOpts (QDiagram b V2 n Any)
MainOpts (Axis b V2 n)
opts (QDiagram b V2 n Any -> IO ())
-> (Axis b V2 n -> QDiagram b V2 n Any) -> Axis b V2 n -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Axis b V2 n -> QDiagram b V2 n Any
forall b (v :: * -> *) n.
RenderAxis b v n =>
Axis b v n -> QDiagram b (BaseSpace v) n Any
renderAxis

instance ToResult (Axis b v n) where
  type Args (Axis b v n) = ()
  type ResultOf (Axis b v n) = Axis b v n

  toResult :: Axis b v n -> Args (Axis b v n) -> ResultOf (Axis b v n)
toResult Axis b v n
d Args (Axis b v n)
_ = ResultOf (Axis b v n)
Axis b v n
d

-- | 'mainWith' specialised to a 2D Axis.
r2AxisMain
  :: (Parseable (MainOpts (QDiagram b V2 Double Any)),
      Mainable (Axis b V2 Double))
  => Axis b V2 Double
  -> IO ()
r2AxisMain :: forall b.
(Parseable (MainOpts (QDiagram b V2 Double Any)),
 Mainable (Axis b V2 Double)) =>
Axis b V2 Double -> IO ()
r2AxisMain = Axis b V2 Double -> IO ()
forall d. (Mainable d, Parseable (MainOpts d)) => d -> IO ()
mainWith

------------------------------------------------------------------------
-- Low level functions
------------------------------------------------------------------------

-- | Build a list of styled plots from the axis, ready to be rendered.
--   This takes into account any 'AxisStyle' changes and applies the
--   'finalPlots' modifications.
--
--   The 'StyledPlots' can be rendered with 'renderStyledPlot' and the
--   legend entries can be obtained with 'styledPlotLegends'. This is
--   what 'renderAxis' can uses internally but might be useful for
--   debugging or generating your own legend.
buildPlots :: BaseSpace c ~ v => Axis b c n -> [StyledPlot b v n]
buildPlots :: forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Axis b c n -> [StyledPlot b v n]
buildPlots Axis b c n
a = (StyledPlot b v n -> StyledPlot b v n)
-> [StyledPlot b v n] -> [StyledPlot b v n]
forall a b. (a -> b) -> [a] -> [b]
map (Endo (StyledPlot b v n) -> StyledPlot b v n -> StyledPlot b v n
forall a. Endo a -> a -> a
appEndo (Endo (StyledPlot b v n) -> StyledPlot b v n -> StyledPlot b v n)
-> Endo (StyledPlot b v n) -> StyledPlot b v n -> StyledPlot b v n
forall a b. (a -> b) -> a -> b
$ Axis b c n
a Axis b c n
-> Getting
     (Endo (StyledPlot b v n)) (Axis b c n) (Endo (StyledPlot b v n))
-> Endo (StyledPlot b v n)
forall s a. s -> Getting a s a -> a
^. Getting
  (Endo (StyledPlot b v n)) (Axis b c n) (Endo (StyledPlot b v n))
forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Lens' (Axis b c n) (Endo (StyledPlot b v n))
plotModifier)
             ([StyledPlot b v n] -> [StyledPlot b v n])
-> [StyledPlot b v n] -> [StyledPlot b v n]
forall a b. (a -> b) -> a -> b
$ (PlotStyle b v n -> DynamicPlot b v n -> StyledPlot b v n)
-> [PlotStyle b v n] -> [DynamicPlot b v n] -> [StyledPlot b v n]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith PlotStyle b v n -> DynamicPlot b v n -> StyledPlot b v n
forall b (v :: * -> *) n.
PlotStyle b v n -> DynamicPlot b v n -> StyledPlot b v n
styleDynamic (Axis b c n
a Axis b c n
-> Getting (Endo [PlotStyle b v n]) (Axis b c n) (PlotStyle b v n)
-> [PlotStyle b v n]
forall s a. s -> Getting (Endo [a]) s a -> [a]
^.. Getting (Endo [PlotStyle b v n]) (Axis b c n) (PlotStyle b v n)
forall a b.
HasAxisStyle a b =>
IndexedTraversal' Int a (PlotStyle b (V a) (N a))
axisStyles) (Axis b c n
a Axis b c n
-> Getting [DynamicPlot b v n] (Axis b c n) [DynamicPlot b v n]
-> [DynamicPlot b v n]
forall s a. s -> Getting a s a -> a
^. Getting [DynamicPlot b v n] (Axis b c n) [DynamicPlot b v n]
forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Lens' (Axis b c n) [DynamicPlot b v n]
axisPlots)
             -- TODO: correct order

------------------------------------------------------------------------
-- Render axis
------------------------------------------------------------------------

-- | Renderable axes.
class RenderAxis b v n where
  -- | Render an axis to a diagram. The size of the diagram is
  --   determined by the 'axisSize'.
  renderAxis :: Axis b v n -> QDiagram b (BaseSpace v) n Any

-- | The 'RenderAxis' class provides a default way to render an axis for
--  each space.
instance (TypeableFloat n, Renderable (Path V2 n) b)
    => RenderAxis b V2 n where
  -- | Render an axis and its plots, as well as the legend and colour
  --   bar.
  renderAxis :: Axis b V2 n -> QDiagram b (BaseSpace V2) n Any
renderAxis = Axis b V2 n -> QDiagram b (BaseSpace V2) n Any
forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
Axis b V2 n -> QDiagram b V2 n Any
renderR2Axis

renderR2Axis :: (TypeableFloat n, Renderable (Path V2 n) b)
  => Axis b V2 n -> QDiagram b V2 n Any
renderR2Axis :: forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
Axis b V2 n -> QDiagram b V2 n Any
renderR2Axis Axis b V2 n
a = n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall (v :: * -> *) n m b.
(Metric v, OrderedField n, Monoid' m) =>
n -> QDiagram b v n m -> QDiagram b v n m
frame n
40
               (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a b. (a -> b) -> a -> b
$ QDiagram b V2 n Any
leg
              QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
ttl
              QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
cBar
              QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
plots
              QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> E V2 -> E V2 -> LabelPosition -> QDiagram b V2 n Any
drawAxis E V2
forall (t :: * -> *). R1 t => E t
ex E V2
forall (t :: * -> *). R2 t => E t
ey LabelPosition
LowerLabels
              QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> E V2 -> E V2 -> LabelPosition -> QDiagram b V2 n Any
drawAxis E V2
forall (t :: * -> *). R2 t => E t
ey E V2
forall (t :: * -> *). R1 t => E t
ex LabelPosition
LeftLabels
  where
    spec :: AxisSpec V2 n
spec  = V2 (n, n)
-> Transformation V2 n -> V2 LogScale -> ColourMap -> AxisSpec V2 n
forall (v :: * -> *) n.
v (n, n)
-> Transformation v n -> v LogScale -> ColourMap -> AxisSpec v n
AxisSpec V2 (n, n)
xs Transformation V2 n
t (Axis b V2 n
aAxis b V2 n
-> Getting (V2 LogScale) (Axis b V2 n) (V2 LogScale) -> V2 LogScale
forall s a. s -> Getting a s a -> a
^.(V2 (SingleAxis b V2 n)
 -> Const (V2 LogScale) (V2 (SingleAxis b V2 n)))
-> Axis b V2 n -> Const (V2 LogScale) (Axis b V2 n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((V2 (SingleAxis b V2 n)
  -> Const (V2 LogScale) (V2 (SingleAxis b V2 n)))
 -> Axis b V2 n -> Const (V2 LogScale) (Axis b V2 n))
-> ((V2 LogScale -> Const (V2 LogScale) (V2 LogScale))
    -> V2 (SingleAxis b V2 n)
    -> Const (V2 LogScale) (V2 (SingleAxis b V2 n)))
-> Getting (V2 LogScale) (Axis b V2 n) (V2 LogScale)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
  (Context LogScale LogScale)
  (SingleAxis b V2 n)
  (SingleAxis b V2 n)
  LogScale
  LogScale
-> Lens
     (V2 (SingleAxis b V2 n))
     (V2 (SingleAxis b V2 n))
     (V2 LogScale)
     (V2 LogScale)
forall (f :: * -> *) a b s t.
Representable f =>
LensLike (Context a b) s t a b -> Lens (f s) (f t) (f a) (f b)
column LensLike
  (Context LogScale LogScale)
  (SingleAxis b V2 n)
  (SingleAxis b V2 n)
  LogScale
  LogScale
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a LogScale
logScale) (Axis b V2 n
a Axis b V2 n
-> Getting ColourMap (Axis b V2 n) ColourMap -> ColourMap
forall s a. s -> Getting a s a -> a
^. Getting ColourMap (Axis b V2 n) ColourMap
forall a b. HasAxisStyle a b => Lens' a ColourMap
axisColourMap)
    plots :: QDiagram b V2 n Any
plots = (StyledPlot b V2 n -> QDiagram b V2 n Any)
-> [StyledPlot b V2 n] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (AxisSpec V2 n -> StyledPlot b V2 n -> QDiagram b V2 n Any
forall n b.
TypeableFloat n =>
AxisSpec V2 n -> StyledPlot b V2 n -> QDiagram b V2 n Any
renderStyledPlot AxisSpec V2 n
spec) [StyledPlot b V2 n]
styledPlots
    drawAxis :: E V2 -> E V2 -> LabelPosition -> QDiagram b V2 n Any
drawAxis E V2
ll E V2
ll2 = Point V2 n
-> V2 (n, n)
-> SingleAxis b V2 n
-> V2 LogScale
-> Transformation V2 n
-> E V2
-> E V2
-> LabelPosition
-> QDiagram b V2 n Any
forall b (v :: * -> *) n.
(v ~ V2, TypeableFloat n, HasLinearMap v, Metric v,
 Renderable (Path V2 n) b, n ~ N (v n), v ~ V (v n),
 OrderedField n) =>
Point v n
-> v (n, n)
-> SingleAxis b v n
-> v LogScale
-> T2 n
-> E v
-> E v
-> LabelPosition
-> QDiagram b V2 n Any
axisOnBasis Point V2 n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin V2 (n, n)
xs (Axis b V2 n
aAxis b V2 n
-> Getting (SingleAxis b V2 n) (Axis b V2 n) (SingleAxis b V2 n)
-> SingleAxis b V2 n
forall s a. s -> Getting a s a -> a
^.(V2 (SingleAxis b V2 n)
 -> Const (SingleAxis b V2 n) (V2 (SingleAxis b V2 n)))
-> Axis b V2 n -> Const (SingleAxis b V2 n) (Axis b V2 n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes((V2 (SingleAxis b V2 n)
  -> Const (SingleAxis b V2 n) (V2 (SingleAxis b V2 n)))
 -> Axis b V2 n -> Const (SingleAxis b V2 n) (Axis b V2 n))
-> ((SingleAxis b V2 n
     -> Const (SingleAxis b V2 n) (SingleAxis b V2 n))
    -> V2 (SingleAxis b V2 n)
    -> Const (SingleAxis b V2 n) (V2 (SingleAxis b V2 n)))
-> Getting (SingleAxis b V2 n) (Axis b V2 n) (SingleAxis b V2 n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.E V2 -> forall x. Lens' (V2 x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E V2
ll) (Axis b V2 n
aAxis b V2 n
-> Getting (V2 LogScale) (Axis b V2 n) (V2 LogScale) -> V2 LogScale
forall s a. s -> Getting a s a -> a
^.(V2 (SingleAxis b V2 n)
 -> Const (V2 LogScale) (V2 (SingleAxis b V2 n)))
-> Axis b V2 n -> Const (V2 LogScale) (Axis b V2 n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes((V2 (SingleAxis b V2 n)
  -> Const (V2 LogScale) (V2 (SingleAxis b V2 n)))
 -> Axis b V2 n -> Const (V2 LogScale) (Axis b V2 n))
-> ((V2 LogScale -> Const (V2 LogScale) (V2 LogScale))
    -> V2 (SingleAxis b V2 n)
    -> Const (V2 LogScale) (V2 (SingleAxis b V2 n)))
-> Getting (V2 LogScale) (Axis b V2 n) (V2 LogScale)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.LensLike
  (Context LogScale LogScale)
  (SingleAxis b V2 n)
  (SingleAxis b V2 n)
  LogScale
  LogScale
-> Lens
     (V2 (SingleAxis b V2 n))
     (V2 (SingleAxis b V2 n))
     (V2 LogScale)
     (V2 LogScale)
forall (f :: * -> *) a b s t.
Representable f =>
LensLike (Context a b) s t a b -> Lens (f s) (f t) (f a) (f b)
column LensLike
  (Context LogScale LogScale)
  (SingleAxis b V2 n)
  (SingleAxis b V2 n)
  LogScale
  LogScale
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a LogScale
logScale) Transformation V2 n
t E V2
ll E V2
ll2
    --
    (V2 (n, n)
xs, Transformation V2 n
tv, Transformation V2 n
t') = V2 (AxisScaling n)
-> BoundingBox V2 n
-> (V2 (n, n), Transformation V2 n, Transformation V2 n)
forall (v :: * -> *) n.
(HasLinearMap v, OrderedField n, Applicative v) =>
v (AxisScaling n)
-> BoundingBox v n
-> (v (n, n), Transformation v n, Transformation v n)
calculateScaling (Axis b V2 n
aAxis b V2 n
-> Getting (V2 (AxisScaling n)) (Axis b V2 n) (V2 (AxisScaling n))
-> V2 (AxisScaling n)
forall s a. s -> Getting a s a -> a
^.(V2 (SingleAxis b V2 n)
 -> Const (V2 (AxisScaling n)) (V2 (SingleAxis b V2 n)))
-> Axis b V2 n -> Const (V2 (AxisScaling n)) (Axis b V2 n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes((V2 (SingleAxis b V2 n)
  -> Const (V2 (AxisScaling n)) (V2 (SingleAxis b V2 n)))
 -> Axis b V2 n -> Const (V2 (AxisScaling n)) (Axis b V2 n))
-> ((V2 (AxisScaling n)
     -> Const (V2 (AxisScaling n)) (V2 (AxisScaling n)))
    -> V2 (SingleAxis b V2 n)
    -> Const (V2 (AxisScaling n)) (V2 (SingleAxis b V2 n)))
-> Getting (V2 (AxisScaling n)) (Axis b V2 n) (V2 (AxisScaling n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.LensLike
  (Context (AxisScaling n) (AxisScaling n))
  (SingleAxis b V2 n)
  (SingleAxis b V2 n)
  (AxisScaling n)
  (AxisScaling n)
-> Lens
     (V2 (SingleAxis b V2 n))
     (V2 (SingleAxis b V2 n))
     (V2 (AxisScaling n))
     (V2 (AxisScaling n))
forall (f :: * -> *) a b s t.
Representable f =>
LensLike (Context a b) s t a b -> Lens (f s) (f t) (f a) (f b)
column LensLike
  (Context (AxisScaling n) (AxisScaling n))
  (SingleAxis b V2 n)
  (SingleAxis b V2 n)
  (AxisScaling n)
  (AxisScaling n)
forall (f :: * -> *) a.
HasAxisScaling f a =>
LensLike' f a (AxisScaling (N a))
axisScaling) ([StyledPlot b V2 n] -> BoundingBox V2 n
forall (v :: * -> *) n a.
(InSpace v n a, HasBasis v, Enveloped a) =>
a -> BoundingBox v n
boundingBox [StyledPlot b V2 n]
styledPlots)
    t :: Transformation V2 n
t = Transformation V2 n
tv Transformation V2 n -> Transformation V2 n -> Transformation V2 n
forall a. Semigroup a => a -> a -> a
<> Transformation V2 n
t'
    --
    bb :: BoundingBox V2 n
bb = Point V2 n -> Point V2 n -> BoundingBox V2 n
forall (v :: * -> *) n.
(Additive v, Foldable v, Ord n) =>
Point v n -> Point v n -> BoundingBox v n
fromCorners (V2 n -> Point V2 n
forall (f :: * -> *) a. f a -> Point f a
P (V2 n -> Point V2 n) -> (V2 n -> V2 n) -> V2 n -> Point V2 n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Transformation V2 n -> V2 n -> V2 n
forall (v :: * -> *) n. Transformation v n -> v n -> v n
apply Transformation V2 n
t (V2 n -> Point V2 n) -> V2 n -> Point V2 n
forall a b. (a -> b) -> a -> b
$ ((n, n) -> n) -> V2 (n, n) -> V2 n
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (n, n) -> n
forall a b. (a, b) -> a
fst V2 (n, n)
xs) (V2 n -> Point V2 n
forall (f :: * -> *) a. f a -> Point f a
P (V2 n -> Point V2 n) -> (V2 n -> V2 n) -> V2 n -> Point V2 n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Transformation V2 n -> V2 n -> V2 n
forall (v :: * -> *) n. Transformation v n -> v n -> v n
apply Transformation V2 n
t (V2 n -> Point V2 n) -> V2 n -> Point V2 n
forall a b. (a -> b) -> a -> b
$ ((n, n) -> n) -> V2 (n, n) -> V2 n
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (n, n) -> n
forall a b. (a, b) -> b
snd V2 (n, n)
xs)
    leg :: QDiagram b V2 n Any
leg = BoundingBox V2 n
-> [(QDiagram b V2 n Any, String)]
-> Legend b n
-> QDiagram b V2 n Any
forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
BoundingBox V2 n
-> [(QDiagram b V2 n Any, String)]
-> Legend b n
-> QDiagram b V2 n Any
drawLegend BoundingBox V2 n
bb ([StyledPlot b V2 n] -> [(QDiagram b V2 n Any, String)]
forall n b (v :: * -> *).
Ord n =>
[StyledPlot b v n] -> [(QDiagram b v n Any, String)]
styledPlotLegends [StyledPlot b V2 n]
styledPlots) (Axis b V2 n
a Axis b V2 n
-> Getting (Legend b n) (Axis b V2 n) (Legend b n) -> Legend b n
forall s a. s -> Getting a s a -> a
^. Getting (Legend b n) (Axis b V2 n) (Legend b n)
forall a b. HasLegend a b => Lens' a (Legend b (N a))
legend)
    --

    -- The colour bar
    cBar :: QDiagram b V2 n Any
cBar = BoundingBox V2 n
-> ColourBar b n -> ColourMap -> (n, n) -> QDiagram b V2 n Any
forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
BoundingBox V2 n
-> ColourBar b n -> ColourMap -> (n, n) -> QDiagram b V2 n Any
addColourBar BoundingBox V2 n
bb (Axis b V2 n
aAxis b V2 n
-> Getting (ColourBar b n) (Axis b V2 n) (ColourBar b n)
-> ColourBar b n
forall s a. s -> Getting a s a -> a
^.Getting (ColourBar b n) (Axis b V2 n) (ColourBar b n)
forall a b. HasColourBar a b => Lens' a (ColourBar b (N a))
colourBar) (Axis b V2 n
a Axis b V2 n
-> Getting ColourMap (Axis b V2 n) ColourMap -> ColourMap
forall s a. s -> Getting a s a -> a
^. Getting ColourMap (Axis b V2 n) ColourMap
forall a b. HasAxisStyle a b => Lens' a ColourMap
axisColourMap) (Axis b V2 n
aAxis b V2 n -> Getting (n, n) (Axis b V2 n) (n, n) -> (n, n)
forall s a. s -> Getting a s a -> a
^.Getting (n, n) (Axis b V2 n) (n, n)
forall b (v :: * -> *) n. Lens' (Axis b v n) (n, n)
colourBarRange)
    -- title
    ttl :: QDiagram b V2 n Any
ttl = BoundingBox V2 n -> Title b V2 n -> QDiagram b V2 n Any
forall n b.
TypeableFloat n =>
BoundingBox V2 n -> Title b V2 n -> QDiagram b V2 n Any
drawTitle BoundingBox V2 n
bb (Axis b V2 n
aAxis b V2 n
-> Getting (Title b V2 n) (Axis b V2 n) (Title b V2 n)
-> Title b V2 n
forall s a. s -> Getting a s a -> a
^.Getting (Title b V2 n) (Axis b V2 n) (Title b V2 n)
forall a b. HasTitle a b => Lens' a (Title b (V a) (N a))
title)
    --
    styledPlots :: [StyledPlot b V2 n]
styledPlots = Axis b V2 n -> [StyledPlot b V2 n]
forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Axis b c n -> [StyledPlot b v n]
buildPlots Axis b V2 n
a

-- | The position of axis labels for a
data LabelPosition
  = NoLabels
  | LowerLabels
  | LeftLabels
  | RightLabels
  | UpperLabels
  deriving (Int -> LabelPosition -> ShowS
[LabelPosition] -> ShowS
LabelPosition -> String
(Int -> LabelPosition -> ShowS)
-> (LabelPosition -> String)
-> ([LabelPosition] -> ShowS)
-> Show LabelPosition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LabelPosition] -> ShowS
$cshowList :: [LabelPosition] -> ShowS
show :: LabelPosition -> String
$cshow :: LabelPosition -> String
showsPrec :: Int -> LabelPosition -> ShowS
$cshowsPrec :: Int -> LabelPosition -> ShowS
Show, LabelPosition -> LabelPosition -> Bool
(LabelPosition -> LabelPosition -> Bool)
-> (LabelPosition -> LabelPosition -> Bool) -> Eq LabelPosition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LabelPosition -> LabelPosition -> Bool
$c/= :: LabelPosition -> LabelPosition -> Bool
== :: LabelPosition -> LabelPosition -> Bool
$c== :: LabelPosition -> LabelPosition -> Bool
Eq, Typeable)

axisOnBasis
  :: forall b v n. (v ~ V2, TypeableFloat n, HasLinearMap v, Metric v,
                    Renderable (Path V2 n) b, n ~ N (v n), v ~ V (v n), OrderedField n)
  => Point v n        -- start of axis
  -> v (n, n)         -- calculated bounds
  -> SingleAxis b v n -- axis data
  -> v LogScale       -- log scale
  -> T2 n             -- transformation to apply to positions of things
  -> E v              -- direction of axis
  -> E v              -- orthogonal direction of axis
  -> LabelPosition    -- where (if at all) should labels be placed?
  -> QDiagram b V2 n Any   -- resulting axis
axisOnBasis :: forall b (v :: * -> *) n.
(v ~ V2, TypeableFloat n, HasLinearMap v, Metric v,
 Renderable (Path V2 n) b, n ~ N (v n), v ~ V (v n),
 OrderedField n) =>
Point v n
-> v (n, n)
-> SingleAxis b v n
-> v LogScale
-> T2 n
-> E v
-> E v
-> LabelPosition
-> QDiagram b V2 n Any
axisOnBasis Point v n
p v (n, n)
bs SingleAxis b v n
a v LogScale
ls T2 n
t E v
e E v
eO LabelPosition
lp
  | SingleAxis b v n
a SingleAxis b v n -> Getting Bool (SingleAxis b v n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. Getting Bool (SingleAxis b v n) Bool
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any -> QDiagram b V2 n Any
forall (v :: * -> *) n a m b.
(InSpace v n a, Monoid' m, Enveloped a, Traced a) =>
a -> QDiagram b v n m
phantom QDiagram b V2 n Any
axis
  | Bool
otherwise   = QDiagram b V2 n Any
axis
  where
    axis :: QDiagram b V2 n Any
axis = QDiagram b V2 n Any
tickLabels QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
axLabels QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
ticks QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
line QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
grid
    tStroke :: Path v n -> QDiagram b V2 n Any
tStroke = Path v n -> QDiagram b V2 n Any
forall n t b.
(InSpace V2 n t, ToPath t, TypeableFloat n,
 Renderable (Path V2 n) b) =>
t -> QDiagram b V2 n Any
stroke (Path v n -> QDiagram b V2 n Any)
-> (Path v n -> Path v n) -> Path v n -> QDiagram b V2 n Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Transformation (V (Path v n)) (N (Path v n))
-> Path v n -> Path v n
forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform Transformation (V (Path v n)) (N (Path v n))
T2 n
t

    -- axis labels (x,y etc.)
    axLabels :: QDiagram b V2 n Any
axLabels
      | String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
txt Bool -> Bool -> Bool
|| LabelPosition
lp LabelPosition -> LabelPosition -> Bool
forall a. Eq a => a -> a -> Bool
== LabelPosition
NoLabels Bool -> Bool -> Bool
|| SingleAxis b v n
a SingleAxis b v n -> Getting Bool (SingleAxis b v n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n))
-> SingleAxis b v n -> Const Bool (SingleAxis b v n)
forall (f :: * -> *) a b.
HasAxisLabel f a b =>
LensLike' f a (AxisLabel b (V a) (N a))
axisLabel ((AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n))
 -> SingleAxis b v n -> Const Bool (SingleAxis b v n))
-> ((Bool -> Const Bool Bool)
    -> AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n))
-> Getting Bool (SingleAxis b v n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden
                  = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
      | Bool
otherwise = (SingleAxis b v n
a SingleAxis b v n
-> Getting
     (TextAlignment (N (SingleAxis b V2 n))
      -> String -> QDiagram b V2 n Any)
     (SingleAxis b v n)
     (TextAlignment (N (SingleAxis b V2 n))
      -> String -> QDiagram b V2 n Any)
-> TextAlignment (N (SingleAxis b V2 n))
-> String
-> QDiagram b V2 n Any
forall s a. s -> Getting a s a -> a
^. Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b v n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a (TextFunction b (V a) (N a))
axisLabelTextFunction) TextAlignment (N (SingleAxis b V2 n))
txtAlign String
txt
                      # moveTo p'
                      # applyStyle (a ^. axisLabelStyle)
      where
        p' :: Point v n
p' = Point v n
p Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
e  ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
x
               Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
y0
               -- & logPoint ls
               Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& Point v n -> Point v n
coscale
               Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& Transformation v n -> Point v n -> Point v n
forall (v :: * -> *) n.
(Additive v, Num n) =>
Transformation v n -> Point v n -> Point v n
papply Transformation v n
T2 n
t
               Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
+~ n -> n
negate' n
labelGap
        labelGap :: n
labelGap = SingleAxis b v n
a SingleAxis b v n -> Getting n (SingleAxis b v n) n -> n
forall s a. s -> Getting a s a -> a
^. Getting n (SingleAxis b v n) n
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a (N a)
axisLabelGap
        txt :: String
txt      = SingleAxis b v n
a SingleAxis b v n
-> Getting String (SingleAxis b v n) String -> String
forall s a. s -> Getting a s a -> a
^. Getting String (SingleAxis b v n) String
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a String
axisLabelText
        x :: n
x = case SingleAxis b v n
a SingleAxis b v n
-> Getting AxisLabelPosition (SingleAxis b v n) AxisLabelPosition
-> AxisLabelPosition
forall s a. s -> Getting a s a -> a
^. Getting AxisLabelPosition (SingleAxis b v n) AxisLabelPosition
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a AxisLabelPosition
axisLabelPosition of
              AxisLabelPosition
MiddleAxisLabel -> (n
x0 n -> n -> n
forall a. Num a => a -> a -> a
+ n
x1) n -> n -> n
forall a. Fractional a => a -> a -> a
/ n
2
              AxisLabelPosition
LowerAxisLabel  -> n
x0
              AxisLabelPosition
UpperAxisLabel  -> n
x1
        -- axLabelD = a ^. axisLabels . el e

    -- tick labels
    tickLabels :: QDiagram b V2 n Any
tickLabels
      | LabelPosition
lp LabelPosition -> LabelPosition -> Bool
forall a. Eq a => a -> a -> Bool
== LabelPosition
NoLabels Bool -> Bool -> Bool
|| SingleAxis b v n
a SingleAxis b v n -> Getting Bool (SingleAxis b v n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (TickLabels b V2 n -> Const Bool (TickLabels b V2 n))
-> SingleAxis b v n -> Const Bool (SingleAxis b v n)
forall (f :: * -> *) a b.
HasTickLabels f a b =>
LensLike' f a (TickLabels b (V a) (N a))
tickLabel ((TickLabels b V2 n -> Const Bool (TickLabels b V2 n))
 -> SingleAxis b v n -> Const Bool (SingleAxis b v n))
-> ((Bool -> Const Bool Bool)
    -> TickLabels b V2 n -> Const Bool (TickLabels b V2 n))
-> Getting Bool (SingleAxis b v n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> TickLabels b V2 n -> Const Bool (TickLabels b V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
      | Bool
otherwise = (n -> QDiagram b V2 n Any) -> [n] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap n -> QDiagram b V2 n Any
drawLabels (((AxisPos, n) -> n) -> [(AxisPos, n)] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map (AxisPos, n) -> n
forall a b. (a, b) -> b
snd ([(AxisPos, n)] -> [n]) -> [(AxisPos, n)] -> [n]
forall a b. (a -> b) -> a -> b
$ Int -> [(AxisPos, n)] -> [(AxisPos, n)]
forall a. Int -> [a] -> [a]
take Int
1 [(AxisPos, n)]
ys)
                      # applyStyle (a ^. tickLabelStyle)
      where
        -- tickLabelsD  = a ^. axisTickLabels . el e
        labelFun :: [n] -> (n, n) -> [(n, String)]
labelFun     = SingleAxis b v n
a SingleAxis b v n
-> Getting
     ([n] -> (n, n) -> [(n, String)])
     (SingleAxis b v n)
     ([n] -> (n, n) -> [(n, String)])
-> [n]
-> (n, n)
-> [(n, String)]
forall s a. s -> Getting a s a -> a
^. Getting
  ([n] -> (n, n) -> [(n, String)])
  (SingleAxis b v n)
  ([n] -> (n, n) -> [(n, String)])
forall (f :: * -> *) a b.
(HasTickLabels f a b, Functor f) =>
LensLike' f a ([N a] -> (N a, N a) -> [(N a, String)])
tickLabelFunction
        drawLabels :: n -> QDiagram b V2 n Any
drawLabels n
y = ((n, String) -> QDiagram b V2 n Any)
-> [(n, String)] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (n, String) -> QDiagram b V2 n Any
f ([n] -> (n, n) -> [(n, String)]
labelFun ((n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
inRange [n]
majorTickXs) (n, n)
b)
          where
            f :: (n, String) -> QDiagram b V2 n Any
f (n
x, String
l) = QDiagram b V2 n Any -> Point v n -> QDiagram b V2 n Any
forall (v :: * -> *) n t.
(InSpace v n t, HasOrigin t) =>
t -> Point v n -> t
place QDiagram b V2 n Any
dia Point v n
p'
              where
                dia :: QDiagram b V2 n Any
dia = Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
-> SingleAxis b V2 n
-> TextAlignment (N (SingleAxis b V2 n))
-> String
-> QDiagram b V2 n Any
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
forall (f :: * -> *) a b.
(HasTickLabels f a b, Functor f) =>
LensLike' f a (TextFunction b (V a) (N a))
tickLabelTextFunction SingleAxis b v n
a TextAlignment (N (SingleAxis b V2 n))
txtAlign String
l
                p' :: Point v n
p' = Point v n
p Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
e  ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
x
                       Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
y
                       -- & logPoint ls
                       Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& Point v n -> Point v n
coscale
                       Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& Transformation v n -> Point v n -> Point v n
forall (v :: * -> *) n.
(Additive v, Num n) =>
Transformation v n -> Point v n -> Point v n
papply Transformation v n
T2 n
t
                       Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
+~ n -> n
negate' (SingleAxis b v n
a SingleAxis b v n -> Getting n (SingleAxis b v n) n -> n
forall s a. s -> Getting a s a -> a
^. Getting n (SingleAxis b v n) n
forall (f :: * -> *) a b.
(HasTickLabels f a b, Functor f) =>
LensLike' f a (N a)
tickLabelGap)

    -- the grid

    grid :: QDiagram b V2 n Any
grid = QDiagram b V2 n Any
majorLines QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
minorLines
      where
        majorLines :: QDiagram b V2 n Any
majorLines
          | SingleAxis b v n
a SingleAxis b v n -> Getting Bool (SingleAxis b v n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n))
-> SingleAxis b v n -> Const Bool (SingleAxis b v n)
forall (f :: * -> *) a.
HasMajorGridLines f a =>
LensLike' f a (MajorGridLines (V a) (N a))
majorGridLines ((MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n))
 -> SingleAxis b v n -> Const Bool (SingleAxis b v n))
-> ((Bool -> Const Bool Bool)
    -> MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n))
-> Getting Bool (SingleAxis b v n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
          | Bool
otherwise = (n -> Path v n) -> [n] -> Path v n
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap n -> Path v n
mkGridLine [n]
majorGridXs'
                          # tStroke
                          # applyStyle (a ^. majorGridLinesStyle)
        majorGridXs :: [n]
majorGridXs  = Getting
  ([n] -> (n, n) -> [n]) (SingleAxis b V2 n) ([n] -> (n, n) -> [n])
-> SingleAxis b V2 n -> [n] -> (n, n) -> [n]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([n] -> (n, n) -> [n]) (SingleAxis b V2 n) ([n] -> (n, n) -> [n])
forall (f :: * -> *) a.
(HasMajorGridLines f a, Functor f) =>
LensLike' f a (GridLineFunction (N a))
majorGridLinesFunction SingleAxis b v n
a [n]
majorTickXs (n, n)
b
        majorGridXs' :: [n]
majorGridXs' = (n -> n) -> [n] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map n -> n
coscaleNum ((n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
inRange [n]
majorGridXs)
        --
        minorLines :: QDiagram b V2 n Any
minorLines
          | SingleAxis b v n
a SingleAxis b v n -> Getting Bool (SingleAxis b v n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n))
-> SingleAxis b v n -> Const Bool (SingleAxis b v n)
forall (f :: * -> *) a.
HasMinorGridLines f a =>
LensLike' f a (MinorGridLines (V a) (N a))
minorGridLines ((MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n))
 -> SingleAxis b v n -> Const Bool (SingleAxis b v n))
-> ((Bool -> Const Bool Bool)
    -> MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n))
-> Getting Bool (SingleAxis b v n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
          | Bool
otherwise = (n -> Path v n) -> [n] -> Path v n
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap n -> Path v n
mkGridLine [n]
minorGridXs'
                       # tStroke
                       # applyStyle (a ^. minorGridLinesStyle)
        minorGridXs :: [n]
minorGridXs  = Getting
  ([n] -> (n, n) -> [n]) (SingleAxis b V2 n) ([n] -> (n, n) -> [n])
-> SingleAxis b V2 n -> [n] -> (n, n) -> [n]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([n] -> (n, n) -> [n]) (SingleAxis b V2 n) ([n] -> (n, n) -> [n])
forall (f :: * -> *) a.
(HasMinorGridLines f a, Functor f) =>
LensLike' f a (GridLineFunction (N a))
minorGridLinesFunction SingleAxis b v n
a [n]
minorTickXs (n, n)
b
        minorGridXs' :: [n]
minorGridXs' = (n -> n) -> [n] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map n -> n
coscaleNum ((n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
inRange [n]
minorGridXs)
        -- --
        mkGridLine :: n -> Path v n
mkGridLine n
x = [Point v n] -> Path v n
forall (v :: * -> *) n.
(Metric v, OrderedField n) =>
[Point v n] -> Path v n
pathFromVertices [n -> Point v n
f n
y0, n -> Point v n
f n
y1]
          where f :: n -> Point v n
f n
y = ASetter (Point v n) (Point v n) (v n) (v n)
-> (v n -> v n) -> Point v n -> Point v n
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter (Point v n) (Point v n) (v n) (v n)
forall (g :: * -> *) a. Lens' (Point g a) (g a)
lensP ((E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
e ((n -> Identity n) -> v n -> Identity (v n)) -> n -> v n -> v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
x) (v n -> v n) -> (v n -> v n) -> v n -> v n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
eO ((n -> Identity n) -> v n -> Identity (v n)) -> n -> v n -> v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
y)) Point v n
p
        --
        -- gridD = a ^. axisGridLines ^. el e -- :: GridLines N

    -- the ticks

    ticks :: QDiagram b V2 n Any
ticks = ((AxisPos, n) -> QDiagram b V2 n Any)
-> [(AxisPos, n)] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (AxisPos, n) -> QDiagram b V2 n Any
drawTicks [(AxisPos, n)]
ys

    drawTicks :: (AxisPos, n) -> QDiagram b V2 n Any
drawTicks (AxisPos
pos,n
y) = QDiagram b V2 n Any
maTicks QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
miTicks
      where
        maTicks :: QDiagram b V2 n Any
maTicks
          | SingleAxis b v n
a SingleAxis b v n -> Getting Bool (SingleAxis b v n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MajorTicks V2 n -> Const Bool (MajorTicks V2 n))
-> SingleAxis b v n -> Const Bool (SingleAxis b v n)
forall (f :: * -> *) a.
HasMajorTicks f a =>
LensLike' f a (MajorTicks (V a) (N a))
majorTicks ((MajorTicks V2 n -> Const Bool (MajorTicks V2 n))
 -> SingleAxis b v n -> Const Bool (SingleAxis b v n))
-> ((Bool -> Const Bool Bool)
    -> MajorTicks V2 n -> Const Bool (MajorTicks V2 n))
-> Getting Bool (SingleAxis b v n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MajorTicks V2 n -> Const Bool (MajorTicks V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
          | Bool
otherwise = (n -> Path v n) -> [n] -> Path v n
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Path v n -> n -> Path v n
positionTick Path v n
majorTick) [n]
majorTickXs'
                       # stroke
                       # applyStyle (a ^. majorTicksStyle)
        --
        miTicks :: QDiagram b V2 n Any
miTicks
          | SingleAxis b v n
a SingleAxis b v n -> Getting Bool (SingleAxis b v n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MinorTicks V2 n -> Const Bool (MinorTicks V2 n))
-> SingleAxis b v n -> Const Bool (SingleAxis b v n)
forall (f :: * -> *) a.
HasMinorTicks f a =>
LensLike' f a (MinorTicks (V a) (N a))
minorTicks ((MinorTicks V2 n -> Const Bool (MinorTicks V2 n))
 -> SingleAxis b v n -> Const Bool (SingleAxis b v n))
-> ((Bool -> Const Bool Bool)
    -> MinorTicks V2 n -> Const Bool (MinorTicks V2 n))
-> Getting Bool (SingleAxis b v n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MinorTicks V2 n -> Const Bool (MinorTicks V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
          | Bool
otherwise = (n -> Path v n) -> [n] -> Path v n
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Path v n -> n -> Path v n
positionTick Path v n
minorTick) [n]
minorTickXs'
                       # stroke
                       # applyStyle (a ^. minorTicksStyle)
        --
        minorTick :: Path v n
minorTick = TicksAlignment -> n -> Path v n
someTick (SingleAxis b v n
a SingleAxis b v n
-> Getting TicksAlignment (SingleAxis b v n) TicksAlignment
-> TicksAlignment
forall s a. s -> Getting a s a -> a
^. Getting TicksAlignment (SingleAxis b v n) TicksAlignment
forall (f :: * -> *) a.
(HasMinorTicks f a, Functor f) =>
LensLike' f a TicksAlignment
minorTicksAlignment) (SingleAxis b v n
a SingleAxis b v n -> Getting n (SingleAxis b v n) n -> n
forall s a. s -> Getting a s a -> a
^. Getting n (SingleAxis b v n) n
forall (f :: * -> *) a.
(HasMinorTicks f a, Functor f) =>
LensLike' f a (N a)
minorTicksLength)
        majorTick :: Path v n
majorTick = TicksAlignment -> n -> Path v n
someTick (SingleAxis b v n
a SingleAxis b v n
-> Getting TicksAlignment (SingleAxis b v n) TicksAlignment
-> TicksAlignment
forall s a. s -> Getting a s a -> a
^. Getting TicksAlignment (SingleAxis b v n) TicksAlignment
forall (f :: * -> *) a.
(HasMajorTicks f a, Functor f) =>
LensLike' f a TicksAlignment
majorTicksAlignment) (SingleAxis b v n
a SingleAxis b v n -> Getting n (SingleAxis b v n) n -> n
forall s a. s -> Getting a s a -> a
^. Getting n (SingleAxis b v n) n
forall (f :: * -> *) a.
(HasMajorTicks f a, Functor f) =>
LensLike' f a (N a)
majorTicksLength)
        --
        someTick :: TicksAlignment -> n -> Path v n
someTick TicksAlignment
tType n
d = [Point v n] -> Path v n
forall (v :: * -> *) n.
(Metric v, OrderedField n) =>
[Point v n] -> Path v n
pathFromVertices ([Point v n] -> Path v n) -> [Point v n] -> Path v n
forall a b. (a -> b) -> a -> b
$
          case TicksAlignment
tType  of
            TicksAlignment
AutoTick ->
              case AxisPos
pos of
                AxisPos
LowerAxis  -> [Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
-~ n
d, Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin]
                AxisPos
MiddleAxis -> [Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
-~ n
d, Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
+~ n
d]
                AxisPos
UpperAxis  -> [Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin, Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
+~ n
d]
            TickSpec (Rational -> n
forall a. Fractional a => Rational -> a
fromRational -> n
aa) (Rational -> n
forall a. Fractional a => Rational -> a
fromRational -> n
bb) ->
              case AxisPos
pos of
                AxisPos
UpperAxis -> [Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
-~ n
dn -> n -> n
forall a. Num a => a -> a -> a
*n
bb, Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
+~ n
dn -> n -> n
forall a. Num a => a -> a -> a
*n
aa]
                AxisPos
_         -> [Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
-~ n
dn -> n -> n
forall a. Num a => a -> a -> a
*n
aa, Point v n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point v n -> (Point v n -> Point v n) -> Point v n
forall a b. a -> (a -> b) -> b
& E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
eO ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> n -> Point v n -> Point v n
forall a s t. Num a => ASetter s t a a -> a -> s -> t
+~ n
dn -> n -> n
forall a. Num a => a -> a -> a
*n
bb]
            -- NoTick -> []
        -- middleTick d =
        --   pathFromVertices
        positionTick :: Path v n -> n -> Path v n
positionTick Path v n
tick n
x = Path v n -> Point v n -> Path v n
forall (v :: * -> *) n t.
(InSpace v n t, HasOrigin t) =>
t -> Point v n -> t
place Path v n
tick Point v n
p'
          where
            p' :: Point v n
p' = ASetter (Point v n) (Point v n) (v n) (v n)
-> (v n -> v n) -> Point v n -> Point v n
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter (Point v n) (Point v n) (v n) (v n)
forall (g :: * -> *) a. Lens' (Point g a) (g a)
lensP ((E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
e ((n -> Identity n) -> v n -> Identity (v n)) -> n -> v n -> v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
x) (v n -> v n) -> (v n -> v n) -> v n -> v n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
eO ((n -> Identity n) -> v n -> Identity (v n)) -> n -> v n -> v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
y)) Point v n
p
                   # transform t

    -- axis lines

    line :: QDiagram b V2 n Any
line
      | SingleAxis b v n
a SingleAxis b v n -> Getting Bool (SingleAxis b v n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (AxisLine V2 n -> Const Bool (AxisLine V2 n))
-> SingleAxis b v n -> Const Bool (SingleAxis b v n)
forall (f :: * -> *) a.
HasAxisLine f a =>
LensLike' f a (AxisLine (V a) (N a))
axisLine ((AxisLine V2 n -> Const Bool (AxisLine V2 n))
 -> SingleAxis b v n -> Const Bool (SingleAxis b v n))
-> ((Bool -> Const Bool Bool)
    -> AxisLine V2 n -> Const Bool (AxisLine V2 n))
-> Getting Bool (SingleAxis b v n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> AxisLine V2 n -> Const Bool (AxisLine V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
      | Bool
otherwise = (n -> Path v n) -> [n] -> Path v n
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap n -> Path v n
mkline (((AxisPos, n) -> n) -> [(AxisPos, n)] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map (AxisPos, n) -> n
forall a b. (a, b) -> b
snd [(AxisPos, n)]
ys) -- merge with ticks?
             # transform t
             # stroke
             # lineCap LineCapSquare
             # applyStyle (a^.axisLineStyle)
      where
        -- TODO: Arrow for R3
        mkline :: n -> Path v n
mkline n
y = [Point v n] -> Path v n
forall (v :: * -> *) n.
(Metric v, OrderedField n) =>
[Point v n] -> Path v n
pathFromVertices
         ([Point v n] -> Path v n) -> [Point v n] -> Path v n
forall a b. (a -> b) -> a -> b
$ (n -> Point v n) -> [n] -> [Point v n]
forall a b. (a -> b) -> [a] -> [b]
map (\n
x -> ASetter (Point v n) (Point v n) (v n) (v n)
-> (v n -> v n) -> Point v n -> Point v n
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter (Point v n) (Point v n) (v n) (v n)
forall (g :: * -> *) a. Lens' (Point g a) (g a)
lensP ((E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
e ((n -> Identity n) -> v n -> Identity (v n)) -> n -> v n -> v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
x) (v n -> v n) -> (v n -> v n) -> v n -> v n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
eO ((n -> Identity n) -> v n -> Identity (v n)) -> n -> v n -> v n
forall s t a b. ASetter s t a b -> b -> s -> t
.~ n
y)) Point v n
p) [n
x0, n
x1] :: Path v n

    -- measurements
    b :: (n, n)
b@(n
x0,n
x1)  = v (n, n)
bs v (n, n) -> Getting (n, n) (v (n, n)) (n, n) -> (n, n)
forall s a. s -> Getting a s a -> a
^. E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
e :: (n, n) -- bounds
    coscale :: Point v n -> Point v n
coscale = E v -> Lens' (Point v n) n
forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep E v
e ((n -> Identity n) -> Point v n -> Identity (Point v n))
-> (n -> n) -> Point v n -> Point v n
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ n -> n
coscaleNum
    coscaleNum :: n -> n
coscaleNum = (n, n) -> LogScale -> n -> n
forall n. Floating n => (n, n) -> LogScale -> n -> n
scaleNum (v (n, n)
bs v (n, n) -> Getting (n, n) (v (n, n)) (n, n) -> (n, n)
forall s a. s -> Getting a s a -> a
^. E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
e) (v LogScale
ls v LogScale -> Getting LogScale (v LogScale) LogScale -> LogScale
forall s a. s -> Getting a s a -> a
^. E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
e)
    yb :: (n, n)
yb@(n
y0,n
y1) = v (n, n)
bs v (n, n) -> Getting (n, n) (v (n, n)) (n, n) -> (n, n)
forall s a. s -> Getting a s a -> a
^. E v -> forall x. Lens' (v x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E v
eO Getting (n, n) (v (n, n)) (n, n)
-> (((n, n) -> Const (n, n) (n, n))
    -> (n, n) -> Const (n, n) (n, n))
-> Getting (n, n) (v (n, n)) (n, n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. if LabelPosition
lp LabelPosition -> LabelPosition -> Bool
forall a. Eq a => a -> a -> Bool
== LabelPosition
UpperLabels
                                 then ((n, n) -> Const (n, n) (n, n)) -> (n, n) -> Const (n, n) (n, n)
forall (p :: * -> * -> *) a b c d.
Swap p =>
Iso (p a b) (p c d) (p b a) (p d c)
swapped
                                 else ((n, n) -> Const (n, n) (n, n)) -> (n, n) -> Const (n, n) (n, n)
forall a. a -> a
id
    inRange :: n -> Bool
inRange n
x = n
x n -> n -> Bool
forall a. Ord a => a -> a -> Bool
>= n
x0 Bool -> Bool -> Bool
&& n
x n -> n -> Bool
forall a. Ord a => a -> a -> Bool
<= n
x1
    --
    majorTickXs :: [n]
majorTickXs  = [n] -> [n]
forall a. Ord a => [a] -> [a]
sort ([n] -> [n]) -> [n] -> [n]
forall a b. (a -> b) -> a -> b
$ Getting ((n, n) -> [n]) (SingleAxis b V2 n) ((n, n) -> [n])
-> SingleAxis b V2 n -> (n, n) -> [n]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting ((n, n) -> [n]) (SingleAxis b V2 n) ((n, n) -> [n])
forall (f :: * -> *) a.
(HasMajorTicks f a, Functor f) =>
LensLike' f a ((N a, N a) -> [N a])
majorTicksFunction SingleAxis b v n
a (n, n)
b
    majorTickXs' :: [n]
majorTickXs' = (n -> n) -> [n] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map n -> n
coscaleNum ((n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
inRange [n]
majorTickXs)
    minorTickXs :: [n]
minorTickXs  = [n] -> [n]
forall a. Ord a => [a] -> [a]
sort ([n] -> [n]) -> [n] -> [n]
forall a b. (a -> b) -> a -> b
$ Getting
  ([n] -> (n, n) -> [n]) (SingleAxis b V2 n) ([n] -> (n, n) -> [n])
-> SingleAxis b V2 n -> [n] -> (n, n) -> [n]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([n] -> (n, n) -> [n]) (SingleAxis b V2 n) ([n] -> (n, n) -> [n])
forall (f :: * -> *) a.
(HasMinorTicks f a, Functor f) =>
LensLike' f a ([N a] -> (N a, N a) -> [N a])
minorTicksFunction SingleAxis b v n
a [n]
majorTickXs (n, n)
b
    minorTickXs' :: [n]
minorTickXs' = (n -> n) -> [n] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map n -> n
coscaleNum ((n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
inRange [n]
minorTickXs)
    --
    ys :: [(AxisPos, n)]
ys       = (n, n) -> AxisLineType -> [(AxisPos, n)]
forall n.
(Num n, Ord n) =>
(n, n) -> AxisLineType -> [(AxisPos, n)]
getAxisLinePos (n, n)
yb AxisLineType
lineType
    lineType :: AxisLineType
lineType = SingleAxis b v n
a SingleAxis b v n
-> Getting AxisLineType (SingleAxis b v n) AxisLineType
-> AxisLineType
forall s a. s -> Getting a s a -> a
^. Getting AxisLineType (SingleAxis b v n) AxisLineType
forall (f :: * -> *) a.
(HasAxisLine f a, Functor f) =>
LensLike' f a AxisLineType
axisLineType
    txtAlign :: TextAlignment (N (SingleAxis b V2 n))
txtAlign =
      case LabelPosition
lp of
         LabelPosition
LowerLabels -> N (SingleAxis b V2 n)
-> N (SingleAxis b V2 n) -> TextAlignment (N (SingleAxis b V2 n))
forall n. n -> n -> TextAlignment n
BoxAlignedText N (SingleAxis b V2 n)
0.5 N (SingleAxis b V2 n)
1
         LabelPosition
LeftLabels  -> N (SingleAxis b V2 n)
-> N (SingleAxis b V2 n) -> TextAlignment (N (SingleAxis b V2 n))
forall n. n -> n -> TextAlignment n
BoxAlignedText N (SingleAxis b V2 n)
1   N (SingleAxis b V2 n)
0.5
         LabelPosition
RightLabels -> N (SingleAxis b V2 n)
-> N (SingleAxis b V2 n) -> TextAlignment (N (SingleAxis b V2 n))
forall n. n -> n -> TextAlignment n
BoxAlignedText N (SingleAxis b V2 n)
0   N (SingleAxis b V2 n)
0.5
         LabelPosition
UpperLabels -> N (SingleAxis b V2 n)
-> N (SingleAxis b V2 n) -> TextAlignment (N (SingleAxis b V2 n))
forall n. n -> n -> TextAlignment n
BoxAlignedText N (SingleAxis b V2 n)
1   N (SingleAxis b V2 n)
0
         LabelPosition
_           -> String -> TextAlignment (N (SingleAxis b V2 n))
forall a. HasCallStack => String -> a
error String
"No labels" -- XXX Temporary
    -- t2 = scaling 4
    --
    negate' :: n -> n
negate' = if LabelPosition
lp LabelPosition -> LabelPosition -> Bool
forall a. Eq a => a -> a -> Bool
== LabelPosition
UpperLabels Bool -> Bool -> Bool
|| LabelPosition
lp LabelPosition -> LabelPosition -> Bool
forall a. Eq a => a -> a -> Bool
== LabelPosition
RightLabels
                then n -> n
forall a. a -> a
id
                else n -> n
forall a. Num a => a -> a
negate

-- utilities

getAxisLinePos :: (Num n, Ord n) => (n, n) -> AxisLineType -> [(AxisPos, n)]
getAxisLinePos :: forall n.
(Num n, Ord n) =>
(n, n) -> AxisLineType -> [(AxisPos, n)]
getAxisLinePos (n
a,n
b) AxisLineType
aType = case AxisLineType
aType of
  AxisLineType
BoxAxisLine    -> [(AxisPos
LowerAxis, n
a), (AxisPos
UpperAxis, n
b)]
  AxisLineType
LeftAxisLine   -> [(AxisPos
LowerAxis, n
a)]
  AxisLineType
MiddleAxisLine -> [(,) AxisPos
MiddleAxis (n -> (AxisPos, n)) -> n -> (AxisPos, n)
forall a b. (a -> b) -> a -> b
$
                     if | n
a n -> n -> Bool
forall a. Ord a => a -> a -> Bool
> n
0     -> n
a
                        | n
b n -> n -> Bool
forall a. Ord a => a -> a -> Bool
< n
0     -> n
b
                        | Bool
otherwise -> n
0]
  AxisLineType
RightAxisLine  -> [(AxisPos
UpperAxis, n
b)]
  AxisLineType
NoAxisLine     -> []

data AxisPos = LowerAxis | MiddleAxis | UpperAxis

------------------------------------------------------------------------
-- Utilities
------------------------------------------------------------------------

ep :: E v -> Lens' (Point v x) x
ep :: forall (v :: * -> *) x. E v -> Lens' (Point v x) x
ep (E forall x. Lens' (v x) x
l) = (v x -> f (v x)) -> Point v x -> f (Point v x)
forall (g :: * -> *) a. Lens' (Point g a) (g a)
lensP ((v x -> f (v x)) -> Point v x -> f (Point v x))
-> ((x -> f x) -> v x -> f (v x))
-> (x -> f x)
-> Point v x
-> f (Point v x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (x -> f x) -> v x -> f (v x)
forall x. Lens' (v x) x
l
{-# INLINE ep #-}

------------------------------------------------------------------------
-- Polar
------------------------------------------------------------------------

instance (TypeableFloat n, Renderable (Path V2 n) b)
    => RenderAxis b Polar n where
  renderAxis :: Axis b Polar n -> QDiagram b (BaseSpace Polar) n Any
renderAxis = Axis b Polar n -> QDiagram b (BaseSpace Polar) n Any
forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
Axis b Polar n -> QDiagram b V2 n Any
renderPolarAxis

-- | An lower and upper bound for the bounding radius using @n@ envelope
--   calculations. The more calculations used, the smaller the range of
--   the bound.
boundingRadiusR :: (InSpace V2 n a, Enveloped a) => Int -> a -> (n, n)
boundingRadiusR :: forall n a. (InSpace V2 n a, Enveloped a) => Int -> a -> (n, n)
boundingRadiusR (Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
3 -> Int
n) a
e =
  case Envelope V2 n -> Maybe (V2 n -> n)
forall (v :: * -> *) n. Envelope v n -> Maybe (v n -> n)
appEnvelope (a -> Envelope (V a) (N a)
forall a. Enveloped a => a -> Envelope (V a) (N a)
getEnvelope a
e) of
    Maybe (V2 n -> n)
Nothing -> (n
0,n
0)
    Just V2 n -> n
f  ->
      let thetas :: [Angle n]
thetas = (n -> Angle n) -> [n] -> [Angle n]
forall a b. (a -> b) -> [a] -> [b]
map (n -> AReview (Angle n) n -> Angle n
forall b a. b -> AReview a b -> a
@@AReview (Angle n) n
forall n. Iso' (Angle n) n
rad) ([n] -> [Angle n]) -> [n] -> [Angle n]
forall a b. (a -> b) -> a -> b
$ n -> n -> Int -> [n]
forall n. Fractional n => n -> n -> Int -> [n]
enumFromToN n
0 n
forall a. Floating a => a
tau Int
n
          vs :: [V2 n]
vs     = (Angle n -> V2 n) -> [Angle n] -> [V2 n]
forall a b. (a -> b) -> [a] -> [b]
map Angle n -> V2 n
forall n. Floating n => Angle n -> V2 n
angleV [Angle n]
thetas

          -- The lower bound is the maximum distance obtained from the
          -- envelope trials. We know the radius will be at least this far.
          lowerBound :: n
lowerBound = (V2 n -> n -> n) -> n -> [V2 n] -> n
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr (\V2 n
v n
r -> n -> n -> n
forall a. Ord a => a -> a -> a
max (V2 n -> n
f V2 n
v) n
r) n
0 [V2 n]
vs

          -- In the worst case, there will be a point at the intersection of
          -- two neighbouring bounding planes from the envelope calculations.
          -- We can calculate the distance to this intersecion using simple
          -- trigonometry.
          -- (Note, this is why we need at least three envelope calculations,
          -- otherwise there wouldn't be any intersection between the bounding
          -- planes)
          upperBound :: n
upperBound = n
lowerBound n -> n -> n
forall a. Fractional a => a -> a -> a
/ n -> n
forall a. Floating a => a -> a
cos (n
forall a. Floating a => a
pi n -> n -> n
forall a. Fractional a => a -> a -> a
/ Int -> n
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n)

      in  (n
lowerBound, n
upperBound)

renderPolarAxis
  :: (TypeableFloat n, Renderable (Path V2 n) b)
  => Axis b Polar n -> QDiagram b V2 n Any
renderPolarAxis :: forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
Axis b Polar n -> QDiagram b V2 n Any
renderPolarAxis Axis b Polar n
a = n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall (v :: * -> *) n m b.
(Metric v, OrderedField n, Monoid' m) =>
n -> QDiagram b v n m -> QDiagram b v n m
frame n
15
               (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a b. (a -> b) -> a -> b
$ QDiagram b V2 n Any
leg
              -- <> colourBar
              -- <> circles
              QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
plots
              QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
theAxis
  where
    r :: n
r = (n, n) -> n
forall a b. (a, b) -> b
snd ((n, n) -> n) -> (n, n) -> n
forall a b. (a -> b) -> a -> b
$ Int -> [StyledPlot b V2 n] -> (n, n)
forall n a. (InSpace V2 n a, Enveloped a) => Int -> a -> (n, n)
boundingRadiusR Int
30 [StyledPlot b V2 n]
styledPlots
    spec :: AxisSpec V2 n
spec  = V2 (n, n)
-> Transformation V2 n -> V2 LogScale -> ColourMap -> AxisSpec V2 n
forall (v :: * -> *) n.
v (n, n)
-> Transformation v n -> v LogScale -> ColourMap -> AxisSpec v n
AxisSpec V2 (n, n)
xs Transformation V2 n
t (LogScale -> V2 LogScale
forall (f :: * -> *) a. Applicative f => a -> f a
pure LogScale
LinearAxis) (Axis b Polar n
a Axis b Polar n
-> Getting ColourMap (Axis b Polar n) ColourMap -> ColourMap
forall s a. s -> Getting a s a -> a
^. Getting ColourMap (Axis b Polar n) ColourMap
forall a b. HasAxisStyle a b => Lens' a ColourMap
axisColourMap)
    plots :: QDiagram b V2 n Any
plots = (StyledPlot b V2 n -> QDiagram b V2 n Any)
-> [StyledPlot b V2 n] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap (AxisSpec V2 n -> StyledPlot b V2 n -> QDiagram b V2 n Any
forall n b.
TypeableFloat n =>
AxisSpec V2 n -> StyledPlot b V2 n -> QDiagram b V2 n Any
renderStyledPlot AxisSpec V2 n
spec) [StyledPlot b V2 n]
styledPlots

    dataBB :: BoundingBox V2 n
dataBB = Point V2 n -> Point V2 n -> BoundingBox V2 n
forall (v :: * -> *) n.
(Additive v, Foldable v, Ord n) =>
Point v n -> Point v n -> BoundingBox v n
fromCorners (n -> n -> Point V2 n
forall n. n -> n -> P2 n
mkP2 (-n
r) (-n
r)) (n -> n -> Point V2 n
forall n. n -> n -> P2 n
mkP2 n
r n
r)
    (V2 (n, n)
xs, Transformation V2 n
tv, Transformation V2 n
t') = V2 (AxisScaling n)
-> BoundingBox V2 n
-> (V2 (n, n), Transformation V2 n, Transformation V2 n)
forall (v :: * -> *) n.
(HasLinearMap v, OrderedField n, Applicative v) =>
v (AxisScaling n)
-> BoundingBox v n
-> (v (n, n), Transformation v n, Transformation v n)
calculateScaling (Getting
  (V2 (AxisScaling n)) (Polar (AxisScaling n)) (V2 (AxisScaling n))
-> Polar (AxisScaling n) -> V2 (AxisScaling n)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (V2 (AxisScaling n)) (Polar (AxisScaling n)) (V2 (AxisScaling n))
forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Wrapped (Polar (AxisScaling n) -> V2 (AxisScaling n))
-> Polar (AxisScaling n) -> V2 (AxisScaling n)
forall a b. (a -> b) -> a -> b
$ Axis b Polar n
aAxis b Polar n
-> Getting
     (Polar (AxisScaling n)) (Axis b Polar n) (Polar (AxisScaling n))
-> Polar (AxisScaling n)
forall s a. s -> Getting a s a -> a
^.(Polar (SingleAxis b V2 n)
 -> Const (Polar (AxisScaling n)) (Polar (SingleAxis b V2 n)))
-> Axis b Polar n -> Const (Polar (AxisScaling n)) (Axis b Polar n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes((Polar (SingleAxis b V2 n)
  -> Const (Polar (AxisScaling n)) (Polar (SingleAxis b V2 n)))
 -> Axis b Polar n
 -> Const (Polar (AxisScaling n)) (Axis b Polar n))
-> ((Polar (AxisScaling n)
     -> Const (Polar (AxisScaling n)) (Polar (AxisScaling n)))
    -> Polar (SingleAxis b V2 n)
    -> Const (Polar (AxisScaling n)) (Polar (SingleAxis b V2 n)))
-> Getting
     (Polar (AxisScaling n)) (Axis b Polar n) (Polar (AxisScaling n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.LensLike
  (Context (AxisScaling n) (AxisScaling n))
  (SingleAxis b V2 n)
  (SingleAxis b V2 n)
  (AxisScaling n)
  (AxisScaling n)
-> Lens
     (Polar (SingleAxis b V2 n))
     (Polar (SingleAxis b V2 n))
     (Polar (AxisScaling n))
     (Polar (AxisScaling n))
forall (f :: * -> *) a b s t.
Representable f =>
LensLike (Context a b) s t a b -> Lens (f s) (f t) (f a) (f b)
column LensLike
  (Context (AxisScaling n) (AxisScaling n))
  (SingleAxis b V2 n)
  (SingleAxis b V2 n)
  (AxisScaling n)
  (AxisScaling n)
forall (f :: * -> *) a.
HasAxisScaling f a =>
LensLike' f a (AxisScaling (N a))
axisScaling) BoundingBox V2 n
dataBB
    t :: Transformation V2 n
t = Transformation V2 n
tv Transformation V2 n -> Transformation V2 n -> Transformation V2 n
forall a. Semigroup a => a -> a -> a
<> Transformation V2 n
t'
    --
    theAxis :: QDiagram b V2 n Any
theAxis = AxisSpec V2 n -> Polar (SingleAxis b V2 n) -> QDiagram b V2 n Any
forall b n.
(Renderable (Path V2 n) b, TypeableFloat n) =>
AxisSpec V2 n -> Polar (SingleAxis b V2 n) -> QDiagram b V2 n Any
drawPolarAxis AxisSpec V2 n
spec (Axis b Polar n
a Axis b Polar n
-> Getting
     (Polar (SingleAxis b V2 n))
     (Axis b Polar n)
     (Polar (SingleAxis b V2 n))
-> Polar (SingleAxis b V2 n)
forall s a. s -> Getting a s a -> a
^. Getting
  (Polar (SingleAxis b V2 n))
  (Axis b Polar n)
  (Polar (SingleAxis b V2 n))
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes)
    --
    bb :: BoundingBox V2 n
bb = Point V2 n -> Point V2 n -> BoundingBox V2 n
forall (v :: * -> *) n.
(Additive v, Foldable v, Ord n) =>
Point v n -> Point v n -> BoundingBox v n
fromCorners (V2 n -> Point V2 n
forall (f :: * -> *) a. f a -> Point f a
P (V2 n -> Point V2 n) -> (V2 n -> V2 n) -> V2 n -> Point V2 n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Transformation V2 n -> V2 n -> V2 n
forall (v :: * -> *) n. Transformation v n -> v n -> v n
apply Transformation V2 n
t (V2 n -> Point V2 n) -> V2 n -> Point V2 n
forall a b. (a -> b) -> a -> b
$ ((n, n) -> n) -> V2 (n, n) -> V2 n
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (n, n) -> n
forall a b. (a, b) -> a
fst V2 (n, n)
xs) (V2 n -> Point V2 n
forall (f :: * -> *) a. f a -> Point f a
P (V2 n -> Point V2 n) -> (V2 n -> V2 n) -> V2 n -> Point V2 n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Transformation V2 n -> V2 n -> V2 n
forall (v :: * -> *) n. Transformation v n -> v n -> v n
apply Transformation V2 n
t (V2 n -> Point V2 n) -> V2 n -> Point V2 n
forall a b. (a -> b) -> a -> b
$ ((n, n) -> n) -> V2 (n, n) -> V2 n
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (n, n) -> n
forall a b. (a, b) -> b
snd V2 (n, n)
xs)
    leg :: QDiagram b V2 n Any
leg = BoundingBox V2 n
-> [(QDiagram b V2 n Any, String)]
-> Legend b n
-> QDiagram b V2 n Any
forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
BoundingBox V2 n
-> [(QDiagram b V2 n Any, String)]
-> Legend b n
-> QDiagram b V2 n Any
drawLegend BoundingBox V2 n
bb ([StyledPlot b V2 n] -> [(QDiagram b V2 n Any, String)]
forall n b (v :: * -> *).
Ord n =>
[StyledPlot b v n] -> [(QDiagram b v n Any, String)]
styledPlotLegends [StyledPlot b V2 n]
styledPlots) (Axis b Polar n
a Axis b Polar n
-> Getting (Legend b n) (Axis b Polar n) (Legend b n) -> Legend b n
forall s a. s -> Getting a s a -> a
^. Getting (Legend b n) (Axis b Polar n) (Legend b n)
forall a b. HasLegend a b => Lens' a (Legend b (N a))
legend)
    --
    styledPlots :: [StyledPlot b V2 n]
styledPlots = (StyledPlot b V2 n -> StyledPlot b V2 n)
-> [StyledPlot b V2 n] -> [StyledPlot b V2 n]
forall a b. (a -> b) -> [a] -> [b]
map (Endo (StyledPlot b V2 n) -> StyledPlot b V2 n -> StyledPlot b V2 n
forall a. Endo a -> a -> a
appEndo (Endo (StyledPlot b V2 n)
 -> StyledPlot b V2 n -> StyledPlot b V2 n)
-> Endo (StyledPlot b V2 n)
-> StyledPlot b V2 n
-> StyledPlot b V2 n
forall a b. (a -> b) -> a -> b
$ Axis b Polar n
a Axis b Polar n
-> Getting
     (Endo (StyledPlot b V2 n))
     (Axis b Polar n)
     (Endo (StyledPlot b V2 n))
-> Endo (StyledPlot b V2 n)
forall s a. s -> Getting a s a -> a
^. Getting
  (Endo (StyledPlot b V2 n))
  (Axis b Polar n)
  (Endo (StyledPlot b V2 n))
forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Lens' (Axis b c n) (Endo (StyledPlot b v n))
plotModifier)
                ([StyledPlot b V2 n] -> [StyledPlot b V2 n])
-> [StyledPlot b V2 n] -> [StyledPlot b V2 n]
forall a b. (a -> b) -> a -> b
$ (PlotStyle b V2 n -> DynamicPlot b V2 n -> StyledPlot b V2 n)
-> [PlotStyle b V2 n]
-> [DynamicPlot b V2 n]
-> [StyledPlot b V2 n]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith PlotStyle b V2 n -> DynamicPlot b V2 n -> StyledPlot b V2 n
forall b (v :: * -> *) n.
PlotStyle b v n -> DynamicPlot b v n -> StyledPlot b v n
styleDynamic (Axis b Polar n
a Axis b Polar n
-> Getting
     (Endo [PlotStyle b V2 n]) (Axis b Polar n) (PlotStyle b V2 n)
-> [PlotStyle b V2 n]
forall s a. s -> Getting (Endo [a]) s a -> [a]
^.. Getting
  (Endo [PlotStyle b V2 n]) (Axis b Polar n) (PlotStyle b V2 n)
forall a b.
HasAxisStyle a b =>
IndexedTraversal' Int a (PlotStyle b (V a) (N a))
axisStyles) (Axis b Polar n
a Axis b Polar n
-> Getting
     [DynamicPlot b V2 n] (Axis b Polar n) [DynamicPlot b V2 n]
-> [DynamicPlot b V2 n]
forall s a. s -> Getting a s a -> a
^. Getting [DynamicPlot b V2 n] (Axis b Polar n) [DynamicPlot b V2 n]
forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Lens' (Axis b c n) [DynamicPlot b v n]
axisPlots)

drawPolarAxis
  :: forall b n. (Renderable (Path V2 n) b, TypeableFloat n)
  => AxisSpec V2 n -> Polar (SingleAxis b V2 n) -> QDiagram b V2 n Any
drawPolarAxis :: forall b n.
(Renderable (Path V2 n) b, TypeableFloat n) =>
AxisSpec V2 n -> Polar (SingleAxis b V2 n) -> QDiagram b V2 n Any
drawPolarAxis AxisSpec V2 n
spec (Polar (V2 SingleAxis b V2 n
rA SingleAxis b V2 n
thetaA)) = AlphaColour Double -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall n a.
(InSpace V2 n a, Floating n, Typeable n, HasStyle a) =>
AlphaColour Double -> a -> a
fcA AlphaColour Double
forall a. Num a => AlphaColour a
transparent (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a b. (a -> b) -> a -> b
$ QDiagram b V2 n Any
rAx QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
thetaAx where

  -- use a radius of the upper x bound for the axis (this is not ideal)
  r :: n
r = AxisSpec V2 n
spec AxisSpec V2 n -> Getting n (AxisSpec V2 n) n -> n
forall s a. s -> Getting a s a -> a
^. (V2 (n, n) -> Const n (V2 (n, n)))
-> AxisSpec V2 n -> Const n (AxisSpec V2 n)
forall (v :: * -> *) n. Lens' (AxisSpec v n) (v (n, n))
specBounds ((V2 (n, n) -> Const n (V2 (n, n)))
 -> AxisSpec V2 n -> Const n (AxisSpec V2 n))
-> ((n -> Const n n) -> V2 (n, n) -> Const n (V2 (n, n)))
-> Getting n (AxisSpec V2 n) n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((n, n) -> Const n (n, n)) -> V2 (n, n) -> Const n (V2 (n, n))
forall (t :: * -> *) a. R1 t => Lens' (t a) a
_x (((n, n) -> Const n (n, n)) -> V2 (n, n) -> Const n (V2 (n, n)))
-> ((n -> Const n n) -> (n, n) -> Const n (n, n))
-> (n -> Const n n)
-> V2 (n, n)
-> Const n (V2 (n, n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (n -> Const n n) -> (n, n) -> Const n (n, n)
forall s t a b. Field2 s t a b => Lens s t a b
_2
  t :: Transformation V2 n
t = AxisSpec V2 n
spec AxisSpec V2 n
-> Getting
     (Transformation V2 n) (AxisSpec V2 n) (Transformation V2 n)
-> Transformation V2 n
forall s a. s -> Getting a s a -> a
^. Getting (Transformation V2 n) (AxisSpec V2 n) (Transformation V2 n)
forall (v :: * -> *) n. Lens' (AxisSpec v n) (Transformation v n)
specTrans
  s :: n
s = Transformation V2 n -> n
forall (v :: * -> *) n.
(Additive v, Traversable v, Floating n) =>
Transformation v n -> n
avgScale Transformation V2 n
t

  rInRange :: n -> Bool
rInRange n
x = n
x n -> n -> Bool
forall a. Ord a => a -> a -> Bool
>= n
0 Bool -> Bool -> Bool
&& n
x n -> n -> Bool
forall a. Ord a => a -> a -> Bool
<= n
rn -> n -> n
forall a. Num a => a -> a -> a
*n
1.000001
  thetaInRange :: a -> Bool
thetaInRange a
x = a
x a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
0 Bool -> Bool -> Bool
&& a
x a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
forall a. Floating a => a
tau

  ----------------------------------------------------------------------
  -- Radial axis
  ----------------------------------------------------------------------

  -- The radial axis consists of an axis line from the centre to the
  -- edge. The ticks and tickLabels are along this line. The grid lines
  -- are made up of circles that pass through the line, centered at the
  -- center of the plot.
  rAx :: QDiagram b V2 n Any
rAx
    | SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. Getting Bool (SingleAxis b V2 n) Bool
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = QDiagram b V2 n Any
rAxLine QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
rAxLabel QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
rAxTicks QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
rAxTickLabels QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
rAxGridLines

  rAxLine :: QDiagram b V2 n Any
rAxLine = QDiagram b V2 n Any
line QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# Bool
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
-> QDiagram b V2 n Any
forall a. Bool -> (a -> a) -> a -> a
whenever (SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (AxisLine V2 n -> Const Bool (AxisLine V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasAxisLine f a =>
LensLike' f a (AxisLine (V a) (N a))
axisLine ((AxisLine V2 n -> Const Bool (AxisLine V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> AxisLine V2 n -> Const Bool (AxisLine V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> AxisLine V2 n -> Const Bool (AxisLine V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden) QDiagram b V2 n Any -> QDiagram b V2 n Any
forall (v :: * -> *) n a m b.
(InSpace v n a, Monoid' m, Enveloped a, Traced a) =>
a -> QDiagram b v n m
phantom
    where
      -- XXX for now the radial axis is on the theta=0 line. Need some
      -- way to change this
      line :: QDiagram b V2 n Any
line = (Point V2 n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point V2 n -> Point V2 n -> QDiagram b V2 n Any
forall t (v :: * -> *) n.
(V t ~ v, N t ~ n, TrailLike t) =>
Point v n -> Point v n -> t
~~ n -> n -> Point V2 n
forall n. n -> n -> P2 n
mkP2 n
r n
0) QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# Style (V (QDiagram b V2 n Any)) (N (QDiagram b V2 n Any))
-> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. HasStyle a => Style (V a) (N a) -> a -> a
applyStyle (SingleAxis b V2 n
rASingleAxis b V2 n
-> Getting (Style V2 n) (SingleAxis b V2 n) (Style V2 n)
-> Style V2 n
forall s a. s -> Getting a s a -> a
^.Getting (Style V2 n) (SingleAxis b V2 n) (Style V2 n)
forall (f :: * -> *) a.
(HasAxisLine f a, Functor f) =>
LensLike' f a (Style (V a) (N a))
axisLineStyle)
                                  # transform t

  -- Radial axis label -------------------------------------------------

  rAxLabel :: QDiagram b V2 n Any
rAxLabel
    | String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
rTxt Bool -> Bool -> Bool
|| SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a b.
HasAxisLabel f a b =>
LensLike' f a (AxisLabel b (V a) (N a))
axisLabel ((AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
-> SingleAxis b V2 n
-> TextAlignment (N (SingleAxis b V2 n))
-> String
-> QDiagram b V2 n Any
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a (TextFunction b (V a) (N a))
axisLabelTextFunction SingleAxis b V2 n
rA TextAlignment (N (SingleAxis b V2 n))
forall {n}. TextAlignment n
rLabelAlign String
rTxt
                    # translate rLabelPos
                    # applyStyle (rA ^. axisLabelStyle)
                    # fc black

  rLabelPos :: V2 n
rLabelPos = n -> n -> V2 n
forall a. a -> a -> V2 a
V2 (n
sn -> n -> n
forall a. Num a => a -> a -> a
*n
x) (- Getting n (SingleAxis b V2 n) n -> SingleAxis b V2 n -> n
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting n (SingleAxis b V2 n) n
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a (N a)
axisLabelGap SingleAxis b V2 n
rA) where
    x :: n
x = case SingleAxis b V2 n
rA SingleAxis b V2 n
-> Getting AxisLabelPosition (SingleAxis b V2 n) AxisLabelPosition
-> AxisLabelPosition
forall s a. s -> Getting a s a -> a
^. Getting AxisLabelPosition (SingleAxis b V2 n) AxisLabelPosition
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a AxisLabelPosition
axisLabelPosition of
          AxisLabelPosition
MiddleAxisLabel -> n
rn -> n -> n
forall a. Fractional a => a -> a -> a
/n
2
          AxisLabelPosition
LowerAxisLabel  -> n
0
          AxisLabelPosition
UpperAxisLabel  -> n
r
  rTxt :: String
rTxt = SingleAxis b V2 n
rA SingleAxis b V2 n
-> Getting String (SingleAxis b V2 n) String -> String
forall s a. s -> Getting a s a -> a
^. Getting String (SingleAxis b V2 n) String
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a String
axisLabelText
  rLabelAlign :: TextAlignment n
rLabelAlign = TextAlignment n
forall {n}. TextAlignment n
BaselineText

  -- Radial ticks ------------------------------------------------------

  -- The positions of major and minor ticks along the radial axis
  majorTickRs :: [n]
majorTickRs  = Getting
  ((N (SingleAxis b V2 n), n) -> [n])
  (SingleAxis b V2 n)
  ((N (SingleAxis b V2 n), n) -> [n])
-> SingleAxis b V2 n -> (N (SingleAxis b V2 n), n) -> [n]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ((N (SingleAxis b V2 n), n) -> [n])
  (SingleAxis b V2 n)
  ((N (SingleAxis b V2 n), n) -> [n])
forall (f :: * -> *) a.
(HasMajorTicks f a, Functor f) =>
LensLike' f a ((N a, N a) -> [N a])
majorTicksFunction SingleAxis b V2 n
rA (N (SingleAxis b V2 n)
0,n
r)
  majorTickRs' :: [n]
majorTickRs' = (n -> n) -> [n] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map (n -> n -> n
forall a. Num a => a -> a -> a
*n
s) ([n] -> [n]) -> [n] -> [n]
forall a b. (a -> b) -> a -> b
$ (n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
rInRange [n]
majorTickRs
  minorTickRs :: [n]
minorTickRs  = Getting
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
  (SingleAxis b V2 n)
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
-> SingleAxis b V2 n -> [n] -> (N (SingleAxis b V2 n), n) -> [n]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
  (SingleAxis b V2 n)
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
forall (f :: * -> *) a.
(HasMinorTicks f a, Functor f) =>
LensLike' f a ([N a] -> (N a, N a) -> [N a])
minorTicksFunction SingleAxis b V2 n
rA [n]
majorTickRs (N (SingleAxis b V2 n)
0,n
r)
  minorTickRs' :: [n]
minorTickRs' = (n -> n) -> [n] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map (n -> n -> n
forall a. Num a => a -> a -> a
*n
s) ([n] -> [n]) -> [n] -> [n]
forall a b. (a -> b) -> a -> b
$ (n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
rInRange [n]
minorTickRs

  -- Major and minor ticks are placed along the line at the calculated
  -- positions majorTickRs
  rAxTicks :: QDiagram b V2 n Any
rAxTicks      = QDiagram b V2 n Any
rAxMajorTicks QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
rAxMinorTicks
  rAxMajorTicks :: QDiagram b V2 n Any
rAxMajorTicks
    | SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MajorTicks V2 n -> Const Bool (MajorTicks V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasMajorTicks f a =>
LensLike' f a (MajorTicks (V a) (N a))
majorTicks ((MajorTicks V2 n -> Const Bool (MajorTicks V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> MajorTicks V2 n -> Const Bool (MajorTicks V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MajorTicks V2 n -> Const Bool (MajorTicks V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = (n -> QDiagram b V2 n Any) -> [n] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap (\n
x -> QDiagram b V2 n Any
rAxMajorTick QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall (v :: * -> *) n t.
(InSpace v n t, R1 v, Transformable t) =>
n -> t -> t
translateX n
x) [n]
majorTickRs'
                       # applyStyle (rA ^. majorTicksStyle)
  rAxMinorTicks :: QDiagram b V2 n Any
rAxMinorTicks
    | SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MinorTicks V2 n -> Const Bool (MinorTicks V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasMinorTicks f a =>
LensLike' f a (MinorTicks (V a) (N a))
minorTicks ((MinorTicks V2 n -> Const Bool (MinorTicks V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> MinorTicks V2 n -> Const Bool (MinorTicks V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MinorTicks V2 n -> Const Bool (MinorTicks V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = (n -> QDiagram b V2 n Any) -> [n] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap (\n
x -> QDiagram b V2 n Any
rAxMinorTick QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall (v :: * -> *) n t.
(InSpace v n t, R1 v, Transformable t) =>
n -> t -> t
translateX n
x) [n]
minorTickRs'
                       # applyStyle (rA ^. minorTicksStyle)

  -- The paths used for individual major and minor ticks
  rAxMajorTick :: QDiagram b V2 n Any
rAxMajorTick = TicksAlignment -> N (QDiagram b V2 n Any) -> QDiagram b V2 n Any
forall {t}. (V t ~ V2, TrailLike t) => TicksAlignment -> N t -> t
someTick (SingleAxis b V2 n
rA SingleAxis b V2 n
-> Getting TicksAlignment (SingleAxis b V2 n) TicksAlignment
-> TicksAlignment
forall s a. s -> Getting a s a -> a
^. Getting TicksAlignment (SingleAxis b V2 n) TicksAlignment
forall (f :: * -> *) a.
(HasMajorTicks f a, Functor f) =>
LensLike' f a TicksAlignment
majorTicksAlignment) (SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting n (SingleAxis b V2 n) n -> n
forall s a. s -> Getting a s a -> a
^. Getting n (SingleAxis b V2 n) n
forall (f :: * -> *) a.
(HasMajorTicks f a, Functor f) =>
LensLike' f a (N a)
majorTicksLength)
  rAxMinorTick :: QDiagram b V2 n Any
rAxMinorTick = TicksAlignment -> N (QDiagram b V2 n Any) -> QDiagram b V2 n Any
forall {t}. (V t ~ V2, TrailLike t) => TicksAlignment -> N t -> t
someTick (SingleAxis b V2 n
rA SingleAxis b V2 n
-> Getting TicksAlignment (SingleAxis b V2 n) TicksAlignment
-> TicksAlignment
forall s a. s -> Getting a s a -> a
^. Getting TicksAlignment (SingleAxis b V2 n) TicksAlignment
forall (f :: * -> *) a.
(HasMinorTicks f a, Functor f) =>
LensLike' f a TicksAlignment
minorTicksAlignment) (SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting n (SingleAxis b V2 n) n -> n
forall s a. s -> Getting a s a -> a
^. Getting n (SingleAxis b V2 n) n
forall (f :: * -> *) a.
(HasMinorTicks f a, Functor f) =>
LensLike' f a (N a)
minorTicksLength)

  someTick :: TicksAlignment -> N t -> t
someTick TicksAlignment
tType N t
d = case TicksAlignment
tType of
    TickSpec (Rational -> N t
forall a. Fractional a => Rational -> a
fromRational -> N t
aa) (Rational -> N t
forall a. Fractional a => Rational -> a
fromRational -> N t
bb)
             -> N t -> N t -> P2 (N t)
forall n. n -> n -> P2 n
mkP2 N t
0 (-N t
dN t -> N t -> N t
forall a. Num a => a -> a -> a
*N t
bb) P2 (N t) -> P2 (N t) -> t
forall t (v :: * -> *) n.
(V t ~ v, N t ~ n, TrailLike t) =>
Point v n -> Point v n -> t
~~ N t -> N t -> P2 (N t)
forall n. n -> n -> P2 n
mkP2 N t
0 (N t
dN t -> N t -> N t
forall a. Num a => a -> a -> a
*N t
aa)
    TicksAlignment
AutoTick -> N t -> N t -> P2 (N t)
forall n. n -> n -> P2 n
mkP2 N t
0 (-N t
d)    P2 (N t) -> P2 (N t) -> t
forall t (v :: * -> *) n.
(V t ~ v, N t ~ n, TrailLike t) =>
Point v n -> Point v n -> t
~~ N t -> N t -> P2 (N t)
forall n. n -> n -> P2 n
mkP2 N t
0 N t
d

  -- Radial grid lines -------------------------------------------------

  rAxGridLines :: QDiagram b V2 n Any
rAxGridLines
    -- - | rA ^. gridLines . hidden = mempty
    | Bool
otherwise                = QDiagram b V2 n Any
rMajorGridLines QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
rMinorGridLines

  majorGridRs :: [n]
majorGridRs  = Getting
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
  (SingleAxis b V2 n)
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
-> SingleAxis b V2 n -> [n] -> (N (SingleAxis b V2 n), n) -> [n]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
  (SingleAxis b V2 n)
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
forall (f :: * -> *) a.
(HasMajorGridLines f a, Functor f) =>
LensLike' f a (GridLineFunction (N a))
majorGridLinesFunction SingleAxis b V2 n
rA [n]
majorTickRs (N (SingleAxis b V2 n)
0,n
r)
  majorGridRs' :: [n]
majorGridRs' = (n -> n) -> [n] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map (n -> n -> n
forall a. Num a => a -> a -> a
*n
s) ([n] -> [n]) -> [n] -> [n]
forall a b. (a -> b) -> a -> b
$ (n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
rInRange [n]
majorGridRs

  rMajorGridLines :: QDiagram b V2 n Any
  rMajorGridLines :: QDiagram b V2 n Any
rMajorGridLines
    | SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasMajorGridLines f a =>
LensLike' f a (MajorGridLines (V a) (N a))
majorGridLines ((MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = (n -> QDiagram b V2 n Any) -> [n] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap n -> QDiagram b V2 n Any
forall t n.
(TrailLike t, V t ~ V2, N t ~ n, Transformable t) =>
n -> t
circle ((n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter (n -> n -> Bool
forall a. Ord a => a -> a -> Bool
>n
0) [n]
majorGridRs')
                    # applyStyle (rA ^. majorGridLinesStyle)

  minorGridRs :: [n]
minorGridRs  = Getting
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
  (SingleAxis b V2 n)
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
-> SingleAxis b V2 n -> [n] -> (N (SingleAxis b V2 n), n) -> [n]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
  (SingleAxis b V2 n)
  ([n] -> (N (SingleAxis b V2 n), n) -> [n])
forall (f :: * -> *) a.
(HasMinorGridLines f a, Functor f) =>
LensLike' f a (GridLineFunction (N a))
minorGridLinesFunction SingleAxis b V2 n
rA [n]
minorTickRs (N (SingleAxis b V2 n)
0,n
r)
  minorGridRs' :: [n]
minorGridRs' = (n -> n) -> [n] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map (n -> n -> n
forall a. Num a => a -> a -> a
*n
s) ([n] -> [n]) -> [n] -> [n]
forall a b. (a -> b) -> a -> b
$ (n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
rInRange [n]
minorGridRs
  rMinorGridLines :: QDiagram b V2 n Any
  rMinorGridLines :: QDiagram b V2 n Any
rMinorGridLines
    | SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasMinorGridLines f a =>
LensLike' f a (MinorGridLines (V a) (N a))
minorGridLines ((MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = (n -> QDiagram b V2 n Any) -> [n] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap n -> QDiagram b V2 n Any
forall t n.
(TrailLike t, V t ~ V2, N t ~ n, Transformable t) =>
n -> t
circle ((n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter (n -> n -> Bool
forall a. Ord a => a -> a -> Bool
>n
0) [n]
minorGridRs')
                    # applyStyle (rA ^. minorGridLinesStyle)

  -- Radial tick labels ------------------------------------------------

  rAxTickLabels :: QDiagram b V2 n Any
  rAxTickLabels :: QDiagram b V2 n Any
rAxTickLabels
    | SingleAxis b V2 n
rA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (TickLabels b V2 n -> Const Bool (TickLabels b V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a b.
HasTickLabels f a b =>
LensLike' f a (TickLabels b (V a) (N a))
tickLabel ((TickLabels b V2 n -> Const Bool (TickLabels b V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> TickLabels b V2 n -> Const Bool (TickLabels b V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> TickLabels b V2 n -> Const Bool (TickLabels b V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise                = ((n, String) -> QDiagram b V2 n Any)
-> [(n, String)] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap (n, String) -> QDiagram b V2 n Any
rDrawTickLabel [(n, String)]
tickLabelRs

  -- The positions of the tick labels.
  tickLabelRs :: [(n, String)]
  tickLabelRs :: [(n, String)]
tickLabelRs = Getting
  ([n] -> (N (SingleAxis b V2 n), n) -> [(n, String)])
  (SingleAxis b V2 n)
  ([n] -> (N (SingleAxis b V2 n), n) -> [(n, String)])
-> SingleAxis b V2 n
-> [n]
-> (N (SingleAxis b V2 n), n)
-> [(n, String)]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([n] -> (N (SingleAxis b V2 n), n) -> [(n, String)])
  (SingleAxis b V2 n)
  ([n] -> (N (SingleAxis b V2 n), n) -> [(n, String)])
forall (f :: * -> *) a b.
(HasTickLabels f a b, Functor f) =>
LensLike' f a ([N a] -> (N a, N a) -> [(N a, String)])
tickLabelFunction SingleAxis b V2 n
rA ((n -> Bool) -> [n] -> [n]
forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
rInRange [n]
majorTickRs) (N (SingleAxis b V2 n)
0,n
r)

  -- Draw a single tick label given the position and the string to use
  rDrawTickLabel :: (n,String) -> QDiagram b V2 n Any
  rDrawTickLabel :: (n, String) -> QDiagram b V2 n Any
rDrawTickLabel (n
x,String
label) =
    Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
-> SingleAxis b V2 n
-> TextAlignment (N (SingleAxis b V2 n))
-> String
-> QDiagram b V2 n Any
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
forall (f :: * -> *) a b.
(HasTickLabels f a b, Functor f) =>
LensLike' f a (TextFunction b (V a) (N a))
tickLabelTextFunction SingleAxis b V2 n
rA (N (SingleAxis b V2 n)
-> N (SingleAxis b V2 n) -> TextAlignment (N (SingleAxis b V2 n))
forall n. n -> n -> TextAlignment n
BoxAlignedText N (SingleAxis b V2 n)
0.5 N (SingleAxis b V2 n)
1) String
label
      # translate (V2 (s*x) (- view axisLabelGap rA))
      # applyStyle (rA ^. tickLabelStyle)
      # fc black

  ----------------------------------------------------------------------
  -- Angular axis
  ----------------------------------------------------------------------

  -- The angular axis is a circular line around the perimeter of the
  -- polar plot. The Ticks and tick labels are placed around this
  -- perimeter. The Grid lines go from the perimeter to the center.
  thetaAx :: QDiagram b V2 n Any
thetaAx
    | SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. Getting Bool (SingleAxis b V2 n) Bool
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = QDiagram b V2 n Any
thetaAxLine QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
thetaAxLabel
         QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
thetaAxTicks QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
thetaAxTickLabels QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
thetaAxGridLines

  theta :: N (SingleAxis b V2 n)
theta = N (SingleAxis b V2 n)
2N (SingleAxis b V2 n)
-> N (SingleAxis b V2 n) -> N (SingleAxis b V2 n)
forall a. Num a => a -> a -> a
*N (SingleAxis b V2 n)
forall a. Floating a => a
pi
  thetaAxLine :: QDiagram b V2 n Any
thetaAxLine = QDiagram b V2 n Any
line QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# Bool
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
-> QDiagram b V2 n Any
forall a. Bool -> (a -> a) -> a -> a
whenever (SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (AxisLine V2 n -> Const Bool (AxisLine V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasAxisLine f a =>
LensLike' f a (AxisLine (V a) (N a))
axisLine ((AxisLine V2 n -> Const Bool (AxisLine V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> AxisLine V2 n -> Const Bool (AxisLine V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> AxisLine V2 n -> Const Bool (AxisLine V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden) QDiagram b V2 n Any -> QDiagram b V2 n Any
forall (v :: * -> *) n a m b.
(InSpace v n a, Monoid' m, Enveloped a, Traced a) =>
a -> QDiagram b v n m
phantom
    where
      -- XXX for now the radial axis is on the theta=0 line. Need some
      -- way to change this
      line :: QDiagram b V2 n Any
line = n -> QDiagram b V2 n Any
forall t n.
(TrailLike t, V t ~ V2, N t ~ n, Transformable t) =>
n -> t
circle (n
sn -> n -> n
forall a. Num a => a -> a -> a
*n
r) QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# Style (V (QDiagram b V2 n Any)) (N (QDiagram b V2 n Any))
-> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. HasStyle a => Style (V a) (N a) -> a -> a
applyStyle (SingleAxis b V2 n
thetaASingleAxis b V2 n
-> Getting (Style V2 n) (SingleAxis b V2 n) (Style V2 n)
-> Style V2 n
forall s a. s -> Getting a s a -> a
^.Getting (Style V2 n) (SingleAxis b V2 n) (Style V2 n)
forall (f :: * -> *) a.
(HasAxisLine f a, Functor f) =>
LensLike' f a (Style (V a) (N a))
axisLineStyle)

  -- Angular axis label ------------------------------------------------

  -- Where should the label go?
  thetaAxLabel :: QDiagram b V2 n Any
thetaAxLabel
    | String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
thetaTxt Bool -> Bool -> Bool
|| SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a b.
HasAxisLabel f a b =>
LensLike' f a (AxisLabel b (V a) (N a))
axisLabel ((AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> AxisLabel b V2 n -> Const Bool (AxisLabel b V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
-> SingleAxis b V2 n
-> TextAlignment (N (SingleAxis b V2 n))
-> String
-> QDiagram b V2 n Any
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a (TextFunction b (V a) (N a))
axisLabelTextFunction SingleAxis b V2 n
thetaA TextAlignment (N (SingleAxis b V2 n))
forall {n}. TextAlignment n
thetaLabelAlign String
thetaTxt
                    # translate thetaLabelPos
                    # applyStyle (thetaA ^. axisLabelStyle)
                    # fc black

  -- thetaLabelPos = V2 (s*x) (- view axisLabelGap thetaA) where
  thetaLabelPos :: V2 n
thetaLabelPos = Getting (V2 n) (Polar n) (V2 n) -> Polar n -> V2 n
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (V2 n) (Polar n) (V2 n)
forall (t :: * -> *) n. (HasY t, RealFloat n) => Lens' (t n) (V2 n)
xy_ (n -> Angle n -> Polar n
forall n. n -> Angle n -> Polar n
mkPolar (n
sn -> n -> n
forall a. Num a => a -> a -> a
*n
r n -> n -> n
forall a. Num a => a -> a -> a
+ Getting n (SingleAxis b V2 n) n -> SingleAxis b V2 n -> n
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting n (SingleAxis b V2 n) n
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a (N a)
axisLabelGap SingleAxis b V2 n
thetaA) Angle n
x) where
    -- The angle on the axis the label is placed, doesn't make much
    -- sense right now.
    x :: Angle n
x = case SingleAxis b V2 n
thetaA SingleAxis b V2 n
-> Getting AxisLabelPosition (SingleAxis b V2 n) AxisLabelPosition
-> AxisLabelPosition
forall s a. s -> Getting a s a -> a
^. Getting AxisLabelPosition (SingleAxis b V2 n) AxisLabelPosition
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a AxisLabelPosition
axisLabelPosition of
          AxisLabelPosition
MiddleAxisLabel -> Angle n
forall v. Floating v => Angle v
quarterTurn
          AxisLabelPosition
LowerAxisLabel  -> Angle n
forall (f :: * -> *) a. (Additive f, Num a) => f a
zero
          AxisLabelPosition
UpperAxisLabel  -> Angle n
forall v. Floating v => Angle v
halfTurn
  thetaTxt :: String
thetaTxt = SingleAxis b V2 n
thetaA SingleAxis b V2 n
-> Getting String (SingleAxis b V2 n) String -> String
forall s a. s -> Getting a s a -> a
^. Getting String (SingleAxis b V2 n) String
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a String
axisLabelText
  thetaLabelAlign :: TextAlignment n
thetaLabelAlign = TextAlignment n
forall {n}. TextAlignment n
BaselineText

  -- Angular axis ticks ------------------------------------------------

  -- The positions of major and minor ticks along the angular axis
  majorTickThetas :: [N (SingleAxis b V2 n)]
majorTickThetas  = Getting
  ((N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
  (SingleAxis b V2 n)
  ((N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
-> SingleAxis b V2 n
-> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
-> [N (SingleAxis b V2 n)]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ((N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
  (SingleAxis b V2 n)
  ((N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
forall (f :: * -> *) a.
(HasMajorTicks f a, Functor f) =>
LensLike' f a ((N a, N a) -> [N a])
majorTicksFunction SingleAxis b V2 n
thetaA (N (SingleAxis b V2 n)
0,N (SingleAxis b V2 n)
theta)
  majorTickThetas' :: [N (SingleAxis b V2 n)]
majorTickThetas' = (N (SingleAxis b V2 n) -> Bool)
-> [N (SingleAxis b V2 n)] -> [N (SingleAxis b V2 n)]
forall a. (a -> Bool) -> [a] -> [a]
filter N (SingleAxis b V2 n) -> Bool
forall {a}. (Ord a, Floating a) => a -> Bool
thetaInRange [N (SingleAxis b V2 n)]
majorTickThetas
  minorTickThetas :: [N (SingleAxis b V2 n)]
minorTickThetas  = Getting
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
  (SingleAxis b V2 n)
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
-> SingleAxis b V2 n
-> [N (SingleAxis b V2 n)]
-> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
-> [N (SingleAxis b V2 n)]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
  (SingleAxis b V2 n)
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
forall (f :: * -> *) a.
(HasMinorTicks f a, Functor f) =>
LensLike' f a ([N a] -> (N a, N a) -> [N a])
minorTicksFunction SingleAxis b V2 n
thetaA [N (SingleAxis b V2 n)]
majorTickThetas (N (SingleAxis b V2 n)
0,N (SingleAxis b V2 n)
theta)
  minorTickThetas' :: [N (SingleAxis b V2 n)]
minorTickThetas' = (N (SingleAxis b V2 n) -> Bool)
-> [N (SingleAxis b V2 n)] -> [N (SingleAxis b V2 n)]
forall a. (a -> Bool) -> [a] -> [a]
filter N (SingleAxis b V2 n) -> Bool
forall {a}. (Ord a, Floating a) => a -> Bool
thetaInRange [N (SingleAxis b V2 n)]
minorTickThetas

  -- Major and minor ticks are placed along perimeter, facing the center
  -- of the axis. Ticks start of horizonal and are rotated to the
  -- correct position on the axis.
  thetaAxTicks :: QDiagram b V2 n Any
thetaAxTicks      = QDiagram b V2 n Any
thetaAxMajorTicks QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
thetaAxMinorTicks
  thetaAxMajorTicks :: QDiagram b V2 n Any
thetaAxMajorTicks
    | SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MajorTicks V2 n -> Const Bool (MajorTicks V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasMajorTicks f a =>
LensLike' f a (MajorTicks (V a) (N a))
majorTicks ((MajorTicks V2 n -> Const Bool (MajorTicks V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> MajorTicks V2 n -> Const Bool (MajorTicks V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MajorTicks V2 n -> Const Bool (MajorTicks V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = (N (SingleAxis b V2 n) -> QDiagram b V2 n Any)
-> [N (SingleAxis b V2 n)] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap (\N (SingleAxis b V2 n)
phi -> QDiagram b V2 n Any
thetaAxMajorTick QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall (v :: * -> *) n t.
(InSpace v n t, R1 v, Transformable t) =>
n -> t -> t
translateX (n
sn -> n -> n
forall a. Num a => a -> a -> a
*n
r) QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# Angle (N (SingleAxis b V2 n))
-> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall n t.
(InSpace V2 n t, Transformable t, Floating n) =>
Angle n -> t -> t
rotate (N (SingleAxis b V2 n)
phiN (SingleAxis b V2 n)
-> AReview (Angle (N (SingleAxis b V2 n))) (N (SingleAxis b V2 n))
-> Angle (N (SingleAxis b V2 n))
forall b a. b -> AReview a b -> a
@@AReview (Angle (N (SingleAxis b V2 n))) (N (SingleAxis b V2 n))
forall n. Iso' (Angle n) n
rad)) [N (SingleAxis b V2 n)]
majorTickThetas'
                       # applyStyle (thetaA ^. majorTicksStyle)
  thetaAxMinorTicks :: QDiagram b V2 n Any
thetaAxMinorTicks
    | SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MinorTicks V2 n -> Const Bool (MinorTicks V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasMinorTicks f a =>
LensLike' f a (MinorTicks (V a) (N a))
minorTicks ((MinorTicks V2 n -> Const Bool (MinorTicks V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> MinorTicks V2 n -> Const Bool (MinorTicks V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MinorTicks V2 n -> Const Bool (MinorTicks V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = (N (SingleAxis b V2 n) -> QDiagram b V2 n Any)
-> [N (SingleAxis b V2 n)] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap (\N (SingleAxis b V2 n)
phi -> QDiagram b V2 n Any
thetaAxMinorTick QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall (v :: * -> *) n t.
(InSpace v n t, R1 v, Transformable t) =>
n -> t -> t
translateX (n
sn -> n -> n
forall a. Num a => a -> a -> a
*n
r) QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# Angle (N (SingleAxis b V2 n))
-> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall n t.
(InSpace V2 n t, Transformable t, Floating n) =>
Angle n -> t -> t
rotate (N (SingleAxis b V2 n)
phiN (SingleAxis b V2 n)
-> AReview (Angle (N (SingleAxis b V2 n))) (N (SingleAxis b V2 n))
-> Angle (N (SingleAxis b V2 n))
forall b a. b -> AReview a b -> a
@@AReview (Angle (N (SingleAxis b V2 n))) (N (SingleAxis b V2 n))
forall n. Iso' (Angle n) n
rad)) [N (SingleAxis b V2 n)]
minorTickThetas'
                       # applyStyle (thetaA ^. minorTicksStyle)

  -- The paths used for individual major and minor ticks
  thetaAxMajorTick :: QDiagram b V2 n Any
thetaAxMajorTick = TicksAlignment -> N (QDiagram b V2 n Any) -> QDiagram b V2 n Any
forall {t}. (V t ~ V2, TrailLike t) => TicksAlignment -> N t -> t
someThetaTick (SingleAxis b V2 n
thetaA SingleAxis b V2 n
-> Getting TicksAlignment (SingleAxis b V2 n) TicksAlignment
-> TicksAlignment
forall s a. s -> Getting a s a -> a
^. Getting TicksAlignment (SingleAxis b V2 n) TicksAlignment
forall (f :: * -> *) a.
(HasMajorTicks f a, Functor f) =>
LensLike' f a TicksAlignment
majorTicksAlignment) (SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting n (SingleAxis b V2 n) n -> n
forall s a. s -> Getting a s a -> a
^. Getting n (SingleAxis b V2 n) n
forall (f :: * -> *) a.
(HasMajorTicks f a, Functor f) =>
LensLike' f a (N a)
majorTicksLength)
  thetaAxMinorTick :: QDiagram b V2 n Any
thetaAxMinorTick = TicksAlignment -> N (QDiagram b V2 n Any) -> QDiagram b V2 n Any
forall {t}. (V t ~ V2, TrailLike t) => TicksAlignment -> N t -> t
someThetaTick (SingleAxis b V2 n
thetaA SingleAxis b V2 n
-> Getting TicksAlignment (SingleAxis b V2 n) TicksAlignment
-> TicksAlignment
forall s a. s -> Getting a s a -> a
^. Getting TicksAlignment (SingleAxis b V2 n) TicksAlignment
forall (f :: * -> *) a.
(HasMinorTicks f a, Functor f) =>
LensLike' f a TicksAlignment
minorTicksAlignment) (SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting n (SingleAxis b V2 n) n -> n
forall s a. s -> Getting a s a -> a
^. Getting n (SingleAxis b V2 n) n
forall (f :: * -> *) a.
(HasMinorTicks f a, Functor f) =>
LensLike' f a (N a)
minorTicksLength)

  someThetaTick :: TicksAlignment -> N t -> t
someThetaTick TicksAlignment
tType N t
d = case TicksAlignment
tType of
    TickSpec (Rational -> N t
forall a. Fractional a => Rational -> a
fromRational -> N t
aa) (Rational -> N t
forall a. Fractional a => Rational -> a
fromRational -> N t
bb)
             -> N t -> N t -> P2 (N t)
forall n. n -> n -> P2 n
mkP2 (-N t
dN t -> N t -> N t
forall a. Num a => a -> a -> a
*N t
bb) N t
0 P2 (N t) -> P2 (N t) -> t
forall t (v :: * -> *) n.
(V t ~ v, N t ~ n, TrailLike t) =>
Point v n -> Point v n -> t
~~ N t -> N t -> P2 (N t)
forall n. n -> n -> P2 n
mkP2 (N t
dN t -> N t -> N t
forall a. Num a => a -> a -> a
*N t
aa) N t
0
    TicksAlignment
AutoTick -> N t -> N t -> P2 (N t)
forall n. n -> n -> P2 n
mkP2 (-N t
d) N t
0    P2 (N t) -> P2 (N t) -> t
forall t (v :: * -> *) n.
(V t ~ v, N t ~ n, TrailLike t) =>
Point v n -> Point v n -> t
~~ N t -> N t -> P2 (N t)
forall n. n -> n -> P2 n
mkP2 N t
d N t
0

  -- Angular grid lines ------------------------------------------------

  -- grid lines go from the centre of the axis to the perimeter
  thetaAxGridLines :: QDiagram b V2 n Any
thetaAxGridLines
    -- - | thetaA ^. gridLines . hidden = mempty
    | Bool
otherwise                = QDiagram b V2 n Any
thetaMajorGridLines QDiagram b V2 n Any -> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall a. Semigroup a => a -> a -> a
<> QDiagram b V2 n Any
thetaMinorGridLines

  majorGridThetas :: [N (SingleAxis b V2 n)]
majorGridThetas = Getting
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
  (SingleAxis b V2 n)
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
-> SingleAxis b V2 n
-> [N (SingleAxis b V2 n)]
-> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
-> [N (SingleAxis b V2 n)]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
  (SingleAxis b V2 n)
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
forall (f :: * -> *) a.
(HasMajorGridLines f a, Functor f) =>
LensLike' f a (GridLineFunction (N a))
majorGridLinesFunction SingleAxis b V2 n
thetaA [N (SingleAxis b V2 n)]
majorTickThetas (N (SingleAxis b V2 n)
0,N (SingleAxis b V2 n)
theta)
  majorGridThetas' :: [N (SingleAxis b V2 n)]
majorGridThetas' = (N (SingleAxis b V2 n) -> Bool)
-> [N (SingleAxis b V2 n)] -> [N (SingleAxis b V2 n)]
forall a. (a -> Bool) -> [a] -> [a]
filter N (SingleAxis b V2 n) -> Bool
forall {a}. (Ord a, Floating a) => a -> Bool
thetaInRange [N (SingleAxis b V2 n)]
majorGridThetas

  thetaMajorGridLines :: QDiagram b V2 n Any
  thetaMajorGridLines :: QDiagram b V2 n Any
thetaMajorGridLines
    | SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasMajorGridLines f a =>
LensLike' f a (MajorGridLines (V a) (N a))
majorGridLines ((MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MajorGridLines V2 n -> Const Bool (MajorGridLines V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = (N (SingleAxis b V2 n) -> QDiagram b V2 n Any)
-> [N (SingleAxis b V2 n)] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap (\N (SingleAxis b V2 n)
phi -> Point V2 n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point V2 n -> Point V2 n -> QDiagram b V2 n Any
forall t (v :: * -> *) n.
(V t ~ v, N t ~ n, TrailLike t) =>
Point v n -> Point v n -> t
~~ n -> n -> Point V2 n
forall n. n -> n -> P2 n
mkP2 n
r n
0 QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# Angle (N (SingleAxis b V2 n))
-> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall n t.
(InSpace V2 n t, Transformable t, Floating n) =>
Angle n -> t -> t
rotate (N (SingleAxis b V2 n)
phiN (SingleAxis b V2 n)
-> AReview (Angle (N (SingleAxis b V2 n))) (N (SingleAxis b V2 n))
-> Angle (N (SingleAxis b V2 n))
forall b a. b -> AReview a b -> a
@@AReview (Angle (N (SingleAxis b V2 n))) (N (SingleAxis b V2 n))
forall n. Iso' (Angle n) n
rad)) [N (SingleAxis b V2 n)]
majorGridThetas'
                    # transform t
                    # applyStyle (thetaA ^. majorGridLinesStyle)

  minorGridThetas :: [N (SingleAxis b V2 n)]
minorGridThetas    = Getting
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
  (SingleAxis b V2 n)
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
-> SingleAxis b V2 n
-> [N (SingleAxis b V2 n)]
-> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
-> [N (SingleAxis b V2 n)]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
  (SingleAxis b V2 n)
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
   -> [N (SingleAxis b V2 n)])
forall (f :: * -> *) a.
(HasMinorGridLines f a, Functor f) =>
LensLike' f a (GridLineFunction (N a))
minorGridLinesFunction SingleAxis b V2 n
thetaA [N (SingleAxis b V2 n)]
minorTickThetas (N (SingleAxis b V2 n)
0,N (SingleAxis b V2 n)
theta)
  minorGridThetas' :: [N (SingleAxis b V2 n)]
minorGridThetas'   = (N (SingleAxis b V2 n) -> Bool)
-> [N (SingleAxis b V2 n)] -> [N (SingleAxis b V2 n)]
forall a. (a -> Bool) -> [a] -> [a]
filter N (SingleAxis b V2 n) -> Bool
forall {a}. (Ord a, Floating a) => a -> Bool
thetaInRange [N (SingleAxis b V2 n)]
minorGridThetas
  thetaMinorGridLines :: QDiagram b V2 n Any
  thetaMinorGridLines :: QDiagram b V2 n Any
thetaMinorGridLines
    | SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a.
HasMinorGridLines f a =>
LensLike' f a (MinorGridLines (V a) (N a))
minorGridLines ((MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> MinorGridLines V2 n -> Const Bool (MinorGridLines V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise = (N (SingleAxis b V2 n) -> QDiagram b V2 n Any)
-> [N (SingleAxis b V2 n)] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap (\N (SingleAxis b V2 n)
phi -> Point V2 n
forall (f :: * -> *) a. (Additive f, Num a) => Point f a
origin Point V2 n -> Point V2 n -> QDiagram b V2 n Any
forall t (v :: * -> *) n.
(V t ~ v, N t ~ n, TrailLike t) =>
Point v n -> Point v n -> t
~~ n -> n -> Point V2 n
forall n. n -> n -> P2 n
mkP2 n
r n
0 QDiagram b V2 n Any
-> (QDiagram b V2 n Any -> QDiagram b V2 n Any)
-> QDiagram b V2 n Any
forall a b. a -> (a -> b) -> b
# Angle (N (SingleAxis b V2 n))
-> QDiagram b V2 n Any -> QDiagram b V2 n Any
forall n t.
(InSpace V2 n t, Transformable t, Floating n) =>
Angle n -> t -> t
rotate (N (SingleAxis b V2 n)
phiN (SingleAxis b V2 n)
-> AReview (Angle (N (SingleAxis b V2 n))) (N (SingleAxis b V2 n))
-> Angle (N (SingleAxis b V2 n))
forall b a. b -> AReview a b -> a
@@AReview (Angle (N (SingleAxis b V2 n))) (N (SingleAxis b V2 n))
forall n. Iso' (Angle n) n
rad)) [N (SingleAxis b V2 n)]
minorGridThetas'
                    # transform t
                    # applyStyle (thetaA ^. minorGridLinesStyle)

  -- Angular tick labels -----------------------------------------------

  thetaAxTickLabels :: QDiagram b V2 n Any
  thetaAxTickLabels :: QDiagram b V2 n Any
thetaAxTickLabels
    | SingleAxis b V2 n
thetaA SingleAxis b V2 n -> Getting Bool (SingleAxis b V2 n) Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (TickLabels b V2 n -> Const Bool (TickLabels b V2 n))
-> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n)
forall (f :: * -> *) a b.
HasTickLabels f a b =>
LensLike' f a (TickLabels b (V a) (N a))
tickLabel ((TickLabels b V2 n -> Const Bool (TickLabels b V2 n))
 -> SingleAxis b V2 n -> Const Bool (SingleAxis b V2 n))
-> ((Bool -> Const Bool Bool)
    -> TickLabels b V2 n -> Const Bool (TickLabels b V2 n))
-> Getting Bool (SingleAxis b V2 n) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool)
-> TickLabels b V2 n -> Const Bool (TickLabels b V2 n)
forall a. HasVisibility a => Lens' a Bool
hidden = QDiagram b V2 n Any
forall a. Monoid a => a
mempty
    | Bool
otherwise                    = ((n, String) -> QDiagram b V2 n Any)
-> [(n, String)] -> QDiagram b V2 n Any
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap (n, String) -> QDiagram b V2 n Any
thetaDrawTickLabel [(n, String)]
tickLabelThetas

  -- The positions of the tick labels.
  tickLabelThetas :: [(n, String)]
  tickLabelThetas :: [(n, String)]
tickLabelThetas = Getting
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n)) -> [(n, String)])
  (SingleAxis b V2 n)
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n)) -> [(n, String)])
-> SingleAxis b V2 n
-> [N (SingleAxis b V2 n)]
-> (N (SingleAxis b V2 n), N (SingleAxis b V2 n))
-> [(n, String)]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n)) -> [(n, String)])
  (SingleAxis b V2 n)
  ([N (SingleAxis b V2 n)]
   -> (N (SingleAxis b V2 n), N (SingleAxis b V2 n)) -> [(n, String)])
forall (f :: * -> *) a b.
(HasTickLabels f a b, Functor f) =>
LensLike' f a ([N a] -> (N a, N a) -> [(N a, String)])
tickLabelFunction SingleAxis b V2 n
thetaA [N (SingleAxis b V2 n)]
majorTickThetas' (N (SingleAxis b V2 n)
0,N (SingleAxis b V2 n)
theta)

  -- Draw a single tick label given the position and the string to use
  thetaDrawTickLabel :: (n, String) -> QDiagram b V2 n Any
  thetaDrawTickLabel :: (n, String) -> QDiagram b V2 n Any
thetaDrawTickLabel (n
x,String
label) =
    Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
-> SingleAxis b V2 n
-> TextAlignment (N (SingleAxis b V2 n))
-> String
-> QDiagram b V2 n Any
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
  (SingleAxis b V2 n)
  (TextAlignment (N (SingleAxis b V2 n))
   -> String -> QDiagram b V2 n Any)
forall (f :: * -> *) a b.
(HasTickLabels f a b, Functor f) =>
LensLike' f a (TextFunction b (V a) (N a))
tickLabelTextFunction SingleAxis b V2 n
thetaA TextAlignment (N (SingleAxis b V2 n))
a String
label
      # translate v
      # applyStyle (thetaA ^. tickLabelStyle)
      # fc black
        where v :: V2 n
v = n -> Angle n -> Polar n
forall n. n -> Angle n -> Polar n
mkPolar (n
sn -> n -> n
forall a. Num a => a -> a -> a
*n
r n -> n -> n
forall a. Num a => a -> a -> a
+ Getting n (SingleAxis b V2 n) n -> SingleAxis b V2 n -> n
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting n (SingleAxis b V2 n) n
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a (N a)
axisLabelGap SingleAxis b V2 n
thetaA) (n
xn -> AReview (Angle n) n -> Angle n
forall b a. b -> AReview a b -> a
@@AReview (Angle n) n
forall n. Iso' (Angle n) n
rad) Polar n -> Getting (V2 n) (Polar n) (V2 n) -> V2 n
forall s a. s -> Getting a s a -> a
^. Getting (V2 n) (Polar n) (V2 n)
forall (t :: * -> *) n. (HasY t, RealFloat n) => Lens' (t n) (V2 n)
xy_
              -- a = BoxAlignedText (0.5-cos x/2) (0.5-sin x/2)
              a :: TextAlignment (N (SingleAxis b V2 n))
a = N (SingleAxis b V2 n)
-> N (SingleAxis b V2 n) -> TextAlignment (N (SingleAxis b V2 n))
forall n. n -> n -> TextAlignment n
BoxAlignedText N (SingleAxis b V2 n)
0.5 N (SingleAxis b V2 n)
0.5

    -- line
    --   | a ^. axisLine . hidden = mempty
    --   | otherwise = F.foldMap mkline (map snd ys) -- merge with ticks?
    --          # transform t
    --          # stroke
    --          -- # applyStyle (a ^. axisLine e . axisArrowOpts . _Just . shaftStyle)
    --          # lineCap LineCapSquare
    --   where
    --     -- TODO: Arrow for R3
    --     mkline y = pathFromVertices
    --      $ map (\x -> over lensP ((el e .~ x) . (el eO .~ y)) p) [x0, x1] :: Path v n