{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
module Graphics.Vega.VegaLite.Core
( transform
, aggregate
, joinAggregate
, opAs
, timeUnitAs
, binAs
, stack
, calculateAs
, filter
, Filter(..)
, FilterRange(..)
, flatten
, flattenAs
, fold
, foldAs
, pivot
, PivotProperty(..)
, lookup
, lookupSelection
, LookupFields(..)
, lookupAs
, impute
, sample
, density
, DensityProperty(..)
, loess
, LoessProperty(..)
, regression
, RegressionProperty(..)
, RegressionMethod(..)
, quantile
, QuantileProperty(..)
, window
, mark
, encoding
, position
, PositionChannel(..)
, SortProperty(..)
, AxisProperty(..)
, ConditionalAxisProperty(..)
, angle
, color
, fill
, fillOpacity
, opacity
, shape
, size
, stroke
, strokeDash
, strokeOpacity
, strokeWidth
, MarkChannel(..)
, text
, tooltip
, tooltips
, TextChannel(..)
, hyperlink
, url
, HyperlinkChannel(..)
, order
, OrderChannel(..)
, row
, column
, detail
, DetailChannel(..)
, ariaDescription
, AriaDescriptionChannel(..)
, ScaleProperty(..)
, categoricalDomainMap
, domainRangeMap
, layer
, vlConcat
, columns
, hConcat
, vConcat
, align
, alignRC
, spacing
, spacingRC
, center
, centerRC
, bounds
, resolve
, resolution
, repeat
, repeatFlow
, facet
, facetFlow
, FacetMapping(..)
, FacetChannel(..)
, BooleanOp(..)
, name
, description
, height
, heightOfContainer
, heightStep
, width
, widthOfContainer
, widthStep
, padding
, autosize
, background
, usermetadata
, viewBackground
, configure
, autosizeProperty
, axisProperty
, paddingSpec
, schemeProperty
)
where
import Prelude hiding (filter, lookup, repeat)
import qualified Data.Aeson as A
#if MIN_VERSION_aeson(2, 0, 0)
import qualified Data.Aeson.Key as Key
#endif
import qualified Data.Text as T
import Data.Aeson (object, toJSON, (.=))
import Data.Aeson.Types (Pair)
import Data.Maybe (mapMaybe)
#if !(MIN_VERSION_base(4, 12, 0))
import Data.Monoid ((<>))
#endif
import Numeric.Natural (Natural)
import Graphics.Vega.VegaLite.Data
( DataValue(..)
, DataValues(..)
, dataValueSpec
, dataValuesSpecs
)
import Graphics.Vega.VegaLite.Foundation
( Angle
, Color
, DashStyle
, DashOffset
, FieldName
, Opacity
, StyleLabel
, VegaExpr
, ZIndex
, FontWeight
, Measurement
, Arrangement
, APosition
, Position
, HAlign
, VAlign
, BandAlign
, Scale
, OverlapStrategy
, Side
, StackProperty
, StackOffset
, StrokeCap
, Channel
, Resolve
, Bounds
, CompositionAlignment
, Padding
, Autosize
, RepeatFields
, CInterpolate
, ViewBackground
, HeaderProperty
, Symbol
, fromT
, fromColor
, fromDS
, splitOnNewline
, field_
, header_
, order_
, fontWeightSpec
, measurementLabel
, arrangementLabel
, anchorLabel
, hAlignLabel
, vAlignLabel
, bandAlignLabel
, scaleLabel
, strokeCapLabel
, positionLabel
, overlapStrategyLabel
, sideLabel
, stackPropertySpecSort
, stackPropertySpecOffset
, stackOffset
, channelLabel
, resolveProperty
, boundsSpec
, compositionAlignmentSpec
, paddingSpec
, autosizeProperty
, repeatFieldsProperty
, cInterpolateSpec
, viewBackgroundSpec
, symbolLabel
, (.=~), toObject, toKey
)
import Graphics.Vega.VegaLite.Input
( Data
)
import Graphics.Vega.VegaLite.Legend
( LegendProperty
, legendProp_
)
import Graphics.Vega.VegaLite.Mark
( Mark
, MarkProperty
, markLabel
, markProperty
)
import Graphics.Vega.VegaLite.Scale
( ScaleDomain(..)
, DomainLimits(..)
, ScaleRange(..)
, ScaleNice
, scaleDomainProperty
, domainLimitsSpec
, scaleNiceSpec
)
import Graphics.Vega.VegaLite.Specification
( VLProperty(..)
, VLSpec
, PropertySpec
, EncodingSpec(..)
, BuildEncodingSpecs
, TransformSpec(..)
, BuildTransformSpecs
, ConfigureSpec(..)
, ResolveSpec(..)
, BuildResolveSpecs
, SelectionLabel
)
import Graphics.Vega.VegaLite.Time
( DateTime
, TimeUnit
, dateTimeSpec
, timeUnitSpec
)
import Graphics.Vega.VegaLite.Transform
( Operation(Count)
, Window
, BinProperty
, WindowProperty
, ImputeProperty
, aggregate_
, op_
, binned_
, impute_
, bin
, binProperty
, operationSpec
, windowTS
, joinAggregateTS
, imputeTS
)
clamped ::
Double
-> Double
-> Double
-> Double
clamped :: Double -> Double -> Double -> Double
clamped Double
xmin Double
xmax Double
x = Double -> Double -> Double
forall a. Ord a => a -> a -> a
max Double
xmin (Double -> Double -> Double
forall a. Ord a => a -> a -> a
min Double
xmax Double
x)
repeat_ :: Arrangement -> Pair
repeat_ :: Arrangement -> Pair
repeat_ Arrangement
arr = Key
"repeat" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Arrangement -> Text
arrangementLabel Arrangement
arr
sort_ :: [SortProperty] -> Pair
sort_ :: [SortProperty] -> Pair
sort_ [SortProperty]
ops = Key
"sort" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SortProperty] -> VLSpec
sortPropertySpec [SortProperty]
ops
mchan_ :: T.Text -> [MarkChannel] -> EncodingSpec
mchan_ :: Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
f [MarkChannel]
ms = (Text, VLSpec) -> EncodingSpec
ES (Text
f Text -> VLSpec -> (Text, VLSpec)
forall a. ToJSON a => Text -> a -> (Text, VLSpec)
.=~ [Pair] -> VLSpec
object ((MarkChannel -> [Pair]) -> [MarkChannel] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap MarkChannel -> [Pair]
markChannelProperty [MarkChannel]
ms))
mtype_ :: Measurement -> Pair
mtype_ :: Measurement -> Pair
mtype_ Measurement
m = Key
"type" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Measurement -> Text
measurementLabel Measurement
m
timeUnit_ :: TimeUnit -> Pair
timeUnit_ :: TimeUnit -> Pair
timeUnit_ TimeUnit
tu = Key
"timeUnit" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TimeUnit -> VLSpec
timeUnitSpec TimeUnit
tu
scaleProp_ :: [ScaleProperty] -> Pair
scaleProp_ :: [ScaleProperty] -> Pair
scaleProp_ [] = Key
"scale" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null
scaleProp_ [ScaleProperty]
sps = Key
"scale" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object ((ScaleProperty -> Pair) -> [ScaleProperty] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map ScaleProperty -> Pair
scaleProperty [ScaleProperty]
sps)
value_ :: T.Text -> Pair
value_ :: Text -> Pair
value_ Text
v = Key
"value" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
v
selCond_ :: (a -> [Pair]) -> BooleanOp -> [a] -> [a] -> [Pair]
selCond_ :: (a -> [Pair]) -> BooleanOp -> [a] -> [a] -> [Pair]
selCond_ a -> [Pair]
getProps BooleanOp
selName [a]
ifClause [a]
elseClause =
let h :: Pair
h = (Key
"condition", VLSpec
hkey)
toProps :: [a] -> [Pair]
toProps = (a -> [Pair]) -> [a] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap a -> [Pair]
getProps
hkey :: VLSpec
hkey = [Pair] -> VLSpec
object ((Text, VLSpec) -> Pair
toKey (Text
"selection", BooleanOp -> VLSpec
booleanOpSpec BooleanOp
selName) Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [a] -> [Pair]
toProps [a]
ifClause)
hs :: [Pair]
hs = [a] -> [Pair]
toProps [a]
elseClause
in (Pair
h Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
hs)
dataCond_ :: (a -> [Pair]) -> [(BooleanOp, [a])] -> [a] -> [Pair]
dataCond_ :: (a -> [Pair]) -> [(BooleanOp, [a])] -> [a] -> [Pair]
dataCond_ a -> [Pair]
getProps [(BooleanOp, [a])]
tests [a]
elseClause =
let h :: Pair
h = (Key
"condition", VLSpec
condClause)
condClause :: VLSpec
condClause = case [VLSpec]
conds of
[VLSpec
cond] -> VLSpec
cond
[VLSpec]
_ -> [VLSpec] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [VLSpec]
conds
conds :: [VLSpec]
conds = ((BooleanOp, [a]) -> VLSpec) -> [(BooleanOp, [a])] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map (BooleanOp, [a]) -> VLSpec
testClause [(BooleanOp, [a])]
tests
testClause :: (BooleanOp, [a]) -> VLSpec
testClause (Selection Text
sel, [a]
ifClause) =
[Pair] -> VLSpec
object ((Key
"selection" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
sel) Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [a] -> [Pair]
toProps [a]
ifClause)
testClause (BooleanOp
predicate, [a]
ifClause) =
[Pair] -> VLSpec
object ((Text, VLSpec) -> Pair
toKey (Text
"test", BooleanOp -> VLSpec
booleanOpSpec BooleanOp
predicate) Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [a] -> [Pair]
toProps [a]
ifClause)
toProps :: [a] -> [Pair]
toProps = (a -> [Pair]) -> [a] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap a -> [Pair]
getProps
hs :: [Pair]
hs = [a] -> [Pair]
toProps [a]
elseClause
in (Pair
h Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
hs)
opAs ::
Operation
-> FieldName
-> FieldName
-> VLSpec
opAs :: Operation -> Text -> Text -> VLSpec
opAs Operation
Count Text
_ Text
label =
[Pair] -> VLSpec
object [ Operation -> Pair
op_ Operation
Count, Key
"as" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
label ]
opAs Operation
op Text
field Text
label =
[Pair] -> VLSpec
object [ Operation -> Pair
op_ Operation
op, Text -> Pair
field_ Text
field, Key
"as" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
label ]
mark :: Mark -> [MarkProperty] -> PropertySpec
mark :: Mark -> [MarkProperty] -> PropertySpec
mark Mark
mrk [MarkProperty]
props =
let jsName :: VLSpec
jsName = Text -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON (Mark -> Text
markLabel Mark
mrk)
vals :: VLSpec
vals = if [MarkProperty] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [MarkProperty]
props
then VLSpec
jsName
else [Pair] -> VLSpec
object ((Key
"type" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
jsName) Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: (MarkProperty -> Pair) -> [MarkProperty] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> Pair
markProperty [MarkProperty]
props)
in (VLProperty
VLMark, VLSpec
vals)
data MarkChannel
= MName FieldName
| MRepeat Arrangement
| MRepeatDatum Arrangement
| MmType Measurement
| MScale [ScaleProperty]
| MBin [BinProperty]
| MBinned
| MSort [SortProperty]
| MTimeUnit TimeUnit
| MTitle T.Text
| MNoTitle
| MAggregate Operation
| MLegend [LegendProperty]
| MSelectionCondition BooleanOp [MarkChannel] [MarkChannel]
| MDataCondition [(BooleanOp, [MarkChannel])] [MarkChannel]
| MPath T.Text
| MDatum DataValue
| MNumber Double
| MString T.Text
| MBoolean Bool
| MNullValue
| MSymbol Symbol
markChannelProperty :: MarkChannel -> [Pair]
markChannelProperty :: MarkChannel -> [Pair]
markChannelProperty (MName Text
s) = [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
markChannelProperty (MRepeat Arrangement
arr) = [Key
"field" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr]]
markChannelProperty (MRepeatDatum Arrangement
arr) = [Key
"datum" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr]]
markChannelProperty (MmType Measurement
t) = [Measurement -> Pair
mtype_ Measurement
t]
markChannelProperty (MScale [ScaleProperty]
sps) = [[ScaleProperty] -> Pair
scaleProp_ [ScaleProperty]
sps]
markChannelProperty (MLegend [LegendProperty]
lps) = [[LegendProperty] -> Pair
legendProp_ [LegendProperty]
lps]
markChannelProperty (MBin [BinProperty]
bps) = [[BinProperty] -> Pair
bin [BinProperty]
bps]
markChannelProperty MarkChannel
MBinned = [Pair
binned_]
markChannelProperty (MSort [SortProperty]
ops) = [[SortProperty] -> Pair
sort_ [SortProperty]
ops]
markChannelProperty (MSelectionCondition BooleanOp
selName [MarkChannel]
ifClause [MarkChannel]
elseClause) =
(MarkChannel -> [Pair])
-> BooleanOp -> [MarkChannel] -> [MarkChannel] -> [Pair]
forall a. (a -> [Pair]) -> BooleanOp -> [a] -> [a] -> [Pair]
selCond_ MarkChannel -> [Pair]
markChannelProperty BooleanOp
selName [MarkChannel]
ifClause [MarkChannel]
elseClause
markChannelProperty (MDataCondition [(BooleanOp, [MarkChannel])]
tests [MarkChannel]
elseClause) =
(MarkChannel -> [Pair])
-> [(BooleanOp, [MarkChannel])] -> [MarkChannel] -> [Pair]
forall a. (a -> [Pair]) -> [(BooleanOp, [a])] -> [a] -> [Pair]
dataCond_ MarkChannel -> [Pair]
markChannelProperty [(BooleanOp, [MarkChannel])]
tests [MarkChannel]
elseClause
markChannelProperty (MTimeUnit TimeUnit
tu) = [TimeUnit -> Pair
timeUnit_ TimeUnit
tu]
markChannelProperty (MAggregate Operation
op) = [Operation -> Pair
aggregate_ Operation
op]
markChannelProperty (MPath Text
s) = [Key
"value" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
markChannelProperty (MDatum DataValue
d) = [Key
"datum" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DataValue -> VLSpec
dataValueSpec DataValue
d]
markChannelProperty (MNumber Double
x) = [Key
"value" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x]
markChannelProperty (MString Text
s) = [Key
"value" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
markChannelProperty (MBoolean Bool
b) = [Key
"value" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b]
markChannelProperty (MSymbol Symbol
s) = [Key
"value" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Symbol -> Text
symbolLabel Symbol
s]
markChannelProperty MarkChannel
MNullValue = [Key
"value" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null]
markChannelProperty (MTitle Text
s) = [Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
splitOnNewline Text
s]
markChannelProperty MarkChannel
MNoTitle = [Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null]
encoding ::
[EncodingSpec]
-> PropertySpec
encoding :: [EncodingSpec] -> PropertySpec
encoding [EncodingSpec]
channels = (VLProperty
VLEncoding, [(Text, VLSpec)] -> VLSpec
toObject ((EncodingSpec -> (Text, VLSpec))
-> [EncodingSpec] -> [(Text, VLSpec)]
forall a b. (a -> b) -> [a] -> [b]
map EncodingSpec -> (Text, VLSpec)
unES [EncodingSpec]
channels))
ariaDescription ::
[AriaDescriptionChannel]
-> BuildEncodingSpecs
ariaDescription :: [AriaDescriptionChannel] -> BuildEncodingSpecs
ariaDescription [AriaDescriptionChannel]
ads [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"description", [Pair] -> VLSpec
object ((AriaDescriptionChannel -> [Pair])
-> [AriaDescriptionChannel] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap AriaDescriptionChannel -> [Pair]
ariaDescriptionChannelProperty [AriaDescriptionChannel]
ads)) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
stack ::
FieldName
-> [FieldName]
-> FieldName
-> FieldName
-> [StackProperty]
-> BuildTransformSpecs
stack :: Text
-> [Text] -> Text -> Text -> [StackProperty] -> BuildTransformSpecs
stack Text
f [Text]
grp Text
start Text
end [StackProperty]
sProps [TransformSpec]
ols =
let addField :: Key -> [v] -> [a]
addField Key
n [v
x] = [Key
n Key -> v -> a
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= v
x]
addField Key
_ [v]
_ = []
mOffset :: [VLSpec]
mOffset = (StackProperty -> Maybe VLSpec) -> [StackProperty] -> [VLSpec]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe StackProperty -> Maybe VLSpec
stackPropertySpecOffset [StackProperty]
sProps
mSort :: [VLSpec]
mSort = (StackProperty -> Maybe VLSpec) -> [StackProperty] -> [VLSpec]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe StackProperty -> Maybe VLSpec
stackPropertySpecSort [StackProperty]
sProps
fields :: [Pair]
fields = [ Key
"stack" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
f
, Key
"groupby" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
grp
, Key
"as" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [ Text
start, Text
end ] ]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> [VLSpec] -> [Pair]
forall a v. (KeyValue a, ToJSON v) => Key -> [v] -> [a]
addField Key
"offset" [VLSpec]
mOffset
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> [VLSpec] -> [Pair]
forall a v. (KeyValue a, ToJSON v) => Key -> [v] -> [a]
addField Key
"sort" [VLSpec]
mSort
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
fields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
data ScaleProperty
= SType Scale
| SAlign Double
| SBase Double
| SBins [Double]
| SClamp Bool
| SConstant Double
| SDomain DomainLimits
| SDomainMid Double
| SDomainOpt ScaleDomain
| SExponent Double
| SInterpolate CInterpolate
| SNice ScaleNice
| SPadding Double
| SPaddingInner Double
| SPaddingOuter Double
| SRange ScaleRange
| SReverse Bool
| SRound Bool
| SScheme T.Text [Double]
| SZero Bool
scaleProperty :: ScaleProperty -> Pair
scaleProperty :: ScaleProperty -> Pair
scaleProperty (SType Scale
sType) = Key
"type" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Scale -> Text
scaleLabel Scale
sType
scaleProperty (SAlign Double
c) = Key
"align" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double -> Double -> Double -> Double
clamped Double
0 Double
1 Double
c
scaleProperty (SBase Double
x) = Key
"base" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
scaleProperty (SBins [Double]
xs) = Key
"bins" Key -> [Double] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Double]
xs
scaleProperty (SClamp Bool
b) = Key
"clamp" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
scaleProperty (SConstant Double
x) = Key
"constant" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
scaleProperty (SDomain DomainLimits
dl) = Key
"domain" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DomainLimits -> VLSpec
domainLimitsSpec DomainLimits
dl
scaleProperty (SDomainMid Double
x) = Key
"domainMid" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
scaleProperty (SDomainOpt ScaleDomain
sd) = ScaleDomain -> Pair
scaleDomainProperty ScaleDomain
sd
scaleProperty (SExponent Double
x) = Key
"exponent" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
scaleProperty (SInterpolate CInterpolate
interp) = Key
"interpolate" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= CInterpolate -> VLSpec
cInterpolateSpec CInterpolate
interp
scaleProperty (SNice ScaleNice
ni) = Key
"nice" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ScaleNice -> VLSpec
scaleNiceSpec ScaleNice
ni
scaleProperty (SPadding Double
x) = Key
"padding" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
scaleProperty (SPaddingInner Double
x) = Key
"paddingInner" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
scaleProperty (SPaddingOuter Double
x) = Key
"paddingOuter" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
scaleProperty (SRange (RField Text
f)) = Key
"range" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
f]
scaleProperty (SRange (RMax Double
x)) = Key
"rangeMax" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
scaleProperty (SRange (RMin Double
x)) = Key
"rangeMin" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
scaleProperty (SRange (RPair Double
lo Double
hi)) = Key
"range" Key -> [Double] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Double
lo, Double
hi]
scaleProperty (SRange (RHeight Double
w)) = Key
"range" Key -> [VLSpec] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text -> VLSpec
fromT Text
"height", Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
w]
scaleProperty (SRange (RWidth Double
h)) = Key
"range" Key -> [VLSpec] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
h, Text -> VLSpec
fromT Text
"width"]
scaleProperty (SRange (RNumbers [Double]
xs)) = Key
"range" Key -> [Double] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Double]
xs
scaleProperty (SRange (RNumberLists [[Double]]
xss)) = Key
"range" Key -> [[Double]] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [[Double]]
xss
scaleProperty (SRange (RStrings [Text]
ss)) = Key
"range" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
ss
scaleProperty (SRange (RName Text
s)) = Key
"range" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
scaleProperty (SReverse Bool
b) = Key
"reverse" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
scaleProperty (SRound Bool
b) = Key
"round" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
scaleProperty (SScheme Text
nme [Double]
extent) = Text -> [Double] -> Pair
schemeProperty Text
nme [Double]
extent
scaleProperty (SZero Bool
b) = Key
"zero" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
schemeProperty :: T.Text -> [Double] -> Pair
schemeProperty :: Text -> [Double] -> Pair
schemeProperty Text
nme [Double
n] = Key
"scheme" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Key
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
nme, Key
"count" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
n]
schemeProperty Text
nme [Double
mn, Double
mx] = Key
"scheme" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Key
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
nme, Key
"extent" Key -> [Double] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Double
mn, Double
mx]]
schemeProperty Text
nme [Double
n, Double
mn, Double
mx] = Key
"scheme" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Key
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
nme, Key
"count" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
n, Key
"extent" Key -> [Double] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Double
mn, Double
mx]]
schemeProperty Text
nme [Double]
_ = Key
"scheme" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
nme
data SortProperty
= Ascending
| Descending
| CustomSort DataValues
| ByRepeatOp Arrangement Operation
| ByFieldOp FieldName Operation
| ByChannel Channel
sortProperty :: SortProperty -> [Pair]
sortProperty :: SortProperty -> [Pair]
sortProperty SortProperty
Ascending = [Text -> Pair
order_ Text
"ascending"]
sortProperty SortProperty
Descending = [Text -> Pair
order_ Text
"descending"]
sortProperty (ByChannel Channel
ch) = [Key
"encoding" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Channel -> Text
channelLabel Channel
ch]
sortProperty (ByFieldOp Text
field Operation
op) = [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field, Operation -> Pair
op_ Operation
op]
sortProperty (ByRepeatOp Arrangement
arr Operation
op) = [Key
"field" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr], Operation -> Pair
op_ Operation
op]
sortProperty (CustomSort DataValues
_) = []
sortPropertySpec :: [SortProperty] -> VLSpec
sortPropertySpec :: [SortProperty] -> VLSpec
sortPropertySpec [] = VLSpec
A.Null
sortPropertySpec [SortProperty
Ascending] = Text -> VLSpec
fromT Text
"ascending"
sortPropertySpec [SortProperty
Descending] = Text -> VLSpec
fromT Text
"descending"
sortPropertySpec [CustomSort DataValues
dvs] = [VLSpec] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON (DataValues -> [VLSpec]
dataValuesSpecs DataValues
dvs)
sortPropertySpec [SortProperty]
sps = [Pair] -> VLSpec
object ((SortProperty -> [Pair]) -> [SortProperty] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap SortProperty -> [Pair]
sortProperty [SortProperty]
sps)
data PositionChannel
= PName FieldName
| PHeight
| PWidth
| PDatum DataValue
| PNumber Double
| PRepeat Arrangement
| PRepeatDatum Arrangement
| PmType Measurement
| PBin [BinProperty]
| PBinned
| PTimeUnit TimeUnit
| PTitle T.Text
| PNoTitle
| PAggregate Operation
| PScale [ScaleProperty]
| PAxis [AxisProperty]
| PSort [SortProperty]
| PStack StackOffset
| PImpute [ImputeProperty]
| PBand Double
positionChannelProperty :: PositionChannel -> Pair
positionChannelProperty :: PositionChannel -> Pair
positionChannelProperty (PName Text
s) = Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
positionChannelProperty (PmType Measurement
m) = Measurement -> Pair
mtype_ Measurement
m
positionChannelProperty (PBin [BinProperty]
b) = [BinProperty] -> Pair
bin [BinProperty]
b
positionChannelProperty PositionChannel
PBinned = Pair
binned_
positionChannelProperty (PAggregate Operation
op) = Operation -> Pair
aggregate_ Operation
op
positionChannelProperty (PTimeUnit TimeUnit
tu) = TimeUnit -> Pair
timeUnit_ TimeUnit
tu
positionChannelProperty (PTitle Text
s) = Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
splitOnNewline Text
s
positionChannelProperty PositionChannel
PNoTitle = Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null
positionChannelProperty (PSort [SortProperty]
ops) = [SortProperty] -> Pair
sort_ [SortProperty]
ops
positionChannelProperty (PScale [ScaleProperty]
sps) = [ScaleProperty] -> Pair
scaleProp_ [ScaleProperty]
sps
positionChannelProperty (PAxis [AxisProperty]
aps) =
let js :: VLSpec
js = if [AxisProperty] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [AxisProperty]
aps
then VLSpec
A.Null
else [Pair] -> VLSpec
object ((AxisProperty -> Pair) -> [AxisProperty] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map AxisProperty -> Pair
axisProperty [AxisProperty]
aps)
in Key
"axis" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
js
positionChannelProperty (PStack StackOffset
so) = StackOffset -> Pair
stackOffset StackOffset
so
positionChannelProperty (PRepeat Arrangement
arr) = Key
"field" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr]
positionChannelProperty (PRepeatDatum Arrangement
arr) = Key
"datum" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr]
positionChannelProperty PositionChannel
PHeight = Text -> Pair
value_ Text
"height"
positionChannelProperty PositionChannel
PWidth = Text -> Pair
value_ Text
"width"
positionChannelProperty (PDatum DataValue
d) = Key
"datum" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DataValue -> VLSpec
dataValueSpec DataValue
d
positionChannelProperty (PNumber Double
x) = Key
"value" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
positionChannelProperty (PImpute [ImputeProperty]
ips) = [ImputeProperty] -> Pair
impute_ [ImputeProperty]
ips
positionChannelProperty (PBand Double
x) = Key
"band" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
background ::
Color
-> PropertySpec
background :: Text -> PropertySpec
background Text
colour = (VLProperty
VLBackground, Text -> VLSpec
fromColor Text
colour)
description :: T.Text -> PropertySpec
description :: Text -> PropertySpec
description Text
s = (VLProperty
VLDescription, Text -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Text
s)
usermetadata ::
A.Object
-> PropertySpec
usermetadata :: Object -> PropertySpec
usermetadata Object
o = (VLProperty
VLUserMetadata, Object -> VLSpec
A.Object Object
o)
{-# DEPRECATED AxDates "Please change AxDates to AxValues" #-}
data AxisProperty
= AxAria Bool
| AxAriaDescription T.Text
| AxBandPosition Double
| AxDataCondition BooleanOp ConditionalAxisProperty
| AxDomain Bool
| AxDomainCap StrokeCap
| AxDomainColor Color
| AxDomainDash DashStyle
| AxDomainDashOffset DashOffset
| AxDomainOpacity Opacity
| AxDomainWidth Double
| AxFormat T.Text
| AxFormatAsNum
| AxFormatAsTemporal
| AxFormatAsCustom T.Text
| AxGrid Bool
| AxGridCap StrokeCap
| AxGridColor Color
| AxGridDash DashStyle
| AxGridDashOffset DashOffset
| AxGridOpacity Opacity
| AxGridWidth Double
| AxLabels Bool
| AxLabelAlign HAlign
| AxLabelAngle Angle
| AxLabelBaseline VAlign
| AxLabelNoBound
| AxLabelBound
| AxLabelBoundValue Double
| AxLabelColor Color
| AxLabelExpr VegaExpr
| AxLabelNoFlush
| AxLabelFlush
| AxLabelFlushValue Double
| AxLabelFlushOffset Double
| AxLabelFont T.Text
| AxLabelFontSize Double
| AxLabelFontStyle T.Text
| AxLabelFontWeight FontWeight
| AxLabelLimit Double
| AxLabelLineHeight Double
| AxLabelOffset Double
| AxLabelOpacity Opacity
| AxLabelOverlap OverlapStrategy
| AxLabelPadding Double
| AxLabelSeparation Double
| AxMaxExtent Double
| AxMinExtent Double
| AxOffset Double
| AxOrient Side
| AxPosition Double
| AxStyle [StyleLabel]
| AxTicks Bool
| AxTickBand BandAlign
| AxTickCap StrokeCap
| AxTickColor Color
| AxTickCount Int
| AxTickCountTime ScaleNice
| AxTickDash DashStyle
| AxTickDashOffset DashOffset
| Bool
| AxTickMinStep Double
| AxTickOffset Double
| AxTickOpacity Opacity
| AxTickRound Bool
| AxTickSize Double
| AxTickWidth Double
| AxTitle T.Text
| AxNoTitle
| AxTitleAlign HAlign
| AxTitleAnchor APosition
| AxTitleAngle Angle
| AxTitleBaseline VAlign
| AxTitleColor Color
| AxTitleFont T.Text
| AxTitleFontSize Double
| AxTitleFontStyle T.Text
| AxTitleFontWeight FontWeight
| AxTitleLimit Double
| AxTitleLineHeight Double
| AxTitleOpacity Opacity
| AxTitlePadding Double
| AxTitleX Double
| AxTitleY Double
| AxTranslateOffset Double
| AxValues DataValues
| AxDates [[DateTime]]
| AxZIndex ZIndex
axisProperty :: AxisProperty -> Pair
axisProperty :: AxisProperty -> Pair
axisProperty (AxStyle [Text
s]) = Key
"style" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
axisProperty (AxStyle [Text]
s) = Key
"style" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
s
axisProperty (AxAria Bool
b) = Key
"aria" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
axisProperty (AxAriaDescription Text
t) = Key
"description" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
axisProperty (AxBandPosition Double
x) = Key
"bandPosition" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxDataCondition BooleanOp
predicate ConditionalAxisProperty
cap) =
let (AxisProperty
ifAxProp, AxisProperty
elseAxProp) = ConditionalAxisProperty -> (AxisProperty, AxisProperty)
conditionalAxisProperty ConditionalAxisProperty
cap
(Key
axKey, VLSpec
ifProp) = AxisProperty -> Pair
axisProperty AxisProperty
ifAxProp
(Key
_, VLSpec
elseProp) = AxisProperty -> Pair
axisProperty AxisProperty
elseAxProp
in Key
axKey Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [ Key
"condition" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [ Key
"test" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BooleanOp -> VLSpec
booleanOpSpec BooleanOp
predicate
, Key
"value" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
ifProp
]
, Key
"value" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
elseProp]
axisProperty (AxDomain Bool
b) = Key
"domain" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
axisProperty (AxDomainCap StrokeCap
c) = Key
"domainCap" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= StrokeCap -> Text
strokeCapLabel StrokeCap
c
axisProperty (AxDomainColor Text
s) = Key
"domainColor" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromColor Text
s
axisProperty (AxDomainDash [Double]
ds) = Key
"domainDash" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Double] -> VLSpec
fromDS [Double]
ds
axisProperty (AxDomainDashOffset Double
x) = Key
"domainDashOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxDomainOpacity Double
x) = Key
"domainOpacity" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxDomainWidth Double
x) = Key
"domainWidth" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxFormat Text
fmt) = Key
"format" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fmt
axisProperty AxisProperty
AxFormatAsNum = Key
"formatType" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"number"
axisProperty AxisProperty
AxFormatAsTemporal = Key
"formatType" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"time"
axisProperty (AxFormatAsCustom Text
c) = Key
"formatType" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
c
axisProperty (AxGrid Bool
b) = Key
"grid" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
axisProperty (AxGridCap StrokeCap
c) = Key
"gridCap" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= StrokeCap -> Text
strokeCapLabel StrokeCap
c
axisProperty (AxGridColor Text
s) = Key
"gridColor" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromColor Text
s
axisProperty (AxGridDash [Double]
ds) = Key
"gridDash" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Double] -> VLSpec
fromDS [Double]
ds
axisProperty (AxGridDashOffset Double
x) = Key
"gridDashOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxGridOpacity Double
x) = Key
"gridOpacity" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxGridWidth Double
x) = Key
"gridWidth" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabels Bool
b) = Key
"labels" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
axisProperty (AxLabelAlign HAlign
ha) = Key
"labelAlign" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= HAlign -> Text
hAlignLabel HAlign
ha
axisProperty (AxLabelAngle Double
a) = Key
"labelAngle" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
a
axisProperty (AxLabelBaseline VAlign
va) = Key
"labelBaseline" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VAlign -> Text
vAlignLabel VAlign
va
axisProperty AxisProperty
AxLabelNoBound = Key
"labelBound" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
False
axisProperty AxisProperty
AxLabelBound = Key
"labelBound" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
True
axisProperty (AxLabelBoundValue Double
x) = Key
"labelBound" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabelColor Text
s) = Key
"labelColor" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromColor Text
s
axisProperty (AxLabelExpr Text
e) = Key
"labelExpr" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
e
axisProperty AxisProperty
AxLabelNoFlush = Key
"labelFlush" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
False
axisProperty AxisProperty
AxLabelFlush = Key
"labelFlush" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
True
axisProperty (AxLabelFlushValue Double
x) = Key
"labelFlush" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabelFlushOffset Double
x) = Key
"labelFlushOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabelFont Text
s) = Key
"labelFont" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
axisProperty (AxLabelFontSize Double
x) = Key
"labelFontSize" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabelFontStyle Text
s) = Key
"labelFontStyle" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
axisProperty (AxLabelFontWeight FontWeight
fw) = Key
"labelFontWeight" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= FontWeight -> VLSpec
fontWeightSpec FontWeight
fw
axisProperty (AxLabelLimit Double
x) = Key
"labelLimit" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabelLineHeight Double
x) = Key
"labelLineHeight" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabelOffset Double
x) = Key
"labelOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabelOpacity Double
x) = Key
"labelOpacity" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabelOverlap OverlapStrategy
s) = Key
"labelOverlap" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= OverlapStrategy -> VLSpec
overlapStrategyLabel OverlapStrategy
s
axisProperty (AxLabelPadding Double
x) = Key
"labelPadding" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxLabelSeparation Double
x) = Key
"labelSeparation" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxMaxExtent Double
n) = Key
"maxExtent" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
n
axisProperty (AxMinExtent Double
n) = Key
"minExtent" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
n
axisProperty (AxOffset Double
n) = Key
"offset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
n
axisProperty (AxOrient Side
side) = Key
"orient" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Side -> Text
sideLabel Side
side
axisProperty (AxPosition Double
n) = Key
"position" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
n
axisProperty (AxTicks Bool
b) = Key
"ticks" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
axisProperty (AxTickBand BandAlign
bnd) = Key
"tickBand" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BandAlign -> Text
bandAlignLabel BandAlign
bnd
axisProperty (AxTickCap StrokeCap
c) = Key
"tickCap" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= StrokeCap -> Text
strokeCapLabel StrokeCap
c
axisProperty (AxTickColor Text
s) = Key
"tickColor" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromColor Text
s
axisProperty (AxTickCount Int
n) = Key
"tickCount" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
n
axisProperty (AxTickCountTime ScaleNice
sn) = Key
"tickCount" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ScaleNice -> VLSpec
scaleNiceSpec ScaleNice
sn
axisProperty (AxTickDash [Double]
ds) = Key
"tickDash" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Double] -> VLSpec
fromDS [Double]
ds
axisProperty (AxTickDashOffset Double
x) = Key
"tickDashOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTickExtra Bool
b) = Key
"tickExtra" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
axisProperty (AxTickMinStep Double
x) = Key
"tickMinStep" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTickOffset Double
x) = Key
"tickOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTickOpacity Double
x) = Key
"tickOpacity" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTickRound Bool
b) = Key
"tickRound" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
axisProperty (AxTickSize Double
x) = Key
"tickSize" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTickWidth Double
x) = Key
"tickWidth" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTitle Text
ttl) = Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
splitOnNewline Text
ttl
axisProperty AxisProperty
AxNoTitle = Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null
axisProperty (AxTitleAlign HAlign
ha) = Key
"titleAlign" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= HAlign -> Text
hAlignLabel HAlign
ha
axisProperty (AxTitleAnchor APosition
a) = Key
"titleAnchor" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= APosition -> Text
anchorLabel APosition
a
axisProperty (AxTitleAngle Double
x) = Key
"titleAngle" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTitleBaseline VAlign
va) = Key
"titleBaseline" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VAlign -> Text
vAlignLabel VAlign
va
axisProperty (AxTitleColor Text
s) = Key
"titleColor" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromColor Text
s
axisProperty (AxTitleFont Text
s) = Key
"titleFont" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
axisProperty (AxTitleFontSize Double
x) = Key
"titleFontSize" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTitleFontStyle Text
s) = Key
"titleFontStyle" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
axisProperty (AxTitleFontWeight FontWeight
fw) = Key
"titleFontWeight" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= FontWeight -> VLSpec
fontWeightSpec FontWeight
fw
axisProperty (AxTitleLimit Double
x) = Key
"titleLimit" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTitleLineHeight Double
x) = Key
"titleLineHeight" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTitleOpacity Double
x) = Key
"titleOpacity" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTitlePadding Double
pad) = Key
"titlePadding" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
pad
axisProperty (AxTitleX Double
x) = Key
"titleX" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTitleY Double
x) = Key
"titleY" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxTranslateOffset Double
x) = Key
"translate" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
axisProperty (AxValues DataValues
vals) = Key
"values" Key -> [VLSpec] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DataValues -> [VLSpec]
dataValuesSpecs DataValues
vals
axisProperty (AxDates [[DateTime]]
dtss) = Key
"values" Key -> [VLSpec] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ([DateTime] -> VLSpec) -> [[DateTime]] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map [DateTime] -> VLSpec
dateTimeSpec [[DateTime]]
dtss
axisProperty (AxZIndex ZIndex
z) = Key
"zindex" Key -> ZIndex -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ZIndex
z
data ConditionalAxisProperty
= CAxGridColor Color Color
| CAxGridDash DashStyle DashStyle
| CAxGridDashOffset DashOffset DashOffset
| CAxGridOpacity Opacity Opacity
| CAxGridWidth Double Double
| CAxLabelAlign HAlign HAlign
| CAxLabelBaseline VAlign VAlign
| CAxLabelColor Color Color
| CAxLabelFont T.Text T.Text
| CAxLabelFontSize Double Double
| CAxLabelFontStyle T.Text T.Text
| CAxLabelFontWeight FontWeight FontWeight
| CAxLabelOffset Double Double
| CAxLabelOpacity Opacity Opacity
| CAxLabelPadding Double Double
| CAxTickColor T.Text T.Text
| CAxTickDash DashStyle DashStyle
| CAxTickDashOffset DashOffset DashOffset
| CAxTickOpacity Opacity Opacity
| CAxTickSize Double Double
| CAxTickWidth Double Double
conditionalAxisProperty :: ConditionalAxisProperty -> (AxisProperty, AxisProperty)
conditionalAxisProperty :: ConditionalAxisProperty -> (AxisProperty, AxisProperty)
conditionalAxisProperty (CAxGridColor Text
t Text
f) = (Text -> AxisProperty
AxGridColor Text
t, Text -> AxisProperty
AxGridColor Text
f)
conditionalAxisProperty (CAxGridDash [Double]
t [Double]
f) = ([Double] -> AxisProperty
AxGridDash [Double]
t, [Double] -> AxisProperty
AxGridDash [Double]
f)
conditionalAxisProperty (CAxGridDashOffset Double
t Double
f) = (Double -> AxisProperty
AxGridDashOffset Double
t, Double -> AxisProperty
AxGridDashOffset Double
f)
conditionalAxisProperty (CAxGridOpacity Double
t Double
f) = (Double -> AxisProperty
AxGridOpacity Double
t, Double -> AxisProperty
AxGridOpacity Double
f)
conditionalAxisProperty (CAxGridWidth Double
t Double
f) = (Double -> AxisProperty
AxGridWidth Double
t, Double -> AxisProperty
AxGridWidth Double
f)
conditionalAxisProperty (CAxLabelAlign HAlign
t HAlign
f) = (HAlign -> AxisProperty
AxLabelAlign HAlign
t, HAlign -> AxisProperty
AxLabelAlign HAlign
f)
conditionalAxisProperty (CAxLabelBaseline VAlign
t VAlign
f) = (VAlign -> AxisProperty
AxLabelBaseline VAlign
t, VAlign -> AxisProperty
AxLabelBaseline VAlign
f)
conditionalAxisProperty (CAxLabelColor Text
t Text
f) = (Text -> AxisProperty
AxLabelColor Text
t, Text -> AxisProperty
AxLabelColor Text
f)
conditionalAxisProperty (CAxLabelFont Text
t Text
f) = (Text -> AxisProperty
AxLabelFont Text
t, Text -> AxisProperty
AxLabelFont Text
f)
conditionalAxisProperty (CAxLabelFontSize Double
t Double
f) = (Double -> AxisProperty
AxLabelFontSize Double
t, Double -> AxisProperty
AxLabelFontSize Double
f)
conditionalAxisProperty (CAxLabelFontStyle Text
t Text
f) = (Text -> AxisProperty
AxLabelFontStyle Text
t, Text -> AxisProperty
AxLabelFontStyle Text
f)
conditionalAxisProperty (CAxLabelFontWeight FontWeight
t FontWeight
f) = (FontWeight -> AxisProperty
AxLabelFontWeight FontWeight
t, FontWeight -> AxisProperty
AxLabelFontWeight FontWeight
f)
conditionalAxisProperty (CAxLabelOffset Double
t Double
f) = (Double -> AxisProperty
AxLabelOffset Double
t, Double -> AxisProperty
AxLabelOffset Double
f)
conditionalAxisProperty (CAxLabelOpacity Double
t Double
f) = (Double -> AxisProperty
AxLabelOpacity Double
t, Double -> AxisProperty
AxLabelOpacity Double
f)
conditionalAxisProperty (CAxLabelPadding Double
t Double
f) = (Double -> AxisProperty
AxLabelPadding Double
t, Double -> AxisProperty
AxLabelPadding Double
f)
conditionalAxisProperty (CAxTickColor Text
t Text
f) = (Text -> AxisProperty
AxTickColor Text
t, Text -> AxisProperty
AxTickColor Text
f)
conditionalAxisProperty (CAxTickDash [Double]
t [Double]
f) = ([Double] -> AxisProperty
AxTickDash [Double]
t, [Double] -> AxisProperty
AxTickDash [Double]
f)
conditionalAxisProperty (CAxTickDashOffset Double
t Double
f) = (Double -> AxisProperty
AxTickDashOffset Double
t, Double -> AxisProperty
AxTickDashOffset Double
f)
conditionalAxisProperty (CAxTickOpacity Double
t Double
f) = (Double -> AxisProperty
AxTickOpacity Double
t, Double -> AxisProperty
AxTickOpacity Double
f)
conditionalAxisProperty (CAxTickSize Double
t Double
f) = (Double -> AxisProperty
AxTickSize Double
t, Double -> AxisProperty
AxTickSize Double
f)
conditionalAxisProperty (CAxTickWidth Double
t Double
f) = (Double -> AxisProperty
AxTickWidth Double
t, Double -> AxisProperty
AxTickWidth Double
f)
autosize :: [Autosize] -> PropertySpec
autosize :: [Autosize] -> PropertySpec
autosize [Autosize]
aus = (VLProperty
VLAutosize, [Pair] -> VLSpec
object ((Autosize -> Pair) -> [Autosize] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map Autosize -> Pair
autosizeProperty [Autosize]
aus))
viewBackground :: [ViewBackground] -> PropertySpec
viewBackground :: [ViewBackground] -> PropertySpec
viewBackground [ViewBackground]
vbs = (VLProperty
VLViewBackground, [Pair] -> VLSpec
object ((ViewBackground -> Pair) -> [ViewBackground] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map ViewBackground -> Pair
viewBackgroundSpec [ViewBackground]
vbs))
data BooleanOp
= Expr VegaExpr
| FilterOp Filter
| FilterOpTrans MarkChannel Filter
| Selection SelectionLabel
| SelectionName SelectionLabel
| And BooleanOp BooleanOp
| Or BooleanOp BooleanOp
| Not BooleanOp
booleanOpSpec :: BooleanOp -> VLSpec
booleanOpSpec :: BooleanOp -> VLSpec
booleanOpSpec (Expr Text
expr) = Text -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Text
expr
booleanOpSpec (FilterOp Filter
f) = Filter -> VLSpec
filterSpec Filter
f
booleanOpSpec (FilterOpTrans MarkChannel
tr Filter
f) = MarkChannel -> Filter -> VLSpec
trFilterSpec MarkChannel
tr Filter
f
booleanOpSpec (SelectionName Text
selName) = Text -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Text
selName
booleanOpSpec (Selection Text
sel) = [Pair] -> VLSpec
object [Key
"selection" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
sel]
booleanOpSpec (And BooleanOp
operand1 BooleanOp
operand2) = [Pair] -> VLSpec
object [Key
"and" Key -> [VLSpec] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [BooleanOp -> VLSpec
booleanOpSpec BooleanOp
operand1, BooleanOp -> VLSpec
booleanOpSpec BooleanOp
operand2]]
booleanOpSpec (Or BooleanOp
operand1 BooleanOp
operand2) = [Pair] -> VLSpec
object [Key
"or" Key -> [VLSpec] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [BooleanOp -> VLSpec
booleanOpSpec BooleanOp
operand1, BooleanOp -> VLSpec
booleanOpSpec BooleanOp
operand2]]
booleanOpSpec (Not BooleanOp
operand) = [Pair] -> VLSpec
object [Key
"not" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BooleanOp -> VLSpec
booleanOpSpec BooleanOp
operand]
data Filter
= FEqual FieldName DataValue
| FLessThan FieldName DataValue
| FLessThanEq FieldName DataValue
| FGreaterThan FieldName DataValue
| FGreaterThanEq FieldName DataValue
| FExpr VegaExpr
| FCompose BooleanOp
| FSelection SelectionLabel
| FOneOf FieldName DataValues
| FRange FieldName FilterRange
| FValid FieldName
#if MIN_VERSION_aeson(2, 0, 0)
fop_ :: FieldName -> Key.Key -> DataValue -> [Pair]
#else
fop_ :: FieldName -> T.Text -> DataValue -> [Pair]
#endif
fop_ :: Text -> Key -> DataValue -> [Pair]
fop_ Text
field Key
label DataValue
val = [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field,
Key
label Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DataValue -> VLSpec
dataValueSpec DataValue
val]
filterProperty :: Filter -> [Pair]
filterProperty :: Filter -> [Pair]
filterProperty (FEqual Text
field DataValue
val) = Text -> Key -> DataValue -> [Pair]
fop_ Text
field Key
"equal" DataValue
val
filterProperty (FLessThan Text
field DataValue
val) = Text -> Key -> DataValue -> [Pair]
fop_ Text
field Key
"lt" DataValue
val
filterProperty (FLessThanEq Text
field DataValue
val) = Text -> Key -> DataValue -> [Pair]
fop_ Text
field Key
"lte" DataValue
val
filterProperty (FGreaterThan Text
field DataValue
val) = Text -> Key -> DataValue -> [Pair]
fop_ Text
field Key
"gt" DataValue
val
filterProperty (FGreaterThanEq Text
field DataValue
val) = Text -> Key -> DataValue -> [Pair]
fop_ Text
field Key
"gte" DataValue
val
filterProperty (FSelection Text
selName) = [Key
"selection" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
selName]
filterProperty (FRange Text
field FilterRange
vals) =
let ans :: [VLSpec]
ans = case FilterRange
vals of
NumberRange Double
mn Double
mx -> (Double -> VLSpec) -> [Double] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Double
mn, Double
mx]
NumberRangeLL Double
mn -> [Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
mn, VLSpec
A.Null]
NumberRangeUL Double
mx -> [VLSpec
A.Null, Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
mx]
DateRange [DateTime]
dMin [DateTime]
dMax -> [[DateTime] -> VLSpec
process [DateTime]
dMin, [DateTime] -> VLSpec
process [DateTime]
dMax]
process :: [DateTime] -> VLSpec
process [] = VLSpec
A.Null
process [DateTime]
dts = [DateTime] -> VLSpec
dateTimeSpec [DateTime]
dts
in [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field, Key
"range" Key -> [VLSpec] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [VLSpec]
ans]
filterProperty (FOneOf Text
field DataValues
vals) =
let ans :: [VLSpec]
ans = case DataValues
vals of
Numbers [Double]
xs -> (Double -> VLSpec) -> [Double] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Double]
xs
DateTimes [[DateTime]]
dts -> ([DateTime] -> VLSpec) -> [[DateTime]] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map [DateTime] -> VLSpec
dateTimeSpec [[DateTime]]
dts
Strings [Text]
ss -> (Text -> VLSpec) -> [Text] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map Text -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
ss
Booleans [Bool]
bs -> (Bool -> VLSpec) -> [Bool] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map Bool -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Bool]
bs
in [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field, Key
"oneOf" Key -> [VLSpec] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [VLSpec]
ans]
filterProperty (FValid Text
field) = [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field, Key
"valid" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
True]
filterProperty Filter
_ = []
filterSpec :: Filter -> VLSpec
filterSpec :: Filter -> VLSpec
filterSpec (FExpr Text
expr) = Text -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Text
expr
filterSpec (FCompose BooleanOp
boolExpr) = BooleanOp -> VLSpec
booleanOpSpec BooleanOp
boolExpr
filterSpec Filter
f = [Pair] -> VLSpec
object (Filter -> [Pair]
filterProperty Filter
f)
trFilterSpec :: MarkChannel -> Filter -> VLSpec
trFilterSpec :: MarkChannel -> Filter -> VLSpec
trFilterSpec MarkChannel
_ (FExpr Text
expr) = Text -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Text
expr
trFilterSpec MarkChannel
_ (FCompose BooleanOp
boolExpr) = BooleanOp -> VLSpec
booleanOpSpec BooleanOp
boolExpr
trFilterSpec MarkChannel
mchan Filter
fi = [Pair] -> VLSpec
object (MarkChannel -> [Pair]
markChannelProperty MarkChannel
mchan [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Filter -> [Pair]
filterProperty Filter
fi)
data FilterRange
= NumberRange Double Double
| NumberRangeLL Double
| NumberRangeUL Double
| DateRange [DateTime] [DateTime]
data HyperlinkChannel
= HName FieldName
| HRepeat Arrangement
| HmType Measurement
| HAggregate Operation
| HyBand Double
| HBin [BinProperty]
| HBinned
| HSelectionCondition BooleanOp [HyperlinkChannel] [HyperlinkChannel]
| HDataCondition [(BooleanOp, [HyperlinkChannel])] [HyperlinkChannel]
| HyFormat T.Text
| HyFormatAsNum
| HyFormatAsTemporal
| HyFormatAsCustom T.Text
| HyLabelExpr VegaExpr
| HString T.Text
| HTimeUnit TimeUnit
| HyTitle T.Text
| HyNoTitle
hyperlinkChannelProperty :: HyperlinkChannel -> [Pair]
hyperlinkChannelProperty :: HyperlinkChannel -> [Pair]
hyperlinkChannelProperty (HName Text
s) = [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
hyperlinkChannelProperty (HRepeat Arrangement
arr) = [Key
"field" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr]]
hyperlinkChannelProperty (HmType Measurement
t) = [Measurement -> Pair
mtype_ Measurement
t]
hyperlinkChannelProperty (HAggregate Operation
op) = [Operation -> Pair
aggregate_ Operation
op]
hyperlinkChannelProperty (HyBand Double
x) = [Key
"band" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x]
hyperlinkChannelProperty (HBin [BinProperty]
bps) = [[BinProperty] -> Pair
bin [BinProperty]
bps]
hyperlinkChannelProperty HyperlinkChannel
HBinned = [Pair
binned_]
hyperlinkChannelProperty (HSelectionCondition BooleanOp
selName [HyperlinkChannel]
ifClause [HyperlinkChannel]
elseClause) =
(HyperlinkChannel -> [Pair])
-> BooleanOp -> [HyperlinkChannel] -> [HyperlinkChannel] -> [Pair]
forall a. (a -> [Pair]) -> BooleanOp -> [a] -> [a] -> [Pair]
selCond_ HyperlinkChannel -> [Pair]
hyperlinkChannelProperty BooleanOp
selName [HyperlinkChannel]
ifClause [HyperlinkChannel]
elseClause
hyperlinkChannelProperty (HDataCondition [(BooleanOp, [HyperlinkChannel])]
tests [HyperlinkChannel]
elseClause) =
(HyperlinkChannel -> [Pair])
-> [(BooleanOp, [HyperlinkChannel])]
-> [HyperlinkChannel]
-> [Pair]
forall a. (a -> [Pair]) -> [(BooleanOp, [a])] -> [a] -> [Pair]
dataCond_ HyperlinkChannel -> [Pair]
hyperlinkChannelProperty [(BooleanOp, [HyperlinkChannel])]
tests [HyperlinkChannel]
elseClause
hyperlinkChannelProperty (HyFormat Text
fmt) = [Key
"format" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fmt]
hyperlinkChannelProperty HyperlinkChannel
HyFormatAsNum = [Key
"formatType" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"number"]
hyperlinkChannelProperty HyperlinkChannel
HyFormatAsTemporal = [Key
"formatType" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"time"]
hyperlinkChannelProperty (HyFormatAsCustom Text
c) = [Key
"formatType" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
c]
hyperlinkChannelProperty (HyLabelExpr Text
lbl) = [Key
"labelExpr" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
lbl]
hyperlinkChannelProperty (HString Text
s) = [Text -> Pair
value_ Text
s]
hyperlinkChannelProperty (HTimeUnit TimeUnit
tu) = [TimeUnit -> Pair
timeUnit_ TimeUnit
tu]
hyperlinkChannelProperty (HyTitle Text
t) = [Key
"title" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t]
hyperlinkChannelProperty HyperlinkChannel
HyNoTitle = [Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null]
data AriaDescriptionChannel
= ADName FieldName
| ADRepeat Arrangement
| ADmType Measurement
| ADAggregate Operation
| ADBand Double
| ADBin [BinProperty]
| ADBinned
| ADSelectionCondition BooleanOp [AriaDescriptionChannel] [AriaDescriptionChannel]
| ADDataCondition [(BooleanOp, [AriaDescriptionChannel])] [AriaDescriptionChannel]
| ADFormat T.Text
| ADFormatAsNum
| ADFormatAsTemporal
| ADFormatAsCustom T.Text
| ADLabelExpr VegaExpr
| ADString T.Text
| ADTimeUnit TimeUnit
| ADTitle T.Text
| ADNoTitle
ariaDescriptionChannelProperty :: AriaDescriptionChannel -> [Pair]
ariaDescriptionChannelProperty :: AriaDescriptionChannel -> [Pair]
ariaDescriptionChannelProperty (ADName Text
s) = [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
ariaDescriptionChannelProperty (ADRepeat Arrangement
arr) = [Key
"field" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr]]
ariaDescriptionChannelProperty (ADmType Measurement
t) = [Measurement -> Pair
mtype_ Measurement
t]
ariaDescriptionChannelProperty (ADAggregate Operation
op) = [Operation -> Pair
aggregate_ Operation
op]
ariaDescriptionChannelProperty (ADBand Double
x) = [Key
"band" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x]
ariaDescriptionChannelProperty (ADBin [BinProperty]
bps) = [[BinProperty] -> Pair
bin [BinProperty]
bps]
ariaDescriptionChannelProperty AriaDescriptionChannel
ADBinned = [Pair
binned_]
ariaDescriptionChannelProperty (ADSelectionCondition BooleanOp
selName [AriaDescriptionChannel]
ifClause [AriaDescriptionChannel]
elseClause) =
(AriaDescriptionChannel -> [Pair])
-> BooleanOp
-> [AriaDescriptionChannel]
-> [AriaDescriptionChannel]
-> [Pair]
forall a. (a -> [Pair]) -> BooleanOp -> [a] -> [a] -> [Pair]
selCond_ AriaDescriptionChannel -> [Pair]
ariaDescriptionChannelProperty BooleanOp
selName [AriaDescriptionChannel]
ifClause [AriaDescriptionChannel]
elseClause
ariaDescriptionChannelProperty (ADDataCondition [(BooleanOp, [AriaDescriptionChannel])]
tests [AriaDescriptionChannel]
elseClause) =
(AriaDescriptionChannel -> [Pair])
-> [(BooleanOp, [AriaDescriptionChannel])]
-> [AriaDescriptionChannel]
-> [Pair]
forall a. (a -> [Pair]) -> [(BooleanOp, [a])] -> [a] -> [Pair]
dataCond_ AriaDescriptionChannel -> [Pair]
ariaDescriptionChannelProperty [(BooleanOp, [AriaDescriptionChannel])]
tests [AriaDescriptionChannel]
elseClause
ariaDescriptionChannelProperty (ADFormat Text
fmt) = [Key
"format" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fmt]
ariaDescriptionChannelProperty AriaDescriptionChannel
ADFormatAsNum = [Key
"formatType" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"number"]
ariaDescriptionChannelProperty AriaDescriptionChannel
ADFormatAsTemporal = [Key
"formatType" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"time"]
ariaDescriptionChannelProperty (ADFormatAsCustom Text
c) = [Key
"formatType" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
c]
ariaDescriptionChannelProperty (ADLabelExpr Text
lbl) = [Key
"labelExpr" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
lbl]
ariaDescriptionChannelProperty (ADString Text
s) = [Text -> Pair
value_ Text
s]
ariaDescriptionChannelProperty (ADTimeUnit TimeUnit
tu) = [TimeUnit -> Pair
timeUnit_ TimeUnit
tu]
ariaDescriptionChannelProperty (ADTitle Text
t) = [Key
"title" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t]
ariaDescriptionChannelProperty AriaDescriptionChannel
ADNoTitle = [Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null]
domainRangeMap :: (Double, Color) -> (Double, Color) -> [ScaleProperty]
domainRangeMap :: (Double, Text) -> (Double, Text) -> [ScaleProperty]
domainRangeMap (Double, Text)
lowerMap (Double, Text)
upperMap =
let ([Double]
domain, [Text]
range) = [(Double, Text)] -> ([Double], [Text])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Double, Text)
lowerMap, (Double, Text)
upperMap]
in [DomainLimits -> ScaleProperty
SDomain ([Double] -> DomainLimits
DNumbers [Double]
domain), ScaleRange -> ScaleProperty
SRange ([Text] -> ScaleRange
RStrings [Text]
range)]
categoricalDomainMap :: [(T.Text, Color)] -> [ScaleProperty]
categoricalDomainMap :: [(Text, Text)] -> [ScaleProperty]
categoricalDomainMap [(Text, Text)]
scaleDomainPairs =
let ([Text]
domain, [Text]
range) = [(Text, Text)] -> ([Text], [Text])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Text, Text)]
scaleDomainPairs
in [DomainLimits -> ScaleProperty
SDomain ([Text] -> DomainLimits
DStrings [Text]
domain), ScaleRange -> ScaleProperty
SRange ([Text] -> ScaleRange
RStrings [Text]
range)]
data FacetChannel
= FName FieldName
| FmType Measurement
| FAggregate Operation
| FAlign CompositionAlignment
| FBin [BinProperty]
| FCenter Bool
| [HeaderProperty]
| FSort [SortProperty]
| FSpacing Double
| FTimeUnit TimeUnit
| FTitle T.Text
| FNoTitle
facetChannelProperty :: FacetChannel -> Pair
facetChannelProperty :: FacetChannel -> Pair
facetChannelProperty (FName Text
s) = Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
facetChannelProperty (FmType Measurement
measure) = Measurement -> Pair
mtype_ Measurement
measure
facetChannelProperty (FAlign CompositionAlignment
algn) = Key
"align" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= CompositionAlignment -> VLSpec
compositionAlignmentSpec CompositionAlignment
algn
facetChannelProperty (FAggregate Operation
op) = Operation -> Pair
aggregate_ Operation
op
facetChannelProperty (FBin [BinProperty]
bps) = [BinProperty] -> Pair
bin [BinProperty]
bps
facetChannelProperty (FCenter Bool
b) = Key
"center" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
facetChannelProperty (FHeader [HeaderProperty]
hps) = (Text, VLSpec) -> Pair
toKey (Text -> [HeaderProperty] -> (Text, VLSpec)
header_ Text
"" [HeaderProperty]
hps)
facetChannelProperty (FSort [SortProperty]
sps) = [SortProperty] -> Pair
sort_ [SortProperty]
sps
facetChannelProperty (FSpacing Double
x) = Key
"spacing" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
facetChannelProperty (FTitle Text
s) = Key
"title" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
facetChannelProperty FacetChannel
FNoTitle = Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null
facetChannelProperty (FTimeUnit TimeUnit
tu) = TimeUnit -> Pair
timeUnit_ TimeUnit
tu
data TextChannel
= TName FieldName
| TRepeat Arrangement
| TRepeatDatum Arrangement
| TmType Measurement
| TAggregate Operation
| TBand Double
| TBin [BinProperty]
| TBinned
| TDataCondition [(BooleanOp, [TextChannel])] [TextChannel]
| TSelectionCondition BooleanOp [TextChannel] [TextChannel]
| TDatum DataValue
| TFormat T.Text
| TFormatAsNum
| TFormatAsTemporal
| TFormatAsCustom T.Text
| TLabelExpr VegaExpr
| TString T.Text
| TStrings [T.Text]
| TTimeUnit TimeUnit
| TTitle T.Text
| TNoTitle
textChannelProperty :: TextChannel -> [Pair]
textChannelProperty :: TextChannel -> [Pair]
textChannelProperty (TName Text
s) = [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
textChannelProperty (TRepeat Arrangement
arr) = [Key
"field" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr]]
textChannelProperty (TRepeatDatum Arrangement
arr) = [Key
"datum" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr]]
textChannelProperty (TmType Measurement
measure) = [Measurement -> Pair
mtype_ Measurement
measure]
textChannelProperty (TAggregate Operation
op) = [Operation -> Pair
aggregate_ Operation
op]
textChannelProperty (TBand Double
x) = [Key
"band" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x]
textChannelProperty (TBin [BinProperty]
bps) = [[BinProperty] -> Pair
bin [BinProperty]
bps]
textChannelProperty TextChannel
TBinned = [Pair
binned_]
textChannelProperty (TDataCondition [(BooleanOp, [TextChannel])]
tests [TextChannel]
elseClause) =
(TextChannel -> [Pair])
-> [(BooleanOp, [TextChannel])] -> [TextChannel] -> [Pair]
forall a. (a -> [Pair]) -> [(BooleanOp, [a])] -> [a] -> [Pair]
dataCond_ TextChannel -> [Pair]
textChannelProperty [(BooleanOp, [TextChannel])]
tests [TextChannel]
elseClause
textChannelProperty (TSelectionCondition BooleanOp
selName [TextChannel]
ifClause [TextChannel]
elseClause) =
(TextChannel -> [Pair])
-> BooleanOp -> [TextChannel] -> [TextChannel] -> [Pair]
forall a. (a -> [Pair]) -> BooleanOp -> [a] -> [a] -> [Pair]
selCond_ TextChannel -> [Pair]
textChannelProperty BooleanOp
selName [TextChannel]
ifClause [TextChannel]
elseClause
textChannelProperty (TDatum DataValue
dv) = [Key
"datum" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DataValue -> VLSpec
dataValueSpec DataValue
dv]
textChannelProperty (TFormat Text
fmt) = [Key
"format" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fmt]
textChannelProperty TextChannel
TFormatAsNum = [Key
"formatType" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"number"]
textChannelProperty TextChannel
TFormatAsTemporal = [Key
"formatType" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"time"]
textChannelProperty (TFormatAsCustom Text
c) = [Key
"formatType" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
c]
textChannelProperty (TLabelExpr Text
e) = [Key
"labelExpr" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
e]
textChannelProperty (TString Text
s) = [Key
"value" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
textChannelProperty (TStrings [Text]
xs) = [Key
"value" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
xs]
textChannelProperty (TTimeUnit TimeUnit
tu) = [TimeUnit -> Pair
timeUnit_ TimeUnit
tu]
textChannelProperty (TTitle Text
s) = [Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
splitOnNewline Text
s]
textChannelProperty TextChannel
TNoTitle = [Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null]
data OrderChannel
= OName FieldName
| ORepeat Arrangement
| OAggregate Operation
| OBand Double
| OBin [BinProperty]
| OSort [SortProperty]
| OTimeUnit TimeUnit
| OTitle T.Text
| ONoTitle
| OmType Measurement
| ODataCondition [(BooleanOp, [OrderChannel])] [OrderChannel]
| OSelectionCondition BooleanOp [OrderChannel] [OrderChannel]
| ONumber Double
orderChannelProperty :: OrderChannel -> [Pair]
orderChannelProperty :: OrderChannel -> [Pair]
orderChannelProperty (OAggregate Operation
op) = [Operation -> Pair
aggregate_ Operation
op]
orderChannelProperty (OBand Double
x) = [Key
"band" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x]
orderChannelProperty (OBin [BinProperty]
bps) = [[BinProperty] -> Pair
bin [BinProperty]
bps]
orderChannelProperty (OName Text
s) = [Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
orderChannelProperty (ORepeat Arrangement
arr) = [Key
"field" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Arrangement -> Pair
repeat_ Arrangement
arr]]
orderChannelProperty (OSort [SortProperty]
ops) = [[SortProperty] -> Pair
sort_ [SortProperty]
ops]
orderChannelProperty (OTimeUnit TimeUnit
tu) = [TimeUnit -> Pair
timeUnit_ TimeUnit
tu]
orderChannelProperty (OTitle Text
s) = [Key
"title" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
orderChannelProperty OrderChannel
ONoTitle = [Key
"title" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null]
orderChannelProperty (OmType Measurement
measure) = [Measurement -> Pair
mtype_ Measurement
measure]
orderChannelProperty (ODataCondition [(BooleanOp, [OrderChannel])]
tests [OrderChannel]
elseClause) =
(OrderChannel -> [Pair])
-> [(BooleanOp, [OrderChannel])] -> [OrderChannel] -> [Pair]
forall a. (a -> [Pair]) -> [(BooleanOp, [a])] -> [a] -> [Pair]
dataCond_ OrderChannel -> [Pair]
orderChannelProperty [(BooleanOp, [OrderChannel])]
tests [OrderChannel]
elseClause
orderChannelProperty (OSelectionCondition BooleanOp
selName [OrderChannel]
ifClause [OrderChannel]
elseClause) =
(OrderChannel -> [Pair])
-> BooleanOp -> [OrderChannel] -> [OrderChannel] -> [Pair]
forall a. (a -> [Pair]) -> BooleanOp -> [a] -> [a] -> [Pair]
selCond_ OrderChannel -> [Pair]
orderChannelProperty BooleanOp
selName [OrderChannel]
ifClause [OrderChannel]
elseClause
orderChannelProperty (ONumber Double
n) = [Key
"value" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
n]
data DetailChannel
= DName FieldName
| DmType Measurement
| DBin [BinProperty]
| DTimeUnit TimeUnit
| DAggregate Operation
detailChannelProperty :: DetailChannel -> Pair
detailChannelProperty :: DetailChannel -> Pair
detailChannelProperty (DName Text
s) = Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
detailChannelProperty (DmType Measurement
t) = Measurement -> Pair
mtype_ Measurement
t
detailChannelProperty (DBin [BinProperty]
bps) = [BinProperty] -> Pair
bin [BinProperty]
bps
detailChannelProperty (DTimeUnit TimeUnit
tu) = TimeUnit -> Pair
timeUnit_ TimeUnit
tu
detailChannelProperty (DAggregate Operation
op) = Operation -> Pair
aggregate_ Operation
op
data FacetMapping
= ColumnBy [FacetChannel]
| RowBy [FacetChannel]
facetMappingProperty :: FacetMapping -> Pair
facetMappingProperty :: FacetMapping -> Pair
facetMappingProperty (RowBy [FacetChannel]
fFields) =
Key
"row" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object ((FacetChannel -> Pair) -> [FacetChannel] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map FacetChannel -> Pair
facetChannelProperty [FacetChannel]
fFields)
facetMappingProperty (ColumnBy [FacetChannel]
fFields) =
Key
"column" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object ((FacetChannel -> Pair) -> [FacetChannel] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map FacetChannel -> Pair
facetChannelProperty [FacetChannel]
fFields)
configure ::
[ConfigureSpec]
-> PropertySpec
configure :: [ConfigureSpec] -> PropertySpec
configure [ConfigureSpec]
configs = (VLProperty
VLConfig, [(Text, VLSpec)] -> VLSpec
toObject ((ConfigureSpec -> (Text, VLSpec))
-> [ConfigureSpec] -> [(Text, VLSpec)]
forall a b. (a -> b) -> [a] -> [b]
map ConfigureSpec -> (Text, VLSpec)
unCS [ConfigureSpec]
configs))
align :: CompositionAlignment -> PropertySpec
align :: CompositionAlignment -> PropertySpec
align CompositionAlignment
algn = (VLProperty
VLAlign, CompositionAlignment -> VLSpec
compositionAlignmentSpec CompositionAlignment
algn)
alignRC ::
CompositionAlignment
-> CompositionAlignment
-> PropertySpec
alignRC :: CompositionAlignment -> CompositionAlignment -> PropertySpec
alignRC CompositionAlignment
alRow CompositionAlignment
alCol =
(VLProperty
VLSpacing, [Pair] -> VLSpec
object [ Key
"row" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= CompositionAlignment -> VLSpec
compositionAlignmentSpec CompositionAlignment
alRow
, Key
"col" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= CompositionAlignment -> VLSpec
compositionAlignmentSpec CompositionAlignment
alCol
])
spacing ::
Double
-> PropertySpec
spacing :: Double -> PropertySpec
spacing Double
sp = (VLProperty
VLSpacing, Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
sp)
spacingRC ::
Double
-> Double
-> PropertySpec
spacingRC :: Double -> Double -> PropertySpec
spacingRC Double
spRow Double
spCol = (VLProperty
VLSpacing, [Pair] -> VLSpec
object [Key
"row" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
spRow, Key
"column" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
spCol])
center :: Bool -> PropertySpec
center :: Bool -> PropertySpec
center Bool
c = (VLProperty
VLCenter, Bool -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Bool
c)
centerRC ::
Bool
-> Bool
-> PropertySpec
centerRC :: Bool -> Bool -> PropertySpec
centerRC Bool
cRow Bool
cCol = (VLProperty
VLCenter, [Pair] -> VLSpec
object [Key
"row" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
cRow, Key
"col" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
cCol])
bounds :: Bounds -> PropertySpec
bounds :: Bounds -> PropertySpec
bounds Bounds
bnds = (VLProperty
VLBounds, Bounds -> VLSpec
boundsSpec Bounds
bnds)
vlConcat :: [VLSpec] -> PropertySpec
vlConcat :: [VLSpec] -> PropertySpec
vlConcat [VLSpec]
specs = (VLProperty
VLConcat, [VLSpec] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [VLSpec]
specs)
facet :: [FacetMapping] -> PropertySpec
facet :: [FacetMapping] -> PropertySpec
facet [FacetMapping]
fMaps = (VLProperty
VLFacet, [Pair] -> VLSpec
object ((FacetMapping -> Pair) -> [FacetMapping] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map FacetMapping -> Pair
facetMappingProperty [FacetMapping]
fMaps))
facetFlow :: [FacetChannel] -> PropertySpec
facetFlow :: [FacetChannel] -> PropertySpec
facetFlow [FacetChannel]
fFields = (VLProperty
VLFacet, [Pair] -> VLSpec
object ((FacetChannel -> Pair) -> [FacetChannel] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map FacetChannel -> Pair
facetChannelProperty [FacetChannel]
fFields))
height :: Double -> PropertySpec
height :: Double -> PropertySpec
height Double
h = (VLProperty
VLHeight, Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
h)
heightOfContainer :: PropertySpec
heightOfContainer :: PropertySpec
heightOfContainer = (VLProperty
VLHeight, Text -> VLSpec
fromT Text
"container")
heightStep :: Double -> PropertySpec
heightStep :: Double -> PropertySpec
heightStep Double
s = (VLProperty
VLHeight, [Pair] -> VLSpec
object [ Key
"step" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
s ])
hConcat :: [VLSpec] -> PropertySpec
hConcat :: [VLSpec] -> PropertySpec
hConcat [VLSpec]
specs = (VLProperty
VLHConcat, [VLSpec] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [VLSpec]
specs)
layer :: [VLSpec] -> PropertySpec
layer :: [VLSpec] -> PropertySpec
layer [VLSpec]
specs = (VLProperty
VLLayer, [VLSpec] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [VLSpec]
specs)
name :: T.Text -> PropertySpec
name :: Text -> PropertySpec
name Text
s = (VLProperty
VLName, Text -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Text
s)
padding :: Padding -> PropertySpec
padding :: Padding -> PropertySpec
padding Padding
pad = (VLProperty
VLPadding, Padding -> VLSpec
paddingSpec Padding
pad)
repeat :: [RepeatFields] -> PropertySpec
repeat :: [RepeatFields] -> PropertySpec
repeat [RepeatFields]
fields = (VLProperty
VLRepeat, [Pair] -> VLSpec
object ((RepeatFields -> Pair) -> [RepeatFields] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map RepeatFields -> Pair
repeatFieldsProperty [RepeatFields]
fields))
repeatFlow ::
[FieldName]
-> PropertySpec
repeatFlow :: [Text] -> PropertySpec
repeatFlow [Text]
fields = (VLProperty
VLRepeat, [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
fields)
resolve ::
[ResolveSpec]
-> PropertySpec
resolve :: [ResolveSpec] -> PropertySpec
resolve [ResolveSpec]
res = (VLProperty
VLResolve, [(Text, VLSpec)] -> VLSpec
toObject ((ResolveSpec -> (Text, VLSpec))
-> [ResolveSpec] -> [(Text, VLSpec)]
forall a b. (a -> b) -> [a] -> [b]
map ResolveSpec -> (Text, VLSpec)
unRS [ResolveSpec]
res))
transform ::
[TransformSpec]
-> PropertySpec
transform :: [TransformSpec] -> PropertySpec
transform [TransformSpec]
transforms =
let js :: VLSpec
js = if [TransformSpec] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [TransformSpec]
transforms then VLSpec
A.Null else [VLSpec] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON ((TransformSpec -> VLSpec) -> [TransformSpec] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map TransformSpec -> VLSpec
unTS [TransformSpec]
transforms)
in (VLProperty
VLTransform, VLSpec
js)
vConcat :: [VLSpec] -> PropertySpec
vConcat :: [VLSpec] -> PropertySpec
vConcat [VLSpec]
specs = (VLProperty
VLVConcat, [VLSpec] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [VLSpec]
specs)
width :: Double -> PropertySpec
width :: Double -> PropertySpec
width Double
w = (VLProperty
VLWidth, Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
w)
widthOfContainer :: PropertySpec
widthOfContainer :: PropertySpec
widthOfContainer = (VLProperty
VLWidth, Text -> VLSpec
fromT Text
"container")
widthStep :: Double -> PropertySpec
widthStep :: Double -> PropertySpec
widthStep Double
s = (VLProperty
VLWidth, [Pair] -> VLSpec
object [ Key
"step" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
s ])
aggregate ::
[VLSpec]
-> [FieldName]
-> BuildTransformSpecs
aggregate :: [VLSpec] -> [Text] -> BuildTransformSpecs
aggregate [VLSpec]
ops [Text]
groups [TransformSpec]
ols =
let fields :: [Pair]
fields = [ Key
"aggregate" Key -> [VLSpec] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [VLSpec]
ops
, Key
"groupby" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
groups ]
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
fields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
joinAggregate ::
[VLSpec]
-> [WindowProperty]
-> BuildTransformSpecs
joinAggregate :: [VLSpec] -> [WindowProperty] -> BuildTransformSpecs
joinAggregate [VLSpec]
ops [WindowProperty]
wProps [TransformSpec]
ols = [VLSpec] -> [WindowProperty] -> TransformSpec
joinAggregateTS [VLSpec]
ops [WindowProperty]
wProps TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
window ::
[([Window], FieldName)]
-> [WindowProperty]
-> BuildTransformSpecs
window :: [([Window], Text)] -> [WindowProperty] -> BuildTransformSpecs
window [([Window], Text)]
wss [WindowProperty]
wProps [TransformSpec]
ols = [([Window], Text)] -> [WindowProperty] -> TransformSpec
windowTS [([Window], Text)]
wss [WindowProperty]
wProps TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
sample :: Int -> BuildTransformSpecs
sample :: Int -> BuildTransformSpecs
sample Int
maxSize [TransformSpec]
ols = VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [ Key
"sample" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
maxSize ]) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
data DensityProperty
= DnAs FieldName FieldName
| DnBandwidth Double
| DnCounts Bool
| DnCumulative Bool
| DnExtent Double Double
| DnGroupBy [FieldName]
| DnMaxSteps Natural
| DnMinSteps Natural
| DnSteps Natural
data DensityPropertyLabel =
DPLGroupby | DPLCumulative | DPLCounts | DPLBandwidth | DPLExtent |
DPLMinsteps | DPLMaxsteps | DPLSteps | DPLAs
densityPropertySpec :: DensityPropertyLabel -> [DensityProperty] -> VLSpec
densityPropertySpec :: DensityPropertyLabel -> [DensityProperty] -> VLSpec
densityPropertySpec DensityPropertyLabel
DPLGroupby [DensityProperty]
ps =
let wanted :: DensityProperty -> Maybe [Text]
wanted (DnGroupBy [Text]
xs) = [Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text]
xs
wanted DensityProperty
_ = Maybe [Text]
forall a. Maybe a
Nothing
in case (DensityProperty -> Maybe [Text]) -> [DensityProperty] -> [[Text]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DensityProperty -> Maybe [Text]
wanted [DensityProperty]
ps of
[[Text]
x] -> [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
x
[[Text]]
_ -> VLSpec
A.Null
densityPropertySpec DensityPropertyLabel
DPLCumulative [DensityProperty]
ps =
let wanted :: DensityProperty -> Maybe Bool
wanted (DnCumulative Bool
xs) = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
xs
wanted DensityProperty
_ = Maybe Bool
forall a. Maybe a
Nothing
in case (DensityProperty -> Maybe Bool) -> [DensityProperty] -> [Bool]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DensityProperty -> Maybe Bool
wanted [DensityProperty]
ps of
[Bool
x] -> Bool -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Bool
x
[Bool]
_ -> VLSpec
A.Null
densityPropertySpec DensityPropertyLabel
DPLCounts [DensityProperty]
ps =
let wanted :: DensityProperty -> Maybe Bool
wanted (DnCounts Bool
xs) = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
xs
wanted DensityProperty
_ = Maybe Bool
forall a. Maybe a
Nothing
in case (DensityProperty -> Maybe Bool) -> [DensityProperty] -> [Bool]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DensityProperty -> Maybe Bool
wanted [DensityProperty]
ps of
[Bool
x] -> Bool -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Bool
x
[Bool]
_ -> VLSpec
A.Null
densityPropertySpec DensityPropertyLabel
DPLBandwidth [DensityProperty]
ps =
let wanted :: DensityProperty -> Maybe Double
wanted (DnBandwidth Double
xs) = Double -> Maybe Double
forall a. a -> Maybe a
Just Double
xs
wanted DensityProperty
_ = Maybe Double
forall a. Maybe a
Nothing
in case (DensityProperty -> Maybe Double) -> [DensityProperty] -> [Double]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DensityProperty -> Maybe Double
wanted [DensityProperty]
ps of
[Double
x] -> Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
x
[Double]
_ -> VLSpec
A.Null
densityPropertySpec DensityPropertyLabel
DPLExtent [DensityProperty]
ps =
let wanted :: DensityProperty -> Maybe [Double]
wanted (DnExtent Double
xs Double
ys) = [Double] -> Maybe [Double]
forall a. a -> Maybe a
Just [Double
xs, Double
ys]
wanted DensityProperty
_ = Maybe [Double]
forall a. Maybe a
Nothing
in case (DensityProperty -> Maybe [Double])
-> [DensityProperty] -> [[Double]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DensityProperty -> Maybe [Double]
wanted [DensityProperty]
ps of
[[Double]
x] -> [Double] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Double]
x
[[Double]]
_ -> VLSpec
A.Null
densityPropertySpec DensityPropertyLabel
DPLMinsteps [DensityProperty]
ps =
let wanted :: DensityProperty -> Maybe ZIndex
wanted (DnMinSteps ZIndex
xs) = ZIndex -> Maybe ZIndex
forall a. a -> Maybe a
Just ZIndex
xs
wanted DensityProperty
_ = Maybe ZIndex
forall a. Maybe a
Nothing
in case (DensityProperty -> Maybe ZIndex) -> [DensityProperty] -> [ZIndex]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DensityProperty -> Maybe ZIndex
wanted [DensityProperty]
ps of
[ZIndex
x] -> ZIndex -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON ZIndex
x
[ZIndex]
_ -> VLSpec
A.Null
densityPropertySpec DensityPropertyLabel
DPLMaxsteps [DensityProperty]
ps =
let wanted :: DensityProperty -> Maybe ZIndex
wanted (DnMaxSteps ZIndex
xs) = ZIndex -> Maybe ZIndex
forall a. a -> Maybe a
Just ZIndex
xs
wanted DensityProperty
_ = Maybe ZIndex
forall a. Maybe a
Nothing
in case (DensityProperty -> Maybe ZIndex) -> [DensityProperty] -> [ZIndex]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DensityProperty -> Maybe ZIndex
wanted [DensityProperty]
ps of
[ZIndex
x] -> ZIndex -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON ZIndex
x
[ZIndex]
_ -> VLSpec
A.Null
densityPropertySpec DensityPropertyLabel
DPLSteps [DensityProperty]
ps =
let wanted :: DensityProperty -> Maybe ZIndex
wanted (DnSteps ZIndex
xs) = ZIndex -> Maybe ZIndex
forall a. a -> Maybe a
Just ZIndex
xs
wanted DensityProperty
_ = Maybe ZIndex
forall a. Maybe a
Nothing
in case (DensityProperty -> Maybe ZIndex) -> [DensityProperty] -> [ZIndex]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DensityProperty -> Maybe ZIndex
wanted [DensityProperty]
ps of
[ZIndex
x] -> ZIndex -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON ZIndex
x
[ZIndex]
_ -> VLSpec
A.Null
densityPropertySpec DensityPropertyLabel
DPLAs [DensityProperty]
ps =
let wanted :: DensityProperty -> Maybe [Text]
wanted (DnAs Text
xs Text
ys) = [Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text
xs, Text
ys]
wanted DensityProperty
_ = Maybe [Text]
forall a. Maybe a
Nothing
in case (DensityProperty -> Maybe [Text]) -> [DensityProperty] -> [[Text]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DensityProperty -> Maybe [Text]
wanted [DensityProperty]
ps of
[[Text]
x] -> [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
x
[[Text]]
_ -> VLSpec
A.Null
density ::
FieldName
-> [DensityProperty]
-> BuildTransformSpecs
density :: Text -> [DensityProperty] -> BuildTransformSpecs
density Text
field [DensityProperty]
dps [TransformSpec]
ols =
let addField :: Key -> DensityPropertyLabel -> [a]
addField Key
n DensityPropertyLabel
p = case DensityPropertyLabel -> [DensityProperty] -> VLSpec
densityPropertySpec DensityPropertyLabel
p [DensityProperty]
dps of
VLSpec
A.Null -> []
VLSpec
x -> [ Key
n Key -> VLSpec -> a
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
x ]
ofields :: [Pair]
ofields = [ Key
"density" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field ]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> DensityPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> DensityPropertyLabel -> [a]
addField Key
"groupby" DensityPropertyLabel
DPLGroupby
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> DensityPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> DensityPropertyLabel -> [a]
addField Key
"cumulative" DensityPropertyLabel
DPLCumulative
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> DensityPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> DensityPropertyLabel -> [a]
addField Key
"counts" DensityPropertyLabel
DPLCounts
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> DensityPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> DensityPropertyLabel -> [a]
addField Key
"bandwidth" DensityPropertyLabel
DPLBandwidth
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> DensityPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> DensityPropertyLabel -> [a]
addField Key
"extent" DensityPropertyLabel
DPLExtent
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> DensityPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> DensityPropertyLabel -> [a]
addField Key
"minsteps" DensityPropertyLabel
DPLMinsteps
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> DensityPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> DensityPropertyLabel -> [a]
addField Key
"maxsteps" DensityPropertyLabel
DPLMaxsteps
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> DensityPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> DensityPropertyLabel -> [a]
addField Key
"steps" DensityPropertyLabel
DPLSteps
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> DensityPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> DensityPropertyLabel -> [a]
addField Key
"as" DensityPropertyLabel
DPLAs
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
ofields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
data LoessProperty
= LsAs FieldName FieldName
| LsBandwidth Double
| LsGroupBy [FieldName]
data LoessPropertyLabel = LLAs | LLBandwidth | LLGroupBy
loessPropertySpec :: LoessPropertyLabel -> [LoessProperty] -> VLSpec
loessPropertySpec :: LoessPropertyLabel -> [LoessProperty] -> VLSpec
loessPropertySpec LoessPropertyLabel
LLAs [LoessProperty]
ps =
let wanted :: LoessProperty -> Maybe [Text]
wanted (LsAs Text
xs Text
ys) = [Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text
xs, Text
ys]
wanted LoessProperty
_ = Maybe [Text]
forall a. Maybe a
Nothing
in case (LoessProperty -> Maybe [Text]) -> [LoessProperty] -> [[Text]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe LoessProperty -> Maybe [Text]
wanted [LoessProperty]
ps of
[[Text]
x] -> [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
x
[[Text]]
_ -> VLSpec
A.Null
loessPropertySpec LoessPropertyLabel
LLBandwidth [LoessProperty]
ps =
let wanted :: LoessProperty -> Maybe Double
wanted (LsBandwidth Double
xs) = Double -> Maybe Double
forall a. a -> Maybe a
Just Double
xs
wanted LoessProperty
_ = Maybe Double
forall a. Maybe a
Nothing
in case (LoessProperty -> Maybe Double) -> [LoessProperty] -> [Double]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe LoessProperty -> Maybe Double
wanted [LoessProperty]
ps of
[Double
x] -> Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
x
[Double]
_ -> VLSpec
A.Null
loessPropertySpec LoessPropertyLabel
LLGroupBy [LoessProperty]
ps =
let wanted :: LoessProperty -> Maybe [Text]
wanted (LsGroupBy [Text]
xs) = [Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text]
xs
wanted LoessProperty
_ = Maybe [Text]
forall a. Maybe a
Nothing
in case (LoessProperty -> Maybe [Text]) -> [LoessProperty] -> [[Text]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe LoessProperty -> Maybe [Text]
wanted [LoessProperty]
ps of
[[Text]
x] -> [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
x
[[Text]]
_ -> VLSpec
A.Null
loess ::
FieldName
-> FieldName
-> [LoessProperty]
-> BuildTransformSpecs
loess :: Text -> Text -> [LoessProperty] -> BuildTransformSpecs
loess Text
depField Text
indField [LoessProperty]
lsp [TransformSpec]
ols =
let addField :: Key -> LoessPropertyLabel -> [a]
addField Key
n LoessPropertyLabel
p = case LoessPropertyLabel -> [LoessProperty] -> VLSpec
loessPropertySpec LoessPropertyLabel
p [LoessProperty]
lsp of
VLSpec
A.Null -> []
VLSpec
x -> [ Key
n Key -> VLSpec -> a
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
x ]
ofields :: [Pair]
ofields = [ Key
"loess" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
depField
, Key
"on" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
indField ]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> LoessPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> LoessPropertyLabel -> [a]
addField Key
"groupby" LoessPropertyLabel
LLGroupBy
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> LoessPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> LoessPropertyLabel -> [a]
addField Key
"bandwidth" LoessPropertyLabel
LLBandwidth
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> LoessPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> LoessPropertyLabel -> [a]
addField Key
"as" LoessPropertyLabel
LLAs
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
ofields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
data RegressionMethod
= RgLinear
| RgLog
| RgExp
| RgPow
| RgQuad
| RgPoly
regressionMethodSpec :: RegressionMethod -> VLSpec
regressionMethodSpec :: RegressionMethod -> VLSpec
regressionMethodSpec RegressionMethod
RgLinear = Text -> VLSpec
fromT Text
"linear"
regressionMethodSpec RegressionMethod
RgLog = Text -> VLSpec
fromT Text
"log"
regressionMethodSpec RegressionMethod
RgExp = Text -> VLSpec
fromT Text
"exp"
regressionMethodSpec RegressionMethod
RgPow = Text -> VLSpec
fromT Text
"pow"
regressionMethodSpec RegressionMethod
RgQuad = Text -> VLSpec
fromT Text
"quad"
regressionMethodSpec RegressionMethod
RgPoly = Text -> VLSpec
fromT Text
"poly"
data RegressionProperty
= RgAs FieldName FieldName
| RgExtent Double Double
| RgGroupBy [FieldName]
| RgMethod RegressionMethod
| RgOrder Natural
| RgParams Bool
data RegressionPropertyLabel =
RPLAs | RPLExtent | RPLGroupBy | RPLMethod | RPLOrder | RPLParams
regressionPropertySpec :: RegressionPropertyLabel -> [RegressionProperty] -> VLSpec
regressionPropertySpec :: RegressionPropertyLabel -> [RegressionProperty] -> VLSpec
regressionPropertySpec RegressionPropertyLabel
RPLAs [RegressionProperty]
ps =
let wanted :: RegressionProperty -> Maybe [Text]
wanted (RgAs Text
xs Text
ys) = [Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text
xs, Text
ys]
wanted RegressionProperty
_ = Maybe [Text]
forall a. Maybe a
Nothing
in case (RegressionProperty -> Maybe [Text])
-> [RegressionProperty] -> [[Text]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe RegressionProperty -> Maybe [Text]
wanted [RegressionProperty]
ps of
[[Text]
x] -> [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
x
[[Text]]
_ -> VLSpec
A.Null
regressionPropertySpec RegressionPropertyLabel
RPLExtent [RegressionProperty]
ps =
let wanted :: RegressionProperty -> Maybe [Double]
wanted (RgExtent Double
xs Double
ys) = [Double] -> Maybe [Double]
forall a. a -> Maybe a
Just [Double
xs, Double
ys]
wanted RegressionProperty
_ = Maybe [Double]
forall a. Maybe a
Nothing
in case (RegressionProperty -> Maybe [Double])
-> [RegressionProperty] -> [[Double]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe RegressionProperty -> Maybe [Double]
wanted [RegressionProperty]
ps of
[[Double]
x] -> [Double] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Double]
x
[[Double]]
_ -> VLSpec
A.Null
regressionPropertySpec RegressionPropertyLabel
RPLGroupBy [RegressionProperty]
ps =
let wanted :: RegressionProperty -> Maybe [Text]
wanted (RgGroupBy [Text]
xs) = [Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text]
xs
wanted RegressionProperty
_ = Maybe [Text]
forall a. Maybe a
Nothing
in case (RegressionProperty -> Maybe [Text])
-> [RegressionProperty] -> [[Text]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe RegressionProperty -> Maybe [Text]
wanted [RegressionProperty]
ps of
[[Text]
x] -> [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
x
[[Text]]
_ -> VLSpec
A.Null
regressionPropertySpec RegressionPropertyLabel
RPLMethod [RegressionProperty]
ps =
let wanted :: RegressionProperty -> Maybe RegressionMethod
wanted (RgMethod RegressionMethod
xs) = RegressionMethod -> Maybe RegressionMethod
forall a. a -> Maybe a
Just RegressionMethod
xs
wanted RegressionProperty
_ = Maybe RegressionMethod
forall a. Maybe a
Nothing
in case (RegressionProperty -> Maybe RegressionMethod)
-> [RegressionProperty] -> [RegressionMethod]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe RegressionProperty -> Maybe RegressionMethod
wanted [RegressionProperty]
ps of
[RegressionMethod
x] -> RegressionMethod -> VLSpec
regressionMethodSpec RegressionMethod
x
[RegressionMethod]
_ -> VLSpec
A.Null
regressionPropertySpec RegressionPropertyLabel
RPLOrder [RegressionProperty]
ps =
let wanted :: RegressionProperty -> Maybe ZIndex
wanted (RgOrder ZIndex
xs) = ZIndex -> Maybe ZIndex
forall a. a -> Maybe a
Just ZIndex
xs
wanted RegressionProperty
_ = Maybe ZIndex
forall a. Maybe a
Nothing
in case (RegressionProperty -> Maybe ZIndex)
-> [RegressionProperty] -> [ZIndex]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe RegressionProperty -> Maybe ZIndex
wanted [RegressionProperty]
ps of
[ZIndex
x] -> ZIndex -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON ZIndex
x
[ZIndex]
_ -> VLSpec
A.Null
regressionPropertySpec RegressionPropertyLabel
RPLParams [RegressionProperty]
ps =
let wanted :: RegressionProperty -> Maybe Bool
wanted (RgParams Bool
xs) = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
xs
wanted RegressionProperty
_ = Maybe Bool
forall a. Maybe a
Nothing
in case (RegressionProperty -> Maybe Bool)
-> [RegressionProperty] -> [Bool]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe RegressionProperty -> Maybe Bool
wanted [RegressionProperty]
ps of
[Bool
x] -> Bool -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Bool
x
[Bool]
_ -> VLSpec
A.Null
regression ::
FieldName
-> FieldName
-> [RegressionProperty]
-> BuildTransformSpecs
regression :: Text -> Text -> [RegressionProperty] -> BuildTransformSpecs
regression Text
depField Text
indField [RegressionProperty]
rps [TransformSpec]
ols =
let addField :: Key -> RegressionPropertyLabel -> [a]
addField Key
n RegressionPropertyLabel
p = case RegressionPropertyLabel -> [RegressionProperty] -> VLSpec
regressionPropertySpec RegressionPropertyLabel
p [RegressionProperty]
rps of
VLSpec
A.Null -> []
VLSpec
x -> [ Key
n Key -> VLSpec -> a
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
x ]
ofields :: [Pair]
ofields = [ Key
"regression" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
depField
, Key
"on" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
indField ]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> RegressionPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> RegressionPropertyLabel -> [a]
addField Key
"groupby" RegressionPropertyLabel
RPLGroupBy
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> RegressionPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> RegressionPropertyLabel -> [a]
addField Key
"method" RegressionPropertyLabel
RPLMethod
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> RegressionPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> RegressionPropertyLabel -> [a]
addField Key
"order" RegressionPropertyLabel
RPLOrder
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> RegressionPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> RegressionPropertyLabel -> [a]
addField Key
"extent" RegressionPropertyLabel
RPLExtent
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> RegressionPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> RegressionPropertyLabel -> [a]
addField Key
"params" RegressionPropertyLabel
RPLParams
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> RegressionPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> RegressionPropertyLabel -> [a]
addField Key
"as" RegressionPropertyLabel
RPLAs
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
ofields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
data QuantileProperty
= QtAs FieldName FieldName
| QtGroupBy [FieldName]
| QtProbs [Double]
| QtStep Double
data QuantilePropertyLabel =
QPLAs | QPLGroupBy | QPLProbs | QPLStep
quantilePropertySpec :: QuantilePropertyLabel -> [QuantileProperty] -> VLSpec
quantilePropertySpec :: QuantilePropertyLabel -> [QuantileProperty] -> VLSpec
quantilePropertySpec QuantilePropertyLabel
QPLAs [QuantileProperty]
ps =
let wanted :: QuantileProperty -> Maybe [Text]
wanted (QtAs Text
xs Text
ys) = [Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text
xs, Text
ys]
wanted QuantileProperty
_ = Maybe [Text]
forall a. Maybe a
Nothing
in case (QuantileProperty -> Maybe [Text])
-> [QuantileProperty] -> [[Text]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe QuantileProperty -> Maybe [Text]
wanted [QuantileProperty]
ps of
[[Text]
x] -> [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
x
[[Text]]
_ -> VLSpec
A.Null
quantilePropertySpec QuantilePropertyLabel
QPLGroupBy [QuantileProperty]
ps =
let wanted :: QuantileProperty -> Maybe [Text]
wanted (QtGroupBy [Text]
xs) = [Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text]
xs
wanted QuantileProperty
_ = Maybe [Text]
forall a. Maybe a
Nothing
in case (QuantileProperty -> Maybe [Text])
-> [QuantileProperty] -> [[Text]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe QuantileProperty -> Maybe [Text]
wanted [QuantileProperty]
ps of
[[Text]
x] -> [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
x
[[Text]]
_ -> VLSpec
A.Null
quantilePropertySpec QuantilePropertyLabel
QPLProbs [QuantileProperty]
ps =
let wanted :: QuantileProperty -> Maybe [Double]
wanted (QtProbs [Double]
xs) = [Double] -> Maybe [Double]
forall a. a -> Maybe a
Just [Double]
xs
wanted QuantileProperty
_ = Maybe [Double]
forall a. Maybe a
Nothing
in case (QuantileProperty -> Maybe [Double])
-> [QuantileProperty] -> [[Double]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe QuantileProperty -> Maybe [Double]
wanted [QuantileProperty]
ps of
[[Double]
x] -> [Double] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Double]
x
[[Double]]
_ -> VLSpec
A.Null
quantilePropertySpec QuantilePropertyLabel
QPLStep [QuantileProperty]
ps =
let wanted :: QuantileProperty -> Maybe Double
wanted (QtStep Double
xs) = Double -> Maybe Double
forall a. a -> Maybe a
Just Double
xs
wanted QuantileProperty
_ = Maybe Double
forall a. Maybe a
Nothing
in case (QuantileProperty -> Maybe Double)
-> [QuantileProperty] -> [Double]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe QuantileProperty -> Maybe Double
wanted [QuantileProperty]
ps of
[Double
x] -> Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Double
x
[Double]
_ -> VLSpec
A.Null
quantile ::
FieldName
-> [QuantileProperty]
-> BuildTransformSpecs
quantile :: Text -> [QuantileProperty] -> BuildTransformSpecs
quantile Text
field [QuantileProperty]
qps [TransformSpec]
ols =
let addField :: Key -> QuantilePropertyLabel -> [a]
addField Key
n QuantilePropertyLabel
p = case QuantilePropertyLabel -> [QuantileProperty] -> VLSpec
quantilePropertySpec QuantilePropertyLabel
p [QuantileProperty]
qps of
VLSpec
A.Null -> []
VLSpec
x -> [ Key
n Key -> VLSpec -> a
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
x ]
ofields :: [Pair]
ofields = [ Key
"quantile" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field ]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> QuantilePropertyLabel -> [Pair]
forall a. KeyValue a => Key -> QuantilePropertyLabel -> [a]
addField Key
"groupby" QuantilePropertyLabel
QPLGroupBy
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> QuantilePropertyLabel -> [Pair]
forall a. KeyValue a => Key -> QuantilePropertyLabel -> [a]
addField Key
"probs" QuantilePropertyLabel
QPLProbs
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> QuantilePropertyLabel -> [Pair]
forall a. KeyValue a => Key -> QuantilePropertyLabel -> [a]
addField Key
"step" QuantilePropertyLabel
QPLStep
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> QuantilePropertyLabel -> [Pair]
forall a. KeyValue a => Key -> QuantilePropertyLabel -> [a]
addField Key
"as" QuantilePropertyLabel
QPLAs
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
ofields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
binAs ::
[BinProperty]
-> FieldName
-> FieldName
-> BuildTransformSpecs
binAs :: [BinProperty] -> Text -> Text -> BuildTransformSpecs
binAs [BinProperty]
bProps Text
field Text
label [TransformSpec]
ols =
let fields :: [Pair]
fields = [ Key
"bin" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= if [BinProperty] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [BinProperty]
bProps then Bool -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON Bool
True else VLSpec
binObj
, Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field
, Key
"as" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
label ]
binObj :: VLSpec
binObj = [Pair] -> VLSpec
object ((BinProperty -> Pair) -> [BinProperty] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map BinProperty -> Pair
binProperty [BinProperty]
bProps)
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
fields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
calculateAs ::
VegaExpr
-> FieldName
-> BuildTransformSpecs
calculateAs :: Text -> Text -> BuildTransformSpecs
calculateAs Text
expr Text
label [TransformSpec]
ols =
let fields :: [Pair]
fields = [ Key
"calculate" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
expr, Key
"as" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
label ]
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
fields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
angle ::
[MarkChannel]
-> BuildEncodingSpecs
angle :: [MarkChannel] -> BuildEncodingSpecs
angle [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"angle" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
color ::
[MarkChannel]
-> BuildEncodingSpecs
color :: [MarkChannel] -> BuildEncodingSpecs
color [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"color" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
column ::
[FacetChannel]
-> BuildEncodingSpecs
column :: [FacetChannel] -> BuildEncodingSpecs
column [FacetChannel]
fFields [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"column", [Pair] -> VLSpec
object ((FacetChannel -> Pair) -> [FacetChannel] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map FacetChannel -> Pair
facetChannelProperty [FacetChannel]
fFields)) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
columns ::
Natural
-> PropertySpec
columns :: ZIndex -> PropertySpec
columns ZIndex
cols = (VLProperty
VLColumns, ZIndex -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON ZIndex
cols)
detail ::
[DetailChannel]
-> BuildEncodingSpecs
detail :: [DetailChannel] -> BuildEncodingSpecs
detail [DetailChannel]
detailProps [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"detail", [Pair] -> VLSpec
object ((DetailChannel -> Pair) -> [DetailChannel] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map DetailChannel -> Pair
detailChannelProperty [DetailChannel]
detailProps)) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
fill ::
[MarkChannel]
-> BuildEncodingSpecs
fill :: [MarkChannel] -> BuildEncodingSpecs
fill [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"fill" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
fillOpacity :: [MarkChannel] -> BuildEncodingSpecs
fillOpacity :: [MarkChannel] -> BuildEncodingSpecs
fillOpacity [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"fillOpacity" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
filter :: Filter -> BuildTransformSpecs
filter :: Filter -> BuildTransformSpecs
filter Filter
f [TransformSpec]
ols = VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [ Key
"filter" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Filter -> VLSpec
filterSpec Filter
f ]) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
flatten :: [FieldName] -> BuildTransformSpecs
flatten :: [Text] -> BuildTransformSpecs
flatten [Text]
fields [TransformSpec]
ols = VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [ Key
"flatten" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
fields ]) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
flattenAs ::
[FieldName]
-> [FieldName]
-> BuildTransformSpecs
flattenAs :: [Text] -> [Text] -> BuildTransformSpecs
flattenAs [Text]
fields [Text]
names [TransformSpec]
ols =
let ofields :: [Pair]
ofields = [ Key
"flatten" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
fields, Key
"as" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
names ]
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
ofields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
fold ::
[FieldName]
-> BuildTransformSpecs
fold :: [Text] -> BuildTransformSpecs
fold [Text]
fields [TransformSpec]
ols = VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [ Key
"fold" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
fields ]) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
foldAs ::
[FieldName]
-> FieldName
-> FieldName
-> BuildTransformSpecs
foldAs :: [Text] -> Text -> Text -> BuildTransformSpecs
foldAs [Text]
fields Text
keyName Text
valName [TransformSpec]
ols =
let ofields :: [Pair]
ofields = [ Key
"fold" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
fields
, Key
"as" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [ Text
keyName, Text
valName ]
]
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
ofields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
pivot ::
FieldName
-> FieldName
-> [PivotProperty]
-> BuildTransformSpecs
pivot :: Text -> Text -> [PivotProperty] -> BuildTransformSpecs
pivot Text
field Text
valField [PivotProperty]
pProps [TransformSpec]
ols =
let addField :: Key -> PivotPropertyLabel -> [a]
addField Key
n PivotPropertyLabel
p = case PivotPropertyLabel -> [PivotProperty] -> VLSpec
pivotPropertySpec PivotPropertyLabel
p [PivotProperty]
pProps of
VLSpec
A.Null -> []
VLSpec
x -> [Key
n Key -> VLSpec -> a
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
x]
ofields :: [Pair]
ofields = [ Key
"pivot" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field
, Key
"value" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
valField ]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> PivotPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> PivotPropertyLabel -> [a]
addField Key
"groupby" PivotPropertyLabel
PPLGroupBy
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> PivotPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> PivotPropertyLabel -> [a]
addField Key
"limit" PivotPropertyLabel
PPLLimit
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> PivotPropertyLabel -> [Pair]
forall a. KeyValue a => Key -> PivotPropertyLabel -> [a]
addField Key
"op" PivotPropertyLabel
PPLOp
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
ofields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
data PivotProperty
= PiGroupBy [FieldName]
| PiLimit Natural
| PiOp Operation
data PivotPropertyLabel = PPLGroupBy | PPLLimit | PPLOp
pivotPropertySpec ::
PivotPropertyLabel
-> [PivotProperty]
-> VLSpec
pivotPropertySpec :: PivotPropertyLabel -> [PivotProperty] -> VLSpec
pivotPropertySpec PivotPropertyLabel
PPLGroupBy [PivotProperty]
ps =
let wanted :: PivotProperty -> Maybe [Text]
wanted (PiGroupBy [Text]
xs) = [Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text]
xs
wanted PivotProperty
_ = Maybe [Text]
forall a. Maybe a
Nothing
in case (PivotProperty -> Maybe [Text]) -> [PivotProperty] -> [[Text]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe PivotProperty -> Maybe [Text]
wanted [PivotProperty]
ps of
[[Text]
x] -> [Text] -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
x
[[Text]]
_ -> VLSpec
A.Null
pivotPropertySpec PivotPropertyLabel
PPLLimit [PivotProperty]
ps =
let wanted :: PivotProperty -> Maybe ZIndex
wanted (PiLimit ZIndex
xs) = ZIndex -> Maybe ZIndex
forall a. a -> Maybe a
Just ZIndex
xs
wanted PivotProperty
_ = Maybe ZIndex
forall a. Maybe a
Nothing
in case (PivotProperty -> Maybe ZIndex) -> [PivotProperty] -> [ZIndex]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe PivotProperty -> Maybe ZIndex
wanted [PivotProperty]
ps of
[ZIndex
x] -> ZIndex -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON ZIndex
x
[ZIndex]
_ -> VLSpec
A.Null
pivotPropertySpec PivotPropertyLabel
PPLOp [PivotProperty]
ps =
let wanted :: PivotProperty -> Maybe Operation
wanted (PiOp Operation
xs) = Operation -> Maybe Operation
forall a. a -> Maybe a
Just Operation
xs
wanted PivotProperty
_ = Maybe Operation
forall a. Maybe a
Nothing
in case (PivotProperty -> Maybe Operation)
-> [PivotProperty] -> [Operation]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe PivotProperty -> Maybe Operation
wanted [PivotProperty]
ps of
[Operation
x] -> Operation -> VLSpec
operationSpec Operation
x
[Operation]
_ -> VLSpec
A.Null
url :: [HyperlinkChannel] -> BuildEncodingSpecs
url :: [HyperlinkChannel] -> BuildEncodingSpecs
url [HyperlinkChannel]
hPs [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"url", [Pair] -> VLSpec
object ((HyperlinkChannel -> [Pair]) -> [HyperlinkChannel] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap HyperlinkChannel -> [Pair]
hyperlinkChannelProperty [HyperlinkChannel]
hPs)) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
hyperlink ::
[HyperlinkChannel]
-> BuildEncodingSpecs
hyperlink :: [HyperlinkChannel] -> BuildEncodingSpecs
hyperlink [HyperlinkChannel]
hyperProps [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"href", [Pair] -> VLSpec
object ((HyperlinkChannel -> [Pair]) -> [HyperlinkChannel] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap HyperlinkChannel -> [Pair]
hyperlinkChannelProperty [HyperlinkChannel]
hyperProps)) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
lookup ::
FieldName
-> Data
-> FieldName
-> LookupFields
-> BuildTransformSpecs
lookup :: Text -> PropertySpec -> Text -> LookupFields -> BuildTransformSpecs
lookup Text
key1 (VLProperty
_, VLSpec
spec) Text
key2 LookupFields
lfields [TransformSpec]
ols =
let get1 :: [(Text, b)] -> Maybe VLSpec
get1 = [Text] -> Maybe VLSpec
forall a. ToJSON a => a -> Maybe VLSpec
jj ([Text] -> Maybe VLSpec)
-> ([(Text, b)] -> [Text]) -> [(Text, b)] -> Maybe VLSpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Text, b) -> Text) -> [(Text, b)] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map (Text, b) -> Text
forall a b. (a, b) -> a
fst
get2 :: [(a, Text)] -> Maybe VLSpec
get2 = [Text] -> Maybe VLSpec
forall a. ToJSON a => a -> Maybe VLSpec
jj ([Text] -> Maybe VLSpec)
-> ([(a, Text)] -> [Text]) -> [(a, Text)] -> Maybe VLSpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a, Text) -> Text) -> [(a, Text)] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map (a, Text) -> Text
forall a b. (a, b) -> b
snd
jj :: A.ToJSON a => a -> Maybe A.Value
jj :: a -> Maybe VLSpec
jj = VLSpec -> Maybe VLSpec
forall a. a -> Maybe a
Just (VLSpec -> Maybe VLSpec) -> (a -> VLSpec) -> a -> Maybe VLSpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON
res :: (Maybe VLSpec, Maybe VLSpec, Maybe VLSpec)
res = case LookupFields
lfields of
LuFields [Text]
fs -> ( [Text] -> Maybe VLSpec
forall a. ToJSON a => a -> Maybe VLSpec
jj [Text]
fs, Maybe VLSpec
forall a. Maybe a
Nothing, Maybe VLSpec
forall a. Maybe a
Nothing )
LuFieldAs [(Text, Text)]
fas -> ( [(Text, Text)] -> Maybe VLSpec
forall b. [(Text, b)] -> Maybe VLSpec
get1 [(Text, Text)]
fas, [(Text, Text)] -> Maybe VLSpec
forall a. [(a, Text)] -> Maybe VLSpec
get2 [(Text, Text)]
fas, Maybe VLSpec
forall a. Maybe a
Nothing )
LuAs Text
s -> ( Maybe VLSpec
forall a. Maybe a
Nothing, Text -> Maybe VLSpec
forall a. ToJSON a => a -> Maybe VLSpec
jj Text
s, Maybe VLSpec
forall a. Maybe a
Nothing )
LuFieldsWithDefault [Text]
fs Text
def
-> ( [Text] -> Maybe VLSpec
forall a. ToJSON a => a -> Maybe VLSpec
jj [Text]
fs, Maybe VLSpec
forall a. Maybe a
Nothing , Text -> Maybe VLSpec
forall a. ToJSON a => a -> Maybe VLSpec
jj Text
def )
LuFieldsAsWithDefault [(Text, Text)]
fas Text
def
-> ( [(Text, Text)] -> Maybe VLSpec
forall b. [(Text, b)] -> Maybe VLSpec
get1 [(Text, Text)]
fas, [(Text, Text)] -> Maybe VLSpec
forall a. [(a, Text)] -> Maybe VLSpec
get2 [(Text, Text)]
fas, Text -> Maybe VLSpec
forall a. ToJSON a => a -> Maybe VLSpec
jj Text
def )
LuAsWithDefault Text
s Text
def -> ( Maybe VLSpec
forall a. Maybe a
Nothing, Text -> Maybe VLSpec
forall a. ToJSON a => a -> Maybe VLSpec
jj Text
s, Text -> Maybe VLSpec
forall a. ToJSON a => a -> Maybe VLSpec
jj Text
def )
(Maybe VLSpec
mfields, Maybe VLSpec
mas, Maybe VLSpec
mdefault) = (Maybe VLSpec, Maybe VLSpec, Maybe VLSpec)
res
addField :: a -> Maybe b -> [(a, b)]
addField a
n (Just b
x) = [ (a
n, b
x) ]
addField a
_ Maybe b
_ = []
fromFields :: [Pair]
fromFields = [ Key
"data" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
spec
, Key
"key" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
key2
]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> Maybe VLSpec -> [Pair]
forall a b. a -> Maybe b -> [(a, b)]
addField Key
"fields" Maybe VLSpec
mfields
ofields :: [Pair]
ofields = [ Key
"lookup" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
key1
, Key
"from" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Pair]
fromFields
]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> Maybe VLSpec -> [Pair]
forall a b. a -> Maybe b -> [(a, b)]
addField Key
"as" Maybe VLSpec
mas
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> Key -> Maybe VLSpec -> [Pair]
forall a b. a -> Maybe b -> [(a, b)]
addField Key
"default" Maybe VLSpec
mdefault
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
ofields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
lookupSelection ::
FieldName
-> SelectionLabel
-> FieldName
-> BuildTransformSpecs
lookupSelection :: Text -> Text -> Text -> BuildTransformSpecs
lookupSelection Text
key1 Text
selName Text
key2 [TransformSpec]
ols =
let ofields :: [Pair]
ofields = [ Key
"lookup" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
key1
, Key
"from" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [ Key
"selection" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
selName
, Key
"key" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
key2 ]
]
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
ofields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
data LookupFields
= LuFields [FieldName]
| LuFieldAs [(FieldName, FieldName)]
| LuAs FieldName
| LuFieldsWithDefault [FieldName] T.Text
| LuFieldsAsWithDefault [(FieldName, FieldName)] T.Text
| LuAsWithDefault FieldName T.Text
{-# DEPRECATED lookupAs "Please change 'lookupAs ... alias' to 'lookup ... (LuAs alias)'" #-}
lookupAs ::
FieldName
-> Data
-> FieldName
-> FieldName
-> BuildTransformSpecs
lookupAs :: Text -> PropertySpec -> Text -> Text -> BuildTransformSpecs
lookupAs Text
key1 PropertySpec
sData Text
key2 Text
asName =
Text -> PropertySpec -> Text -> LookupFields -> BuildTransformSpecs
lookup Text
key1 PropertySpec
sData Text
key2 (Text -> LookupFields
LuAs Text
asName)
impute ::
FieldName
-> FieldName
-> [ImputeProperty]
-> BuildTransformSpecs
impute :: Text -> Text -> [ImputeProperty] -> BuildTransformSpecs
impute Text
fields Text
keyField [ImputeProperty]
imProps [TransformSpec]
ols = Text -> Text -> [ImputeProperty] -> TransformSpec
imputeTS Text
fields Text
keyField [ImputeProperty]
imProps TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
opacity :: [MarkChannel] -> BuildEncodingSpecs
opacity :: [MarkChannel] -> BuildEncodingSpecs
opacity [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"opacity" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
order ::
[OrderChannel]
-> BuildEncodingSpecs
order :: [OrderChannel] -> BuildEncodingSpecs
order [OrderChannel]
oDefs [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"order", [Pair] -> VLSpec
object ((OrderChannel -> [Pair]) -> [OrderChannel] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap OrderChannel -> [Pair]
orderChannelProperty [OrderChannel]
oDefs)) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
position ::
Position
-> [PositionChannel]
-> BuildEncodingSpecs
position :: Position -> [PositionChannel] -> BuildEncodingSpecs
position Position
pos [PositionChannel]
pDefs [EncodingSpec]
ols =
let defs :: VLSpec
defs = [Pair] -> VLSpec
object ((PositionChannel -> Pair) -> [PositionChannel] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map PositionChannel -> Pair
positionChannelProperty [PositionChannel]
pDefs)
in (Text, VLSpec) -> EncodingSpec
ES (Position -> Text
positionLabel Position
pos, VLSpec
defs) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
resolution ::
Resolve
-> BuildResolveSpecs
resolution :: Resolve -> BuildResolveSpecs
resolution Resolve
res [ResolveSpec]
ols = Resolve -> ResolveSpec
resolveProperty Resolve
res ResolveSpec -> BuildResolveSpecs
forall a. a -> [a] -> [a]
: [ResolveSpec]
ols
row ::
[FacetChannel]
-> BuildEncodingSpecs
row :: [FacetChannel] -> BuildEncodingSpecs
row [FacetChannel]
fFields [EncodingSpec]
ols = (Text, VLSpec) -> EncodingSpec
ES (Text
"row", [Pair] -> VLSpec
object ((FacetChannel -> Pair) -> [FacetChannel] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map FacetChannel -> Pair
facetChannelProperty [FacetChannel]
fFields)) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
shape ::
[MarkChannel]
-> BuildEncodingSpecs
shape :: [MarkChannel] -> BuildEncodingSpecs
shape [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"shape" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
size ::
[MarkChannel]
-> BuildEncodingSpecs
size :: [MarkChannel] -> BuildEncodingSpecs
size [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"size" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
stroke ::
[MarkChannel]
-> BuildEncodingSpecs
stroke :: [MarkChannel] -> BuildEncodingSpecs
stroke [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"stroke" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
strokeDash ::
[MarkChannel]
-> BuildEncodingSpecs
strokeDash :: [MarkChannel] -> BuildEncodingSpecs
strokeDash [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"strokeDash" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
strokeOpacity ::
[MarkChannel]
-> BuildEncodingSpecs
strokeOpacity :: [MarkChannel] -> BuildEncodingSpecs
strokeOpacity [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"strokeOpacity" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
strokeWidth ::
[MarkChannel]
-> BuildEncodingSpecs
strokeWidth :: [MarkChannel] -> BuildEncodingSpecs
strokeWidth [MarkChannel]
markProps [EncodingSpec]
ols = Text -> [MarkChannel] -> EncodingSpec
mchan_ Text
"strokeWidth" [MarkChannel]
markProps EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
text ::
[TextChannel]
-> BuildEncodingSpecs
text :: [TextChannel] -> BuildEncodingSpecs
text [TextChannel]
tDefs [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"text", [Pair] -> VLSpec
object ((TextChannel -> [Pair]) -> [TextChannel] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap TextChannel -> [Pair]
textChannelProperty [TextChannel]
tDefs)) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
timeUnitAs ::
TimeUnit
-> FieldName
-> FieldName
-> BuildTransformSpecs
timeUnitAs :: TimeUnit -> Text -> Text -> BuildTransformSpecs
timeUnitAs TimeUnit
tu Text
field Text
label [TransformSpec]
ols =
let fields :: [Pair]
fields = [ Key
"timeUnit" Key -> VLSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TimeUnit -> VLSpec
timeUnitSpec TimeUnit
tu
, Key
"field" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
field
, Key
"as" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
label ]
in VLSpec -> TransformSpec
TS ([Pair] -> VLSpec
object [Pair]
fields) TransformSpec -> BuildTransformSpecs
forall a. a -> [a] -> [a]
: [TransformSpec]
ols
tooltip ::
[TextChannel]
-> BuildEncodingSpecs
tooltip :: [TextChannel] -> BuildEncodingSpecs
tooltip [] [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"tooltip", VLSpec
A.Null) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
tooltip [TextChannel]
tDefs [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"tooltip", [Pair] -> VLSpec
object ((TextChannel -> [Pair]) -> [TextChannel] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap TextChannel -> [Pair]
textChannelProperty [TextChannel]
tDefs)) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols
tooltips ::
[[TextChannel]]
-> BuildEncodingSpecs
tooltips :: [[TextChannel]] -> BuildEncodingSpecs
tooltips [[TextChannel]]
tDefs [EncodingSpec]
ols =
(Text, VLSpec) -> EncodingSpec
ES (Text
"tooltip" Text -> [VLSpec] -> (Text, VLSpec)
forall a. ToJSON a => Text -> a -> (Text, VLSpec)
.=~ ([TextChannel] -> VLSpec) -> [[TextChannel]] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map ([Pair] -> VLSpec
object ([Pair] -> VLSpec)
-> ([TextChannel] -> [Pair]) -> [TextChannel] -> VLSpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextChannel -> [Pair]) -> [TextChannel] -> [Pair]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap TextChannel -> [Pair]
textChannelProperty) [[TextChannel]]
tDefs) EncodingSpec -> BuildEncodingSpecs
forall a. a -> [a] -> [a]
: [EncodingSpec]
ols