{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module Graphics.Vega.VegaLite.Foundation
( Angle
, Color
, DashStyle
, DashOffset
, FieldName
, Opacity
, StyleLabel
, VegaExpr
, ZIndex
, FontWeight(..)
, Measurement(..)
, Arrangement(..)
, APosition(..)
, Orientation(..)
, Position(..)
, HAlign(..)
, VAlign(..)
, BandAlign(..)
, StrokeCap(..)
, StrokeJoin(..)
, Scale(..)
, SortField(..)
, Cursor(..)
, OverlapStrategy(..)
, Side(..)
, Symbol(..)
, StackProperty(..)
, StackOffset(..)
, TooltipContent(..)
, Channel(..)
, Resolve(..)
, Resolution(..)
, Bounds(..)
, CompositionAlignment(..)
, Padding(..)
, Autosize(..)
, RepeatFields(..)
, CInterpolate(..)
, ViewBackground(..)
, HeaderProperty(..)
, fontWeightSpec
, measurementLabel
, arrangementLabel
, anchorLabel
, orientationSpec
, hAlignLabel
, vAlignLabel
, bandAlignLabel
, strokeCapLabel
, strokeJoinLabel
, scaleLabel
, positionLabel
, sortFieldSpec
, cursorLabel
, overlapStrategyLabel
, sideLabel
, symbolLabel
, stackPropertySpecSort
, stackPropertySpecOffset
, stackOffset
, ttContentLabel
, channelLabel
, resolveProperty
, boundsSpec
, compositionAlignmentSpec
, paddingSpec
, autosizeProperty
, repeatFieldsProperty
, cInterpolateSpec
, viewBackgroundSpec
, fromT
, fromColor
, fromDS
, splitOnNewline
, field_
, header_
, order_
, allowNull
)
where
import qualified Data.Aeson as A
import qualified Data.Text as T
import Data.Aeson ((.=), object, toJSON)
#if !(MIN_VERSION_base(4, 12, 0))
import Data.Monoid ((<>))
#endif
import Numeric.Natural (Natural)
import Graphics.Vega.VegaLite.Specification
( VLSpec
, LabelledSpec
, ResolveSpec(..)
)
field_ :: FieldName -> LabelledSpec
field_ :: FieldName -> LabelledSpec
field_ FieldName
f = FieldName
"field" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
f
header_ :: T.Text -> [HeaderProperty] -> LabelledSpec
FieldName
extra [HeaderProperty]
hps = (FieldName
"header" FieldName -> FieldName -> FieldName
forall a. Semigroup a => a -> a -> a
<> FieldName
extra) FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= [LabelledSpec] -> Value
object ((HeaderProperty -> LabelledSpec)
-> [HeaderProperty] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map HeaderProperty -> LabelledSpec
headerProperty [HeaderProperty]
hps)
order_ :: T.Text -> LabelledSpec
order_ :: FieldName -> LabelledSpec
order_ FieldName
o = FieldName
"order" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
o
allowNull :: Maybe Int -> VLSpec
allowNull :: Maybe Int -> Value
allowNull (Just Int
a) = Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
a
allowNull Maybe Int
Nothing = Value
A.Null
type FieldName = T.Text
type Color = T.Text
fromColor :: Color -> VLSpec
fromColor :: FieldName -> Value
fromColor = FieldName -> Value
cleanT
cleanT :: T.Text -> VLSpec
cleanT :: FieldName -> Value
cleanT FieldName
t =
let tout :: FieldName
tout = FieldName -> FieldName
T.strip FieldName
t
in if FieldName -> Bool
T.null FieldName
tout
then Value
A.Null
else FieldName -> Value
forall a. ToJSON a => a -> Value
toJSON FieldName
tout
type DashStyle = [Double]
fromDS :: DashStyle -> VLSpec
fromDS :: DashStyle -> Value
fromDS = DashStyle -> Value
forall a. ToJSON a => a -> Value
toJSON
type DashOffset = Double
type Opacity = Double
type StyleLabel = T.Text
type Angle = Double
type ZIndex = Natural
type VegaExpr = T.Text
data FontWeight
= Bold
| Bolder
| Lighter
| Normal
| W100
| W200
| W300
| W400
| W500
| W600
| W700
| W800
| W900
fromF :: Double -> VLSpec
fromF :: Double -> Value
fromF = Double -> Value
forall a. ToJSON a => a -> Value
toJSON
fromT :: T.Text -> VLSpec
fromT :: FieldName -> Value
fromT = FieldName -> Value
forall a. ToJSON a => a -> Value
toJSON
splitOnNewline :: T.Text -> VLSpec
splitOnNewline :: FieldName -> Value
splitOnNewline FieldName
ts =
case (Char -> Bool) -> FieldName -> [FieldName]
T.split (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\n') FieldName
ts of
[] -> FieldName -> Value
fromT FieldName
""
[FieldName
s] -> FieldName -> Value
forall a. ToJSON a => a -> Value
toJSON FieldName
s
[FieldName]
s -> [FieldName] -> Value
forall a. ToJSON a => a -> Value
toJSON [FieldName]
s
fontWeightSpec :: FontWeight -> VLSpec
fontWeightSpec :: FontWeight -> Value
fontWeightSpec FontWeight
Bold = FieldName -> Value
fromT FieldName
"bold"
fontWeightSpec FontWeight
Bolder = FieldName -> Value
fromT FieldName
"bolder"
fontWeightSpec FontWeight
Lighter = FieldName -> Value
fromT FieldName
"lighter"
fontWeightSpec FontWeight
Normal = FieldName -> Value
fromT FieldName
"normal"
fontWeightSpec FontWeight
W100 = Double -> Value
fromF Double
100
fontWeightSpec FontWeight
W200 = Double -> Value
fromF Double
200
fontWeightSpec FontWeight
W300 = Double -> Value
fromF Double
300
fontWeightSpec FontWeight
W400 = Double -> Value
fromF Double
400
fontWeightSpec FontWeight
W500 = Double -> Value
fromF Double
500
fontWeightSpec FontWeight
W600 = Double -> Value
fromF Double
600
fontWeightSpec FontWeight
W700 = Double -> Value
fromF Double
700
fontWeightSpec FontWeight
W800 = Double -> Value
fromF Double
800
fontWeightSpec FontWeight
W900 = Double -> Value
fromF Double
900
data Measurement
= Nominal
| Ordinal
| Quantitative
| Temporal
| GeoFeature
measurementLabel :: Measurement -> T.Text
measurementLabel :: Measurement -> FieldName
measurementLabel Measurement
Nominal = FieldName
"nominal"
measurementLabel Measurement
Ordinal = FieldName
"ordinal"
measurementLabel Measurement
Quantitative = FieldName
"quantitative"
measurementLabel Measurement
Temporal = FieldName
"temporal"
measurementLabel Measurement
GeoFeature = FieldName
"geojson"
data Arrangement
= Column
| Row
| Flow
| Layer
arrangementLabel :: Arrangement -> T.Text
arrangementLabel :: Arrangement -> FieldName
arrangementLabel Arrangement
Column = FieldName
"column"
arrangementLabel Arrangement
Row = FieldName
"row"
arrangementLabel Arrangement
Flow = FieldName
"repeat"
arrangementLabel Arrangement
Layer = FieldName
"layer"
data APosition
= AStart
| AMiddle
| AEnd
anchorLabel :: APosition -> T.Text
anchorLabel :: APosition -> FieldName
anchorLabel APosition
AStart = FieldName
"start"
anchorLabel APosition
AMiddle = FieldName
"middle"
anchorLabel APosition
AEnd = FieldName
"end"
data Orientation
= Horizontal
| Vertical
orientationSpec :: Orientation -> VLSpec
orientationSpec :: Orientation -> Value
orientationSpec Orientation
Horizontal = Value
"horizontal"
orientationSpec Orientation
Vertical = Value
"vertical"
data Position
= X
| Y
| X2
| Y2
| Theta
| Theta2
| R
| R2
| XError
| XError2
| YError
| YError2
| Longitude
| Latitude
| Longitude2
| Latitude2
positionLabel :: Position -> T.Text
positionLabel :: Position -> FieldName
positionLabel Position
X = FieldName
"x"
positionLabel Position
Y = FieldName
"y"
positionLabel Position
X2 = FieldName
"x2"
positionLabel Position
Y2 = FieldName
"y2"
positionLabel Position
Theta = FieldName
"theta"
positionLabel Position
Theta2 = FieldName
"theta2"
positionLabel Position
R = FieldName
"radius"
positionLabel Position
R2 = FieldName
"radius2"
positionLabel Position
XError = FieldName
"xError"
positionLabel Position
YError = FieldName
"yError"
positionLabel Position
XError2 = FieldName
"xError2"
positionLabel Position
YError2 = FieldName
"yError2"
positionLabel Position
Longitude = FieldName
"longitude"
positionLabel Position
Latitude = FieldName
"latitude"
positionLabel Position
Longitude2 = FieldName
"longitude2"
positionLabel Position
Latitude2 = FieldName
"latitude2"
data HAlign
= AlignCenter
| AlignLeft
| AlignRight
data VAlign
= AlignTop
| AlignMiddle
| AlignBottom
| AlignBaseline
| AlignLineTop
| AlignLineBottom
hAlignLabel :: HAlign -> T.Text
hAlignLabel :: HAlign -> FieldName
hAlignLabel HAlign
AlignLeft = FieldName
"left"
hAlignLabel HAlign
AlignCenter = FieldName
"center"
hAlignLabel HAlign
AlignRight = FieldName
"right"
vAlignLabel :: VAlign -> T.Text
vAlignLabel :: VAlign -> FieldName
vAlignLabel VAlign
AlignTop = FieldName
"top"
vAlignLabel VAlign
AlignMiddle = FieldName
"middle"
vAlignLabel VAlign
AlignBottom = FieldName
"bottom"
vAlignLabel VAlign
AlignBaseline = FieldName
"alphabetic"
vAlignLabel VAlign
AlignLineTop = FieldName
"line-top"
vAlignLabel VAlign
AlignLineBottom = FieldName
"line-bottom"
data BandAlign
= BCenter
| BExtent
bandAlignLabel :: BandAlign -> T.Text
bandAlignLabel :: BandAlign -> FieldName
bandAlignLabel BandAlign
BCenter = FieldName
"center"
bandAlignLabel BandAlign
BExtent = FieldName
"extent"
data StrokeCap
= CButt
| CRound
| CSquare
strokeCapLabel :: StrokeCap -> T.Text
strokeCapLabel :: StrokeCap -> FieldName
strokeCapLabel StrokeCap
CButt = FieldName
"butt"
strokeCapLabel StrokeCap
CRound = FieldName
"round"
strokeCapLabel StrokeCap
CSquare = FieldName
"square"
data StrokeJoin
= JMiter
| JRound
| JBevel
strokeJoinLabel :: StrokeJoin -> T.Text
strokeJoinLabel :: StrokeJoin -> FieldName
strokeJoinLabel StrokeJoin
JMiter = FieldName
"miter"
strokeJoinLabel StrokeJoin
JRound = FieldName
"round"
strokeJoinLabel StrokeJoin
JBevel = FieldName
"bevel"
data Scale
= ScLinear
| ScLog
| ScPow
| ScSqrt
| ScSymLog
| ScTime
| ScUtc
| ScQuantile
| ScQuantize
| ScThreshold
| ScBinOrdinal
| ScOrdinal
| ScPoint
| ScBand
scaleLabel :: Scale -> T.Text
scaleLabel :: Scale -> FieldName
scaleLabel Scale
ScLinear = FieldName
"linear"
scaleLabel Scale
ScLog = FieldName
"log"
scaleLabel Scale
ScPow = FieldName
"pow"
scaleLabel Scale
ScSqrt = FieldName
"sqrt"
scaleLabel Scale
ScSymLog = FieldName
"symlog"
scaleLabel Scale
ScTime = FieldName
"time"
scaleLabel Scale
ScUtc = FieldName
"utc"
scaleLabel Scale
ScQuantile = FieldName
"quantile"
scaleLabel Scale
ScQuantize = FieldName
"quantize"
scaleLabel Scale
ScThreshold = FieldName
"threshold"
scaleLabel Scale
ScBinOrdinal = FieldName
"bin-ordinal"
scaleLabel Scale
ScOrdinal = FieldName
"ordinal"
scaleLabel Scale
ScPoint = FieldName
"point"
scaleLabel Scale
ScBand = FieldName
"band"
data SortField
= WAscending FieldName
| WDescending FieldName
sortFieldSpec :: SortField -> VLSpec
sortFieldSpec :: SortField -> Value
sortFieldSpec (WAscending FieldName
f) = [LabelledSpec] -> Value
object [FieldName -> LabelledSpec
field_ FieldName
f, FieldName -> LabelledSpec
order_ FieldName
"ascending"]
sortFieldSpec (WDescending FieldName
f) = [LabelledSpec] -> Value
object [FieldName -> LabelledSpec
field_ FieldName
f, FieldName -> LabelledSpec
order_ FieldName
"descending"]
data Cursor
= CAuto
| CDefault
| CNone
|
| CHelp
| CPointer
| CProgress
| CWait
| CCell
| CCrosshair
| CText
| CVerticalText
| CAlias
| CCopy
| CMove
| CNoDrop
| CNotAllowed
| CAllScroll
| CColResize
| CRowResize
| CNResize
| CEResize
| CSResize
| CWResize
| CNEResize
| CNWResize
| CSEResize
| CSWResize
| CEWResize
| CNSResize
| CNESWResize
| CNWSEResize
| CZoomIn
| CZoomOut
| CGrab
| CGrabbing
cursorLabel :: Cursor -> T.Text
cursorLabel :: Cursor -> FieldName
cursorLabel Cursor
CAuto = FieldName
"auto"
cursorLabel Cursor
CDefault = FieldName
"default"
cursorLabel Cursor
CNone = FieldName
"none"
cursorLabel Cursor
CContextMenu = FieldName
"context-menu"
cursorLabel Cursor
CHelp = FieldName
"help"
cursorLabel Cursor
CPointer = FieldName
"pointer"
cursorLabel Cursor
CProgress = FieldName
"progress"
cursorLabel Cursor
CWait = FieldName
"wait"
cursorLabel Cursor
CCell = FieldName
"cell"
cursorLabel Cursor
CCrosshair = FieldName
"crosshair"
cursorLabel Cursor
CText = FieldName
"text"
cursorLabel Cursor
CVerticalText = FieldName
"vertical-text"
cursorLabel Cursor
CAlias = FieldName
"alias"
cursorLabel Cursor
CCopy = FieldName
"copy"
cursorLabel Cursor
CMove = FieldName
"move"
cursorLabel Cursor
CNoDrop = FieldName
"no-drop"
cursorLabel Cursor
CNotAllowed = FieldName
"not-allowed"
cursorLabel Cursor
CAllScroll = FieldName
"all-scroll"
cursorLabel Cursor
CColResize = FieldName
"col-resize"
cursorLabel Cursor
CRowResize = FieldName
"row-resize"
cursorLabel Cursor
CNResize = FieldName
"n-resize"
cursorLabel Cursor
CEResize = FieldName
"e-resize"
cursorLabel Cursor
CSResize = FieldName
"s-resize"
cursorLabel Cursor
CWResize = FieldName
"w-resize"
cursorLabel Cursor
CNEResize = FieldName
"ne-resize"
cursorLabel Cursor
CNWResize = FieldName
"nw-resize"
cursorLabel Cursor
CSEResize = FieldName
"se-resize"
cursorLabel Cursor
CSWResize = FieldName
"sw-resize"
cursorLabel Cursor
CEWResize = FieldName
"ew-resize"
cursorLabel Cursor
CNSResize = FieldName
"ns-resize"
cursorLabel Cursor
CNESWResize = FieldName
"nesw-resize"
cursorLabel Cursor
CNWSEResize = FieldName
"nwse-resize"
cursorLabel Cursor
CZoomIn = FieldName
"zoom-in"
cursorLabel Cursor
CZoomOut = FieldName
"zoom-out"
cursorLabel Cursor
CGrab = FieldName
"grab"
cursorLabel Cursor
CGrabbing = FieldName
"grabbing"
data OverlapStrategy
= ONone
| OParity
| OGreedy
overlapStrategyLabel :: OverlapStrategy -> VLSpec
overlapStrategyLabel :: OverlapStrategy -> Value
overlapStrategyLabel OverlapStrategy
ONone = Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
False
overlapStrategyLabel OverlapStrategy
OParity = Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
True
overlapStrategyLabel OverlapStrategy
OGreedy = FieldName -> Value
fromT FieldName
"greedy"
data Side
= STop
| SBottom
| SLeft
| SRight
sideLabel :: Side -> T.Text
sideLabel :: Side -> FieldName
sideLabel Side
STop = FieldName
"top"
sideLabel Side
SBottom = FieldName
"bottom"
sideLabel Side
SLeft = FieldName
"left"
sideLabel Side
SRight = FieldName
"right"
data Symbol
= SymCircle
| SymSquare
| SymCross
| SymDiamond
| SymTriangleUp
| SymTriangleDown
| SymTriangleRight
| SymTriangleLeft
| SymStroke
| SymArrow
| SymTriangle
| SymWedge
| SymPath T.Text
symbolLabel :: Symbol -> T.Text
symbolLabel :: Symbol -> FieldName
symbolLabel Symbol
SymCircle = FieldName
"circle"
symbolLabel Symbol
SymSquare = FieldName
"square"
symbolLabel Symbol
SymCross = FieldName
"cross"
symbolLabel Symbol
SymDiamond = FieldName
"diamond"
symbolLabel Symbol
SymTriangleUp = FieldName
"triangle-up"
symbolLabel Symbol
SymTriangleDown = FieldName
"triangle-down"
symbolLabel Symbol
SymTriangleRight = FieldName
"triangle-right"
symbolLabel Symbol
SymTriangleLeft = FieldName
"triangle-left"
symbolLabel Symbol
SymStroke = FieldName
"stroke"
symbolLabel Symbol
SymArrow = FieldName
"arrow"
symbolLabel Symbol
SymTriangle = FieldName
"triangle"
symbolLabel Symbol
SymWedge = FieldName
"wedge"
symbolLabel (SymPath FieldName
svgPath) = FieldName
svgPath
data StackProperty
= StOffset StackOffset
| StSort [SortField]
data StackOffset
= StZero
| StNormalize
| StCenter
| NoStack
stackOffsetSpec :: StackOffset -> VLSpec
stackOffsetSpec :: StackOffset -> Value
stackOffsetSpec StackOffset
StZero = Value
"zero"
stackOffsetSpec StackOffset
StNormalize = Value
"normalize"
stackOffsetSpec StackOffset
StCenter = Value
"center"
stackOffsetSpec StackOffset
NoStack = Value
A.Null
stackOffset :: StackOffset -> LabelledSpec
stackOffset :: StackOffset -> LabelledSpec
stackOffset StackOffset
so = FieldName
"stack" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= StackOffset -> Value
stackOffsetSpec StackOffset
so
stackPropertySpecOffset , stackPropertySpecSort:: StackProperty -> Maybe VLSpec
stackPropertySpecOffset :: StackProperty -> Maybe Value
stackPropertySpecOffset (StOffset StackOffset
op) = Value -> Maybe Value
forall a. a -> Maybe a
Just (StackOffset -> Value
stackOffsetSpec StackOffset
op)
stackPropertySpecOffset StackProperty
_ = Maybe Value
forall a. Maybe a
Nothing
stackPropertySpecSort :: StackProperty -> Maybe Value
stackPropertySpecSort (StSort [SortField]
sfs) = Value -> Maybe Value
forall a. a -> Maybe a
Just ([Value] -> Value
forall a. ToJSON a => a -> Value
toJSON ((SortField -> Value) -> [SortField] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map SortField -> Value
sortFieldSpec [SortField]
sfs))
stackPropertySpecSort StackProperty
_ = Maybe Value
forall a. Maybe a
Nothing
data TooltipContent
= TTEncoding
| TTData
| TTNone
ttContentLabel :: TooltipContent -> T.Text
ttContentLabel :: TooltipContent -> FieldName
ttContentLabel TooltipContent
TTEncoding = FieldName
"encoding"
ttContentLabel TooltipContent
TTData = FieldName
"data"
ttContentLabel TooltipContent
TTNone = FieldName
"null"
data Channel
= ChX
| ChY
| ChX2
| ChY2
| ChLongitude
| ChLongitude2
| ChLatitude
| ChLatitude2
| ChAngle
| ChTheta
| ChTheta2
| ChRadius
| ChRadius2
| ChColor
| ChFill
| ChFillOpacity
| ChHref
| ChKey
| ChOpacity
| ChShape
| ChSize
| ChStroke
| ChStrokeDash
| ChStrokeOpacity
| ChStrokeWidth
| ChText
| ChDescription
| ChURL
channelLabel :: Channel -> T.Text
channelLabel :: Channel -> FieldName
channelLabel Channel
ChX = FieldName
"x"
channelLabel Channel
ChY = FieldName
"y"
channelLabel Channel
ChX2 = FieldName
"x2"
channelLabel Channel
ChY2 = FieldName
"y2"
channelLabel Channel
ChLongitude = FieldName
"longitude"
channelLabel Channel
ChLongitude2 = FieldName
"longitude2"
channelLabel Channel
ChLatitude = FieldName
"latitude"
channelLabel Channel
ChLatitude2 = FieldName
"latitude2"
channelLabel Channel
ChAngle = FieldName
"angle"
channelLabel Channel
ChTheta = FieldName
"theta"
channelLabel Channel
ChTheta2 = FieldName
"theta2"
channelLabel Channel
ChRadius = FieldName
"radius"
channelLabel Channel
ChRadius2 = FieldName
"radius2"
channelLabel Channel
ChColor = FieldName
"color"
channelLabel Channel
ChFill = FieldName
"fill"
channelLabel Channel
ChFillOpacity = FieldName
"fillOpacity"
channelLabel Channel
ChHref = FieldName
"href"
channelLabel Channel
ChKey = FieldName
"key"
channelLabel Channel
ChOpacity = FieldName
"opacity"
channelLabel Channel
ChShape = FieldName
"shape"
channelLabel Channel
ChSize = FieldName
"size"
channelLabel Channel
ChStroke = FieldName
"stroke"
channelLabel Channel
ChStrokeDash = FieldName
"strokeDash"
channelLabel Channel
ChStrokeOpacity = FieldName
"strokeOpacity"
channelLabel Channel
ChStrokeWidth = FieldName
"strokeWidth"
channelLabel Channel
ChText = FieldName
"text"
channelLabel Channel
ChDescription = FieldName
"description"
channelLabel Channel
ChURL = FieldName
"url"
data Resolution
= Shared
| Independent
resolutionLabel :: Resolution -> T.Text
resolutionLabel :: Resolution -> FieldName
resolutionLabel Resolution
Shared = FieldName
"shared"
resolutionLabel Resolution
Independent = FieldName
"independent"
data Resolve
= RAxis [(Channel, Resolution)]
| RLegend [(Channel, Resolution)]
| RScale [(Channel, Resolution)]
resolveProperty :: Resolve -> ResolveSpec
resolveProperty :: Resolve -> ResolveSpec
resolveProperty Resolve
res =
let (FieldName
nme, [(Channel, Resolution)]
rls) = case Resolve
res of
RAxis [(Channel, Resolution)]
chRules -> (FieldName
"axis", [(Channel, Resolution)]
chRules)
RLegend [(Channel, Resolution)]
chRules -> (FieldName
"legend", [(Channel, Resolution)]
chRules)
RScale [(Channel, Resolution)]
chRules -> (FieldName
"scale", [(Channel, Resolution)]
chRules)
ans :: [LabelledSpec]
ans = ((Channel, Resolution) -> LabelledSpec)
-> [(Channel, Resolution)] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map (\(Channel
ch, Resolution
rule) -> Channel -> FieldName
channelLabel Channel
ch FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Resolution -> FieldName
resolutionLabel Resolution
rule) [(Channel, Resolution)]
rls
in LabelledSpec -> ResolveSpec
RS (FieldName
nme, [LabelledSpec] -> Value
object [LabelledSpec]
ans)
data Bounds
= Full
| Flush
boundsSpec :: Bounds -> VLSpec
boundsSpec :: Bounds -> Value
boundsSpec Bounds
Full = Value
"full"
boundsSpec Bounds
Flush = Value
"flush"
data CompositionAlignment
= CANone
| CAEach
| CAAll
compositionAlignmentSpec :: CompositionAlignment -> VLSpec
compositionAlignmentSpec :: CompositionAlignment -> Value
compositionAlignmentSpec CompositionAlignment
CANone = Value
"none"
compositionAlignmentSpec CompositionAlignment
CAEach = Value
"each"
compositionAlignmentSpec CompositionAlignment
CAAll = Value
"all"
data Padding
= PSize Double
| PEdges Double Double Double Double
paddingSpec :: Padding -> VLSpec
paddingSpec :: Padding -> Value
paddingSpec (PSize Double
p) = Double -> Value
forall a. ToJSON a => a -> Value
toJSON Double
p
paddingSpec (PEdges Double
l Double
t Double
r Double
b) =
[LabelledSpec] -> Value
object [ FieldName
"left" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
l
, FieldName
"top" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
t
, FieldName
"right" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
r
, FieldName
"bottom" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
b
]
data Autosize
= AContent
| AFit
| AFitX
| AFitY
| ANone
| APad
| APadding
| AResize
autosizeProperty :: Autosize -> LabelledSpec
autosizeProperty :: Autosize -> LabelledSpec
autosizeProperty Autosize
APad = FieldName
"type" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromT FieldName
"pad"
autosizeProperty Autosize
AFit = FieldName
"type" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromT FieldName
"fit"
autosizeProperty Autosize
AFitX = FieldName
"type" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromT FieldName
"fit-x"
autosizeProperty Autosize
AFitY = FieldName
"type" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromT FieldName
"fit-y"
autosizeProperty Autosize
ANone = FieldName
"type" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromT FieldName
"none"
autosizeProperty Autosize
AResize = FieldName
"resize" FieldName -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Bool
True
autosizeProperty Autosize
AContent = FieldName
"contains" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromT FieldName
"content"
autosizeProperty Autosize
APadding = FieldName
"contains" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromT FieldName
"padding"
data RepeatFields
= RowFields [FieldName]
| ColumnFields [FieldName]
| LayerFields [FieldName]
repeatFieldsProperty :: RepeatFields -> LabelledSpec
repeatFieldsProperty :: RepeatFields -> LabelledSpec
repeatFieldsProperty (RowFields [FieldName]
fs) = FieldName
"row" FieldName -> [FieldName] -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= [FieldName]
fs
repeatFieldsProperty (ColumnFields [FieldName]
fs) = FieldName
"column" FieldName -> [FieldName] -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= [FieldName]
fs
repeatFieldsProperty (LayerFields [FieldName]
fs) = FieldName
"layer" FieldName -> [FieldName] -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= [FieldName]
fs
data CInterpolate
= CubeHelix Double
| CubeHelixLong Double
| Hcl
| HclLong
| Hsl
| HslLong
| Lab
| Rgb Double
pairT :: T.Text -> T.Text -> (T.Text, A.Value)
pairT :: FieldName -> FieldName -> LabelledSpec
pairT FieldName
a FieldName
b = FieldName
a FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
b
cInterpolateSpec :: CInterpolate -> VLSpec
cInterpolateSpec :: CInterpolate -> Value
cInterpolateSpec (Rgb Double
gamma) = [LabelledSpec] -> Value
object [FieldName -> FieldName -> LabelledSpec
pairT FieldName
"type" FieldName
"rgb", FieldName
"gamma" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
gamma]
cInterpolateSpec CInterpolate
Hsl = [LabelledSpec] -> Value
object [FieldName -> FieldName -> LabelledSpec
pairT FieldName
"type" FieldName
"hsl"]
cInterpolateSpec CInterpolate
HslLong = [LabelledSpec] -> Value
object [FieldName -> FieldName -> LabelledSpec
pairT FieldName
"type" FieldName
"hsl-long"]
cInterpolateSpec CInterpolate
Lab = [LabelledSpec] -> Value
object [FieldName -> FieldName -> LabelledSpec
pairT FieldName
"type" FieldName
"lab"]
cInterpolateSpec CInterpolate
Hcl = [LabelledSpec] -> Value
object [FieldName -> FieldName -> LabelledSpec
pairT FieldName
"type" FieldName
"hcl"]
cInterpolateSpec CInterpolate
HclLong = [LabelledSpec] -> Value
object [FieldName -> FieldName -> LabelledSpec
pairT FieldName
"type" FieldName
"hcl-long"]
cInterpolateSpec (CubeHelix Double
gamma) = [LabelledSpec] -> Value
object [FieldName -> FieldName -> LabelledSpec
pairT FieldName
"type" FieldName
"cubehelix", FieldName
"gamma" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
gamma]
cInterpolateSpec (CubeHelixLong Double
gamma) = [LabelledSpec] -> Value
object [FieldName -> FieldName -> LabelledSpec
pairT FieldName
"type" FieldName
"cubehelix-long", FieldName
"gamma" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
gamma]
data ViewBackground
= VBStyle [StyleLabel]
| VBCornerRadius Double
| VBFill Color
| VBNoFill
| VBFillOpacity Opacity
| VBOpacity Opacity
| VBStroke Color
| VBNoStroke
| VBStrokeOpacity Opacity
| VBStrokeWidth Double
| VBStrokeCap StrokeCap
| VBStrokeDash DashStyle
| VBStrokeDashOffset DashOffset
| VBStrokeJoin StrokeJoin
| VBStrokeMiterLimit Double
viewBackgroundSpec :: ViewBackground -> LabelledSpec
viewBackgroundSpec :: ViewBackground -> LabelledSpec
viewBackgroundSpec (VBStyle [FieldName
style]) = FieldName
"style" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
style
viewBackgroundSpec (VBStyle [FieldName]
styles) = FieldName
"style" FieldName -> [FieldName] -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= [FieldName]
styles
viewBackgroundSpec (VBCornerRadius Double
r) = FieldName
"cornerRadius" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
r
viewBackgroundSpec (VBFill FieldName
s) = FieldName
"fill" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
s
viewBackgroundSpec ViewBackground
VBNoFill = FieldName
"fill" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Value
A.Null
viewBackgroundSpec (VBFillOpacity Double
x) = FieldName
"fillOpacity" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
viewBackgroundSpec (VBOpacity Double
x) = FieldName
"opacity" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
viewBackgroundSpec (VBStroke FieldName
s) = FieldName
"stroke" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
s
viewBackgroundSpec ViewBackground
VBNoStroke = FieldName
"stroke" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Value
A.Null
viewBackgroundSpec (VBStrokeOpacity Double
x) = FieldName
"strokeOpacity" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
viewBackgroundSpec (VBStrokeCap StrokeCap
cap) = FieldName
"strokeCap" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= StrokeCap -> FieldName
strokeCapLabel StrokeCap
cap
viewBackgroundSpec (VBStrokeJoin StrokeJoin
jn) = FieldName
"strokeJoin" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= StrokeJoin -> FieldName
strokeJoinLabel StrokeJoin
jn
viewBackgroundSpec (VBStrokeWidth Double
x) = FieldName
"strokeWidth" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
viewBackgroundSpec (VBStrokeDash DashStyle
xs) = FieldName
"strokeDash" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= DashStyle -> Value
fromDS DashStyle
xs
viewBackgroundSpec (VBStrokeDashOffset Double
x) = FieldName
"strokeDashOffset" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
viewBackgroundSpec (VBStrokeMiterLimit Double
x) = FieldName
"strokeMiterLimit" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
data
= HFormat T.Text
| HFormatAsNum
| HFormatAsTemporal
| HFormatAsCustom T.Text
| HLabel Bool
| HLabelAlign HAlign
| HLabelAnchor APosition
| HLabelAngle Angle
| HLabelBaseline VAlign
| HLabelColor Color
| HLabelExpr VegaExpr
| HLabelFont T.Text
| HLabelFontSize Double
| HLabelFontStyle T.Text
| HLabelFontWeight FontWeight
| HLabelLimit Double
| HLabelLineHeight Double
| HLabelOrient Side
| HLabelPadding Double
| HOrient Side
| HTitle T.Text
| HNoTitle
| HTitleAlign HAlign
| HTitleAnchor APosition
| HTitleAngle Angle
| HTitleBaseline VAlign
| HTitleColor Color
| HTitleFont T.Text
| HTitleFontSize Double
| HTitleFontStyle T.Text
| HTitleFontWeight FontWeight
| HTitleLimit Double
| HTitleLineHeight Double
| HTitleOrient Side
| HTitlePadding Double
headerProperty :: HeaderProperty -> LabelledSpec
(HFormat FieldName
fmt) = FieldName
"format" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
fmt
headerProperty HeaderProperty
HFormatAsNum = FieldName
"formatType" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromT FieldName
"number"
headerProperty HeaderProperty
HFormatAsTemporal = FieldName
"formatType" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromT FieldName
"time"
headerProperty (HFormatAsCustom FieldName
c) = FieldName
"formatType" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
c
headerProperty (HTitle FieldName
ttl) = FieldName
"title" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
splitOnNewline FieldName
ttl
headerProperty HeaderProperty
HNoTitle = FieldName
"title" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Value
A.Null
headerProperty (HLabel Bool
b) = FieldName
"labels" FieldName -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Bool
b
headerProperty (HLabelAlign HAlign
ha) = FieldName
"labelAlign" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= HAlign -> FieldName
hAlignLabel HAlign
ha
headerProperty (HLabelAnchor APosition
a) = FieldName
"labelAnchor" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= APosition -> FieldName
anchorLabel APosition
a
headerProperty (HLabelAngle Double
x) = FieldName
"labelAngle" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
headerProperty (HLabelBaseline VAlign
va) = FieldName
"labelBaseline" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= VAlign -> FieldName
vAlignLabel VAlign
va
headerProperty (HLabelColor FieldName
s) = FieldName
"labelColor" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromColor FieldName
s
headerProperty (HLabelExpr FieldName
s) = FieldName
"labelExpr" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
s
headerProperty (HLabelFont FieldName
s) = FieldName
"labelFont" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
s
headerProperty (HLabelFontSize Double
x) = FieldName
"labelFontSize" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
headerProperty (HLabelFontStyle FieldName
s) = FieldName
"labelFontStyle" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
s
headerProperty (HLabelFontWeight FontWeight
w) = FieldName
"labelFontWeight" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FontWeight -> Value
fontWeightSpec FontWeight
w
headerProperty (HLabelLimit Double
x) = FieldName
"labelLimit" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
headerProperty (HLabelLineHeight Double
x) = FieldName
"labelLineHeight" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
headerProperty (HLabelOrient Side
orient) = FieldName
"labelOrient" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Side -> FieldName
sideLabel Side
orient
headerProperty (HLabelPadding Double
x) = FieldName
"labelPadding" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
headerProperty (HOrient Side
orient) = FieldName
"orient" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Side -> FieldName
sideLabel Side
orient
headerProperty (HTitleAlign HAlign
ha) = FieldName
"titleAlign" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= HAlign -> FieldName
hAlignLabel HAlign
ha
headerProperty (HTitleAnchor APosition
a) = FieldName
"titleAnchor" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= APosition -> FieldName
anchorLabel APosition
a
headerProperty (HTitleAngle Double
x) = FieldName
"titleAngle" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
headerProperty (HTitleBaseline VAlign
va) = FieldName
"titleBaseline" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= VAlign -> FieldName
vAlignLabel VAlign
va
headerProperty (HTitleColor FieldName
s) = FieldName
"titleColor" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName -> Value
fromColor FieldName
s
headerProperty (HTitleFont FieldName
s) = FieldName
"titleFont" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
s
headerProperty (HTitleFontWeight FontWeight
fw) = FieldName
"titleFontWeight" FieldName -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FontWeight -> Value
fontWeightSpec FontWeight
fw
headerProperty (HTitleFontSize Double
x) = FieldName
"titleFontSize" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
headerProperty (HTitleFontStyle FieldName
s) = FieldName
"titleFontStyle" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= FieldName
s
headerProperty (HTitleLimit Double
x) = FieldName
"titleLimit" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
headerProperty (HTitleLineHeight Double
x) = FieldName
"titleLineHeight" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x
headerProperty (HTitleOrient Side
orient) = FieldName
"titleOrient" FieldName -> FieldName -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Side -> FieldName
sideLabel Side
orient
headerProperty (HTitlePadding Double
x) = FieldName
"titlePadding" FieldName -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => FieldName -> v -> kv
.= Double
x