{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}

{-|
Module      : Graphics.Vega.VegaLite.Mark
Copyright   : (c) Douglas Burke, 2018-2021
License     : BSD3

Maintainer  : dburke.gw@gmail.com
Stability   : unstable
Portability : CPP, OverloadedStrings

This provides the functionality of the VegaLite module but is
not directly exported to the user.

-}

module Graphics.Vega.VegaLite.Mark
       ( Mark(..)
       , MarkProperty(..)
       , MarkInterpolation(..)
       , PointMarker(..)
       , LineMarker(..)
       , MarkErrorExtent(..)
       , GradientCoord
       , GradientStops
       , ColorGradient(..)
       , GradientProperty(..)
       , TextDirection(..)
       , BlendMode(..)

         -- not for external export
       , 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
  )


-- As of version 0.6.0.0, an empty list is mapped to True
#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)

-- Used by Configuration to create top-level data
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)


-- | Type of visual mark used to represent data in the visualization.
--
--   The properties of the mark can be changed with the 'MarkProperty'
--   constructors - such as 'MHeight' and 'MWidth' -  although not all
--   properties apply to all marks.
--
data Mark
    = Arc
      -- ^ An arc mark.
      --
      --   @since 0.9.0.0
    | Area
      -- ^ An [area mark](https://vega.github.io/vega-lite/docs/area.html)
      --   for representing a series of data elements, such as in a stacked
      --   area chart or streamgraph.
    | Bar
      -- ^ [Bar mark](https://vega.github.io/vega-lite/docs/bar.html)
      --   for histograms, bar charts etc.
    | Boxplot
      -- ^ [Boxplot composite mark](https://vega.github.io/vega-lite/docs/boxplot.html)
      --   for showing summaries of statistical distributions.
      --
      --   Tick marks can be added using 'MTicks' and outliers turned
      --   off with 'MNoOutliers' or configured with 'MOutliers'.
      --   For example:
      --
      --   @
      --   'Graphics.Vega.VegaLite.mark' Boxplot
      --       [ 'MTicks' [ 'MColor' \"black\", 'MSize' 8 ]
      --       , 'MBox' [ 'MFill' \"grey\" ]
      --       , 'MOutliers' [ 'MColor' \"firebrick\" ]
      --   ]
      --   @
      --
      --   The range of the box plot is controlled with 'MExtent' with
      --   the 'IqrScale' or 'ExRange' options (the default is
      --   @IqrScale 1.5@).
      --
      --   @since 0.4.0.0
    | Circle
      -- ^ [Circle mark](https://vega.github.io/vega-lite/docs/circle.html)
      --   for representing points.
    | ErrorBar
      -- ^ [Errorbar composite mark](https://vega.github.io/vega-lite/docs/errorbar.html)
      --   for showing summaries of variation along a signal. By default
      --   no ticks are drawn. To add ticks with default properties use
      --   @`MTicks` []@, otherwise supply a list of configuration options:
      --
      --   @
      --   'Graphics.Vega.VegaLite.mark' ErrorBar [ 'MTicks' [ 'MColor' \"black\", 'MSize' 8 ] ]
      --   @
      --
      --   @since 0.4.0.0
    | ErrorBand
      -- ^ [Errorband composite mark](https://vega.github.io/vega-lite/docs/errorband.html)
      --   for showing summaries of variation along a signal. By default
      --   no border is drawn. To add a border with default properties use
      --   @'MBorders' []@, otherwise supply a list of configuration options:
      --
      --   @
      --   'Graphics.Vega.VegaLite.mark' ErrorBand [ 'MBorders' [ 'MColor' \"black\", 'MStrokeWidth' 0.5 ] ]
      --   @
      --
      --   @since 0.4.0.0
    | Geoshape
      -- ^ [Geoshape](https://vega.github.io/vega-lite/docs/geoshape.html)
      --   determined by geographically referenced coordinates.
    | Image
      -- ^ [Vega Lite image mark](https://vega.github.io/vega-lite/docs/image.html),
      --   where the image to display is given via the
      --   'Graphics.Vega.VegaLite.url' channel, and the width and height
      --   defined by the 'MWidth' and 'MHeight' properties.
      --
      --   @since 0.5.0.0
    | Line
      -- ^ [Line mark](https://vega.github.io/vega-lite/docs/line.html)
      --   for symbolising a sequence of values.
    | Point
      -- ^ [Point mark](https://vega.github.io/vega-lite/docs/point.html)
      --   for symbolising a data point with a symbol.
    | Rect
      -- ^ [Rectangle mark](https://vega.github.io/vega-lite/docs/rect.html).
    | Rule
      -- ^ [Rule line](https://vega.github.io/vega-lite/docs/rule.html)
      --   connecting two vertices.
    | Square
      -- ^ [Square mark](https://vega.github.io/vega-lite/docs/square.html)
      --   for symbolising points.
    | Text
      -- ^ [Text mark](https://vega.github.io/vega-lite/docs/text.html)
      --   to be displayed at some point location.
    | Tick
      -- ^ Short line - [tick](https://vega.github.io/vega-lite/docs/tick.html) -
      --   mark for symbolising point locations.
    | Trail
      -- ^ [Trail mark](https://vega.github.io/vega-lite/docs/trail.html)
      --   (line with variable width along its length).
      --
      --   @since 0.4.0.0


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"


{-|

Properties for customising the appearance of a mark. For details see the
<https://vega.github.io/vega-lite/docs/mark.html#config Vega-Lite documentation>.

Not all properties are valid for each mark type.

Some properties which take a list - such as 'MBox' - will
create a @true@ value if the list is empty, and @false@ if the
@\"No\"@ variant of the constructor is used (e.g. 'MNoBox').

In @version 0.5.0.0@ the 'MRemoveInvalid' constructor was added, which
replaces the @RemoveInvalid@ constructor of @ConfigurationProperty@, and the
@MShortTimeLabels@ constuctor was removed.

-}

-- DOC NOTE: using 'Graphics.Vega.VegaLite.ConfigurationProperty' doesn't create
-- the correct link, so changed to @ConfigurationProperty@.

-- based on schema
--     #/definitions/MarkConfig
--     #/definitions/MarkDef
--     #/definitions/OverlayMarkDef
--
--     #/definitions/TickConfig
--
-- ie it conflates meaning

data MarkProperty
    = MAlign HAlign
      -- ^ Horizontal alignment of a text mark.
    | MAngle Angle
      -- ^ Rotation angle of a text, point, or square marks.
    | MAria Bool
      -- ^ Should [ARIA attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA)
      --   be included (SVG output only).
      --
      --   If False, the \"aria-hidden\" attribute will be set on the output SVG element,
      --   removing the mark item from the ARIA accessibility tree.
      --
      --   @since 0.9.0.0
    | MAriaDescription T.Text
      -- ^ A text description of the mark item for
      --   [ARIA accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA)
      --   (SVG output only).
      --
      --   If specified, this property determines the
      --   [\"aria-label\" attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute).
      --
      --   @since 0.9.0.0
    | MAriaRole T.Text
      -- ^ Sets the type of user interface element of the mark item for
      --   [ARIA accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA)
      --   (SVG output only).
      --
      --   If specified, this property determines the \"role\" attribute.
      --
      --   Warning: this property is experimental and may be changed in the future.
      --
      --   @since 0.9.0.0
    | MAriaRoleDescription T.Text
      -- ^ A human-readable, author-localized description for the role of the mark item for
      --   [ARIA accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA)
      --   (SVG output only).
      --
      --   If specified, this property determines the \"aria-roledescription\" attribute.
      --
      --   Warning: this property is experimental and may be changed in the future.
      --
      --   @since 0.9.0.0
    | MAspect Bool
      -- ^ Should the aspect ratio of an 'Image' mark be preserved?
      --
      --   @since 0.5.0.0
    | MBandSize Double
      -- ^ Band size of a bar mark.
    | MBaseline VAlign
      -- ^ Vertical alignment of a text mark.
    | MBinSpacing Double
      -- ^ Offset between bars for a binned field using a bar mark.
      --
      --   The ideal value for this is either @0@ (preferred by statisticians)
      --   or @1@ (the Vega-Lite default value, D3 example style).
    | MBlend BlendMode
      -- ^ How should the item be blended with its background?
      --
      --   Added in Vega-Lite 4.6.0.
      --
      --   @since 0.7.0.0
    | MBorders [MarkProperty]
      -- ^ Border properties for an 'ErrorBand' mark. See also 'MNoBorders'.
      --
      --   @since 0.4.0.0
    | MNoBorders
      -- ^ Do not draw a border for an 'ErrorBand' mark.
      --
      --   @since 0.6.0.0
    | MBox [MarkProperty]
      -- ^ Box-symbol properties for a 'Boxplot' mark. See also 'MNoBox'.
      --
      --   @since 0.4.0.0
    | MNoBox
      -- ^ Do not draw outliers with the 'Boxplot' mark.
      --
      --   @since 0.6.0.0
    | MClip Bool
      -- ^ Should a mark be clipped to the enclosing group's dimensions.
    | MColor Color
      -- ^ Default color of a mark. Note that 'MFill' and 'MStroke' have higher
      --   precedence and will override this if specified.
    | MColorGradient ColorGradient GradientStops [GradientProperty]
      -- ^ The color gradient to apply to a mark. The first argument
      --   determines its type, the second is the list of color
      --   interpolation points, and the third
      --   allows for customization.
      --
      --   @
      --   'MColorGradient'
      --       'GrRadial'
      --       [ ( 0, \"red\" ), ( 1, \"blue\" ) ]
      --       [ ]
      --   @
      --
      --   @since 0.5.0.0
    | MCornerRadius Double
      -- ^ Corner radius of all corners of a rectangular mark, in pixels.
      --
      --   The default is 0. This value is over-ridden by any of
      --   'MCornerRadiusTL', 'MCornerRadiusTR', 'MCornerRadiusBL',
      --   or 'MCornerRadiusBR'.
      --
      --   @since 0.5.0.0
    | MCornerRadiusEnd Double
      -- ^ The radius used for bars, in pixels. For vertical bars it
      --   defines the top-left and top-right radius, and for
      --   horizontal bars it is the top-right and bottom-right.
      --
      --   For an example, see the
      --   <https://vega.github.io/vega-lite/docs/bar.html#bar-chart-with-rounded-corners Vega-Lite documentation>.
      --
      --   @since 0.6.0.0
    | MCornerRadiusTL Double
      -- ^ Top-left corner radius of a rectangular mark, in pixels.
      --
      --   The default is 0.
      --
      --   @since 0.5.0.0
    | MCornerRadiusTR Double
      -- ^ Top-right corner radius of a rectangular mark, in pixels.
      --
      --   The default is 0.
      --
      --   @since 0.5.0.0
    | MCornerRadiusBL Double
      -- ^ Bottom-left corner radius of a rectangular mark, in pixels.
      --
      --   The default is 0.
      --
      --   @since 0.5.0.0
    | MCornerRadiusBR Double
      -- ^ Bottom-right corner radius of a rectangular mark, in pixels.
      --
      --   The default is 0.
      --
      --   @since 0.5.0.0
    | MCursor Cursor
      -- ^ Cursor to be associated with a hyperlink mark.
    | MDir TextDirection
      -- ^ Direction of the text. This property determines which side of the
      --   label is truncated by the 'MLimit' parameter. See also 'MEllipsis'.
      --
      --   The default is 'LTR'.
      --
      --   @since 0.5.0.0
    | MContinuousBandSize Double
      -- ^ Continuous band size of a bar mark.
    | MDiscreteBandSize Double
      -- ^ Discrete band size of a bar mark.
    | MdX Double
      -- ^ Horizontal offset between a text mark and its anchor.
    | MdY Double
      -- ^ Vertical offset between a text mark and its anchor.
    | MEllipsis T.Text
      -- ^ The ellipsis string for text truncated in response to
      --   'MLimit'. See also 'MDir'.
      --
      --   The default is @\"…\"@.
      --
      --   @since 0.5.0.0
    | MExtent MarkErrorExtent
      -- ^ Extent of whiskers used with 'Boxplot', 'ErrorBar', and
      --   'ErrorBand' marks.
      --
      --   @since 0.4.0.0
    | MFill Color
      -- ^ Default fill color of a mark.
      --
      --   This was changed to use the @Color@ type alias in version @0.5.0.0@.
    | MFilled Bool
      -- ^ Should a mark's color should be used as the fill color instead of
      --   stroke color.
    | MFillGradient ColorGradient GradientStops [GradientProperty]
      -- ^ The color gradient to apply to the interior of a mark. The first argument
      --   determines its type, the second is the list of color
      --   interpolation points, and the third
      --   allows for customization.
      --
      --   @
      --   'MFillGradient'
      --       'GrLinear'
      --       [ ( 0, \"orange\" ), ( 1, \"green\" ) ]
      --       [ ]
      --   @
      --
      --   @since 0.5.0.0
    | MFillOpacity Opacity
      -- ^ Fill opacity of a mark.
    | MFont T.Text
      -- ^ Font of a text mark. Can be any font name made accessible via
      -- a css file (or a generic font like \"serif\", \"monospace\" etc.).
    | MFontSize Double
      -- ^ Font size, in pixels, used by a text mark.
    | MFontStyle T.Text
      -- ^ Font style (e.g. \"italic\") used by a text mark.
    | MFontWeight FontWeight
      -- ^ Font weight used by a text mark.
    | MHeight Double
      -- ^ Explicitly set the height of a mark. See also 'MWidth'.
      --
      --   @since 0.4.0.0
    | MHRef T.Text
      -- ^ Hyperlink to be associated with a mark making it a clickable
      --   hyperlink.
      --
      --   @since 0.4.0.0
    | MInnerRadius Double
      -- ^ The inner radius, in pixels, of arc marks. It is an alias for
      --    'MRadius2'.
      --
      --   @since 0.9.0.0
    | MInterpolate MarkInterpolation
      -- ^ Interpolation method used by line and area marks.
    | MLimit Double
      -- ^ The maximum length of the text mark in pixels. If the text is
      --   larger then it will be truncated, with the truncation controlled
      --   by 'MEllipsis' and 'MDir'.
      --
      --   The default value is @0@, which indicates no truncation.
      --
      --   @since 0.5.0.0
    | MLine LineMarker
      -- ^ How should the vertices of an area mark be joined?
      --
      --   @since 0.4.0.0
    | MLineBreak T.Text
      -- ^ A delimeter, such as a newline character, upon which to break
      --   text strings into multiple lines.
      --
      --   Note that @hvega@ automatically breaks text on the @\\n@ character,
      --   which will over-ride this setting. Therefore setting this only
      --   makes sense if the text does not contain @\n@ characters.
      --
      --   @since 0.5.0.0
    | MLineHeight Double
      -- ^ The height, in pixels, of each line of text in a multi-line text mark.
      --
      --   @since 0.5.0.0
    | MMedian [MarkProperty]
      -- ^ Median-line properties for the 'Boxplot' mark. See also 'MNoMedian'.
      --
      --   @since 0.4.0.0
    | MNoMedian
      -- ^ Do not draw the median of the 'Boxplot' mark.
      --
      --   @since 0.6.0.0
    | MOpacity Opacity
      -- ^ Overall opacity of a mark in the range 0 to 1.
    | MOrder Bool
      -- ^ Ordering of vertices in a line or area mark. If @True@ (the default),
      --   the order is determined by measurement type or order channel. If
      --   @False@, the original data order is used.
      --
      --   @since 0.4.0.0
    | MOrient Orientation
      -- ^ Orientation of a non-stacked bar, tick, area or line mark.
    | MOuterRadius Double
      -- ^ The outer radius, in pixels, of arc marks. It is an alias for 'MRadius'.
      --
      --   @since 0.9.0.0
    | MOutliers [MarkProperty]
      -- ^ Outlier symbol properties for the 'Boxplot' mark. See also 'MNoOutliers'.
      --
      --   @since 0.4.0.0
    | MNoOutliers
      -- ^ Do not draw outliers with the 'Boxplot' mark.
      --
      --   @since 0.4.0.0
    | MPadAngle Double
      -- ^ The angular padding apploed to sides of the arc, in radians.
      --
      --   @since 0.9.0.0
    | MPoint PointMarker
      -- ^ Appearance of a point marker joining the vertices of a line or area mark.
      --
      --   @since 0.4.0.0
    | MRadius Double
      -- ^ Polar coordinate radial offset of a text mark, in pixels, from its origin.
      --   For an arc mark this defines the outer radius, in pixels.
    | MRadius2 Double
      -- ^ The inner radius, in pixels, of an arc mark.
      --
      --   @since 0.9.0.0
    | MRadiusOffset Double
      -- ^ The offset for 'MRadius'.
      --
      --   @since 0.9.0.0
    | MRadius2Offset Double
      -- ^ The offset for 'MRadius2'.
      --
      --   @since 0.9.0.0
    | MRemoveInvalid Bool
      -- ^ The default handling of invalid (@null@ and @NaN@) values. If @True@,
      --   invalid values are skipped or filtered out when represented as marks,
      --   otherwise they are taken to be @0@.
      --
      --   This replaces @RemoveInvalid@ from
      --   'Graphics.Vega.VegaLite.ConfigurationProperty'
      --   in version 0.4 of @hvega@.
      --
      --   @since 0.5.0.0
    | MRule [MarkProperty]
      -- ^ Rule (main line) properties for the 'ErrorBar' and 'Boxplot' marks. See also 'MNoRule'.
      --
      --   @since 0.4.0.0
    | MNoRule
      -- ^ Do not draw the rule for 'ErrorBar' and 'Boxplot' marks.
      --
      --   @since 0.6.0.0
    | MShape Symbol
      -- ^ Shape of a point mark.
    | MSize Double
      -- ^ Size of a mark.
    | MStroke Color
      -- ^ Default stroke color of a mark.
      --
      --   This was changed to use the @Color@ type alias in version @0.5.0.0@.
    | MStrokeCap StrokeCap
      -- ^ Cap style of a mark's stroke.
      --
      --   @since 0.4.0.0
    | MStrokeDash DashStyle
      -- ^ The stroke dash pattern used by a mark.
    | MStrokeDashOffset DashOffset
      -- ^ The offset for the dash pattern.
    | MStrokeGradient ColorGradient GradientStops [GradientProperty]
      -- ^ The color gradient to apply to the boundary of a mark. The first argument
      --   determines its type, the second is the list of color
      --   interpolation points, and the third
      --   allows for customization.
      --
      --   @
      --   'MStrokeGradient'
      --       'GrLinear'
      --       [ ( 0, \"pink\" ), ( 1, \"violet\" ) ]
      --       [ ]
      --   @
      --
      --   @since 0.5.0.0
    | MStrokeJoin StrokeJoin
      -- ^ Line segment join style of a mark's stroke.
      --
      --   @since 0.4.0.0
    | MStrokeMiterLimit Double
      -- ^ Mitre limit at which to bevel a join between line segments of a
      --   mark's stroke.
      --
      --   @since 0.4.0.0
    | MStrokeOpacity Opacity
      -- ^ Stroke opacity of a mark in the range 0 to 1.
    | MStrokeWidth Double
      -- ^ Stroke width of a mark in pixels.
    | MStyle [StyleLabel]
      -- ^ Names of custom styles to apply to a mark. Each should refer to a named style
      --   defined in a separate style configuration (using
      --   'Graphics.Vega.VegaLite.MarkNamedStyles').
    | MTension Double
      -- ^ Interpolation tension used when interpolating line and area marks.
    | MText T.Text
      -- ^ Placeholder text for a text mark for when a text channel is not specified.
      --
      --   See 'MTexts' for supplying an array of text values.
    | MTexts [T.Text]
      -- ^ Placeholder text for a text mark for when a text channel is not specified.
      --
      --   See 'MText' for supplying a single text value.
      --
      --   @since 0.6.0.0
    | MTheta Double
      -- ^ Polar coordinate angle (clockwise from north in radians)
      --   of a text mark from the origin (determined by its
      --   x and y properties). For arc marks, the arc length in radians
      --   if theta2 is not specified, otherwise the start arc angle,
      --   where a value of 0 refers to \"up\" or \"north\", and increases
      --   clockwise).
    | MTheta2 Double
      -- ^ The end angle of arc marks, in radians. A value of 0 indicated
      --   \"up\" or \"north", and increases clockwise.
      --
      --   @since 0.9.0.0
    | MThetaOffset Double
      -- ^ Offset for 'MTheta'.
      --
      --   @since 0.9.0.0
    | MTheta2Offset Double
      -- ^ Offset for 'MTheta2'.
      --
      --   @since 0.9.0.0
    | MThickness Double
      -- ^ Thickness of a tick mark.
    | MTicks [MarkProperty]
      -- ^ Tick properties for the 'ErrorBar' or 'Boxplot' mark. See also 'MNoTicks'.
      --
      --   @since 0.4.0.0
    | MNoTicks
      -- ^ Do not draw ticks for 'ErrorBar' or 'Boxplot' marks.
      --
      --   The default behavior for ticks is for them to not be drawn, so @MNoTicks@
      --   is only needed if the visualization contains something like:
      --
      --   @'Graphics.Vega.VegaLite.configure' ('Graphics.Vega.VegaLite.configuration' ('Graphics.Vega.VegaLite.BoxplotStyle' ['MTicks' []] []))@
      --
      --   @since 0.6.0.0
    | MTimeUnitBand Double
      -- ^ The default relative band size for a time unit.
      --
      --   If set to 1 the bandwidth of the marks will be equal to the time unit band step,
      --   and if set to 0.5 they will be half that.
      --
      --   @since 0.5.0.0
    | MTimeUnitBandPosition Double
      -- ^ The default relative band position for a time unit.
      --
      --   If set to 0 the marks will be positioned at the start of the band,
      --   and if set to 0.5 they will be in the middle.
      --
      --   @since 0.5.0.0
    | MTooltip TooltipContent
      -- ^ The tooltip content for a mark.
      --
      --   @since 0.4.0.0
    | MWidth Double
      -- ^ Explicitly set the width of a mark (e.g. the bar width). See also
      --   'MHeight'.
      --
      --   @since 0.4.0.0
    | MX Double
      -- ^ X position of a mark. See also 'MXWidth'.
      --
      --   @since 0.4.0.0
    | MX2 Double
      -- ^ X2 position of a mark. This is the secondary position for
      --   lines and area marks). See also 'MX2Width'.
      --
      --   @since 0.4.0.0
    | MXOffset Double
      -- ^ X position offset of a mark.
      --
      --   @since 0.4.0.0
    | MX2Offset Double
      -- ^ X2 position offset of a mark.
      --
      --   @since 0.4.0.0
    | MY Double
      -- ^ Y position of a mark. See also 'MYHeight'.
      --
      --   @since 0.4.0.0
    | MY2 Double
      -- ^ Y2 position of a mark. This is the secondary position for
      --   lines and area marks). See also 'MY2Height'.
      --
      --   @since 0.4.0.0
    | MYOffset Double
      -- ^ Y position offset of a mark.
      --
      --   @since 0.4.0.0
    | MY2Offset Double
      -- ^ Y2 position offset of a mark.
      --
      --   @since 0.4.0.0
    | MXWidth
      -- ^ Specify the X coordinate as the \"width\" of the plot.
      --
      --   @since 0.9.0.0
    | MX2Width
      -- ^ Specify the X2 coordinate as the \"width\" of the plot.
      --
      --   @since 0.9.0.0
    | MYHeight
      -- ^ Specify the Y coordinate as the \"height\" of the plot.
      --
      --   @since 0.9.0.0
    | MY2Height
      -- ^ Specify the Y2 coordinate as the \"height\" of the plot.
      --
      --   @since 0.9.0.0


markProperty :: MarkProperty -> Pair

-- special case the gradients
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

-- where are these defined?
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

-- only available in TickConfig
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

-- only available in AreaConfig, BarConfig, LineConfig, MarkConfig,
--                   MarkDef, OverlayMarkDef, RectConfig, TickConfig
markProperty (MBlend BlendMode
bl) = Key
"blend" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BlendMode -> Value
blendModeSpec BlendMode
bl

-- only available in ErrorBand[Config|Def], PartsMixins<ErrorBandPart>
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

-- BoxPlot[Config|Deg], PartsMixins<BoxPlotPart>
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

-- combo of BoxPlot[Config|Def], ErrorBand[Config|Def], ErrorBar[Config|Def]
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

-- BoxPlot[Config|Def] possibly others
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

-- what uses this?
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

-- what uses this?
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  -- special case singleton
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

-- what uses this?
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"

-- unlike elm, need to sort the stops list since we don't have a
-- smart constructor (although it's not obvious this is actually needed,
-- as I think Vega-Lite doesn't require this).
--
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)


{-|

Indicates the mark interpolation style. See the
<https://vega.github.io/vega-lite/docs/mark.html#mark-def Vega-Lite documentation>
for details.
-}
data MarkInterpolation
    = Basis
      -- ^ A B-spline interpolation between points anchored at the first
      --   and last points.
    | BasisClosed
      -- ^ Closed B-spline interpolation between points forming a polygon.
    | BasisOpen
      -- ^ Open B-spline interpolation between points, which may not
      --   intersect the first and last points.
    | Bundle
      -- ^ Bundle curve interpolation between points. This is equivalent to 'Basis'
      --   except that the tension parameter is used to straighten the spline.
    | Cardinal
      -- ^ Cardinal spline interpolation between points anchored at the first
      --   and last points.
    | CardinalClosed
      -- ^ Closed Cardinal spline interpolation between points forming a polygon.
    | CardinalOpen
      -- ^ Open Cardinal spline interpolation between points, which may not
      --   intersect the first and last points.
    | Linear
      -- ^ Linear interpolation between points.
    | LinearClosed
      -- ^ Closed linear interpolaiton between points forming a polygon.
    | Monotone
      -- ^ Cubic spline interpolation that preserves monotonicity between points.
    | StepAfter
      -- ^ Piecewise (stepped) constant interpolation function after each point in a
      --   sequence.
    | StepBefore
      -- ^ Piecewise (stepped) constant interpolation function before each point in a
      --   sequence.
    | Stepwise
      -- ^ Piecewise (stepped) constant interpolation function centred on each point
      --   in a sequence.


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"


-- | The properties of a point marker on a line or area mark.
--   For use with 'MPoint'.
--
--   @since 0.4.0.0

data PointMarker
    = PMTransparent
    -- ^ A transparent marker is used, which can be useful for
    --   interactive selections.
    | PMNone
    -- ^ No marker to be shown.
    | PMMarker [MarkProperty]
    -- ^ The properties of the marks to be shown at the points.
    --
    --   Use an empty list to use a filled point with default properties.

-- An empty object has the same meaning as true, so there is no real need to
-- treat 'PMMarker []' specially, but I don't think it complicates things
-- here.
--
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)


{-|

Appearance of a line marker that is overlaid on an area mark.
For use with 'MLine'.

@since 0.4.0.0

-}

data LineMarker
  = LMNone
    -- ^ No line marker.
  | LMMarker [MarkProperty]
    -- ^ The properties of a line marker overlain on an area mark.
    --
    --   Use an empty list to use a filled point with default properties.


-- An empty object has the same meaning as true, so there is no real need to
-- treat 'LMMarker []' specially, but I don't think it complicates things
-- here.
--
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)


{-|

Indicates the extent of the rule used for the error bar.  See
<https://vega.github.io/vega-lite/docs/errorbar.html#properties Vega-Lite documentation>
for details.

Note that not all options are valid for all mark types.

This is called @SummaryExtent@ in Elm and the constructors also have
different names.

@since 0.4.0.0
-}

-- based on schema 3.3.0 #/definitions/ErrorBarExtent
--          (ConfidenceInterval to Iqr)
-- and combined with the box/band "min-max" and IQR scaling values
--

data MarkErrorExtent
  = ConfidenceInterval
    -- ^ Band extent between the 95% confidence intervals of a distribution.
  | StdErr
    -- ^ Band extent as the standard error about the mean of a distribution.
  | StdDev
    -- ^ Band extent as the standard deviation of a distribution.
  | Iqr
    -- ^ Band extent between the lower and upper quartiles of a distribution
    --   (the inter-quartile range, q1 to q3).
  | ExRange
    -- ^ Band extent between the minimum and maximum values in a distribution.
  | IqrScale Double
    -- ^ A scaling of the interquartile range to be used as whiskers in a
    --   'Boxplot'. For example @IqrScale 1.5@  would extend whiskers to
    --   ±1.5x the IQR from the mean.

-- This is a little different from the other calls since I wanted to
-- make sure the scale factor was encoded as a number not a string.
--
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


{-|
Define the form of the
<https://vega.github.io/vega-lite/docs/types.html#gradient color gradient>
(for use with 'MColorGradient' and 'MFillGradient').

@since 0.5.0.0

-}

data ColorGradient
  = GrLinear
    -- ^ A linear gradient.
  | GrRadial
    -- ^ A radial gradient.


colorGradientLabel :: ColorGradient -> T.Text
colorGradientLabel :: ColorGradient -> Text
colorGradientLabel ColorGradient
GrLinear = Text
"linear"
colorGradientLabel ColorGradient
GrRadial = Text
"radial"


{-|

Convenience type-annotation to label a normalized coordinate
for color gradients. The value should be in the range 0 to 1,
inclusive. There is __no attempt__ to validate that the number
lies within this range.

@since 0.5.0.0
-}
type GradientCoord = Double


{-|

Convenience type-annotation label to indicate the color interpolation
points - i.e. the colors to use at points along the
normalized range 0 to 1 (inclusive).

The list does not have to be sorted. There is no check that the
color is valid (i.e. not empty or a valid color specification).

@since 0.5.0.0
-}
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 ]


{-|

Control the appearance of the gradient. Used by 'MColorGradient',
'MFillGradient', and 'MStrokeGradient'.

@since 0.5.0.0

-}

data GradientProperty
  = GrX1 GradientCoord
    -- ^ The start of the color gradient (X axis); for radial
    --   gradients it represents the center of the inner circle.
    --
    --   The default for linear gradients is 0, and for radial
    --   gradients it is 0.5.
  | GrY1 GradientCoord
    -- ^ The start of the color gradient (Y axis); for radial
    --   gradients it represents the center of the inner circle.
    --
    --   The default for linear gradients is 0, and for radial
    --   gradients it is 0.5.
  | GrX2 GradientCoord
    -- ^ The end of the color gradient (X axis); for radial
    --   gradients it represents the center of the outer circle.
    --
    --   The default for linear gradients is 1, and for radial
    --   gradients it is 0.5.
  | GrY2 GradientCoord
    -- ^ The end of the color gradient (Y axis); for radial
    --   gradients it represents the center of the outer circle.
    --
    --   The default for linear gradients is 1, and for radial
    --   gradients it is 0.5.
  | GrR1 GradientCoord
    -- ^ The radius of the inner circle (radial color gradients
    --   only). The default is 0.
  | GrR2 GradientCoord
    -- ^ The radius of the outer circle (radial color gradients
    --   only). The default is 0.5.


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


{-|
Determine the direction to draw the text.

Used by 'MDir'.

@since 0.5.0.0
-}
data TextDirection
  = LTR
    -- ^ Left to right.
  | RTL
    -- ^ Right to left.

textdirLabel :: TextDirection -> T.Text
textdirLabel :: TextDirection -> Text
textdirLabel TextDirection
LTR = Text
"ltr"
textdirLabel TextDirection
RTL = Text
"rtl"


-- | The blend mode for drawing an item on its background. This is used with 'MBlend'.
--
--   This is based on CSS <https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode mix-blend-mode>
--   and the default is 'BMNormal'.
--
--   Added in Vega-Lite 4.6.0.
--
--   @since 0.7.0.0

data BlendMode
  = BMNormal
    -- ^ The default behavior for Vega-Lite, which is the @\"normal\"@ CSS mix-blend-mode
    --   for SVG output and @\"source-over\"@ for Canvas output (this constructor
    --   creates a @null@ value in the JON output).
  | BMMultiply
    -- ^ @multiply@ mode.
  | BMScreen
    -- ^ @screen@ mode.
  | BMOverlay
    -- ^ @overlay@ mode.
  | BMDarken
    -- ^ @darken@ mode.
  | BMLighten
    -- ^ @lighten@ mode.
  | BMColorDodge
    -- ^ @color-dodge@ mode.
  | BMColorBurn
    -- ^ @color-burn@ mode.
  | BMHardLight
    -- ^ @hard-light@ mode.
  | BMSoftLight
    -- ^ @soft-light@ mode.
  | BMDifference
    -- ^ @difference@ mode.
  | BMExclusion
    -- ^ @exclusion@ mode.
  | BMHue
    -- ^ @hue@ mode.
  | BMSaturation
    -- ^ @saturation@ mode.
  | BMColor
    -- ^ @color@ mode.
  | BMLuminosity
    -- ^ @luminosity@ mode.


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"