{-# LANGUAGE OverloadedStrings #-}
module Graphics.Vega.VegaLite.Mark
( Mark(..)
, MarkProperty(..)
, MarkInterpolation(..)
, PointMarker(..)
, LineMarker(..)
, MarkErrorExtent(..)
, GradientCoord
, GradientStops
, ColorGradient(..)
, GradientProperty(..)
, TextDirection(..)
, BlendMode(..)
, mprops_
, markLabel
, markProperty
) where
import qualified Data.Aeson as A
import qualified Data.Text as T
import Data.Aeson ((.=), object, toJSON)
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
)
mprops_ :: T.Text -> [MarkProperty] -> LabelledSpec
mprops_ :: Text -> [MarkProperty] -> LabelledSpec
mprops_ Text
f [] = Text
f Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
True
mprops_ Text
f [MarkProperty]
mps = Text
f Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [LabelledSpec] -> Value
object ((MarkProperty -> LabelledSpec) -> [MarkProperty] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> LabelledSpec
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 -> LabelledSpec
markProperty :: MarkProperty -> LabelledSpec
markProperty (MColorGradient ColorGradient
dir GradientStops
stops [GradientProperty]
opts) =
Text
"color" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ColorGradient -> GradientStops -> [GradientProperty] -> Value
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
opts
markProperty (MFillGradient ColorGradient
dir GradientStops
stops [GradientProperty]
opts) =
Text
"fill" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ColorGradient -> GradientStops -> [GradientProperty] -> Value
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
opts
markProperty (MStrokeGradient ColorGradient
dir GradientStops
stops [GradientProperty]
opts) =
Text
"stroke" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ColorGradient -> GradientStops -> [GradientProperty] -> Value
gradientSpec ColorGradient
dir GradientStops
stops [GradientProperty]
opts
markProperty (MContinuousBandSize Double
x) = Text
"continuousBandSize" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MDiscreteBandSize Double
x) = Text
"discreteBandSize" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MAlign HAlign
algn) = Text
"align" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= HAlign -> Text
hAlignLabel HAlign
algn
markProperty (MAngle Double
x) = Text
"angle" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MAria Bool
b) = Text
"aria" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
b
markProperty (MAriaDescription Text
t) = Text
"description" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
t
markProperty (MAriaRole Text
t) = Text
"ariaRole" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
t
markProperty (MAriaRoleDescription Text
t) = Text
"ariaRoleDescription" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
t
markProperty (MAspect Bool
b) = Text
"aspect" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
b
markProperty (MBaseline VAlign
va) = Text
"baseline" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= VAlign -> Text
vAlignLabel VAlign
va
markProperty (MBandSize Double
x) = Text
"bandSize" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MBinSpacing Double
x) = Text
"binSpacing" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MBlend BlendMode
bl) = Text
"blend" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= BlendMode -> Value
blendModeSpec BlendMode
bl
markProperty MarkProperty
MNoBorders = Text
"borders" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
False
markProperty (MBorders [MarkProperty]
mps) = Text -> [MarkProperty] -> LabelledSpec
mprops_ Text
"borders" [MarkProperty]
mps
markProperty MarkProperty
MNoBox = Text
"box" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
False
markProperty (MBox [MarkProperty]
mps) = Text -> [MarkProperty] -> LabelledSpec
mprops_ Text
"box" [MarkProperty]
mps
markProperty (MClip Bool
b) = Text
"clip" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
b
markProperty (MColor Text
col) = Text
"color" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
fromColor Text
col
markProperty (MCornerRadius Double
x) = Text
"cornerRadius" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MCornerRadiusEnd Double
x) = Text
"cornerRadiusEnd" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MCornerRadiusTL Double
x) = Text
"cornerRadiusTopLeft" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MCornerRadiusTR Double
x) = Text
"cornerRadiusTopRight" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MCornerRadiusBL Double
x) = Text
"cornerRadiusBottomLeft" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MCornerRadiusBR Double
x) = Text
"cornerRadiusBottomRight" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MCursor Cursor
cur) = Text
"cursor" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Cursor -> Text
cursorLabel Cursor
cur
markProperty (MDir TextDirection
td) = Text
"dir" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= TextDirection -> Text
textdirLabel TextDirection
td
markProperty (MdX Double
dx) = Text
"dx" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
dx
markProperty (MdY Double
dy) = Text
"dy" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
dy
markProperty (MEllipsis Text
s) = Text
"ellipsis" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
s
markProperty (MExtent MarkErrorExtent
mee) = MarkErrorExtent -> LabelledSpec
markErrorExtentLSpec MarkErrorExtent
mee
markProperty (MFill Text
col) = Text
"fill" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
fromColor Text
col
markProperty (MFilled Bool
b) = Text
"filled" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
b
markProperty (MFillOpacity Double
x) = Text
"fillOpacity" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MFont Text
fnt) = Text
"font" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
fnt
markProperty (MFontSize Double
x) = Text
"fontSize" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MFontStyle Text
fSty) = Text
"fontStyle" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
fSty
markProperty (MFontWeight FontWeight
w) = Text
"fontWeight" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= FontWeight -> Value
fontWeightSpec FontWeight
w
markProperty (MHeight Double
x) = Text
"height" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MHRef Text
s) = Text
"href" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
s
markProperty (MInnerRadius Double
r) = Text
"innerRadius" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
r
markProperty (MInterpolate MarkInterpolation
interp) = Text
"interpolate" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= MarkInterpolation -> Text
markInterpolationLabel MarkInterpolation
interp
markProperty (MRemoveInvalid Bool
b) = Text
"invalid" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= if Bool
b then Value
"filter" else Value
A.Null
markProperty (MLimit Double
x) = Text
"limit" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MLine LineMarker
lm) = Text
"line" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= LineMarker -> Value
lineMarkerSpec LineMarker
lm
markProperty (MLineBreak Text
s) = Text
"lineBreak" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
s
markProperty (MLineHeight Double
x) = Text
"lineHeight" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty MarkProperty
MNoMedian = Text
"median" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
False
markProperty (MMedian [MarkProperty]
mps) = Text -> [MarkProperty] -> LabelledSpec
mprops_ Text
"median" [MarkProperty]
mps
markProperty (MOpacity Double
x) = Text
"opacity" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MOrder Bool
b) = Text
"order" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
b
markProperty (MOrient Orientation
orient) = Text
"orient" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Orientation -> Value
orientationSpec Orientation
orient
markProperty (MOuterRadius Double
r) = Text
"outerRadius" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
r
markProperty MarkProperty
MNoOutliers = Text
"outliers" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
False
markProperty (MOutliers [MarkProperty]
mps) = Text -> [MarkProperty] -> LabelledSpec
mprops_ Text
"outliers" [MarkProperty]
mps
markProperty (MPadAngle Double
x) = Text
"padAngle" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MPoint PointMarker
pm) = Text
"point" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PointMarker -> Value
pointMarkerSpec PointMarker
pm
markProperty (MRadius Double
x) = Text
"radius" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MRadius2 Double
x) = Text
"radius2" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MRadiusOffset Double
x) = Text
"radiusOffset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MRadius2Offset Double
x) = Text
"radius2Offset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty MarkProperty
MNoRule = Text
"rule" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
False
markProperty (MRule [MarkProperty]
mps) = Text -> [MarkProperty] -> LabelledSpec
mprops_ Text
"rule" [MarkProperty]
mps
markProperty (MShape Symbol
sym) = Text
"shape" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Symbol -> Text
symbolLabel Symbol
sym
markProperty (MSize Double
x) = Text
"size" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MStroke Text
t) = Text
"stroke" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
fromColor Text
t
markProperty (MStrokeCap StrokeCap
sc) = Text
"strokeCap" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= StrokeCap -> Text
strokeCapLabel StrokeCap
sc
markProperty (MStrokeDash DashStyle
xs) = Text
"strokeDash" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= DashStyle -> Value
fromDS DashStyle
xs
markProperty (MStrokeDashOffset Double
x) = Text
"strokeDashOffset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MStrokeJoin StrokeJoin
sj) = Text
"strokeJoin" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= StrokeJoin -> Text
strokeJoinLabel StrokeJoin
sj
markProperty (MStrokeMiterLimit Double
x) = Text
"strokeMiterLimit" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MStrokeOpacity Double
x) = Text
"strokeOpacity" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MStrokeWidth Double
w) = Text
"strokeWidth" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
w
markProperty (MStyle [Text
style]) = Text
"style" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
style
markProperty (MStyle [Text]
styles) = Text
"style" Text -> [Text] -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [Text]
styles
markProperty (MTension Double
x) = Text
"tension" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MText Text
t) = Text
"text" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
t
markProperty (MTexts [Text]
ts) = Text
"text" Text -> [Text] -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [Text]
ts
markProperty (MTheta Double
x) = Text
"theta" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MTheta2 Double
x) = Text
"theta2" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MThetaOffset Double
x) = Text
"thetaOffset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MTheta2Offset Double
x) = Text
"theta2Offset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MThickness Double
x) = Text
"thickness" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty MarkProperty
MNoTicks = Text
"ticks" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
False
markProperty (MTicks [MarkProperty]
mps) = Text -> [MarkProperty] -> LabelledSpec
mprops_ Text
"ticks" [MarkProperty]
mps
markProperty (MTimeUnitBand Double
x) = Text
"timeUnitBand" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MTimeUnitBandPosition Double
x) = Text
"timeUnitBandPosition" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MTooltip TooltipContent
TTNone) = Text
"tooltip" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Value
A.Null
markProperty (MTooltip TooltipContent
tc) = Text
"tooltip" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [LabelledSpec] -> Value
object [Text
"content" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= TooltipContent -> Text
ttContentLabel TooltipContent
tc]
markProperty (MWidth Double
x) = Text
"width" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MX Double
x) = Text
"x" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MY Double
x) = Text
"y" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MX2 Double
x) = Text
"x2" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MY2 Double
x) = Text
"y2" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MXOffset Double
x) = Text
"xOffset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MYOffset Double
x) = Text
"yOffset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MX2Offset Double
x) = Text
"x2Offset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty (MY2Offset Double
x) = Text
"y2Offset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
markProperty MarkProperty
MXWidth = Text
"x" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
fromT Text
"width"
markProperty MarkProperty
MX2Width = Text
"x2" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
fromT Text
"width"
markProperty MarkProperty
MYHeight = Text
"y" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
fromT Text
"height"
markProperty MarkProperty
MY2Height = Text
"y2" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 [LabelledSpec] -> Value
object ([ Text
"gradient" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ColorGradient -> Text
colorGradientLabel ColorGradient
dir
, Text
"stops" Text -> [Value] -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ((Double, Text) -> Value) -> GradientStops -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map (Double, Text) -> Value
stopSpec GradientStops
sortedStops ]
[LabelledSpec] -> [LabelledSpec] -> [LabelledSpec]
forall a. [a] -> [a] -> [a]
++ (GradientProperty -> LabelledSpec)
-> [GradientProperty] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map GradientProperty -> LabelledSpec
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) = [LabelledSpec] -> Value
object ((MarkProperty -> LabelledSpec) -> [MarkProperty] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> LabelledSpec
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) = [LabelledSpec] -> Value
object ((MarkProperty -> LabelledSpec) -> [MarkProperty] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> LabelledSpec
markProperty [MarkProperty]
mps)
data MarkErrorExtent
= ConfidenceInterval
| StdErr
| StdDev
| Iqr
| ExRange
| IqrScale Double
extent_ :: T.Text -> LabelledSpec
extent_ :: Text -> LabelledSpec
extent_ Text
v = Text
"extent" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
v
markErrorExtentLSpec :: MarkErrorExtent -> LabelledSpec
markErrorExtentLSpec :: MarkErrorExtent -> LabelledSpec
markErrorExtentLSpec MarkErrorExtent
ConfidenceInterval = Text -> LabelledSpec
extent_ Text
"ci"
markErrorExtentLSpec MarkErrorExtent
StdErr = Text -> LabelledSpec
extent_ Text
"stderr"
markErrorExtentLSpec MarkErrorExtent
StdDev = Text -> LabelledSpec
extent_ Text
"stdev"
markErrorExtentLSpec MarkErrorExtent
Iqr = Text -> LabelledSpec
extent_ Text
"iqr"
markErrorExtentLSpec MarkErrorExtent
ExRange = Text -> LabelledSpec
extent_ Text
"min-max"
markErrorExtentLSpec (IqrScale Double
sc) = Text
"extent" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) = [LabelledSpec] -> Value
object [ Text
"offset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x, Text
"color" Text -> Value -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
fromColor Text
c ]
data GradientProperty
= GrX1 GradientCoord
| GrY1 GradientCoord
| GrX2 GradientCoord
| GrY2 GradientCoord
| GrR1 GradientCoord
| GrR2 GradientCoord
gradientProperty :: GradientProperty -> LabelledSpec
gradientProperty :: GradientProperty -> LabelledSpec
gradientProperty (GrX1 Double
x) = Text
"x1" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
gradientProperty (GrX2 Double
x) = Text
"x2" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
gradientProperty (GrY1 Double
x) = Text
"y1" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
gradientProperty (GrY2 Double
x) = Text
"y2" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
gradientProperty (GrR1 Double
x) = Text
"r1" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
gradientProperty (GrR2 Double
x) = Text
"r2" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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"