hvega 0.9.1.0 → 0.10.0.0
raw patch · 41 files changed
+1149/−205 lines, 41 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Graphics.Vega.VegaLite: DTDayOfYear :: Int -> DateTime
+ Graphics.Vega.VegaLite: DTWeek :: Int -> DateTime
+ Graphics.Vega.VegaLite: DayHours :: BaseTimeUnit
+ Graphics.Vega.VegaLite: DayHoursMinutes :: BaseTimeUnit
+ Graphics.Vega.VegaLite: DayHoursMinutesSeconds :: BaseTimeUnit
+ Graphics.Vega.VegaLite: DayOfYear :: BaseTimeUnit
+ Graphics.Vega.VegaLite: MonthDateHours :: BaseTimeUnit
+ Graphics.Vega.VegaLite: MonthDateHoursMinutes :: BaseTimeUnit
+ Graphics.Vega.VegaLite: MonthDateHoursMinutesSeconds :: BaseTimeUnit
+ Graphics.Vega.VegaLite: NTU :: NTimeUnit -> ScaleNice
+ Graphics.Vega.VegaLite: TU :: BaseTimeUnit -> TimeUnit
+ Graphics.Vega.VegaLite: UtcStep :: Double -> BaseTimeUnit -> TimeUnit
+ Graphics.Vega.VegaLite: Week :: BaseTimeUnit
+ Graphics.Vega.VegaLite: WeekDay :: BaseTimeUnit
+ Graphics.Vega.VegaLite: WeeksDayHours :: BaseTimeUnit
+ Graphics.Vega.VegaLite: WeeksDayHoursMinutes :: BaseTimeUnit
+ Graphics.Vega.VegaLite: WeeksDayHoursMinutesSeconds :: BaseTimeUnit
+ Graphics.Vega.VegaLite: YearDayOfYear :: BaseTimeUnit
+ Graphics.Vega.VegaLite: YearWeek :: BaseTimeUnit
+ Graphics.Vega.VegaLite: YearWeekDay :: BaseTimeUnit
+ Graphics.Vega.VegaLite: YearWeekDayHours :: BaseTimeUnit
+ Graphics.Vega.VegaLite: YearWeekDayHoursMinutes :: BaseTimeUnit
+ Graphics.Vega.VegaLite: YearWeekDayHoursMinutesSeconds :: BaseTimeUnit
+ Graphics.Vega.VegaLite: data BaseTimeUnit
+ Graphics.Vega.VegaLite: data NTimeUnit
- Graphics.Vega.VegaLite: Date :: TimeUnit
+ Graphics.Vega.VegaLite: Date :: BaseTimeUnit
- Graphics.Vega.VegaLite: Day :: TimeUnit
+ Graphics.Vega.VegaLite: Day :: BaseTimeUnit
- Graphics.Vega.VegaLite: Hours :: TimeUnit
+ Graphics.Vega.VegaLite: Hours :: BaseTimeUnit
- Graphics.Vega.VegaLite: HoursMinutes :: TimeUnit
+ Graphics.Vega.VegaLite: HoursMinutes :: BaseTimeUnit
- Graphics.Vega.VegaLite: HoursMinutesSeconds :: TimeUnit
+ Graphics.Vega.VegaLite: HoursMinutesSeconds :: BaseTimeUnit
- Graphics.Vega.VegaLite: Milliseconds :: TimeUnit
+ Graphics.Vega.VegaLite: Milliseconds :: BaseTimeUnit
- Graphics.Vega.VegaLite: Minutes :: TimeUnit
+ Graphics.Vega.VegaLite: Minutes :: BaseTimeUnit
- Graphics.Vega.VegaLite: MinutesSeconds :: TimeUnit
+ Graphics.Vega.VegaLite: MinutesSeconds :: BaseTimeUnit
- Graphics.Vega.VegaLite: Month :: TimeUnit
+ Graphics.Vega.VegaLite: Month :: BaseTimeUnit
- Graphics.Vega.VegaLite: MonthDate :: TimeUnit
+ Graphics.Vega.VegaLite: MonthDate :: BaseTimeUnit
- Graphics.Vega.VegaLite: NDay :: ScaleNice
+ Graphics.Vega.VegaLite: NDay :: NTimeUnit
- Graphics.Vega.VegaLite: NHour :: ScaleNice
+ Graphics.Vega.VegaLite: NHour :: NTimeUnit
- Graphics.Vega.VegaLite: NInterval :: TimeUnit -> Int -> ScaleNice
+ Graphics.Vega.VegaLite: NInterval :: NTimeUnit -> Int -> ScaleNice
- Graphics.Vega.VegaLite: NMillisecond :: ScaleNice
+ Graphics.Vega.VegaLite: NMillisecond :: NTimeUnit
- Graphics.Vega.VegaLite: NMinute :: ScaleNice
+ Graphics.Vega.VegaLite: NMinute :: NTimeUnit
- Graphics.Vega.VegaLite: NMonth :: ScaleNice
+ Graphics.Vega.VegaLite: NMonth :: NTimeUnit
- Graphics.Vega.VegaLite: NSecond :: ScaleNice
+ Graphics.Vega.VegaLite: NSecond :: NTimeUnit
- Graphics.Vega.VegaLite: NWeek :: ScaleNice
+ Graphics.Vega.VegaLite: NWeek :: NTimeUnit
- Graphics.Vega.VegaLite: NYear :: ScaleNice
+ Graphics.Vega.VegaLite: NYear :: NTimeUnit
- Graphics.Vega.VegaLite: Quarter :: TimeUnit
+ Graphics.Vega.VegaLite: Quarter :: BaseTimeUnit
- Graphics.Vega.VegaLite: QuarterMonth :: TimeUnit
+ Graphics.Vega.VegaLite: QuarterMonth :: BaseTimeUnit
- Graphics.Vega.VegaLite: Seconds :: TimeUnit
+ Graphics.Vega.VegaLite: Seconds :: BaseTimeUnit
- Graphics.Vega.VegaLite: SecondsMilliseconds :: TimeUnit
+ Graphics.Vega.VegaLite: SecondsMilliseconds :: BaseTimeUnit
- Graphics.Vega.VegaLite: TUStep :: Double -> TimeUnit -> TimeUnit
+ Graphics.Vega.VegaLite: TUStep :: Double -> BaseTimeUnit -> TimeUnit
- Graphics.Vega.VegaLite: Utc :: TimeUnit -> TimeUnit
+ Graphics.Vega.VegaLite: Utc :: BaseTimeUnit -> TimeUnit
- Graphics.Vega.VegaLite: Year :: TimeUnit
+ Graphics.Vega.VegaLite: Year :: BaseTimeUnit
- Graphics.Vega.VegaLite: YearMonth :: TimeUnit
+ Graphics.Vega.VegaLite: YearMonth :: BaseTimeUnit
- Graphics.Vega.VegaLite: YearMonthDate :: TimeUnit
+ Graphics.Vega.VegaLite: YearMonthDate :: BaseTimeUnit
- Graphics.Vega.VegaLite: YearMonthDateHours :: TimeUnit
+ Graphics.Vega.VegaLite: YearMonthDateHours :: BaseTimeUnit
- Graphics.Vega.VegaLite: YearMonthDateHoursMinutes :: TimeUnit
+ Graphics.Vega.VegaLite: YearMonthDateHoursMinutes :: BaseTimeUnit
- Graphics.Vega.VegaLite: YearMonthDateHoursMinutesSeconds :: TimeUnit
+ Graphics.Vega.VegaLite: YearMonthDateHoursMinutesSeconds :: BaseTimeUnit
- Graphics.Vega.VegaLite: YearQuarter :: TimeUnit
+ Graphics.Vega.VegaLite: YearQuarter :: BaseTimeUnit
- Graphics.Vega.VegaLite: YearQuarterMonth :: TimeUnit
+ Graphics.Vega.VegaLite: YearQuarterMonth :: BaseTimeUnit
Files
- CHANGELOG.md +26/−0
- README.md +2/−2
- hvega.cabal +1/−1
- hvega.nix +1/−1
- src/Graphics/Vega/VegaLite.hs +36/−1
- src/Graphics/Vega/VegaLite/Core.hs +7/−4
- src/Graphics/Vega/VegaLite/Scale.hs +51/−32
- src/Graphics/Vega/VegaLite/Time.hs +220/−101
- tests/CompositeTests.hs +1/−1
- tests/ConditionalTests.hs +2/−2
- tests/ConfigTests.hs +2/−2
- tests/FilterTests.hs +1/−1
- tests/Gallery/Advanced.hs +3/−3
- tests/Gallery/Area.hs +6/−6
- tests/Gallery/Bar.hs +2/−2
- tests/Gallery/Error.hs +1/−1
- tests/Gallery/Facet.hs +1/−1
- tests/Gallery/Interaction.hs +5/−4
- tests/Gallery/Label.hs +4/−4
- tests/Gallery/Layer.hs +5/−5
- tests/Gallery/Line.hs +2/−2
- tests/Gallery/Multi.hs +1/−1
- tests/Gallery/Repeat.hs +4/−4
- tests/Gallery/Table.hs +4/−4
- tests/InteractionTests.hs +1/−1
- tests/TimeTests.hs +318/−9
- tests/TransformTests.hs +1/−1
- tests/WindowTransformTests.hs +5/−5
- tests/specs/time/customizeStep.vl +87/−0
- tests/specs/time/monthAggregate.vl +22/−0
- tests/specs/time/nestedTime1.vl +53/−0
- tests/specs/time/nestedTime2.vl +43/−0
- tests/specs/time/outputAsUTC.vl +42/−0
- tests/specs/time/outputScaledAsUTC.vl +45/−0
- tests/specs/time/parseAsFormat.vl +29/−0
- tests/specs/time/parseAsLocal.vl +24/−0
- tests/specs/time/parseAsUTC.vl +24/−0
- tests/specs/time/timeUnitTransform.vl +28/−0
- tests/specs/time/utcTime.vl +1/−4
- tests/specs/time/withBar.vl +19/−0
- tests/specs/time/withBarOrdinal.vl +19/−0
CHANGELOG.md view
@@ -1,6 +1,32 @@ For the latest version of this document, please see [https://github.com/DougBurke/hvega/blob/master/hvega/CHANGELOG.md](https://github.com/DougBurke/hvega/blob/master/hvega/CHANGELOG.md). +## 0.10.0.0++The Vega-Lite tests are now validated against version 4.13 of the+Vega-Lite schema.++### Breaking Changes++The handling of time units (for both `TimeUnit` and `ScaleNice`) has+changed. The contents of these types have been split into two parts: a+"time unit" and the options that get applied to it (rather than having+a single type that combines both functions). This does mean that+setting time units has now become __more verbose__, but it has stopped+some problem cases (and, in the case of `ScaleNice`, fixed a logical+error on my part). The new time units are `BaseTimeUnit` and+`NTimeUnit`, and contain the "basic" constructors for the time+units. The `TimeUnit` and `ScaleNice` constructors now reference these+types rather than include them in their definition, so that `PTimeUnit+Month` has been changed to `PTimeUnit (TU Month)` and `SNice NMinute`+has changed to `SNice (NTU NMinute)`.++The `BaseTimeUnit' type has seen a number of additions: the `Week` and+`DayOfYear` time units added in Vega-Lite 4.13.0, along with the+associated composite units (such as `YearWeek`), and a number of+composite types that were missing (such as `MonthDateHours`). The+`DateTime` type has added the `DTWeek` and `DTDayOfYear` constructors.+ ## 0.9.1.0 The tutorial has been expanded to add a section describing the
README.md view
@@ -1,9 +1,9 @@ # hvega -[](https://vega.github.io/vega-lite/)+[](https://vega.github.io/vega-lite/) Create [Vega-Lite](https://vega.github.io/vega-lite/) visualizations in-Haskell. It targets version 4.12 of the Vega-Lite specification. Note that+Haskell. It targets version 4.13 of the Vega-Lite specification. Note that the module does not include a viewer for these visualizations (which are JSON files), but does provide several helper functions, such as [toHtmlFile](https://hackage.haskell.org/package/hvega/docs/Graphics-Vega-VegaLite.html#v:toHtmlFile),
hvega.cabal view
@@ -1,5 +1,5 @@ name: hvega-version: 0.9.1.0+version: 0.10.0.0 synopsis: Create Vega-Lite visualizations (version 4) in Haskell. description: This is based on the elm-vegalite package (<http://package.elm-lang.org/packages/gicentre/elm-vegalite/latest>)
hvega.nix view
@@ -4,7 +4,7 @@ }: mkDerivation { pname = "hvega";- version = "0.9.1.0";+ version = "0.10.0.0"; src = ./.; configureFlags = [ "-ftools" ]; isLibrary = true;
src/Graphics/Vega/VegaLite.hs view
@@ -14,7 +14,7 @@ it has been updated to match later versions. This module allows users to create a Vega-Lite specification, targeting __version 4__ of the <https://vega.github.io/schema/vega-lite/v4.json JSON schema>.-Version 0.9 of @hvega@ supports version 4.12 of the Vega-Lite specification.+Version 0.10 of @hvega@ supports version 4.13 of the Vega-Lite specification. Although this is based on the Elm module, there are differences, such as using type constructors rather than functions for many properties -@@ -666,6 +666,7 @@ , VL.ScaleDomain(..) , VL.ScaleRange(..) , VL.ScaleNice(..)+ , VL.NTimeUnit(..) -- *** Color scaling --@@ -850,11 +851,16 @@ , VL.MonthName(..) , VL.DayName(..) , VL.TimeUnit(..)+ , VL.BaseTimeUnit(..) -- * Update notes -- -- $update + -- ** Version 0.10+ --+ -- $update01000+ -- ** Version 0.9 -- -- $update0910@@ -1256,6 +1262,35 @@ -- $update -- The following section describes how to update code that used -- an older version of @hvega@.++-- $update01000+-- The @0.10.0.0@ release updates @hvega@ to support version 4.13 of+-- the Vega-Lite schema.+--+-- __Breaking Changes__+--+-- The handling of time units (for both 'VL.TimeUnit' and 'VL.ScaleNice') has+-- changed. The contents of these types have been split into two parts:+-- a \"time unit\" and the options that get applied to it (rather than having+-- a single type that combines both functions). This does mean that setting+-- time units has now become __more verbose__, but it has stopped some+-- problem cases (and, in the case of 'VL.ScaleNice', fixed a logical error+-- on my part). The new time units are 'VL.BaseTimeUnit' and 'VL.NTimeUnit',+-- and contain the \"basic\" constructors for the time units. The+-- 'VL.TimeUnit' and 'VL.ScaleNice' constructors now reference these+-- types rather than include them in their definition, so that+-- @PTimeUnit Month@ has been changed to+-- @'VL.PTimeUnit' ('VL.TU' 'VL.Month')@+-- and+-- @SNice NMinute@ has changed to+-- @'VL.SNice' ('VL.NTU' 'VL.NMinute')@.+--+-- The 'VL.BaseTimeUnit' type has seen a number of additions: the 'VL.Week' and+-- 'VL.DayOfYear' time units added in Vega-Lite 4.13.0, along with the+-- associated composite units (such as 'VL.YearWeek'), and a number of+-- composite types that were missing (such as 'VL.MonthDateHours').+-- The 'VL.DateTime' type has added the 'VL.DTWeek' and 'VL.DTDayOfYear'+-- constructors. -- $update0910 -- The tutorial has been expanded to add a section with pie charts.
src/Graphics/Vega/VegaLite/Core.hs view
@@ -1231,7 +1231,7 @@ -- @ -- 'PAxis' [ 'AxDataCondition' -- ('FEqual' "value" ('Graphics.Vega.VegaLite.DateTime' ['Grahics.Vega.VegaLite.DTMonth' 'Graphics.Vega.VegaLite.Jan', 'Graphics.Vega.VegaLite.DTDate' 1])- -- & 'FilterOpTrans' ('MTimeUnit' 'Graphics.Vega.VegaLite.MonthDate'))+ -- & 'FilterOpTrans' ('MTimeUnit' ('Graphics.Vega.VegaLite.TU' 'Graphics.Vega.VegaLite.MonthDate'))) -- ('CAxGridDash' [] [2, 2]) -- ] -- @@@ -1882,7 +1882,7 @@ -- -- @ -- 'filter' ('FRange' "date" ('NumberRange' 2010 2017)- -- & 'FilterOpTrans' ('MTimeUnit' 'Graphics.Vega.VegaLite.Year')+ -- & 'FilterOpTrans' ('MTimeUnit' ('Graphics.Vega.VegaLite.TU' 'Graphics.Vega.VegaLite.Year')) -- & 'FCompose' -- ) -- @@@ -4928,17 +4928,20 @@ grouping by month: @-trans = 'transform' . 'timeUnitAs' 'Graphics.Vega.VegaLite.Month' \"date\" \"monthly\"+trans = 'transform' . 'timeUnitAs' ('Graphics.Vega.VegaLite.TU' 'Graphics.Vega.VegaLite.Month') \"date\" \"monthly\" enc = 'encoding'- . 'position' 'Graphics.Vega.VegaLite.X' [ 'PName' \"date\", 'PmType' 'Graphics.Vega.VegaLite.Temporal', 'PTimeUnit' 'Graphics.Vega.VegaLite.Day' ]+ . 'position' 'Graphics.Vega.VegaLite.X' [ 'PName' \"date\", 'PmType' 'Graphics.Vega.VegaLite.Temporal', 'PTimeUnit' ('Graphics.Vega.VegaLite.TU' 'Graphics.Vega.VegaLite.Day') ] . 'position' 'Graphics.Vega.VegaLite.Y' [ 'PAggregate' 'Graphics.Vega.VegaLite.Sum', 'PmType' 'Graphics.Vega.VegaLite.Quantitative' ] . 'detail' [ 'DName' \"monthly\", 'DmType' 'Graphics.Vega.VegaLite.Temporal' ] @+ -} timeUnitAs :: TimeUnit -- ^ The width of each bin.+ --+ -- Prior to @0.10.0.0@ this was sent a single time unit. -> FieldName -- ^ The field to bin. -> FieldName
src/Graphics/Vega/VegaLite/Scale.hs view
@@ -17,6 +17,7 @@ ( ScaleDomain(..) , ScaleRange(..) , ScaleNice(..)+ , NTimeUnit(..) -- not for external export , scaleDomainSpec@@ -40,9 +41,7 @@ ) import Graphics.Vega.VegaLite.Time ( DateTime- , TimeUnit , dateTimeProperty- , timeUnitSpec ) @@ -112,43 +111,63 @@ Describes the way a scale can be rounded to \"nice\" numbers. For full details see the <https://vega.github.io/vega-lite/docs/scale.html#continuous Vega-Lite documentation>.++Prior to version @0.10.0.0@ the time units were included in the constructors+for @ScaleNice@.+ -} data ScaleNice- = NMillisecond- -- ^ Nice time intervals that try to align with rounded milliseconds.- | NSecond- -- ^ Nice time intervals that try to align with whole or rounded seconds.- | NMinute- -- ^ Nice time intervals that try to align with whole or rounded minutes.- | NHour- -- ^ Nice time intervals that try to align with whole or rounded hours.- | NDay- -- ^ Nice time intervals that try to align with whole or rounded days.- | NWeek+ = NTU NTimeUnit+ -- ^ Time range.+ | NInterval NTimeUnit Int+ -- ^ \"Nice\" temporal interval values when scaling.+ | IsNice Bool+ -- ^ Enable or disable nice scaling.+ | NTickCount Int+ -- ^ Desired number of tick marks in a \"nice\" scaling.++{-|++The time intervals that can be rounded to \"nice\" numbers.++Prior to @0.10.0.0@ these were part of 'ScaleNice'.++-}++data NTimeUnit+ = NMillisecond+ -- ^ Nice time intervals that try to align with rounded milliseconds.+ | NSecond+ -- ^ Nice time intervals that try to align with whole or rounded seconds.+ | NMinute+ -- ^ Nice time intervals that try to align with whole or rounded minutes.+ | NHour+ -- ^ Nice time intervals that try to align with whole or rounded hours.+ | NDay+ -- ^ Nice time intervals that try to align with whole or rounded days.+ | NWeek -- ^ Nice time intervals that try to align with whole or rounded weeks.- | NMonth- -- ^ Nice time intervals that try to align with whole or rounded months.- | NYear- -- ^ Nice time intervals that try to align with whole or rounded years.- | NInterval TimeUnit Int- -- ^ \"Nice\" temporal interval values when scaling.- | IsNice Bool- -- ^ Enable or disable nice scaling.- | NTickCount Int- -- ^ Desired number of tick marks in a \"nice\" scaling.+ | NMonth+ -- ^ Nice time intervals that try to align with whole or rounded months.+ | NYear+ -- ^ Nice time intervals that try to align with whole or rounded years. +nTimeUnitSpec :: NTimeUnit -> VLSpec+nTimeUnitSpec NMillisecond = fromT "millisecond"+nTimeUnitSpec NSecond = fromT "second"+nTimeUnitSpec NMinute = fromT "minute"+nTimeUnitSpec NHour = fromT "hour"+nTimeUnitSpec NDay = fromT "day"+nTimeUnitSpec NWeek = fromT "week"+nTimeUnitSpec NMonth = fromT "month"+nTimeUnitSpec NYear = fromT "year"++ scaleNiceSpec :: ScaleNice -> VLSpec-scaleNiceSpec NMillisecond = fromT "millisecond"-scaleNiceSpec NSecond = fromT "second"-scaleNiceSpec NMinute = fromT "minute"-scaleNiceSpec NHour = fromT "hour"-scaleNiceSpec NDay = fromT "day"-scaleNiceSpec NWeek = fromT "week"-scaleNiceSpec NMonth = fromT "month"-scaleNiceSpec NYear = fromT "year"+scaleNiceSpec (NTU tu) = nTimeUnitSpec tu scaleNiceSpec (NInterval tu step) =- object ["interval" .= timeUnitSpec tu, "step" .= step]+ object ["interval" .= nTimeUnitSpec tu, "step" .= step] scaleNiceSpec (IsNice b) = toJSON b scaleNiceSpec (NTickCount n) = toJSON n
src/Graphics/Vega/VegaLite/Time.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-|@@ -18,6 +19,7 @@ , MonthName(..) , DayName(..) , TimeUnit(..)+ , BaseTimeUnit(..) -- not for external export , dateTimeProperty@@ -27,8 +29,12 @@ import qualified Data.Text as T -import Data.Aeson ((.=), object)+import Data.Aeson ((.=), object, toJSON) +#if !(MIN_VERSION_base(4, 12, 0))+import Data.Monoid ((<>))+#endif+ -- added in base 4.8.0.0 / ghc 7.10.1 import Numeric.Natural (Natural) @@ -58,13 +64,23 @@ -- ^ The month number (1 to 12, inclusive). -- -- @since 0.5.0.0- | DTDate Int- -- ^ Day of the month (1 to 31, inclusive).+ | DTWeek Int+ -- ^ The week number. Each week begins on Sunday, which means that days+ -- before the first Sunday of the year are considered to be in week 0,+ -- as the first Sunday of the year is the start of week 1.+ --+ -- @since 0.10.0.0 | DTDay DayName | DTDayNum Int -- ^ The day number (1 represents Monday, 7 is Sunday). --- -- @since 0.5.0.0+ -- @since 0.5.0.0+ | DTDayOfYear Int+ -- ^ The day of the year (1 to 366).+ --+ -- @since 0.10.0.0+ | DTDate Int+ -- ^ Day of the month (1 to 31, inclusive). | DTHours Int -- ^ Hour of the day, where 0 is midnight, 1 is 1am, and -- 23 is 11pm.@@ -105,18 +121,7 @@ | Dec -{-| -Describes a unit of time. Useful for encoding and transformations. See the-<https://vega.github.io/vega-lite/docs/timeunit.html Vega-Lite documentation>-for further details.--@-'Graphics.Vega.VegaLite.encoding'- . 'Graphics.Vega.VegaLite.position' 'Graphics.Vega.VegaLite.X' [ 'Graphics.Vega.VegaLite.PName' "date", 'Graphics.Vega.VegaLite.PmType' 'Graphics.Vega.VegaLite.Temporal', 'Graphics.Vega.VegaLite.PTimeUnit' ('Utc' 'YearMonthDateHours') ]-@--}- -- Vega-Lite 4.4.0 has -- LocalMultiTimeUnit which is yearquarter, yearquartermonth, ,secondsmilliseconds -- LocalSingleTimeUnit year, quarter, ..., milliseconds@@ -136,16 +141,93 @@ -- unit - this is TimeUnit -- utc - boolean ----- So, could be something like "TU <time unit type> [options]"--- where an empty array means it's a "TimeUnit", and the options are from--- TimeUnitParams (apart from the unit field). Unfortunately this doesn't--- capture the use case of supplying "maxbins" only (it may be that "step"--- can also be used without any other value).--- +{-|++Describes a unit of time. Useful for encoding and transformations. See the+<https://vega.github.io/vega-lite/docs/timeunit.html Vega-Lite documentation>+for further details.++@+'Graphics.Vega.VegaLite.encoding'+ . 'Graphics.Vega.VegaLite.position' 'Graphics.Vega.VegaLite.X' [ 'Graphics.Vega.VegaLite.PName' "date", 'Graphics.Vega.VegaLite.PmType' 'Graphics.Vega.VegaLite.Temporal', 'Graphics.Vega.VegaLite.PTimeUnit' ('Utc' 'YearMonthDateHours') ]+@++Prior to version @0.10.0.0@ the field was a combination of what is now+'BaseTimeUnit' and the \"option\" fields (e.g. encode as UTC or the+maximum nuber of bins).++-}++ data TimeUnit+ = TU BaseTimeUnit+ -- ^ Encode a time as local time.+ | Utc BaseTimeUnit+ -- ^ Encode a time as UTC (coordinated universal time, independent of local time+ -- zones or daylight saving).+ | TUMaxBins Natural+ -- ^ The maximum number of bins to use when discretising time values.+ -- This can be useful as an algternative to explicitly providing the+ -- time unit to bin by, as it will be inferred from the temporal+ -- extent and the number of bins. As an example, @[TUMaxBins 366]@+ -- will bin by day when applied to a dataset of hourly readings+ -- for a full year.+ --+ -- @since 0.6.0.0+ | TUStep Double BaseTimeUnit+ -- ^ The number of steps between time-unit bins, in terms of the+ -- least-significant unit provided. So @TUStep 14 YearMonthDate@+ -- will bin temporal data into bi-weekly groups.+ --+ -- @since 0.6.0.0+ | UtcStep Double BaseTimeUnit+ -- ^ The number of steps between time-unit bins, in terms of the+ -- least-significant unit provided for UTC times.+ -- So @UtcStep 14 YearMonthDate]@+ -- will bin temporal data into bi-weekly groups.+ --+ -- @since 0.10.0.0+++{-|++Define the time unit, either as a base unit - such as 'Hours' - or+as a composite type, for example 'WeeksDayHours'.++@since 0.10.0.0++-}++data BaseTimeUnit = Year -- ^ Year.+ | Quarter+ -- ^ Quarter of the year.+ | Month+ -- ^ Month of the year.+ | Week+ -- ^ Sunday-based week number. Days before the first Sunday of the year+ -- are considered to be in week 0, and the first Sunday of the year+ -- is the start of week 1,+ --+ -- @since 0.10.0.0+ | Date+ -- ^ Day of the month (1 to 31).+ | Day+ -- ^ Day of the week.+ | DayOfYear+ -- ^ Day of the year (starting at 1).+ --+ -- @since 0.10.0.0+ | Hours+ -- ^ Hour of the day.+ | Minutes+ -- ^ Minutes of the hour.+ | Seconds+ -- ^ Seconds of the minute.+ | Milliseconds+ -- ^ Milliseconds. | YearQuarter -- ^ Year and quarter. | YearQuarterMonth@@ -160,61 +242,137 @@ -- ^ Year, month, day of month, hour of day, and minutes. | YearMonthDateHoursMinutesSeconds -- ^ Year, month, day of month, hour of day, minutes, and seconds.- | Quarter- -- ^ Quarter of the year.+ | YearWeek+ -- ^ Year and week.+ --+ -- @since 0.10.0+ | YearWeekDay+ -- ^ Year, week, and day.+ --+ -- @since 0.10.0+ | YearWeekDayHours+ -- ^ Year, week, day, and hour of day.+ --+ -- @since 0.10.0+ | YearWeekDayHoursMinutes+ -- ^ Year, week, day, hour of day, and minutes.+ --+ -- @since 0.10.0+ | YearWeekDayHoursMinutesSeconds+ -- ^ Year, week, day, hour of day, minutes, and seconds.+ --+ -- @since 0.10.0+ | YearDayOfYear+ -- ^ Year and day of year.+ --+ -- @since 0.10.0 | QuarterMonth -- ^ Quarter of the year and month.- | Month- -- ^ Month of the year. | MonthDate -- ^ Month of the year and day of the month.- | Date- -- ^ Day of the month (1 to 31).- | Day- -- ^ Day of the week.- | Hours- -- ^ Hour of the day.+ | MonthDateHours+ -- ^ Month, day of the month, and hours.+ --+ -- @since 0.10.0.0+ | MonthDateHoursMinutes+ -- ^ Month, day of the month, hours, and minutes.+ --+ -- @since 0.10.0.0+ | MonthDateHoursMinutesSeconds+ -- ^ Month, day of the month, hours, minutes, and seconds.+ --+ -- @since 0.10.0.0+ | WeekDay+ -- ^ Week and day of month.+ --+ -- @since 0.10.0.0+ | WeeksDayHours+ -- ^ Week, day of month, and hours.+ --+ -- @since 0.10.0.0+ | WeeksDayHoursMinutes+ -- ^ Week, day of month, hours, and minutes.+ --+ -- @since 0.10.0.0+ | WeeksDayHoursMinutesSeconds+ -- ^ Week, day of month, hours, minutes, and seconds.+ --+ -- @since 0.10.0.0+ | DayHours+ -- ^ Day of the week and hours.+ --+ -- @since 0.10.0.0+ | DayHoursMinutes+ -- ^ Day of the week, hours, and minutes.+ --+ -- @since 0.10.0.0+ | DayHoursMinutesSeconds+ -- ^ Day of the week, hours, minutes, and seconds.+ --+ -- @since 0.10.0.0 | HoursMinutes -- ^ Hour of the day and minutes. | HoursMinutesSeconds -- ^ Hour of the day, minutes, and seconds.- | Minutes- -- ^ Minutes of the hour. | MinutesSeconds -- ^ Minutes of the hour and seconds.- | Seconds- -- ^ Seconds of the minute. | SecondsMilliseconds -- ^ Seconds of the minute and milliseconds.- | Milliseconds- -- ^ Milliseconds.- | Utc TimeUnit- -- ^ Encode a time as UTC (coordinated universal time, independent of local time- -- zones or daylight saving).- | TUMaxBins Natural- -- ^ The maximum number of bins to use when discretising time values.- -- This can be useful as an algternative to explicitly providing the- -- time unit to bin by, as it will be inferred from the temporal- -- extent and the number of bins. As an example, @TUMaxBins 366@- -- will bin by day when applied to a dataset of hourly readings- -- for a full year.- --- -- @since 0.6.0.0- | TUStep Double TimeUnit- -- ^ The number of steps between time-unit bins, in terms of the- -- least-significant unit provided. So @TUStep 14 YearMonthDate@- -- wull bin temporal data into bi-weekly groups.- --- -- @since 0.6.0.0 +baseTimeUnitLabel :: BaseTimeUnit -> T.Text+baseTimeUnitLabel Year = "year"+baseTimeUnitLabel Quarter = "quarter"+baseTimeUnitLabel Month = "month"+baseTimeUnitLabel Week = "week"+baseTimeUnitLabel Date = "date"+baseTimeUnitLabel Day = "day"+baseTimeUnitLabel DayOfYear = "dayofyear"+baseTimeUnitLabel Hours = "hours"+baseTimeUnitLabel Minutes = "minutes"+baseTimeUnitLabel Seconds = "seconds"+baseTimeUnitLabel Milliseconds = "milliseconds"++baseTimeUnitLabel YearQuarter = "yearquarter"+baseTimeUnitLabel YearQuarterMonth = "yearquartermonth"+baseTimeUnitLabel YearMonth = "yearmonth"+baseTimeUnitLabel YearMonthDate = "yearmonthdate"+baseTimeUnitLabel YearMonthDateHours = "yearmonthdatehours"+baseTimeUnitLabel YearMonthDateHoursMinutes = "yearmonthdatehoursminutes"+baseTimeUnitLabel YearMonthDateHoursMinutesSeconds = "yearmonthdatehoursminutesseconds"+baseTimeUnitLabel YearWeek = "yearweek"+baseTimeUnitLabel YearWeekDay = "yearweekday"+baseTimeUnitLabel YearWeekDayHours = "yearweekdayhours"+baseTimeUnitLabel YearWeekDayHoursMinutes = "yearweekdayhoursminutes"+baseTimeUnitLabel YearWeekDayHoursMinutesSeconds = "yearweekdayhoursminutesseconds"+baseTimeUnitLabel YearDayOfYear = "yeardayofyear"+baseTimeUnitLabel QuarterMonth = "quartermonth"+baseTimeUnitLabel MonthDate = "monthdate"+baseTimeUnitLabel MonthDateHours = "monthdatehours"+baseTimeUnitLabel MonthDateHoursMinutes = "monthdatehoursminutes"+baseTimeUnitLabel MonthDateHoursMinutesSeconds = "monthdatehoursminutesseconds"+baseTimeUnitLabel WeekDay = "weekday"+baseTimeUnitLabel WeeksDayHours = "weeksdayhours"+baseTimeUnitLabel WeeksDayHoursMinutes = "weeksdayhoursminutes"+baseTimeUnitLabel WeeksDayHoursMinutesSeconds = "weeksdayhoursminutesseconds"+baseTimeUnitLabel DayHours = "dayhours"+baseTimeUnitLabel DayHoursMinutes = "dayhoursminutes"+baseTimeUnitLabel DayHoursMinutesSeconds = "dayhoursminutesseconds"+baseTimeUnitLabel HoursMinutes = "hoursminutes"+baseTimeUnitLabel HoursMinutesSeconds = "hoursminutesseconds"+baseTimeUnitLabel MinutesSeconds = "minutesseconds"+baseTimeUnitLabel SecondsMilliseconds = "secondsmilliseconds"++ dateTimeProperty :: DateTime -> LabelledSpec dateTimeProperty (DTYear y) = "year" .= y dateTimeProperty (DTQuarter q) = "quarter" .= q dateTimeProperty (DTMonth mon) = "month" .= monthNameLabel mon dateTimeProperty (DTMonthNum n) = "month" .= n+dateTimeProperty (DTWeek w) = "week" .= w dateTimeProperty (DTDate dt) = "date" .= dt dateTimeProperty (DTDay day) = "day" .= dayLabel day+dateTimeProperty (DTDayOfYear n) = "dayofyear" .= n dateTimeProperty (DTDayNum n) = "day" .= n dateTimeProperty (DTHours h) = "hours" .= h dateTimeProperty (DTMinutes m) = "minutes" .= m@@ -247,51 +405,12 @@ monthNameLabel Dec = "Dec" --- Assume there's no "embedded" values the time unit used by--- the "grouping" cases, such as Utc, are "singular" and not--- themselves compound.------ Ideally this would know when it could just return the label--- and not a labelled spec, but for now leave it as is.----timeHelper :: T.Text -> [LabelledSpec]-timeHelper unit = ["unit" .= unit]--timeUnitProperties :: TimeUnit -> [LabelledSpec]-timeUnitProperties Year = timeHelper "year"-timeUnitProperties YearQuarter = timeHelper "yearquarter"-timeUnitProperties YearQuarterMonth = timeHelper "yearquartermonth"-timeUnitProperties YearMonth = timeHelper "yearmonth"-timeUnitProperties YearMonthDate = timeHelper "yearmonthdate"-timeUnitProperties YearMonthDateHours = timeHelper "yearmonthdatehours"-timeUnitProperties YearMonthDateHoursMinutes = timeHelper "yearmonthdatehoursminutes"-timeUnitProperties YearMonthDateHoursMinutesSeconds = timeHelper "yearmonthdatehoursminutesseconds"-timeUnitProperties Quarter = timeHelper "quarter"-timeUnitProperties QuarterMonth = timeHelper "quartermonth"-timeUnitProperties Month = timeHelper "month"-timeUnitProperties MonthDate = timeHelper "monthdate"-timeUnitProperties Date = timeHelper "date"-timeUnitProperties Day = timeHelper "day"-timeUnitProperties Hours = timeHelper "hours"-timeUnitProperties HoursMinutes = timeHelper "hoursminutes"-timeUnitProperties HoursMinutesSeconds = timeHelper "hoursminutesseconds"-timeUnitProperties Minutes = timeHelper "minutes"-timeUnitProperties MinutesSeconds = timeHelper "minutesseconds"-timeUnitProperties Seconds = timeHelper "seconds"-timeUnitProperties SecondsMilliseconds = timeHelper "secondsmilliseconds"-timeUnitProperties Milliseconds = timeHelper "milliseconds"-timeUnitProperties (Utc tu) = "utc" .= True : timeUnitProperties tu-timeUnitProperties (TUStep x tu) = "step" .= x : timeUnitProperties tu-timeUnitProperties (TUMaxBins n) = [ "maxbins" .= n ]-+fromT :: T.Text -> VLSpec+fromT = toJSON --- Special case this so that--- {'unit': blah} -> blah--- {'unit': blah, 'utc': true} -> 'utc' <> blah [would be nice but not done for now]--- timeUnitSpec :: TimeUnit -> VLSpec-timeUnitSpec tu =- let props = timeUnitProperties tu- in case props of- [(k, v)] | k == "unit" -> v- _ -> object props+timeUnitSpec (TU tu) = fromT (baseTimeUnitLabel tu)+timeUnitSpec (Utc tu) = fromT ("utc" <> baseTimeUnitLabel tu)+timeUnitSpec (TUStep x tu) = object ["step" .= x, "unit" .= baseTimeUnitLabel tu]+timeUnitSpec (UtcStep x tu) = object ["step" .= x, "unit" .= ("utc" <> baseTimeUnitLabel tu)]+timeUnitSpec (TUMaxBins n) = object ["maxbins" .= n]
tests/CompositeTests.hs view
@@ -145,7 +145,7 @@ enc = encoding- . position X [ PName "Year", PmType Temporal, PTimeUnit Year ]+ . position X [ PName "Year", PmType Temporal, PTimeUnit (TU Year) ] . position Y [ PName "Miles_per_Gallon" , PmType Quantitative
tests/ConditionalTests.hs view
@@ -163,10 +163,10 @@ encoding . position X [ PName "Year" , PmType Temporal- , PTimeUnit Year+ , PTimeUnit (TU Year) , PAxis [ AxDataCondition (FEqual "value" (DateTime [DTMonth Jan, DTDate 1])- & FilterOpTrans (MTimeUnit MonthDate))+ & FilterOpTrans (MTimeUnit (TU MonthDate))) (CAxGridWidth 4 1) ] ]
tests/ConfigTests.hs view
@@ -91,7 +91,7 @@ streamEnc = encoding- . position X [ PName "Year", PmType Temporal, PTimeUnit Year ]+ . position X [ PName "Year", PmType Temporal, PTimeUnit (TU Year) ] . yCount [ PStack StCenter, PAxis [] ] . color mOrigin @@ -129,7 +129,7 @@ streamEnc = encoding- . position X [ PName "Year", PmType Temporal, PTimeUnit Year ]+ . position X [ PName "Year", PmType Temporal, PTimeUnit (TU Year) ] . yCount [ PStack StCenter, PAxis [] ] . color mOrigin
tests/FilterTests.hs view
@@ -48,7 +48,7 @@ dateFilterNumbers :: Maybe Double -> Maybe Double -> VegaLite dateFilterNumbers mlo mhi = let yearRange = FRange "date" frange- & FilterOpTrans (MTimeUnit Year)+ & FilterOpTrans (MTimeUnit (TU Year)) & FCompose frange = case (mlo, mhi) of
tests/Gallery/Advanced.hs view
@@ -125,7 +125,7 @@ trans = transform . filter (FExpr "isValid(datum.IMDB_Rating)")- . timeUnitAs Year "Release_Date" "year"+ . timeUnitAs (TU Year) "Release_Date" "year" . window [ ( [ WAggregateOp Mean, WField "IMDB_Rating" ], "AverageYearRating" ) ] [ WGroupBy [ "year" ], WFrame Nothing Nothing ] . filter (FExpr "(datum.IMDB_Rating - datum.AverageYearRating) > 2.5")@@ -662,11 +662,11 @@ trans = transform . filter (FExpr "datum.symbol === 'GOOG'") encRaw = encoding- . position X [ PName "date", pTemporal, PTimeUnit Year ]+ . position X [ PName "date", pTemporal, PTimeUnit (TU Year) ] . position Y [ PName "price", pQuant ] encAv = encoding- . position X [ PName "date", pTemporal, PTimeUnit Year ]+ . position X [ PName "date", pTemporal, PTimeUnit (TU Year) ] . position Y [ PName "price", PAggregate Mean, pQuant ] specRaw = asSpec [ encRaw [], mark Point [ MOpacity 0.3 ] ]
tests/Gallery/Area.hs view
@@ -36,7 +36,7 @@ enc = encoding- . position X [ PName "date", PmType Temporal, PTimeUnit YearMonth, PAxis [ AxFormat "%Y" ] ]+ . position X [ PName "date", PmType Temporal, PTimeUnit (TU YearMonth), PAxis [ AxFormat "%Y" ] ] . position Y [ PName "count", PmType Quantitative, PAggregate Sum, PAxis [ AxTitle "Count" ] ] in toVegaLite@@ -80,7 +80,7 @@ enc = encoding- . position X [ PName "date", PmType Temporal, PTimeUnit YearMonth, PAxis [ AxFormat "%Y" ] ]+ . position X [ PName "date", PmType Temporal, PTimeUnit (TU YearMonth), PAxis [ AxFormat "%Y" ] ] . position Y [ PName "count", PmType Quantitative, PAggregate Sum ] . color [ MName "series", MmType Nominal, MScale [ SScheme "category20b" [] ] ] in@@ -100,7 +100,7 @@ enc = encoding- . position X [ PName "date", PmType Temporal, PTimeUnit YearMonth, PAxis [ AxDomain False, AxFormat "%Y" ] ]+ . position X [ PName "date", PmType Temporal, PTimeUnit (TU YearMonth), PAxis [ AxDomain False, AxFormat "%Y" ] ] . position Y [ PName "count", PmType Quantitative, PAggregate Sum, PAxis [], PStack StNormalize ] . color [ MName "series", MmType Nominal, MScale [ SScheme "category20b" [] ] ] in@@ -122,7 +122,7 @@ enc = encoding- . position X [ PName "date", PmType Temporal, PTimeUnit YearMonth, PAxis [ AxDomain False, AxFormat "%Y" ] ]+ . position X [ PName "date", PmType Temporal, PTimeUnit (TU YearMonth), PAxis [ AxDomain False, AxFormat "%Y" ] ] . position Y [ PName "count", PmType Quantitative, PAggregate Sum, PAxis [], PStack StCenter ] . color [ MName "series", MmType Nominal, MScale [ SScheme "category20b" [] ] ] in@@ -290,10 +290,10 @@ ] xCondition = FEqual "value" (DateTime [DTMonthNum 1, DTDate 1])- & FilterOpTrans (MTimeUnit MonthDate)+ & FilterOpTrans (MTimeUnit (TU MonthDate)) enc = encoding- . position X [ PTimeUnit YearMonthDate+ . position X [ PTimeUnit (TU YearMonthDate) , PName "date" , PmType Ordinal , PTitle "Time"
tests/Gallery/Bar.hs view
@@ -189,7 +189,7 @@ encoding . position X [ PName "date" , PmType Ordinal- , PTimeUnit Month+ , PTimeUnit (TU Month) , PAxis [ AxTitle "Month of the year" ] ] . position Y [ PmType Quantitative, PAggregate Count ]@@ -751,7 +751,7 @@ , encoding . position X [ PName "date" , PmType Temporal- , PTimeUnit Month+ , PTimeUnit (TU Month) , PAxis [ AxLabelAlign AlignLeft , AxLabelExpr "datum.label[0]" ]
tests/Gallery/Error.hs view
@@ -111,7 +111,7 @@ description "Line chart with confidence interval band." encTime =- encoding . position X [ PName "Year", PmType Temporal, PTimeUnit Year ]+ encoding . position X [ PName "Year", PmType Temporal, PTimeUnit (TU Year) ] encBand = encoding
tests/Gallery/Facet.hs view
@@ -253,7 +253,7 @@ , configure (configuration (Axis [Grid False, Domain False]) []) , facet [ RowBy [ FName "date" , FmType Nominal- , FTimeUnit Hours+ , FTimeUnit (TU Hours) , FSort [ByFieldOp "order" Max] -- don't want an operation , FHeader [ HLabelAngle 0 , HLabelPadding 2
tests/Gallery/Interaction.hs view
@@ -148,7 +148,7 @@ enc = encoding- . position X [ PName "date", PmType Temporal, PTimeUnit YearMonth ]+ . position X [ PName "date", PmType Temporal, PTimeUnit (TU YearMonth) ] . position Y [ PName "count", PmType Quantitative, PAggregate Sum ] specBackground =@@ -290,7 +290,7 @@ enc1 = encoding- . position X [ PName "date", PmType Ordinal, PTimeUnit Month ]+ . position X [ PName "date", PmType Ordinal, PTimeUnit (TU Month) ] . opacity [ MSelectionCondition (SelectionName "myBrush") [ MNumber 1 ]@@ -395,11 +395,12 @@ configure . configuration (AxisY [ MinExtent 30 ]) + timeUnit = TU YearMonthDate enc = encoding- . position X [ PName "date", PmType Temporal, PTimeUnit YearMonthDate ]+ . position X [ PName "date", PmType Temporal, PTimeUnit timeUnit ] . tooltips- [ [ TName "date", TmType Temporal, TTimeUnit YearMonthDate ]+ [ [ TName "date", TmType Temporal, TTimeUnit timeUnit ] , [ TName "temp_max", TmType Quantitative ] , [ TName "temp_min", TmType Quantitative ] ]
tests/Gallery/Label.hs view
@@ -271,7 +271,7 @@ encBar = encoding- . position X [ PName "date", PmType Ordinal, PTimeUnit Month ]+ . position X [ PName "date", PmType Ordinal, PTimeUnit (TU Month) ] . position Y [ PName "precipitation", PmType Quantitative, PAggregate Mean ] specBar =@@ -342,8 +342,8 @@ encRects = encoding- . position X [ PName "start", PmType Temporal, PTimeUnit Year, PAxis [] ]- . position X2 [ PName "end", PTimeUnit Year ]+ . position X [ PName "start", PmType Temporal, PTimeUnit (TU Year), PAxis [] ]+ . position X2 [ PName "end", PTimeUnit (TU Year) ] . color [ MName "event", MmType Nominal ] specRects =@@ -351,7 +351,7 @@ encPopulation = encoding- . position X [ PName "year", PmType Temporal, PTimeUnit Year, PAxis [ AxNoTitle ] ]+ . position X [ PName "year", PmType Temporal, PTimeUnit (TU Year), PAxis [ AxNoTitle ] ] . position Y [ PName "population", PmType Quantitative ] . color [ MString "#333" ]
tests/Gallery/Layer.hs view
@@ -55,7 +55,7 @@ . position X [ PName "date" , PmType Temporal- , PTimeUnit YearMonthDate+ , PTimeUnit (TU YearMonthDate) , PScale [ SDomain (DDateTimes [ [ DTMonth May, DTDate 31, DTYear 2009 ], [ DTMonth Jul, DTDate 1, DTYear 2009 ] ]) ] , PAxis [ AxTitle "Date in 2009", AxFormat "%m/%d" ] ]@@ -68,7 +68,7 @@ encBar = encoding- . position X [ PName "date", PmType Temporal, PTimeUnit YearMonthDate ]+ . position X [ PName "date", PmType Temporal, PTimeUnit (TU YearMonthDate) ] . position Y [ PName "open", PmType Quantitative ] . position Y2 [ PName "close" ] . size [ MNumber 5 ]@@ -221,7 +221,7 @@ description "Layered bar/line chart with dual axes" encTime =- encoding . position X [ PName "date", PmType Ordinal, PTimeUnit Month ]+ encoding . position X [ PName "date", PmType Ordinal, PTimeUnit (TU Month) ] encBar = encoding@@ -411,7 +411,7 @@ layerTimeunitRect = let desc = "Drawing rect bin from the beginning of May to end of July" - xAxis = [ PTimeUnit Month+ xAxis = [ PTimeUnit (TU Month) , PName "date" , PmType Temporal ]@@ -437,7 +437,7 @@ , mark Rect [MOpacity 0.5, MColor "grey"] , encoding . position X xAxis- . position X2 [PTimeUnit Month, PName "date_end"]+ . position X2 [PTimeUnit (TU Month), PName "date_end"] $ [] ]
tests/Gallery/Line.hs view
@@ -359,10 +359,10 @@ expr = "[timeFormat(datum.value, '%b'), timeFormat(datum.value, '%m') == '01' ? timeFormat(datum.value, '%Y') : '']" cond = FEqual "value" (Number 1)- & FilterOpTrans (MTimeUnit Month)+ & FilterOpTrans (MTimeUnit (TU Month)) yearRange = FRange "date" (NumberRange 2006 2007)- & FilterOpTrans (MTimeUnit Year)+ & FilterOpTrans (MTimeUnit (TU Year)) & FCompose in toVegaLite [ description "Line chart with conditional axis ticks, labels, and grid."
tests/Gallery/Multi.hs view
@@ -262,7 +262,7 @@ . position X [ PName "date" , PmType Temporal- , PTimeUnit MonthDate+ , PTimeUnit (TU MonthDate) , PAxis [ AxTitle "Date", AxFormat "%b" ] ] . position Y
tests/Gallery/Repeat.hs view
@@ -32,9 +32,9 @@ enc1 = encoding- . position X [ PName "date", PmType Ordinal, PTimeUnit Month ]+ . position X [ PName "date", PmType Ordinal, PTimeUnit (TU Month) ] . position Y [ PRepeat Column, PmType Quantitative, PAggregate Mean ]- . detail [ DName "date", DmType Temporal, DTimeUnit Year ]+ . detail [ DName "date", DmType Temporal, DTimeUnit (TU Year) ] . color [ MName "location", MmType Nominal ] . opacity [ MNumber 0.2 ] @@ -43,7 +43,7 @@ enc2 = encoding- . position X [ PName "date", PmType Ordinal, PTimeUnit Month ]+ . position X [ PName "date", PmType Ordinal, PTimeUnit (TU Month) ] . position Y [ PRepeat Column, PmType Quantitative, PAggregate Mean ] . color [ MName "location", MmType Nominal ] @@ -73,7 +73,7 @@ enc1 = encoding- . position X [ PName "date", PTimeUnit Month, PmType Ordinal ]+ . position X [ PName "date", PTimeUnit (TU Month), PmType Ordinal ] . position Y [ PName "precipitation", PmType Quantitative, PAggregate Mean ] spec1 =
tests/Gallery/Table.hs view
@@ -54,8 +54,8 @@ enc = encoding- . position X [ PName "date", PmType Ordinal, PTimeUnit Date, PAxis [ AxTitle "Day", AxLabelAngle 0, AxFormat "%e" ] ]- . position Y [ PName "date", PmType Ordinal, PTimeUnit Month, PAxis [ AxTitle "Month" ] ]+ . position X [ PName "date", PmType Ordinal, PTimeUnit (TU Date), PAxis [ AxTitle "Day", AxLabelAngle 0, AxFormat "%e" ] ]+ . position Y [ PName "date", PmType Ordinal, PTimeUnit (TU Month), PAxis [ AxTitle "Month" ] ] . color [ MName "temp", MmType Quantitative, MAggregate Max, MLegend [ LNoTitle ] ] in toVegaLite@@ -117,8 +117,8 @@ enc = encoding- . position X [ PName "time", PmType Ordinal, PTimeUnit Hours ]- . position Y [ PName "time", PmType Ordinal, PTimeUnit Day ]+ . position X [ PName "time", PmType Ordinal, PTimeUnit (TU Hours) ]+ . position Y [ PName "time", PmType Ordinal, PTimeUnit (TU Day) ] . size [ MName "count", MmType Quantitative, MAggregate Sum ] in toVegaLite
tests/InteractionTests.hs view
@@ -300,7 +300,7 @@ , encoding . text [ TName "date" , TmType Temporal- , TTimeUnit YearMonth+ , TTimeUnit (TU YearMonth) ] . position Y [PNumber 310] $ []
tests/TimeTests.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes #-} -- -- Based on the Elm VegaLite TimeTests.elm as of version 1.12.0@@ -6,6 +7,9 @@ module TimeTests (testSpecs) where +import Data.Aeson (Value)+import Data.Aeson.QQ.Simple (aesonQQ)+ import Graphics.Vega.VegaLite import Prelude hiding (filter)@@ -28,19 +32,31 @@ , ("timeMinutesSeconds", timeMinutesSeconds) , ("localTime", localTime) , ("utcTime", utcTime)+ , ("monthAggregate", monthAggregate)+ , ("withBar", withBar) , ("timeBand", timeBand)+ , ("withBarOrdinal", withBarOrdinal)+ , ("timeUnitTransform", timeUnitTransform)+ , ("parseAsUTC", parseAsUTC)+ , ("parseAsLocal", parseAsLocal)+ , ("parseAsFormat", parseAsFormat)+ , ("outputAsUTC", outputAsUTC)+ , ("outputScaledAsUTC", outputScaledAsUTC)+ , ("customizeStep", customizeStep)+ , ("nestedTime1", nestedTime1)+ , ("nestedTime2", nestedTime2) ] -timeByUnit :: TimeUnit -> VegaLite-timeByUnit tu =+timeByUnit :: BaseTimeUnit -> VegaLite+timeByUnit btu = let dataVals = dataFromUrl "https://gicentre.github.io/data/tests/timeTest.tsv" [] enc = encoding- . position X [ PName "date", PmType Temporal, PTimeUnit tu ]+ . position X [ PName "date", PmType Temporal, PTimeUnit (TU btu) ] . position Y [ PName "temperature", PmType Quantitative , PAggregate Mean, PScale [ SZero False ] ] in@@ -132,7 +148,7 @@ tu = case dType of Local ->- PTimeUnit YearMonthDateHours+ PTimeUnit (TU YearMonthDateHours) UTC -> PTimeUnit (Utc YearMonthDateHours)@@ -169,19 +185,312 @@ utcTime = parseTime UTC +-- examples from the documentation+--+-- https://vega.github.io/vega-lite/docs/timeunit.html++seattleTemps :: Data+seattleTemps = dataFromUrl "https://vega.github.io/vega-lite/data/seattle-temps.csv" []++seattleWeather :: Data+seattleWeather = dataFromUrl "https://vega.github.io/vega-lite/data/seattle-weather.csv" []+++monthAggregate :: VegaLite+monthAggregate =+ let enc = encoding+ . position X [ PName "date"+ , PTimeUnit (TU Month)+ , PmType Temporal+ ]+ . position Y [ PName "temp"+ , PAggregate Mean+ , PmType Quantitative ]++ in toVegaLite+ [ seattleTemps+ , mark Line [MInterpolate Monotone]+ , enc []+ ]+++withBar :: VegaLite+withBar =+ let enc = encoding+ . position X [ PName "date"+ , PTimeUnit (TU Month)+ , PmType Temporal+ ]+ . position Y [ PName "precipitation"+ , PAggregate Mean+ , PmType Quantitative ]++ in toVegaLite+ [ seattleWeather+ , mark Bar []+ , enc []+ ]+++-- https://vega.github.io/vega-lite/docs/timeunit.html#time-units-band+ timeBand :: VegaLite timeBand =- let dvals = dataFromUrl "https://vega.github.io/vega-lite/data/seattle-temps.csv" []-- enc = encoding- . position X [ PName "date", PTimeUnit Month+ let enc = encoding+ . position X [ PName "date", PTimeUnit (TU Month) , PmType Temporal, PBand 0.5 ] . position Y [ PName "temp", PAggregate Mean , PmType Quantitative ] in toVegaLite [ width 400- , dvals+ , seattleTemps , enc [] , mark Line [ MPoint (PMMarker [ MFill "black" ]) ] ]+++-- https://vega.github.io/vega-lite/docs/timeunit.html#time-unit-with-ordinal-fields++withBarOrdinal :: VegaLite+withBarOrdinal =+ let enc = encoding+ . position X [ PName "date"+ , PTimeUnit (TU Month)+ , PmType Ordinal+ ]+ . position Y [ PName "precipitation"+ , PAggregate Mean+ , PmType Quantitative ]++ in toVegaLite+ [ seattleWeather+ , mark Bar []+ , enc []+ ]+++-- https://vega.github.io/vega-lite/docs/timeunit.html#transform++timeUnitTransform :: VegaLite+timeUnitTransform =+ let enc = encoding+ . position X [ PName "month"+ , PmType Temporal+ , PAxis [AxFormat "%b"]+ ]+ . position Y [ PName "temp_max"+ , PAggregate Max+ , PmType Quantitative ]++ in toVegaLite+ [ seattleWeather+ , mark Line []+ , transform (timeUnitAs (TU Month) "date" "month" [])+ , enc []+ ]+++-- https://vega.github.io/vega-lite/docs/timeunit.html#input++parseAsUTC :: VegaLite+parseAsUTC =+ toVegaLite [ dataFromColumns []+ . dataColumn "date" (Strings ["2011-10-10", "2011-10-12"])+ $ []+ , mark Point []+ , encoding+ . position Y [ PName "date"+ , PmType Ordinal+ , PTimeUnit (Utc Hours)+ , PAxis [AxTitle "time"]+ ]+ $ []+ ]+++parseAsLocal :: VegaLite+parseAsLocal =+ toVegaLite [ dataFromColumns []+ . dataColumn "date" (Strings ["10 Oct 2011 22:48:00", "11 Oct 2022 23:00:00"])+ $ []+ , mark Point []+ , encoding+ . position Y [ PName "date"+ , PmType Ordinal+ , PTimeUnit (TU HoursMinutes)+ , PAxis [AxTitle "time"]+ ]+ $ []+ ]+++parseAsFormat :: VegaLite+parseAsFormat =+ toVegaLite [ dataFromColumns [Parse [("date", FoUtc "%d %b %Y %H:%M:%S")]]+ . dataColumn "date" (Strings ["10 Oct 2011 22:48:00", "11 Oct 2022 23:00:00"])+ $ []+ , mark Point []+ , encoding+ . position Y [ PName "date"+ , PmType Ordinal+ , PTimeUnit (TU HoursMinutes)+ , PAxis [AxTitle "time"]+ ]+ $ []+ ]+++-- https://vega.github.io/vega-lite/docs/timeunit.html#output++exampleData :: Data+exampleData =+ dataFromColumns []+ . dataColumn "date" (Strings [ "Sun, 01 Jan 2012 23:00:00"+ , "Sun, 02 Jan 2012 00:00:00"+ , "Sun, 02 Jan 2012 01:00:00"+ , "Sun, 02 Jan 2012 02:00:00"+ , "Sun, 02 Jan 2012 03:00:00"+ ])++ . dataColumn "price" (Numbers [150, 100, 170, 165, 200])+ $ []+++outputAsUTC :: VegaLite+outputAsUTC =+ toVegaLite [ exampleData+ , mark Line []+ , encoding+ . position X [ PName "date"+ , PmType Temporal+ , PTimeUnit (Utc YearMonthDateHoursMinutes)+ , PAxis [AxLabelAngle 15]+ ]+ . position Y [ PName "price"+ , PmType Quantitative+ ]+ $ []+ ]+++outputScaledAsUTC :: VegaLite+outputScaledAsUTC =+ toVegaLite [ exampleData+ , mark Line []+ , encoding+ . position X [ PName "date"+ , PmType Temporal+ , PTimeUnit (TU YearMonthDateHoursMinutes)+ , PScale [SType ScUtc]+ , PAxis [AxLabelAngle 15]+ ]+ . position Y [ PName "price"+ , PmType Quantitative+ ]+ $ []+ ]+++-- https://vega.github.io/vega-lite/docs/timeunit.html#example-customizing-step++customizeStep :: VegaLite+customizeStep =+ toVegaLite [ dataFromColumns []+ . dataColumn "date" (Strings [ "Sun, 01 Jan 2012 00:00:00"+ , "Sun, 01 Jan 2012 00:01:00"+ , "Sun, 01 Jan 2012 00:02:00"+ , "Sun, 01 Jan 2012 00:03:00"+ , "Sun, 01 Jan 2012 00:04:00"+ , "Sun, 01 Jan 2012 00:05:00"+ , "Sun, 01 Jan 2012 00:06:00"+ , "Sun, 01 Jan 2012 00:07:00"+ , "Sun, 01 Jan 2012 00:08:00"+ , "Sun, 01 Jan 2012 00:09:00"+ , "Sun, 01 Jan 2012 00:10:00"+ , "Sun, 01 Jan 2012 00:11:00"+ , "Sun, 01 Jan 2012 00:12:00"+ , "Sun, 01 Jan 2012 00:13:00"+ , "Sun, 01 Jan 2012 00:14:00"+ , "Sun, 01 Jan 2012 00:15:00"+ ])+ . dataColumn "distance" (Numbers [ 1+ , 1+ , 2+ , 1+ , 4+ , 2+ , 5+ , 2+ , 6+ , 4+ , 1+ , 1+ , 3+ , 0+ , 2+ , 3+ ])+ $ []+ , mark Bar []+ , encoding+ . position X [ PName "date"+ , PmType Temporal+ , PTimeUnit (TUStep 5 Minutes)+ ]+ . position Y [ PName "distance"+ , PmType Quantitative+ , PAggregate Sum+ ]+ $ []+ ]+++embeddedData, flattenedData :: Value+embeddedData = [aesonQQ|+[+ {"histo": {"date": "Sun, 02 Jan 2012 00:00:00", "price": 150}},+ {"histo": {"date": "Sun, 02 Jan 2012 00:00:00", "price": 100}},+ {"histo": {"date": "Sun, 02 Jan 2012 01:00:00", "price": 170}},+ {"histo": {"date": "Sun, 02 Jan 2012 02:00:00", "price": 165}},+ {"histo": {"date": "Sun, 02 Jan 2012 03:00:00", "price": 200}}+]+|]+ +flattenedData = [aesonQQ|+[+ {"date": "Sun, 02 Jan 2012 00:00:00", "price": 150},+ {"date": "Sun, 02 Jan 2012 00:00:00", "price": 100},+ {"date": "Sun, 02 Jan 2012 01:00:00", "price": 170},+ {"date": "Sun, 02 Jan 2012 02:00:00", "price": 165},+ {"date": "Sun, 02 Jan 2012 03:00:00", "price": 200}+]+|]+ ++-- https://github.com/vega/vega-lite/issues/5662++nestedTime :: Value -> FieldName -> FieldName -> VegaLite+nestedTime jData xname yname =+ let desc = "Google's stock price over time."+ dvals = dataFromJson jData []+ + in toVegaLite [ description desc+ , dvals+ , mark Line []+ , encoding+ . position X [ PName xname+ , PmType Temporal+ , PTimeUnit (TU YearMonthDateHoursMinutes)+ , PScale [SType ScUtc]+ ]+ . position Y [ PName yname+ , PmType Quantitative+ ]+ $ []+ ]++ +nestedTime1, nestedTime2 :: VegaLite+nestedTime1 = nestedTime embeddedData "histo.date" "histo.price"+nestedTime2 = nestedTime flattenedData "date" "price"
tests/TransformTests.hs view
@@ -354,7 +354,7 @@ ] weatherByMonth :: VegaLite-weatherByMonth = weather Month "month"+weatherByMonth = weather (TU Month) "month" weatherByTwoMonths :: VegaLite weatherByTwoMonths = weather (TUStep 2 Month) "bimonth"
tests/WindowTransformTests.hs view
@@ -82,7 +82,7 @@ let trans = transform . filter (FExpr "datum.IMDB_Rating != null")- . timeUnitAs Year "Release_Date" "year"+ . timeUnitAs (TU Year) "Release_Date" "year" . window [ ( [ WAggregateOp Mean, WField "IMDB_Rating" ], "AverageYearRating" ) ] [ WGroupBy [ "year" ], WFrame Nothing Nothing ] . filter (FExpr "(datum.IMDB_Rating - datum.AverageYearRating) > 2.5")@@ -186,13 +186,13 @@ trans = transform . filter (FExpr "datum.Miles_per_Gallon !== null")- . timeUnitAs Year "Year" "year"+ . timeUnitAs (TU Year) "Year" "year" . window [ ( [ WAggregateOp Mean, WField "Miles_per_Gallon" ], "Average_MPG" ) ] [ WSort [ WAscending "year" ], WIgnorePeers False, WFrame Nothing (Just 0) ] circleEnc = encoding- . position X [ PName "Year", PmType Temporal, PTimeUnit Year ]+ . position X [ PName "Year", PmType Temporal, PTimeUnit (TU Year) ] . position Y [ PName "Miles_per_Gallon", PmType Quantitative ] circleSpec =@@ -200,7 +200,7 @@ lineEnc = encoding- . position X [ PName "Year", PmType Temporal, PTimeUnit Year ]+ . position X [ PName "Year", PmType Temporal, PTimeUnit (TU Year) ] . position Y [ PName "Average_MPG", PmType Quantitative, PAxis [ AxTitle "Miles per gallon" ] ] lineSpec =@@ -259,7 +259,7 @@ trans = transform . filter (FExpr "datum.IMDB_Rating != null")- . timeUnitAs Year "Release_Date" "year"+ . timeUnitAs (TU Year) "Release_Date" "year" . joinAggregate [ opAs Mean "IMDB_Rating" "AverageYearRating" ] [ WGroupBy [ "year" ] ] . filter (FExpr "(datum.IMDB_Rating - datum.AverageYearRating) > 2.5")
+ tests/specs/time/customizeStep.vl view
@@ -0,0 +1,87 @@+{+ "mark": "bar",+ "data": {+ "values": [+ {+ "distance": 1,+ "date": "Sun, 01 Jan 2012 00:00:00"+ },+ {+ "distance": 1,+ "date": "Sun, 01 Jan 2012 00:01:00"+ },+ {+ "distance": 2,+ "date": "Sun, 01 Jan 2012 00:02:00"+ },+ {+ "distance": 1,+ "date": "Sun, 01 Jan 2012 00:03:00"+ },+ {+ "distance": 4,+ "date": "Sun, 01 Jan 2012 00:04:00"+ },+ {+ "distance": 2,+ "date": "Sun, 01 Jan 2012 00:05:00"+ },+ {+ "distance": 5,+ "date": "Sun, 01 Jan 2012 00:06:00"+ },+ {+ "distance": 2,+ "date": "Sun, 01 Jan 2012 00:07:00"+ },+ {+ "distance": 6,+ "date": "Sun, 01 Jan 2012 00:08:00"+ },+ {+ "distance": 4,+ "date": "Sun, 01 Jan 2012 00:09:00"+ },+ {+ "distance": 1,+ "date": "Sun, 01 Jan 2012 00:10:00"+ },+ {+ "distance": 1,+ "date": "Sun, 01 Jan 2012 00:11:00"+ },+ {+ "distance": 3,+ "date": "Sun, 01 Jan 2012 00:12:00"+ },+ {+ "distance": 0,+ "date": "Sun, 01 Jan 2012 00:13:00"+ },+ {+ "distance": 2,+ "date": "Sun, 01 Jan 2012 00:14:00"+ },+ {+ "distance": 3,+ "date": "Sun, 01 Jan 2012 00:15:00"+ }+ ]+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "x": {+ "field": "date",+ "timeUnit": {+ "step": 5,+ "unit": "minutes"+ },+ "type": "temporal"+ },+ "y": {+ "field": "distance",+ "aggregate": "sum",+ "type": "quantitative"+ }+ }+}
+ tests/specs/time/monthAggregate.vl view
@@ -0,0 +1,22 @@+{+ "mark": {+ "interpolate": "monotone",+ "type": "line"+ },+ "data": {+ "url": "https://vega.github.io/vega-lite/data/seattle-temps.csv"+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "x": {+ "field": "date",+ "timeUnit": "month",+ "type": "temporal"+ },+ "y": {+ "field": "temp",+ "aggregate": "mean",+ "type": "quantitative"+ }+ }+}
+ tests/specs/time/nestedTime1.vl view
@@ -0,0 +1,53 @@+{+ "mark": "line",+ "data": {+ "values": [+ {+ "histo": {+ "date": "Sun, 02 Jan 2012 00:00:00",+ "price": 150+ }+ },+ {+ "histo": {+ "date": "Sun, 02 Jan 2012 00:00:00",+ "price": 100+ }+ },+ {+ "histo": {+ "date": "Sun, 02 Jan 2012 01:00:00",+ "price": 170+ }+ },+ {+ "histo": {+ "date": "Sun, 02 Jan 2012 02:00:00",+ "price": 165+ }+ },+ {+ "histo": {+ "date": "Sun, 02 Jan 2012 03:00:00",+ "price": 200+ }+ }+ ]+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "x": {+ "field": "histo.date",+ "scale": {+ "type": "utc"+ },+ "timeUnit": "yearmonthdatehoursminutes",+ "type": "temporal"+ },+ "y": {+ "field": "histo.price",+ "type": "quantitative"+ }+ },+ "description": "Google's stock price over time."+}
+ tests/specs/time/nestedTime2.vl view
@@ -0,0 +1,43 @@+{+ "mark": "line",+ "data": {+ "values": [+ {+ "date": "Sun, 02 Jan 2012 00:00:00",+ "price": 150+ },+ {+ "date": "Sun, 02 Jan 2012 00:00:00",+ "price": 100+ },+ {+ "date": "Sun, 02 Jan 2012 01:00:00",+ "price": 170+ },+ {+ "date": "Sun, 02 Jan 2012 02:00:00",+ "price": 165+ },+ {+ "date": "Sun, 02 Jan 2012 03:00:00",+ "price": 200+ }+ ]+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "x": {+ "field": "date",+ "scale": {+ "type": "utc"+ },+ "timeUnit": "yearmonthdatehoursminutes",+ "type": "temporal"+ },+ "y": {+ "field": "price",+ "type": "quantitative"+ }+ },+ "description": "Google's stock price over time."+}
+ tests/specs/time/outputAsUTC.vl view
@@ -0,0 +1,42 @@+{+ "mark": "line",+ "data": {+ "values": [+ {+ "date": "Sun, 01 Jan 2012 23:00:00",+ "price": 150+ },+ {+ "date": "Sun, 02 Jan 2012 00:00:00",+ "price": 100+ },+ {+ "date": "Sun, 02 Jan 2012 01:00:00",+ "price": 170+ },+ {+ "date": "Sun, 02 Jan 2012 02:00:00",+ "price": 165+ },+ {+ "date": "Sun, 02 Jan 2012 03:00:00",+ "price": 200+ }+ ]+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "x": {+ "field": "date",+ "timeUnit": "utcyearmonthdatehoursminutes",+ "type": "temporal",+ "axis": {+ "labelAngle": 15+ }+ },+ "y": {+ "field": "price",+ "type": "quantitative"+ }+ }+}
+ tests/specs/time/outputScaledAsUTC.vl view
@@ -0,0 +1,45 @@+{+ "mark": "line",+ "data": {+ "values": [+ {+ "date": "Sun, 01 Jan 2012 23:00:00",+ "price": 150+ },+ {+ "date": "Sun, 02 Jan 2012 00:00:00",+ "price": 100+ },+ {+ "date": "Sun, 02 Jan 2012 01:00:00",+ "price": 170+ },+ {+ "date": "Sun, 02 Jan 2012 02:00:00",+ "price": 165+ },+ {+ "date": "Sun, 02 Jan 2012 03:00:00",+ "price": 200+ }+ ]+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "x": {+ "field": "date",+ "scale": {+ "type": "utc"+ },+ "timeUnit": "yearmonthdatehoursminutes",+ "type": "temporal",+ "axis": {+ "labelAngle": 15+ }+ },+ "y": {+ "field": "price",+ "type": "quantitative"+ }+ }+}
+ tests/specs/time/parseAsFormat.vl view
@@ -0,0 +1,29 @@+{+ "mark": "point",+ "data": {+ "values": [+ {+ "date": "10 Oct 2011 22:48:00"+ },+ {+ "date": "11 Oct 2022 23:00:00"+ }+ ],+ "format": {+ "parse": {+ "date": "utc:'%d %b %Y %H:%M:%S'"+ }+ }+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "y": {+ "field": "date",+ "timeUnit": "hoursminutes",+ "type": "ordinal",+ "axis": {+ "title": "time"+ }+ }+ }+}
+ tests/specs/time/parseAsLocal.vl view
@@ -0,0 +1,24 @@+{+ "mark": "point",+ "data": {+ "values": [+ {+ "date": "10 Oct 2011 22:48:00"+ },+ {+ "date": "11 Oct 2022 23:00:00"+ }+ ]+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "y": {+ "field": "date",+ "timeUnit": "hoursminutes",+ "type": "ordinal",+ "axis": {+ "title": "time"+ }+ }+ }+}
+ tests/specs/time/parseAsUTC.vl view
@@ -0,0 +1,24 @@+{+ "mark": "point",+ "data": {+ "values": [+ {+ "date": "2011-10-10"+ },+ {+ "date": "2011-10-12"+ }+ ]+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "y": {+ "field": "date",+ "timeUnit": "utchours",+ "type": "ordinal",+ "axis": {+ "title": "time"+ }+ }+ }+}
+ tests/specs/time/timeUnitTransform.vl view
@@ -0,0 +1,28 @@+{+ "transform": [+ {+ "as": "month",+ "field": "date",+ "timeUnit": "month"+ }+ ],+ "mark": "line",+ "data": {+ "url": "https://vega.github.io/vega-lite/data/seattle-weather.csv"+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "x": {+ "field": "month",+ "type": "temporal",+ "axis": {+ "format": "%b"+ }+ },+ "y": {+ "field": "temp_max",+ "aggregate": "max",+ "type": "quantitative"+ }+ }+}
tests/specs/time/utcTime.vl view
@@ -48,10 +48,7 @@ "scale": { "type": "utc" },- "timeUnit": {- "utc": true,- "unit": "yearmonthdatehours"- },+ "timeUnit": "utcyearmonthdatehours", "type": "temporal", "axis": { "format": "%d %b %H:%M"
+ tests/specs/time/withBar.vl view
@@ -0,0 +1,19 @@+{+ "mark": "bar",+ "data": {+ "url": "https://vega.github.io/vega-lite/data/seattle-weather.csv"+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "x": {+ "field": "date",+ "timeUnit": "month",+ "type": "temporal"+ },+ "y": {+ "field": "precipitation",+ "aggregate": "mean",+ "type": "quantitative"+ }+ }+}
+ tests/specs/time/withBarOrdinal.vl view
@@ -0,0 +1,19 @@+{+ "mark": "bar",+ "data": {+ "url": "https://vega.github.io/vega-lite/data/seattle-weather.csv"+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "x": {+ "field": "date",+ "timeUnit": "month",+ "type": "ordinal"+ },+ "y": {+ "field": "precipitation",+ "aggregate": "mean",+ "type": "quantitative"+ }+ }+}