module Graphics.Gnuplot.Private.Graph2D where
import qualified Graphics.Gnuplot.Private.FrameOptionSet as OptionSet
import qualified Graphics.Gnuplot.Private.FrameOption as Option
import qualified Graphics.Gnuplot.Private.LineSpecification as LineSpec
import qualified Graphics.Gnuplot.Private.Graph2DType as GraphType
import qualified Graphics.Gnuplot.Private.Graph as Graph
import qualified Graphics.Gnuplot.Value.Atom as Atom
import qualified Data.Map as Map
import qualified Data.List as List
import Prelude hiding (lines, )
data T x y =
Cons {
T x y -> Columns
column_ :: Columns,
T x y -> Type
type_ :: Type,
T x y -> T
lineSpec_ :: LineSpec.T
}
type Columns = [Int]
type Type = String
columnToString :: Columns -> String
columnToString :: Columns -> Type
columnToString =
[Type] -> Type
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([Type] -> Type) -> (Columns -> [Type]) -> Columns -> Type
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> [Type] -> [Type]
forall a. a -> [a] -> [a]
List.intersperse Type
":" ([Type] -> [Type]) -> (Columns -> [Type]) -> Columns -> [Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Type) -> Columns -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map Int -> Type
forall a. Show a => a -> Type
show
toString :: T x y -> String
toString :: T x y -> Type
toString (Cons Columns
c Type
t T
l) =
Type
"using " Type -> Type -> Type
forall a. [a] -> [a] -> [a]
++ Columns -> Type
columnToString Columns
c Type -> Type -> Type
forall a. [a] -> [a] -> [a]
++
Type
" with " Type -> Type -> Type
forall a. [a] -> [a] -> [a]
++ Type
t Type -> Type -> Type
forall a. [a] -> [a] -> [a]
++
Type
" " Type -> Type -> Type
forall a. [a] -> [a] -> [a]
++ T -> Type
LineSpec.toString T
l
type AxisOption x y a =
OptionSet.T (T x y) -> Atom.OptionSet a
defltOptions :: (Atom.C x, Atom.C y) => OptionSet.T (T x y)
defltOptions :: T (T x y)
defltOptions =
let mk ::
Option.T -> Option.T ->
Atom.OptionSet a -> [(Option.T, [String])]
mk :: T -> T -> OptionSet a -> [(T, [Type])]
mk T
optData T
optFormat OptionSet a
opts =
(T
optData, OptionSet a -> [Type]
forall a. OptionSet a -> [Type]
Atom.optData OptionSet a
opts) (T, [Type]) -> [(T, [Type])] -> [(T, [Type])]
forall a. a -> [a] -> [a]
:
(T
optFormat, OptionSet a -> [Type]
forall a. OptionSet a -> [Type]
Atom.optFormat OptionSet a
opts) (T, [Type]) -> [(T, [Type])] -> [(T, [Type])]
forall a. a -> [a] -> [a]
:
OptionSet a -> [(T, [Type])]
forall a. OptionSet a -> [(T, [Type])]
Atom.optOthers OptionSet a
opts
result ::
Atom.OptionSet x ->
Atom.OptionSet y ->
OptionSet.T (T x y)
result :: OptionSet x -> OptionSet y -> T (T x y)
result OptionSet x
optX OptionSet y
optY =
Plain -> T (T x y)
forall graph. Plain -> T graph
OptionSet.Cons (Plain -> T (T x y)) -> Plain -> T (T x y)
forall a b. (a -> b) -> a -> b
$
(Plain -> Plain -> Plain) -> Plain -> Plain -> Plain
forall a b c. (a -> b -> c) -> b -> a -> c
flip Plain -> Plain -> Plain
forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union Plain
OptionSet.deflt (Plain -> Plain) -> Plain -> Plain
forall a b. (a -> b) -> a -> b
$
[(T, [Type])] -> Plain
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(T, [Type])] -> Plain) -> [(T, [Type])] -> Plain
forall a b. (a -> b) -> a -> b
$
T -> T -> OptionSet x -> [(T, [Type])]
forall a. T -> T -> OptionSet a -> [(T, [Type])]
mk T
Option.xData T
Option.xFormat OptionSet x
optX [(T, [Type])] -> [(T, [Type])] -> [(T, [Type])]
forall a. [a] -> [a] -> [a]
++
T -> T -> OptionSet y -> [(T, [Type])]
forall a. T -> T -> OptionSet a -> [(T, [Type])]
mk T
Option.yData T
Option.yFormat OptionSet y
optY [(T, [Type])] -> [(T, [Type])] -> [(T, [Type])]
forall a. [a] -> [a] -> [a]
++
(T
Option.zData, []) (T, [Type]) -> [(T, [Type])] -> [(T, [Type])]
forall a. a -> [a] -> [a]
:
(T
Option.zFormat, []) (T, [Type]) -> [(T, [Type])] -> [(T, [Type])]
forall a. a -> [a] -> [a]
:
[]
in OptionSet x -> OptionSet y -> T (T x y)
forall x y. OptionSet x -> OptionSet y -> T (T x y)
result OptionSet x
forall a. C a => OptionSet a
Atom.options OptionSet y
forall a. C a => OptionSet a
Atom.options
instance (Atom.C x, Atom.C y) => Graph.C (T x y) where
command :: Command (T x y)
command = Type -> Command (T x y)
forall graph. Type -> Command graph
Graph.Command Type
"plot"
toString :: T x y -> Type
toString = T x y -> Type
forall x y. T x y -> Type
toString
defltOptions :: T (T x y)
defltOptions = T (T x y)
forall x y. (C x, C y) => T (T x y)
defltOptions
deflt :: GraphType.T x y a -> Columns -> T x y
deflt :: T x y a -> Columns -> T x y
deflt T x y a
t Columns
c = Columns -> Type -> T -> T x y
forall x y. Columns -> Type -> T -> T x y
Cons Columns
c (T x y a -> Type
forall x y a. T x y a -> Type
GraphType.toString T x y a
t) T
LineSpec.deflt
typ :: Type -> T x y -> T x y
typ :: Type -> T x y -> T x y
typ Type
t T x y
gr = T x y
gr{type_ :: Type
type_ = Type
t}
lineSpec :: LineSpec.T -> T x y -> T x y
lineSpec :: T -> T x y -> T x y
lineSpec T
ls T x y
gr = T x y
gr{lineSpec_ :: T
lineSpec_ = T
ls}