{-# 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 forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
True
mprops_ Key
f [MarkProperty]
mps = Key
f forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object (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 forall a. ToJSON a => Text -> a -> LabelledSpec
.=~ Bool
True
oldMprops_ Text
f [MarkProperty]
mps = Text
f forall a. ToJSON a => Text -> a -> LabelledSpec
.=~ [Pair] -> VLSpec
object (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" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ColorGradient -> GradientStops -> [GradientProperty] -> VLSpec
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
opts
markProperty (MFillGradient ColorGradient
dir GradientStops
stops [GradientProperty]
opts) =
Key
"fill" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ColorGradient -> GradientStops -> [GradientProperty] -> VLSpec
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
opts
markProperty (MStrokeGradient ColorGradient
dir GradientStops
stops [GradientProperty]
opts) =
Key
"stroke" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ColorGradient -> GradientStops -> [GradientProperty] -> VLSpec
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
opts
markProperty (MContinuousBandSize GradientCoord
x) = Key
"continuousBandSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MDiscreteBandSize GradientCoord
x) = Key
"discreteBandSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MAlign HAlign
algn) = Key
"align" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= HAlign -> Text
hAlignLabel HAlign
algn
markProperty (MAngle GradientCoord
x) = Key
"angle" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MAria Bool
b) = Key
"aria" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MAriaDescription Text
t) = Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
markProperty (MAriaRole Text
t) = Key
"ariaRole" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
markProperty (MAriaRoleDescription Text
t) = Key
"ariaRoleDescription" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
markProperty (MAspect Bool
b) = Key
"aspect" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MBaseline VAlign
va) = Key
"baseline" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VAlign -> Text
vAlignLabel VAlign
va
markProperty (MBandSize GradientCoord
x) = Key
"bandSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MBinSpacing GradientCoord
x) = Key
"binSpacing" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MBlend BlendMode
bl) = Key
"blend" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BlendMode -> VLSpec
blendModeSpec BlendMode
bl
markProperty MarkProperty
MNoBorders = Key
"borders" 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" 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" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MColor Text
col) = Key
"color" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromColor Text
col
markProperty (MCornerRadius GradientCoord
x) = Key
"cornerRadius" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MCornerRadiusEnd GradientCoord
x) = Key
"cornerRadiusEnd" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MCornerRadiusTL GradientCoord
x) = Key
"cornerRadiusTopLeft" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MCornerRadiusTR GradientCoord
x) = Key
"cornerRadiusTopRight" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MCornerRadiusBL GradientCoord
x) = Key
"cornerRadiusBottomLeft" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MCornerRadiusBR GradientCoord
x) = Key
"cornerRadiusBottomRight" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MCursor Cursor
cur) = Key
"cursor" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Cursor -> Text
cursorLabel Cursor
cur
markProperty (MDir TextDirection
td) = Key
"dir" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TextDirection -> Text
textdirLabel TextDirection
td
markProperty (MdX GradientCoord
dx) = Key
"dx" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
dx
markProperty (MdY GradientCoord
dy) = Key
"dy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
dy
markProperty (MEllipsis Text
s) = Key
"ellipsis" 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" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromColor Text
col
markProperty (MFilled Bool
b) = Key
"filled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MFillOpacity GradientCoord
x) = Key
"fillOpacity" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MFont Text
fnt) = Key
"font" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fnt
markProperty (MFontSize GradientCoord
x) = Key
"fontSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MFontStyle Text
fSty) = Key
"fontStyle" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fSty
markProperty (MFontWeight FontWeight
w) = Key
"fontWeight" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= FontWeight -> VLSpec
fontWeightSpec FontWeight
w
markProperty (MHeight GradientCoord
x) = Key
"height" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MHRef Text
s) = Key
"href" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
markProperty (MInnerRadius GradientCoord
r) = Key
"innerRadius" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
r
markProperty (MInterpolate MarkInterpolation
interp) = Key
"interpolate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= MarkInterpolation -> Text
markInterpolationLabel MarkInterpolation
interp
markProperty (MRemoveInvalid Bool
b) = Key
"invalid" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= if Bool
b then VLSpec
"filter" else VLSpec
A.Null
markProperty (MLimit GradientCoord
x) = Key
"limit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MLine LineMarker
lm) = Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= LineMarker -> VLSpec
lineMarkerSpec LineMarker
lm
markProperty (MLineBreak Text
s) = Key
"lineBreak" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s
markProperty (MLineHeight GradientCoord
x) = Key
"lineHeight" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty MarkProperty
MNoMedian = Key
"median" 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 GradientCoord
x) = Key
"opacity" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MOrder Bool
b) = Key
"order" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
b
markProperty (MOrient Orientation
orient) = Key
"orient" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Orientation -> VLSpec
orientationSpec Orientation
orient
markProperty (MOuterRadius GradientCoord
r) = Key
"outerRadius" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
r
markProperty MarkProperty
MNoOutliers = Key
"outliers" 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 GradientCoord
x) = Key
"padAngle" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MPoint PointMarker
pm) = Key
"point" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PointMarker -> VLSpec
pointMarkerSpec PointMarker
pm
markProperty (MRadius GradientCoord
x) = Key
"radius" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MRadius2 GradientCoord
x) = Key
"radius2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MRadiusOffset GradientCoord
x) = Key
"radiusOffset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MRadius2Offset GradientCoord
x) = Key
"radius2Offset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty MarkProperty
MNoRule = Key
"rule" 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" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Symbol -> Text
symbolLabel Symbol
sym
markProperty (MSize GradientCoord
x) = Key
"size" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MStroke Text
t) = Key
"stroke" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromColor Text
t
markProperty (MStrokeCap StrokeCap
sc) = Key
"strokeCap" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= StrokeCap -> Text
strokeCapLabel StrokeCap
sc
markProperty (MStrokeDash DashStyle
xs) = Key
"strokeDash" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DashStyle -> VLSpec
fromDS DashStyle
xs
markProperty (MStrokeDashOffset GradientCoord
x) = Key
"strokeDashOffset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MStrokeJoin StrokeJoin
sj) = Key
"strokeJoin" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= StrokeJoin -> Text
strokeJoinLabel StrokeJoin
sj
markProperty (MStrokeMiterLimit GradientCoord
x) = Key
"strokeMiterLimit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MStrokeOpacity GradientCoord
x) = Key
"strokeOpacity" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MStrokeWidth GradientCoord
w) = Key
"strokeWidth" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
w
markProperty (MStyle [Text
style]) = Key
"style" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
style
markProperty (MStyle [Text]
styles) = Key
"style" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
styles
markProperty (MTension GradientCoord
x) = Key
"tension" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MText Text
t) = Key
"text" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
markProperty (MTexts [Text]
ts) = Key
"text" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
ts
markProperty (MTheta GradientCoord
x) = Key
"theta" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MTheta2 GradientCoord
x) = Key
"theta2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MThetaOffset GradientCoord
x) = Key
"thetaOffset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MTheta2Offset GradientCoord
x) = Key
"theta2Offset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MThickness GradientCoord
x) = Key
"thickness" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty MarkProperty
MNoTicks = Key
"ticks" 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 GradientCoord
x) = Key
"timeUnitBand" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MTimeUnitBandPosition GradientCoord
x) = Key
"timeUnitBandPosition" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MTooltip TooltipContent
TTNone) = Key
"tooltip" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VLSpec
A.Null
markProperty (MTooltip TooltipContent
tc) = Key
"tooltip" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> VLSpec
object [Key
"content" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TooltipContent -> Text
ttContentLabel TooltipContent
tc]
markProperty (MWidth GradientCoord
x) = Key
"width" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MX GradientCoord
x) = Key
"x" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MY GradientCoord
x) = Key
"y" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MX2 GradientCoord
x) = Key
"x2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MY2 GradientCoord
x) = Key
"y2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MXOffset GradientCoord
x) = Key
"xOffset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MYOffset GradientCoord
x) = Key
"yOffset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MX2Offset GradientCoord
x) = Key
"x2Offset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty (MY2Offset GradientCoord
x) = Key
"y2Offset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
markProperty MarkProperty
MXWidth = Key
"x" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"width"
markProperty MarkProperty
MX2Width = Key
"x2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"width"
markProperty MarkProperty
MYHeight = Key
"y" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"height"
markProperty MarkProperty
MY2Height = Key
"y2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
fromT Text
"height"
gradientSpec :: ColorGradient -> GradientStops -> [GradientProperty] -> VLSpec
gradientSpec :: ColorGradient -> GradientStops -> [GradientProperty] -> VLSpec
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
props =
let sortedStops :: GradientStops
sortedStops = forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn forall a b. (a, b) -> a
fst GradientStops
stops
in [Pair] -> VLSpec
object ([ Key
"gradient" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ColorGradient -> Text
colorGradientLabel ColorGradient
dir
, Key
"stops" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a b. (a -> b) -> [a] -> [b]
map (GradientCoord, Text) -> VLSpec
stopSpec GradientStops
sortedStops ]
forall a. [a] -> [a] -> [a]
++ 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 -> VLSpec
pointMarkerSpec PointMarker
PMTransparent = VLSpec
"transparent"
pointMarkerSpec PointMarker
PMNone = forall a. ToJSON a => a -> VLSpec
toJSON Bool
False
pointMarkerSpec (PMMarker []) = forall a. ToJSON a => a -> VLSpec
toJSON Bool
True
pointMarkerSpec (PMMarker [MarkProperty]
mps) = [Pair] -> VLSpec
object (forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> Pair
markProperty [MarkProperty]
mps)
data LineMarker
= LMNone
| LMMarker [MarkProperty]
lineMarkerSpec :: LineMarker -> VLSpec
lineMarkerSpec :: LineMarker -> VLSpec
lineMarkerSpec LineMarker
LMNone = forall a. ToJSON a => a -> VLSpec
toJSON Bool
False
lineMarkerSpec (LMMarker []) = forall a. ToJSON a => a -> VLSpec
toJSON Bool
True
lineMarkerSpec (LMMarker [MarkProperty]
mps) = [Pair] -> VLSpec
object (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" 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 GradientCoord
sc) = Key
"extent" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
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 :: (GradientCoord, Text) -> VLSpec
stopSpec (GradientCoord
x, Text
c) = [Pair] -> VLSpec
object [ Key
"offset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x, Key
"color" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> VLSpec
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 GradientCoord
x) = Key
"x1" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
gradientProperty (GrX2 GradientCoord
x) = Key
"x2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
gradientProperty (GrY1 GradientCoord
x) = Key
"y1" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
gradientProperty (GrY2 GradientCoord
x) = Key
"y2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
gradientProperty (GrR1 GradientCoord
x) = Key
"r1" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
x
gradientProperty (GrR2 GradientCoord
x) = Key
"r2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GradientCoord
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 -> VLSpec
blendModeSpec BlendMode
BMNormal = VLSpec
A.Null
blendModeSpec BlendMode
BMMultiply = Text -> VLSpec
fromT Text
"multiply"
blendModeSpec BlendMode
BMScreen = Text -> VLSpec
fromT Text
"screen"
blendModeSpec BlendMode
BMOverlay = Text -> VLSpec
fromT Text
"overlay"
blendModeSpec BlendMode
BMDarken = Text -> VLSpec
fromT Text
"darken"
blendModeSpec BlendMode
BMLighten = Text -> VLSpec
fromT Text
"lighten"
blendModeSpec BlendMode
BMColorDodge = Text -> VLSpec
fromT Text
"color-dodge"
blendModeSpec BlendMode
BMColorBurn = Text -> VLSpec
fromT Text
"color-burn"
blendModeSpec BlendMode
BMHardLight = Text -> VLSpec
fromT Text
"hard-light"
blendModeSpec BlendMode
BMSoftLight = Text -> VLSpec
fromT Text
"soft-light"
blendModeSpec BlendMode
BMDifference = Text -> VLSpec
fromT Text
"difference"
blendModeSpec BlendMode
BMExclusion = Text -> VLSpec
fromT Text
"exclusion"
blendModeSpec BlendMode
BMHue = Text -> VLSpec
fromT Text
"hue"
blendModeSpec BlendMode
BMSaturation = Text -> VLSpec
fromT Text
"saturation"
blendModeSpec BlendMode
BMColor = Text -> VLSpec
fromT Text
"color"
blendModeSpec BlendMode
BMLuminosity = Text -> VLSpec
fromT Text
"luminosity"