{-# LANGUAGE OverloadedStrings #-}
module Graphics.Vega.VegaLite.Legend
( LegendType(..)
, LegendOrientation(..)
, LegendLayout(..)
, BaseLegendLayout(..)
, LegendProperty(..)
, LegendValues(..)
, legendProp_
, legendOrientLabel
, legendLayoutSpec
) where
import qualified Data.Aeson as A
import qualified Data.Text as T
import Data.Aeson ((.=), object, toJSON)
import Graphics.Vega.VegaLite.Foundation
( APosition
, Bounds
, Color
, CompositionAlignment
, DashStyle
, DashOffset
, FontWeight
, HAlign
, Opacity
, Orientation
, OverlapStrategy
, Side
, Symbol
, VAlign
, VegaExpr
, ZIndex
, anchorLabel
, boundsSpec
, compositionAlignmentSpec
, fontWeightSpec
, hAlignLabel
, orientationSpec
, overlapStrategyLabel
, sideLabel
, symbolLabel
, vAlignLabel
, fromT
, fromColor
, fromDS
, splitOnNewline
)
import Graphics.Vega.VegaLite.Scale
( ScaleNice
, scaleNiceSpec
)
import Graphics.Vega.VegaLite.Specification (VLSpec, LabelledSpec)
import Graphics.Vega.VegaLite.Time
( DateTime
, dateTimeSpec
)
data LegendType
= GradientLegend
| SymbolLegend
legendLabel :: LegendType -> T.Text
legendLabel :: LegendType -> Text
legendLabel LegendType
GradientLegend = Text
"gradient"
legendLabel LegendType
SymbolLegend = Text
"symbol"
data LegendOrientation
= LONone
| LOLeft
| LORight
| LOTop
| LOBottom
| LOTopLeft
| LOTopRight
| LOBottomLeft
| LOBottomRight
legendOrientLabel :: LegendOrientation -> T.Text
legendOrientLabel :: LegendOrientation -> Text
legendOrientLabel LegendOrientation
LONone = Text
"none"
legendOrientLabel LegendOrientation
LOLeft = Text
"left"
legendOrientLabel LegendOrientation
LORight = Text
"right"
legendOrientLabel LegendOrientation
LOTop = Text
"top"
legendOrientLabel LegendOrientation
LOBottom = Text
"bottom"
legendOrientLabel LegendOrientation
LOTopLeft = Text
"top-left"
legendOrientLabel LegendOrientation
LOTopRight = Text
"top-right"
legendOrientLabel LegendOrientation
LOBottomLeft = Text
"bottom-left"
legendOrientLabel LegendOrientation
LOBottomRight = Text
"bottom-right"
data LegendLayout
= LeLAnchor APosition
| LeLBottom [BaseLegendLayout]
| LeLBottomLeft [BaseLegendLayout]
| LeLBottomRight [BaseLegendLayout]
| LeLBounds Bounds
| LeLCenter Bool
| LeLDirection Orientation
| LeLLeft [BaseLegendLayout]
| LeLMargin Double
| LeLOffset Double
| LeLRight [BaseLegendLayout]
| LeLTop [BaseLegendLayout]
| LeLTopLeft [BaseLegendLayout]
| LeLTopRight [BaseLegendLayout]
legendLayoutSpec :: LegendLayout -> LabelledSpec
legendLayoutSpec :: LegendLayout -> LabelledSpec
legendLayoutSpec (LeLAnchor APosition
anc) = Text
"anchor" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= APosition -> Text
anchorLabel APosition
anc
legendLayoutSpec (LeLBottom [BaseLegendLayout]
bl) = Text
"bottom" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [BaseLegendLayout] -> VLSpec
toBLSpec [BaseLegendLayout]
bl
legendLayoutSpec (LeLBottomLeft [BaseLegendLayout]
bl) = Text
"bottom-left" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [BaseLegendLayout] -> VLSpec
toBLSpec [BaseLegendLayout]
bl
legendLayoutSpec (LeLBottomRight [BaseLegendLayout]
bl) = Text
"bottom-right" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [BaseLegendLayout] -> VLSpec
toBLSpec [BaseLegendLayout]
bl
legendLayoutSpec (LeLBounds Bounds
bnds) = Text
"bounds" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bounds -> VLSpec
boundsSpec Bounds
bnds
legendLayoutSpec (LeLCenter Bool
b) = Text
"center" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
b
legendLayoutSpec (LeLDirection Orientation
o) = Text
"direction" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Orientation -> VLSpec
orientationSpec Orientation
o
legendLayoutSpec (LeLLeft [BaseLegendLayout]
bl) = Text
"left" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [BaseLegendLayout] -> VLSpec
toBLSpec [BaseLegendLayout]
bl
legendLayoutSpec (LeLMargin Double
x) = Text
"margin" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendLayoutSpec (LeLOffset Double
x) = Text
"offset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendLayoutSpec (LeLRight [BaseLegendLayout]
bl) = Text
"right" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [BaseLegendLayout] -> VLSpec
toBLSpec [BaseLegendLayout]
bl
legendLayoutSpec (LeLTop [BaseLegendLayout]
bl) = Text
"top" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [BaseLegendLayout] -> VLSpec
toBLSpec [BaseLegendLayout]
bl
legendLayoutSpec (LeLTopLeft [BaseLegendLayout]
bl) = Text
"top-left" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [BaseLegendLayout] -> VLSpec
toBLSpec [BaseLegendLayout]
bl
legendLayoutSpec (LeLTopRight [BaseLegendLayout]
bl) = Text
"top-right" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [BaseLegendLayout] -> VLSpec
toBLSpec [BaseLegendLayout]
bl
data BaseLegendLayout
= BLeLAnchor APosition
| BLeLBounds Bounds
| BLeLCenter Bool
| BLeLDirection Orientation
| BLeLMargin Double
| BLeLOffset Double
toBLSpec :: [BaseLegendLayout] -> VLSpec
toBLSpec :: [BaseLegendLayout] -> VLSpec
toBLSpec = [LabelledSpec] -> VLSpec
object ([LabelledSpec] -> VLSpec)
-> ([BaseLegendLayout] -> [LabelledSpec])
-> [BaseLegendLayout]
-> VLSpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (BaseLegendLayout -> LabelledSpec)
-> [BaseLegendLayout] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map BaseLegendLayout -> LabelledSpec
baseLegendLayoutSpec
baseLegendLayoutSpec :: BaseLegendLayout -> LabelledSpec
baseLegendLayoutSpec :: BaseLegendLayout -> LabelledSpec
baseLegendLayoutSpec (BLeLAnchor APosition
anc) = Text
"anchor" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= APosition -> Text
anchorLabel APosition
anc
baseLegendLayoutSpec (BLeLBounds Bounds
bnds) = Text
"bounds" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bounds -> VLSpec
boundsSpec Bounds
bnds
baseLegendLayoutSpec (BLeLCenter Bool
b) = Text
"center" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
b
baseLegendLayoutSpec (BLeLDirection Orientation
o) = Text
"direction" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Orientation -> VLSpec
orientationSpec Orientation
o
baseLegendLayoutSpec (BLeLMargin Double
x) = Text
"margin" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
baseLegendLayoutSpec (BLeLOffset Double
x) = Text
"offset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
data LegendProperty
= LAria Bool
| LAriaDescription T.Text
| LClipHeight Double
| LColumnPadding Double
| LColumns Int
| LCornerRadius Double
| LDirection Orientation
| LFillColor Color
| LFormat T.Text
| LFormatAsNum
| LFormatAsTemporal
| LFormatAsCustom T.Text
| LGradientLength Double
| LGradientOpacity Opacity
| LGradientStrokeColor Color
| LGradientStrokeWidth Double
| LGradientThickness Double
| LGridAlign CompositionAlignment
| LLabelAlign HAlign
| LLabelBaseline VAlign
| LLabelColor Color
| LLabelExpr VegaExpr
| LLabelFont T.Text
| LLabelFontSize Double
| LLabelFontStyle T.Text
| LLabelFontWeight FontWeight
| LLabelLimit Double
| LLabelOffset Double
| LLabelOpacity Opacity
| LLabelOverlap OverlapStrategy
| LLabelPadding Double
| LLabelSeparation Double
| LOffset Double
| LOrient LegendOrientation
| LPadding Double
| LRowPadding Double
| LStrokeColor Color
| LSymbolDash DashStyle
| LSymbolDashOffset DashOffset
| LSymbolFillColor Color
| LSymbolLimit Int
| LSymbolOffset Double
| LSymbolOpacity Opacity
| LSymbolSize Double
| LSymbolStrokeColor Color
| LSymbolStrokeWidth Double
| LSymbolType Symbol
| LTickCount Double
| LTickCountTime ScaleNice
| LTickMinStep Double
| LTitle T.Text
| LNoTitle
| LTitleAlign HAlign
| LTitleAnchor APosition
| LTitleBaseline VAlign
| LTitleColor Color
| LTitleFont T.Text
| LTitleFontSize Double
| LTitleFontStyle T.Text
| LTitleFontWeight FontWeight
| LTitleLimit Double
| LTitleLineHeight Double
| LTitleOpacity Opacity
| LTitleOrient Side
| LTitlePadding Double
| LType LegendType
| LValues LegendValues
| LeX Double
| LeY Double
| LZIndex ZIndex
legendProperty :: LegendProperty -> LabelledSpec
legendProperty :: LegendProperty -> LabelledSpec
legendProperty (LAria Bool
b) = Text
"aria" Text -> Bool -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Bool
b
legendProperty (LAriaDescription Text
t) = Text
"description" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
t
legendProperty (LClipHeight Double
x) = Text
"clipHeight" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LColumnPadding Double
x) = Text
"columnPadding" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LColumns Int
n) = Text
"columns" Text -> Int -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Int
n
legendProperty (LCornerRadius Double
x) = Text
"cornerRadius" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LDirection Orientation
o) = Text
"direction" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Orientation -> VLSpec
orientationSpec Orientation
o
legendProperty (LFillColor Text
s) = Text
"fillColor" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
fromColor Text
s
legendProperty (LFormat Text
s) = Text
"format" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
s
legendProperty LegendProperty
LFormatAsNum = Text
"formatType" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
fromT Text
"number"
legendProperty LegendProperty
LFormatAsTemporal = Text
"formatType" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
fromT Text
"time"
legendProperty (LFormatAsCustom Text
c) = Text
"formatType" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
c
legendProperty (LGradientLength Double
x) = Text
"gradientLength" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LGradientOpacity Double
x) = Text
"gradientOpacity" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LGradientStrokeColor Text
s) = Text
"gradientStrokeColor" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
fromColor Text
s
legendProperty (LGradientStrokeWidth Double
x) = Text
"gradientStrokeWidth" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LGradientThickness Double
x) = Text
"gradientThickness" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LGridAlign CompositionAlignment
ga) = Text
"gridAlign" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= CompositionAlignment -> VLSpec
compositionAlignmentSpec CompositionAlignment
ga
legendProperty (LLabelAlign HAlign
ha) = Text
"labelAlign" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= HAlign -> Text
hAlignLabel HAlign
ha
legendProperty (LLabelBaseline VAlign
va) = Text
"labelBaseline" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= VAlign -> Text
vAlignLabel VAlign
va
legendProperty (LLabelColor Text
s) = Text
"labelColor" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
fromColor Text
s
legendProperty (LLabelExpr Text
s) = Text
"labelExpr" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
s
legendProperty (LLabelFont Text
s) = Text
"labelFont" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
s
legendProperty (LLabelFontSize Double
x) = Text
"labelFontSize" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LLabelFontStyle Text
s) = Text
"labelFontStyle" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
s
legendProperty (LLabelFontWeight FontWeight
fw) = Text
"labelFontWeight" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= FontWeight -> VLSpec
fontWeightSpec FontWeight
fw
legendProperty (LLabelLimit Double
x) = Text
"labelLimit" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LLabelOffset Double
x) = Text
"labelOffset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LLabelOpacity Double
x) = Text
"labelOpacity" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LLabelOverlap OverlapStrategy
strat) = Text
"labelOverlap" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= OverlapStrategy -> VLSpec
overlapStrategyLabel OverlapStrategy
strat
legendProperty (LLabelPadding Double
x) = Text
"labelPadding" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LLabelSeparation Double
x) = Text
"labelSeparation" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LOffset Double
x) = Text
"offset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LOrient LegendOrientation
orl) = Text
"orient" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= LegendOrientation -> Text
legendOrientLabel LegendOrientation
orl
legendProperty (LPadding Double
x) = Text
"padding" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LRowPadding Double
x) = Text
"rowPadding" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LStrokeColor Text
s) = Text
"strokeColor" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
fromColor Text
s
legendProperty (LSymbolDash DashStyle
ds) = Text
"symbolDash" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= DashStyle -> VLSpec
fromDS DashStyle
ds
legendProperty (LSymbolDashOffset Double
x) = Text
"symbolDashOffset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LSymbolFillColor Text
s) = Text
"symbolFillColor" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
fromColor Text
s
legendProperty (LSymbolLimit Int
x) = Text
"symbolLimit" Text -> Int -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Int
x
legendProperty (LSymbolOffset Double
x) = Text
"symbolOffset" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LSymbolOpacity Double
x) = Text
"symbolOpacity" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LSymbolSize Double
x) = Text
"symbolSize" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LSymbolStrokeColor Text
s) = Text
"symbolStrokeColor" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
fromColor Text
s
legendProperty (LSymbolStrokeWidth Double
x) = Text
"symbolStrokeWidth" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LSymbolType Symbol
sym) = Text
"symbolType" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Symbol -> Text
symbolLabel Symbol
sym
legendProperty (LTickCount Double
x) = Text
"tickCount" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LTickCountTime ScaleNice
sn) = Text
"tickCount" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ScaleNice -> VLSpec
scaleNiceSpec ScaleNice
sn
legendProperty (LTickMinStep Double
x) = Text
"tickMinStep" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LTitle Text
s) = Text
"title" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
splitOnNewline Text
s
legendProperty LegendProperty
LNoTitle = Text
"title" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= VLSpec
A.Null
legendProperty (LTitleAlign HAlign
ha) = Text
"titleAlign" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= HAlign -> Text
hAlignLabel HAlign
ha
legendProperty (LTitleAnchor APosition
anc) = Text
"titleAnchor" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= APosition -> Text
anchorLabel APosition
anc
legendProperty (LTitleBaseline VAlign
va) = Text
"titleBaseline" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= VAlign -> Text
vAlignLabel VAlign
va
legendProperty (LTitleColor Text
s) = Text
"titleColor" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> VLSpec
fromColor Text
s
legendProperty (LTitleFont Text
s) = Text
"titleFont" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
s
legendProperty (LTitleFontSize Double
x) = Text
"titleFontSize" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LTitleFontStyle Text
s) = Text
"titleFontStyle" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
s
legendProperty (LTitleFontWeight FontWeight
fw) = Text
"titleFontWeight" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= FontWeight -> VLSpec
fontWeightSpec FontWeight
fw
legendProperty (LTitleLimit Double
x) = Text
"titleLimit" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LTitleLineHeight Double
x) = Text
"titleLineHeight" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LTitleOpacity Double
x) = Text
"titleOpacity" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LTitleOrient Side
orient) = Text
"titleOrient" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Side -> Text
sideLabel Side
orient
legendProperty (LTitlePadding Double
x) = Text
"titlePadding" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LType LegendType
lType) = Text
"type" Text -> Text -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= LegendType -> Text
legendLabel LegendType
lType
legendProperty (LValues LegendValues
vals) =
let ls :: [VLSpec]
ls = case LegendValues
vals of
LNumbers DashStyle
xs -> (Double -> VLSpec) -> DashStyle -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map Double -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON DashStyle
xs
LDateTimes [[DateTime]]
dts -> ([DateTime] -> VLSpec) -> [[DateTime]] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map [DateTime] -> VLSpec
dateTimeSpec [[DateTime]]
dts
LStrings [Text]
ss -> (Text -> VLSpec) -> [Text] -> [VLSpec]
forall a b. (a -> b) -> [a] -> [b]
map Text -> VLSpec
forall a. ToJSON a => a -> VLSpec
toJSON [Text]
ss
in Text
"values" Text -> [VLSpec] -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [VLSpec]
ls
legendProperty (LeX Double
x) = Text
"legendX" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LeY Double
x) = Text
"legendY" Text -> Double -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Double
x
legendProperty (LZIndex ZIndex
z) = Text
"zindex" Text -> ZIndex -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ZIndex
z
legendProp_ :: [LegendProperty] -> LabelledSpec
legendProp_ :: [LegendProperty] -> LabelledSpec
legendProp_ [] = Text
"legend" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= VLSpec
A.Null
legendProp_ [LegendProperty]
lps = Text
"legend" Text -> VLSpec -> LabelledSpec
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [LabelledSpec] -> VLSpec
object ((LegendProperty -> LabelledSpec)
-> [LegendProperty] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map LegendProperty -> LabelledSpec
legendProperty [LegendProperty]
lps)
data LegendValues
= LDateTimes [[DateTime]]
| LNumbers [Double]
| LStrings [T.Text]