{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module Graphics.Vega.VegaLite.Mark
( Mark(..)
, MarkProperty(..)
, MarkInterpolation(..)
, PointMarker(..)
, LineMarker(..)
, MarkErrorExtent(..)
, GradientCoord
, GradientStops
, ColorGradient(..)
, GradientProperty(..)
, TextDirection(..)
, BlendMode(..)
, oldMprops_
, markLabel
, markProperty
) where
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.List (sortOn)
import Graphics.Vega.VegaLite.Foundation
( Angle
, Color
, DashStyle
, DashOffset
, Cursor
, FontWeight
, Opacity
, StyleLabel
, Orientation
, StrokeCap
, StrokeJoin
, Symbol
, TooltipContent(TTNone)
, HAlign
, VAlign
, fromColor
, fromDS
, fromT
, cursorLabel
, fontWeightSpec
, orientationSpec
, strokeCapLabel
, strokeJoinLabel
, symbolLabel
, ttContentLabel
, hAlignLabel
, vAlignLabel
, (.=~)
)
import Graphics.Vega.VegaLite.Specification
( VLSpec
, LabelledSpec
)
#if MIN_VERSION_aeson(2, 0, 0)
mprops_ :: Key.Key -> [MarkProperty] -> Pair
#else
mprops_ :: T.Text -> [MarkProperty] -> Pair
#endif
mprops_ :: Key -> [MarkProperty] -> Pair
mprops_ Key
f [] = Key
f Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
True
mprops_ Key
f [MarkProperty]
mps = Key
f Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object ((MarkProperty -> Pair) -> [MarkProperty] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> Pair
markProperty [MarkProperty]
mps)
oldMprops_ :: T.Text -> [MarkProperty] -> LabelledSpec
oldMprops_ :: Text -> [MarkProperty] -> LabelledSpec
oldMprops_ Text
f [] = Text
f Text -> Bool -> LabelledSpec
forall a. ToJSON a => Text -> a -> LabelledSpec
.=~ Bool
True
oldMprops_ Text
f [MarkProperty]
mps = Text
f Text -> Value -> LabelledSpec
forall a. ToJSON a => Text -> a -> LabelledSpec
.=~ [Pair] -> Value
object ((MarkProperty -> Pair) -> [MarkProperty] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> Pair
markProperty [MarkProperty]
mps)
data Mark
= Arc
| Area
| Bar
| Boxplot
| Circle
| ErrorBar
| ErrorBand
| Geoshape
| Image
| Line
| Point
| Rect
| Rule
| Square
| Text
| Tick
| Trail
markLabel :: Mark -> T.Text
markLabel :: Mark -> Text
markLabel Mark
Arc = Text
"arc"
markLabel Mark
Area = Text
"area"
markLabel Mark
Bar = Text
"bar"
markLabel Mark
Boxplot = Text
"boxplot"
markLabel Mark
Circle = Text
"circle"
markLabel Mark
ErrorBar = Text
"errorbar"
markLabel Mark
ErrorBand = Text
"errorband"
markLabel Mark
Line = Text
"line"
markLabel Mark
Geoshape = Text
"geoshape"
markLabel Mark
Image = Text
"image"
markLabel Mark
Point = Text
"point"
markLabel Mark
Rect = Text
"rect"
markLabel Mark
Rule = Text
"rule"
markLabel Mark
Square = Text
"square"
markLabel Mark
Text = Text
"text"
markLabel Mark
Tick = Text
"tick"
markLabel Mark
Trail = Text
"trail"
data MarkProperty
= MAlign HAlign
| MAngle Angle
| MAria Bool
| MAriaDescription T.Text
| MAriaRole T.Text
| MAriaRoleDescription T.Text
| MAspect Bool
| MBandSize Double
| MBaseline VAlign
| MBinSpacing Double
| MBlend BlendMode
| MBorders [MarkProperty]
| MNoBorders
| MBox [MarkProperty]
| MNoBox
| MClip Bool
| MColor Color
| MColorGradient ColorGradient GradientStops [GradientProperty]
| MCornerRadius Double
| MCornerRadiusEnd Double
| MCornerRadiusTL Double
| MCornerRadiusTR Double
| MCornerRadiusBL Double
| MCornerRadiusBR Double
| MCursor Cursor
| MDir TextDirection
| MContinuousBandSize Double
| MDiscreteBandSize Double
| MdX Double
| MdY Double
| MEllipsis T.Text
| MExtent MarkErrorExtent
| MFill Color
| MFilled Bool
| MFillGradient ColorGradient GradientStops [GradientProperty]
| MFillOpacity Opacity
| MFont T.Text
| MFontSize Double
| MFontStyle T.Text
| MFontWeight FontWeight
| MHeight Double
| MHRef T.Text
| MInnerRadius Double
| MInterpolate MarkInterpolation
| MLimit Double
| MLine LineMarker
| MLineBreak T.Text
| MLineHeight Double
| MMedian [MarkProperty]
| MNoMedian
| MOpacity Opacity
| MOrder Bool
| MOrient Orientation
| MOuterRadius Double
| MOutliers [MarkProperty]
| MNoOutliers
| MPadAngle Double
| MPoint PointMarker
| MRadius Double
| MRadius2 Double
| MRadiusOffset Double
| MRadius2Offset Double
| MRemoveInvalid Bool
| MRule [MarkProperty]
| MNoRule
| MShape Symbol
| MSize Double
| MStroke Color
| MStrokeCap StrokeCap
| MStrokeDash DashStyle
| MStrokeDashOffset DashOffset
| MStrokeGradient ColorGradient GradientStops [GradientProperty]
| MStrokeJoin StrokeJoin
| MStrokeMiterLimit Double
| MStrokeOpacity Opacity
| MStrokeWidth Double
| MStyle [StyleLabel]
| MTension Double
| MText T.Text
| MTexts [T.Text]
| MTheta Double
| MTheta2 Double
| MThetaOffset Double
| MTheta2Offset Double
| MThickness Double
| MTicks [MarkProperty]
| MNoTicks
| MTimeUnitBand Double
| MTimeUnitBandPosition Double
| MTooltip TooltipContent
| MWidth Double
| MX Double
| MX2 Double
| MXOffset Double
| MX2Offset Double
| MY Double
| MY2 Double
| MYOffset Double
| MY2Offset Double
| MXWidth
| MX2Width
| MYHeight
| MY2Height
markProperty :: MarkProperty -> Pair
markProperty :: MarkProperty -> Pair
markProperty (MColorGradient ColorGradient
dir GradientStops
stops [GradientProperty]
opts) =
Key
"color" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ColorGradient -> GradientStops -> [GradientProperty] -> Value
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
opts
markProperty (MFillGradient ColorGradient
dir GradientStops
stops [GradientProperty]
opts) =
Key
"fill" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ColorGradient -> GradientStops -> [GradientProperty] -> Value
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
opts
markProperty (MStrokeGradient ColorGradient
dir GradientStops
stops [GradientProperty]
opts) =
Key
"stroke" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ColorGradient -> GradientStops -> [GradientProperty] -> Value
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
opts
markProperty (MContinuousBandSize Double
x) = Key
"continuousBandSize" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MDiscreteBandSize Double
x) = Key
"discreteBandSize" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MAlign HAlign
algn) = Key
"align" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= HAlign -> Text
hAlignLabel HAlign
algn
markProperty (MAngle Double
x) = Key
"angle" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MAria Bool
b) = Key
"aria" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MAriaDescription Text
t) = Key
"description" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
markProperty (MAriaRole Text
t) = Key
"ariaRole" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
markProperty (MAriaRoleDescription Text
t) = Key
"ariaRoleDescription" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
markProperty (MAspect Bool
b) = Key
"aspect" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MBaseline VAlign
va) = Key
"baseline" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VAlign -> Text
vAlignLabel VAlign
va
markProperty (MBandSize Double
x) = Key
"bandSize" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MBinSpacing Double
x) = Key
"binSpacing" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MBlend BlendMode
bl) = Key
"blend" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BlendMode -> Value
blendModeSpec BlendMode
bl
markProperty MarkProperty
MNoBorders = Key
"borders" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
False
markProperty (MBorders [MarkProperty]
mps) = Key -> [MarkProperty] -> Pair
mprops_ Key
"borders" [MarkProperty]
mps
markProperty MarkProperty
MNoBox = Key
"box" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
False
markProperty (MBox [MarkProperty]
mps) = Key -> [MarkProperty] -> Pair
mprops_ Key
"box" [MarkProperty]
mps
markProperty (MClip Bool
b) = Key
"clip" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MColor Text
col) = Key
"color" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
fromColor Text
col
markProperty (MCornerRadius Double
x) = Key
"cornerRadius" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MCornerRadiusEnd Double
x) = Key
"cornerRadiusEnd" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MCornerRadiusTL Double
x) = Key
"cornerRadiusTopLeft" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MCornerRadiusTR Double
x) = Key
"cornerRadiusTopRight" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MCornerRadiusBL Double
x) = Key
"cornerRadiusBottomLeft" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MCornerRadiusBR Double
x) = Key
"cornerRadiusBottomRight" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MCursor Cursor
cur) = Key
"cursor" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Cursor -> Text
cursorLabel Cursor
cur
markProperty (MDir TextDirection
td) = Key
"dir" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TextDirection -> Text
textdirLabel TextDirection
td
markProperty (MdX Double
dx) = Key
"dx" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
dx
markProperty (MdY Double
dy) = Key
"dy" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
dy
markProperty (MEllipsis Text
s) = Key
"ellipsis" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
markProperty (MExtent MarkErrorExtent
mee) = MarkErrorExtent -> Pair
markErrorExtentLSpec MarkErrorExtent
mee
markProperty (MFill Text
col) = Key
"fill" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
fromColor Text
col
markProperty (MFilled Bool
b) = Key
"filled" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MFillOpacity Double
x) = Key
"fillOpacity" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MFont Text
fnt) = Key
"font" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fnt
markProperty (MFontSize Double
x) = Key
"fontSize" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MFontStyle Text
fSty) = Key
"fontStyle" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fSty
markProperty (MFontWeight FontWeight
w) = Key
"fontWeight" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= FontWeight -> Value
fontWeightSpec FontWeight
w
markProperty (MHeight Double
x) = Key
"height" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MHRef Text
s) = Key
"href" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
markProperty (MInnerRadius Double
r) = Key
"innerRadius" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
r
markProperty (MInterpolate MarkInterpolation
interp) = Key
"interpolate" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= MarkInterpolation -> Text
markInterpolationLabel MarkInterpolation
interp
markProperty (MRemoveInvalid Bool
b) = Key
"invalid" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= if Bool
b then Value
"filter" else Value
A.Null
markProperty (MLimit Double
x) = Key
"limit" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MLine LineMarker
lm) = Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= LineMarker -> Value
lineMarkerSpec LineMarker
lm
markProperty (MLineBreak Text
s) = Key
"lineBreak" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
markProperty (MLineHeight Double
x) = Key
"lineHeight" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty MarkProperty
MNoMedian = Key
"median" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
False
markProperty (MMedian [MarkProperty]
mps) = Key -> [MarkProperty] -> Pair
mprops_ Key
"median" [MarkProperty]
mps
markProperty (MOpacity Double
x) = Key
"opacity" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MOrder Bool
b) = Key
"order" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MOrient Orientation
orient) = Key
"orient" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Orientation -> Value
orientationSpec Orientation
orient
markProperty (MOuterRadius Double
r) = Key
"outerRadius" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
r
markProperty MarkProperty
MNoOutliers = Key
"outliers" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
False
markProperty (MOutliers [MarkProperty]
mps) = Key -> [MarkProperty] -> Pair
mprops_ Key
"outliers" [MarkProperty]
mps
markProperty (MPadAngle Double
x) = Key
"padAngle" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MPoint PointMarker
pm) = Key
"point" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PointMarker -> Value
pointMarkerSpec PointMarker
pm
markProperty (MRadius Double
x) = Key
"radius" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MRadius2 Double
x) = Key
"radius2" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MRadiusOffset Double
x) = Key
"radiusOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MRadius2Offset Double
x) = Key
"radius2Offset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty MarkProperty
MNoRule = Key
"rule" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
False
markProperty (MRule [MarkProperty]
mps) = Key -> [MarkProperty] -> Pair
mprops_ Key
"rule" [MarkProperty]
mps
markProperty (MShape Symbol
sym) = Key
"shape" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Symbol -> Text
symbolLabel Symbol
sym
markProperty (MSize Double
x) = Key
"size" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MStroke Text
t) = Key
"stroke" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
fromColor Text
t
markProperty (MStrokeCap StrokeCap
sc) = Key
"strokeCap" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= StrokeCap -> Text
strokeCapLabel StrokeCap
sc
markProperty (MStrokeDash DashStyle
xs) = Key
"strokeDash" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DashStyle -> Value
fromDS DashStyle
xs
markProperty (MStrokeDashOffset Double
x) = Key
"strokeDashOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MStrokeJoin StrokeJoin
sj) = Key
"strokeJoin" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= StrokeJoin -> Text
strokeJoinLabel StrokeJoin
sj
markProperty (MStrokeMiterLimit Double
x) = Key
"strokeMiterLimit" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MStrokeOpacity Double
x) = Key
"strokeOpacity" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MStrokeWidth Double
w) = Key
"strokeWidth" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
w
markProperty (MStyle [Text
style]) = Key
"style" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
style
markProperty (MStyle [Text]
styles) = Key
"style" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
styles
markProperty (MTension Double
x) = Key
"tension" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MText Text
t) = Key
"text" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
markProperty (MTexts [Text]
ts) = Key
"text" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
ts
markProperty (MTheta Double
x) = Key
"theta" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MTheta2 Double
x) = Key
"theta2" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MThetaOffset Double
x) = Key
"thetaOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MTheta2Offset Double
x) = Key
"theta2Offset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MThickness Double
x) = Key
"thickness" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty MarkProperty
MNoTicks = Key
"ticks" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
False
markProperty (MTicks [MarkProperty]
mps) = Key -> [MarkProperty] -> Pair
mprops_ Key
"ticks" [MarkProperty]
mps
markProperty (MTimeUnitBand Double
x) = Key
"timeUnitBand" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MTimeUnitBandPosition Double
x) = Key
"timeUnitBandPosition" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MTooltip TooltipContent
TTNone) = Key
"tooltip" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value
A.Null
markProperty (MTooltip TooltipContent
tc) = Key
"tooltip" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [Key
"content" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TooltipContent -> Text
ttContentLabel TooltipContent
tc]
markProperty (MWidth Double
x) = Key
"width" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MX Double
x) = Key
"x" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MY Double
x) = Key
"y" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MX2 Double
x) = Key
"x2" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MY2 Double
x) = Key
"y2" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MXOffset Double
x) = Key
"xOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MYOffset Double
x) = Key
"yOffset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MX2Offset Double
x) = Key
"x2Offset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty (MY2Offset Double
x) = Key
"y2Offset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
markProperty MarkProperty
MXWidth = Key
"x" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
fromT Text
"width"
markProperty MarkProperty
MX2Width = Key
"x2" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
fromT Text
"width"
markProperty MarkProperty
MYHeight = Key
"y" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
fromT Text
"height"
markProperty MarkProperty
MY2Height = Key
"y2" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
fromT Text
"height"
gradientSpec :: ColorGradient -> GradientStops -> [GradientProperty] -> VLSpec
gradientSpec :: ColorGradient -> GradientStops -> [GradientProperty] -> Value
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
props =
let sortedStops :: GradientStops
sortedStops = ((Double, Text) -> Double) -> GradientStops -> GradientStops
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn (Double, Text) -> Double
forall a b. (a, b) -> a
fst GradientStops
stops
in [Pair] -> Value
object ([ Key
"gradient" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ColorGradient -> Text
colorGradientLabel ColorGradient
dir
, Key
"stops" Key -> [Value] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ((Double, Text) -> Value) -> GradientStops -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map (Double, Text) -> Value
stopSpec GradientStops
sortedStops ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ (GradientProperty -> Pair) -> [GradientProperty] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map GradientProperty -> Pair
gradientProperty [GradientProperty]
props)
data MarkInterpolation
= Basis
| BasisClosed
| BasisOpen
| Bundle
| Cardinal
| CardinalClosed
| CardinalOpen
| Linear
| LinearClosed
| Monotone
| StepAfter
| StepBefore
| Stepwise
markInterpolationLabel :: MarkInterpolation -> T.Text
markInterpolationLabel :: MarkInterpolation -> Text
markInterpolationLabel MarkInterpolation
Linear = Text
"linear"
markInterpolationLabel MarkInterpolation
LinearClosed = Text
"linear-closed"
markInterpolationLabel MarkInterpolation
Stepwise = Text
"step"
markInterpolationLabel MarkInterpolation
StepBefore = Text
"step-before"
markInterpolationLabel MarkInterpolation
StepAfter = Text
"step-after"
markInterpolationLabel MarkInterpolation
Basis = Text
"basis"
markInterpolationLabel MarkInterpolation
BasisOpen = Text
"basis-open"
markInterpolationLabel MarkInterpolation
BasisClosed = Text
"basis-closed"
markInterpolationLabel MarkInterpolation
Cardinal = Text
"cardinal"
markInterpolationLabel MarkInterpolation
CardinalOpen = Text
"cardinal-open"
markInterpolationLabel MarkInterpolation
CardinalClosed = Text
"cardinal-closed"
markInterpolationLabel MarkInterpolation
Bundle = Text
"bundle"
markInterpolationLabel MarkInterpolation
Monotone = Text
"monotone"
data PointMarker
= PMTransparent
| PMNone
| PMMarker [MarkProperty]
pointMarkerSpec :: PointMarker -> VLSpec
pointMarkerSpec :: PointMarker -> Value
pointMarkerSpec PointMarker
PMTransparent = Value
"transparent"
pointMarkerSpec PointMarker
PMNone = Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
False
pointMarkerSpec (PMMarker []) = Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
True
pointMarkerSpec (PMMarker [MarkProperty]
mps) = [Pair] -> Value
object ((MarkProperty -> Pair) -> [MarkProperty] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> Pair
markProperty [MarkProperty]
mps)
data LineMarker
= LMNone
| LMMarker [MarkProperty]
lineMarkerSpec :: LineMarker -> VLSpec
lineMarkerSpec :: LineMarker -> Value
lineMarkerSpec LineMarker
LMNone = Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
False
lineMarkerSpec (LMMarker []) = Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
True
lineMarkerSpec (LMMarker [MarkProperty]
mps) = [Pair] -> Value
object ((MarkProperty -> Pair) -> [MarkProperty] -> [Pair]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> Pair
markProperty [MarkProperty]
mps)
data MarkErrorExtent
= ConfidenceInterval
| StdErr
| StdDev
| Iqr
| ExRange
| IqrScale Double
extent_ :: T.Text -> Pair
extent_ :: Text -> Pair
extent_ Text
v = Key
"extent" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
v
markErrorExtentLSpec :: MarkErrorExtent -> Pair
markErrorExtentLSpec :: MarkErrorExtent -> Pair
markErrorExtentLSpec MarkErrorExtent
ConfidenceInterval = Text -> Pair
extent_ Text
"ci"
markErrorExtentLSpec MarkErrorExtent
StdErr = Text -> Pair
extent_ Text
"stderr"
markErrorExtentLSpec MarkErrorExtent
StdDev = Text -> Pair
extent_ Text
"stdev"
markErrorExtentLSpec MarkErrorExtent
Iqr = Text -> Pair
extent_ Text
"iqr"
markErrorExtentLSpec MarkErrorExtent
ExRange = Text -> Pair
extent_ Text
"min-max"
markErrorExtentLSpec (IqrScale Double
sc) = Key
"extent" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
sc
data ColorGradient
= GrLinear
| GrRadial
colorGradientLabel :: ColorGradient -> T.Text
colorGradientLabel :: ColorGradient -> Text
colorGradientLabel ColorGradient
GrLinear = Text
"linear"
colorGradientLabel ColorGradient
GrRadial = Text
"radial"
type GradientCoord = Double
type GradientStops = [(GradientCoord, Color)]
stopSpec :: (GradientCoord, Color) -> VLSpec
stopSpec :: (Double, Text) -> Value
stopSpec (Double
x, Text
c) = [Pair] -> Value
object [ Key
"offset" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x, Key
"color" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
fromColor Text
c ]
data GradientProperty
= GrX1 GradientCoord
| GrY1 GradientCoord
| GrX2 GradientCoord
| GrY2 GradientCoord
| GrR1 GradientCoord
| GrR2 GradientCoord
gradientProperty :: GradientProperty -> Pair
gradientProperty :: GradientProperty -> Pair
gradientProperty (GrX1 Double
x) = Key
"x1" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
gradientProperty (GrX2 Double
x) = Key
"x2" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
gradientProperty (GrY1 Double
x) = Key
"y1" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
gradientProperty (GrY2 Double
x) = Key
"y2" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
gradientProperty (GrR1 Double
x) = Key
"r1" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
gradientProperty (GrR2 Double
x) = Key
"r2" Key -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double
x
data TextDirection
= LTR
| RTL
textdirLabel :: TextDirection -> T.Text
textdirLabel :: TextDirection -> Text
textdirLabel TextDirection
LTR = Text
"ltr"
textdirLabel TextDirection
RTL = Text
"rtl"
data BlendMode
= BMNormal
| BMMultiply
| BMScreen
| BMOverlay
| BMDarken
| BMLighten
| BMColorDodge
| BMColorBurn
| BMHardLight
| BMSoftLight
| BMDifference
| BMExclusion
| BMHue
| BMSaturation
| BMColor
| BMLuminosity
blendModeSpec :: BlendMode -> VLSpec
blendModeSpec :: BlendMode -> Value
blendModeSpec BlendMode
BMNormal = Value
A.Null
blendModeSpec BlendMode
BMMultiply = Text -> Value
fromT Text
"multiply"
blendModeSpec BlendMode
BMScreen = Text -> Value
fromT Text
"screen"
blendModeSpec BlendMode
BMOverlay = Text -> Value
fromT Text
"overlay"
blendModeSpec BlendMode
BMDarken = Text -> Value
fromT Text
"darken"
blendModeSpec BlendMode
BMLighten = Text -> Value
fromT Text
"lighten"
blendModeSpec BlendMode
BMColorDodge = Text -> Value
fromT Text
"color-dodge"
blendModeSpec BlendMode
BMColorBurn = Text -> Value
fromT Text
"color-burn"
blendModeSpec BlendMode
BMHardLight = Text -> Value
fromT Text
"hard-light"
blendModeSpec BlendMode
BMSoftLight = Text -> Value
fromT Text
"soft-light"
blendModeSpec BlendMode
BMDifference = Text -> Value
fromT Text
"difference"
blendModeSpec BlendMode
BMExclusion = Text -> Value
fromT Text
"exclusion"
blendModeSpec BlendMode
BMHue = Text -> Value
fromT Text
"hue"
blendModeSpec BlendMode
BMSaturation = Text -> Value
fromT Text
"saturation"
blendModeSpec BlendMode
BMColor = Text -> Value
fromT Text
"color"
blendModeSpec BlendMode
BMLuminosity = Text -> Value
fromT Text
"luminosity"