Skip to content

Commit

Permalink
MarkChannel: added MSort constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
DougBurke committed Jul 11, 2019
1 parent f29489b commit 6a1e0ed
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
9 changes: 9 additions & 0 deletions hvega/src/Graphics/Vega/VegaLite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,10 @@ data MarkChannel
-- ^ Indicate that data encoding with a mark are already binned.
--
-- @since 0.4.0.0
| MSort [SortProperty]
-- ^ Sort order.
--
-- @since 0.4.0.0
| MImpute [ImputeProperty]
-- ^ Set the imputation rules for a mark channel. See the
-- [Vega-Lite impute documentation](https://vega.github.io/vega-lite/docs/impute.html).
Expand Down Expand Up @@ -2030,6 +2034,7 @@ markChannelProperty (MScale sps) = [scaleProp_ sps]
markChannelProperty (MLegend lps) = [legendProp_ lps]
markChannelProperty (MBin bps) = [bin bps]
markChannelProperty MBinned = [binned_]
markChannelProperty (MSort ops) = [sort_ ops]
markChannelProperty (MImpute ips) = [impute_ ips]
markChannelProperty (MSelectionCondition selName ifClause elseClause) =
selCond_ markChannelProperty selName ifClause elseClause
Expand Down Expand Up @@ -2078,6 +2083,10 @@ supported in @hvega@.
-}

-- based on schema 3.3.0 #/definitions/MarkConfig
--
-- but it also contains a number of other properties

data MarkProperty
= MAlign HAlign
-- ^ Horizontal alignment of a text mark.
Expand Down
14 changes: 10 additions & 4 deletions hvega/tests/ColorTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,24 @@ namedContinuous2 =
(color [ MName "Acceleration", MmType Quantitative, MScale [ SScheme "plasma" [ 0.5, 1 ] ] ])


-- TODO: use of SReverse is not to spec; need an MSort constructor
namedContinuous3 :: VegaLite
namedContinuous3 =
chart "Continuous colour scale based on named vega schame. Should use the flipped plasma colour scheme (i.e. red to orange)."
(color [ MName "Acceleration", MmType Quantitative, MScale [ SScheme "plasma" [] {- , SReverse True -} ] ])
(color [ MName "Acceleration"
, MmType Quantitative
, MScale [ SScheme "plasma" [] ]
, MSort [ Descending ]
])


-- TODO: use of SReverse is not to spec; need an MSort constructor
namedContinuous4 :: VegaLite
namedContinuous4 =
chart "Continuous colour scale based on named vega schame. Should use the first half of the flipped plasma colour scheme (i.e. red to orange)."
(color [ MName "Acceleration", MmType Quantitative, MScale [ SScheme "plasma" [ 0, 0.5 ] {- , SReverse True -} ] ])
(color [ MName "Acceleration"
, MmType Quantitative
, MScale [ SScheme "plasma" [ 0, 0.5 ] ]
, MSort [ Descending ]
])


customContinuous :: VegaLite
Expand Down
1 change: 1 addition & 0 deletions hvega/tests/color/namedContinuous3.vl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"scale": {
"scheme": "plasma"
},
"sort": "descending",
"type": "quantitative"
},
"size": {
Expand Down
1 change: 1 addition & 0 deletions hvega/tests/color/namedContinuous4.vl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"name": "plasma"
}
},
"sort": "descending",
"type": "quantitative"
},
"size": {
Expand Down

0 comments on commit 6a1e0ed

Please sign in to comment.