{-# LANGUAGE OverloadedStrings #-}

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

Maintainer  : dburke.gw@gmail.com
Stability   : unstable
Portability : 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
       , 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
  )


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


-- | 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 -> LabelledSpec

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

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

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

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

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

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

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

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

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

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

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

-- 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 [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)


{-|

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) = [LabelledSpec] -> Value
object ((MarkProperty -> LabelledSpec) -> [MarkProperty] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> LabelledSpec
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) = [LabelledSpec] -> Value
object ((MarkProperty -> LabelledSpec) -> [MarkProperty] -> [LabelledSpec]
forall a b. (a -> b) -> [a] -> [b]
map MarkProperty -> LabelledSpec
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 -> 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


{-|
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) = [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 ]


{-|

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 -> 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


{-|
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"