diff --git a/examples/compiled/bar_binned_yearmonth_grouped.png b/examples/compiled/bar_binned_yearmonth_grouped.png index 96f3a926395..c47310973c3 100644 Binary files a/examples/compiled/bar_binned_yearmonth_grouped.png and b/examples/compiled/bar_binned_yearmonth_grouped.png differ diff --git a/examples/compiled/bar_binned_yearmonth_grouped.svg b/examples/compiled/bar_binned_yearmonth_grouped.svg index 0d88d3b01a0..1d3814b5623 100644 --- a/examples/compiled/bar_binned_yearmonth_grouped.svg +++ b/examples/compiled/bar_binned_yearmonth_grouped.svg @@ -1 +1 @@ -Jan 2005Feb 2005Mar 2005Apr 2005date050100150200priceAAPLAMZNGOOGIBMMSFTsymbol \ No newline at end of file +Jan 2005Feb 2005Mar 2005date050100150200priceAAPLAMZNGOOGIBMMSFTsymbol \ No newline at end of file diff --git a/examples/compiled/bar_binned_yearmonth_grouped.vg.json b/examples/compiled/bar_binned_yearmonth_grouped.vg.json index 4d0ef4b7d47..addd923f0b1 100644 --- a/examples/compiled/bar_binned_yearmonth_grouped.vg.json +++ b/examples/compiled/bar_binned_yearmonth_grouped.vg.json @@ -21,6 +21,16 @@ "expr": "timeOffset('month', datum['date'], 1)", "as": "date_end" }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['date'], -1) + 0.5 * datum['date']", + "as": "date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['date'] + 0.5 * datum['date_end']", + "as": "date_offsetted_rect_end" + }, { "type": "stack", "groupby": ["date", "symbol"], @@ -65,7 +75,10 @@ { "name": "x", "type": "time", - "domain": {"data": "source_0", "fields": ["date", "date_end"]}, + "domain": { + "data": "source_0", + "fields": ["date_offsetted_rect_start", "date_offsetted_rect_end"] + }, "range": [0, {"signal": "width"}] }, { @@ -82,10 +95,10 @@ "domain": {"data": "source_0", "field": "symbol", "sort": true}, "range": [ { - "signal": "0.1 * (scale('x', datetime(2001, 1, 1, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" + "signal": "-0.4 * (scale('x', datetime(2001, 1, 1, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" }, { - "signal": "0.9 * (scale('x', datetime(2001, 1, 1, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" + "signal": "0.4 * (scale('x', datetime(2001, 1, 1, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" } ] }, diff --git a/examples/compiled/bar_binnedyearmonth.png b/examples/compiled/bar_binnedyearmonth.png index a1110895bb0..91420854692 100644 Binary files a/examples/compiled/bar_binnedyearmonth.png and b/examples/compiled/bar_binnedyearmonth.png differ diff --git a/examples/compiled/bar_binnedyearmonth.svg b/examples/compiled/bar_binnedyearmonth.svg index 371924fe1a9..cd3bbfc6c02 100644 --- a/examples/compiled/bar_binnedyearmonth.svg +++ b/examples/compiled/bar_binnedyearmonth.svg @@ -1 +1 @@ -Jan 2005Jan 2006Jan 2007Jan 2008Jan 2009Jan 2010date0200400600800price \ No newline at end of file +Jan 2005Jan 2006Jan 2007Jan 2008Jan 2009Jan 2010date0200400600800price \ No newline at end of file diff --git a/examples/compiled/bar_binnedyearmonth.vg.json b/examples/compiled/bar_binnedyearmonth.vg.json index d4f5d85d577..909e6048da3 100644 --- a/examples/compiled/bar_binnedyearmonth.vg.json +++ b/examples/compiled/bar_binnedyearmonth.vg.json @@ -18,6 +18,16 @@ "expr": "timeOffset('month', datum['date'], 1)", "as": "date_end" }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['date'], -1) + 0.5 * datum['date']", + "as": "date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['date'] + 0.5 * datum['date_end']", + "as": "date_offsetted_rect_end" + }, { "type": "stack", "groupby": ["date"], @@ -48,14 +58,14 @@ }, "x2": { "scale": "x", - "field": "date", + "field": "date_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"date_end\"]) - scale(\"x\", datum[\"date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"date_end\"]) - scale(\"x\", datum[\"date\"])))) : 0.5)" } }, "x": { "scale": "x", - "field": "date_end", + "field": "date_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"date_end\"]) - scale(\"x\", datum[\"date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"date_end\"]) - scale(\"x\", datum[\"date\"])))) : -0.5)" } @@ -70,7 +80,10 @@ { "name": "x", "type": "time", - "domain": {"data": "source_0", "fields": ["date", "date_end"]}, + "domain": { + "data": "source_0", + "fields": ["date_offsetted_rect_start", "date_offsetted_rect_end"] + }, "range": [0, {"signal": "width"}] }, { diff --git a/examples/compiled/bar_custom_time_domain.png b/examples/compiled/bar_custom_time_domain.png index f0e49ab8c6e..59f754c98ef 100644 Binary files a/examples/compiled/bar_custom_time_domain.png and b/examples/compiled/bar_custom_time_domain.png differ diff --git a/examples/compiled/bar_custom_time_domain.svg b/examples/compiled/bar_custom_time_domain.svg index 370ec0b5843..186bc3540fe 100644 --- a/examples/compiled/bar_custom_time_domain.svg +++ b/examples/compiled/bar_custom_time_domain.svg @@ -1 +1 @@ -00:0003:0006:0009:0012:0015:0018:0021:0000:00a (hours)051015202530b \ No newline at end of file +00:0003:0006:0009:0012:0015:0018:0021:0000:00a (hours)051015202530b \ No newline at end of file diff --git a/examples/compiled/bar_custom_time_domain.vg.json b/examples/compiled/bar_custom_time_domain.vg.json index 6bf7b6bbbce..e73904b2346 100644 --- a/examples/compiled/bar_custom_time_domain.vg.json +++ b/examples/compiled/bar_custom_time_domain.vg.json @@ -26,6 +26,16 @@ "units": ["hours"], "as": ["hours_a", "hours_a_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('hours', datum['hours_a'], -1) + 0.5 * datum['hours_a']", + "as": "hours_a_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['hours_a'] + 0.5 * datum['hours_a_end']", + "as": "hours_a_offsetted_rect_end" + }, { "type": "stack", "groupby": ["hours_a"], @@ -56,14 +66,14 @@ }, "x2": { "scale": "x", - "field": "hours_a", + "field": "hours_a_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"hours_a_end\"]) - scale(\"x\", datum[\"hours_a\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"hours_a_end\"]) - scale(\"x\", datum[\"hours_a\"])))) : 0.5)" } }, "x": { "scale": "x", - "field": "hours_a_end", + "field": "hours_a_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"hours_a_end\"]) - scale(\"x\", datum[\"hours_a\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"hours_a_end\"]) - scale(\"x\", datum[\"hours_a\"])))) : -0.5)" } diff --git a/examples/compiled/bar_group_timeunit.png b/examples/compiled/bar_group_timeunit.png index 370381b1e30..f1dbf414175 100644 Binary files a/examples/compiled/bar_group_timeunit.png and b/examples/compiled/bar_group_timeunit.png differ diff --git a/examples/compiled/bar_group_timeunit.svg b/examples/compiled/bar_group_timeunit.svg index 59619b40081..0bf64fe4995 100644 --- a/examples/compiled/bar_group_timeunit.svg +++ b/examples/compiled/bar_group_timeunit.svg @@ -1 +1 @@ -19691970197119721973197419751976197719781979198019811982Year (year)05101520253035Number of CarsEuropeJapanUSAOrigin \ No newline at end of file +1969197019711972197319741975197619771978197919801981Year (year)05101520253035Number of CarsEuropeJapanUSAOrigin \ No newline at end of file diff --git a/examples/compiled/bar_group_timeunit.vg.json b/examples/compiled/bar_group_timeunit.vg.json index 41207af3b08..714914399b0 100644 --- a/examples/compiled/bar_group_timeunit.vg.json +++ b/examples/compiled/bar_group_timeunit.vg.json @@ -17,9 +17,25 @@ "units": ["year"], "as": ["year_Year", "year_Year_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('year', datum['year_Year'], -1) + 0.5 * datum['year_Year']", + "as": "year_Year_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['year_Year'] + 0.5 * datum['year_Year_end']", + "as": "year_Year_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["year_Year", "year_Year_end", "Origin"], + "groupby": [ + "year_Year", + "year_Year_end", + "year_Year_offsetted_rect_start", + "year_Year_offsetted_rect_end", + "Origin" + ], "ops": ["count"], "fields": [null], "as": ["__count"] @@ -60,7 +76,13 @@ { "name": "x", "type": "time", - "domain": {"data": "source_0", "fields": ["year_Year", "year_Year_end"]}, + "domain": { + "data": "source_0", + "fields": [ + "year_Year_offsetted_rect_start", + "year_Year_offsetted_rect_end" + ] + }, "range": [0, {"signal": "width"}] }, { @@ -77,10 +99,10 @@ "domain": {"data": "source_0", "field": "Origin", "sort": true}, "range": [ { - "signal": "0.1 * (scale('x', datetime(2002, 0, 1, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" + "signal": "-0.4 * (scale('x', datetime(2002, 0, 1, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" }, { - "signal": "0.9 * (scale('x', datetime(2002, 0, 1, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" + "signal": "0.4 * (scale('x', datetime(2002, 0, 1, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" } ] }, diff --git a/examples/compiled/bar_grouped_timeunit_yearweek.png b/examples/compiled/bar_grouped_timeunit_yearweek.png index f99a136a90b..e55fdf914a4 100644 Binary files a/examples/compiled/bar_grouped_timeunit_yearweek.png and b/examples/compiled/bar_grouped_timeunit_yearweek.png differ diff --git a/examples/compiled/bar_grouped_timeunit_yearweek.svg b/examples/compiled/bar_grouped_timeunit_yearweek.svg index 0ad1710782a..49aefa0c4a2 100644 --- a/examples/compiled/bar_grouped_timeunit_yearweek.svg +++ b/examples/compiled/bar_grouped_timeunit_yearweek.svg @@ -1 +1 @@ -1971 W001971 W051971 W091971 W131971 W171971 W221971 W261971 W311971 W351971 W391971 W441971 W481972 W00Year (year-week)02468101214161820Number of CarsEuropeJapanUSAOrigin \ No newline at end of file +1971 W001971 W051971 W091971 W131971 W171971 W221971 W261971 W311971 W351971 W391971 W441971 W48Year (year-week)02468101214161820Number of CarsEuropeJapanUSAOrigin \ No newline at end of file diff --git a/examples/compiled/bar_grouped_timeunit_yearweek.vg.json b/examples/compiled/bar_grouped_timeunit_yearweek.vg.json index af91bf87f1a..c0ec7915208 100644 --- a/examples/compiled/bar_grouped_timeunit_yearweek.vg.json +++ b/examples/compiled/bar_grouped_timeunit_yearweek.vg.json @@ -21,9 +21,25 @@ "units": ["year", "week"], "as": ["yearweek_Year", "yearweek_Year_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('date', datum['yearweek_Year'], -7) + 0.5 * datum['yearweek_Year']", + "as": "yearweek_Year_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['yearweek_Year'] + 0.5 * datum['yearweek_Year_end']", + "as": "yearweek_Year_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["yearweek_Year", "yearweek_Year_end", "Origin"], + "groupby": [ + "yearweek_Year", + "yearweek_Year_end", + "yearweek_Year_offsetted_rect_start", + "yearweek_Year_offsetted_rect_end", + "Origin" + ], "ops": ["count"], "fields": [null], "as": ["__count"] @@ -66,7 +82,10 @@ "type": "time", "domain": { "data": "source_0", - "fields": ["yearweek_Year", "yearweek_Year_end"] + "fields": [ + "yearweek_Year_offsetted_rect_start", + "yearweek_Year_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, @@ -84,10 +103,10 @@ "domain": {"data": "source_0", "field": "Origin", "sort": true}, "range": [ { - "signal": "0.1 * (scale('x', datetime(2001, 0, 8, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" + "signal": "-0.4 * (scale('x', datetime(2001, 0, 8, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" }, { - "signal": "0.9 * (scale('x', datetime(2001, 0, 8, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" + "signal": "0.4 * (scale('x', datetime(2001, 0, 8, 0, 0, 0, 0)) - scale('x', datetime(2001, 0, 1, 0, 0, 0, 0)))" } ] }, diff --git a/examples/compiled/bar_month.vg.json b/examples/compiled/bar_month.vg.json index d59b3b4477e..9cf325f9b70 100644 --- a/examples/compiled/bar_month.vg.json +++ b/examples/compiled/bar_month.vg.json @@ -16,6 +16,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date"], diff --git a/examples/compiled/bar_month_band.png b/examples/compiled/bar_month_band.png index c1210128889..b0ef9ccfd1a 100644 Binary files a/examples/compiled/bar_month_band.png and b/examples/compiled/bar_month_band.png differ diff --git a/examples/compiled/bar_month_band.svg b/examples/compiled/bar_month_band.svg index 552e1e03369..0244c81a3cc 100644 --- a/examples/compiled/bar_month_band.svg +++ b/examples/compiled/bar_month_band.svg @@ -1 +1 @@ -JanFebMarAprMayJunJulAugSepOctNovDecJandate (month)012345Mean of precipitation \ No newline at end of file +JanFebMarAprMayJunJulAugSepOctNovDecdate (month)012345Mean of precipitation \ No newline at end of file diff --git a/examples/compiled/bar_month_band.vg.json b/examples/compiled/bar_month_band.vg.json index 9165a52a807..fb9b6fb9288 100644 --- a/examples/compiled/bar_month_band.vg.json +++ b/examples/compiled/bar_month_band.vg.json @@ -17,9 +17,24 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["month_date", "month_date_end"], + "groupby": [ + "month_date", + "month_date_end", + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ], "ops": ["mean"], "fields": ["precipitation"], "as": ["mean_precipitation"] @@ -45,13 +60,13 @@ "signal": "\"date (month): \" + (timeFormat(datum[\"month_date\"], timeUnitSpecifier([\"month\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; Mean of precipitation: \" + (format(datum[\"mean_precipitation\"], \"\"))" }, "x2": { - "signal": "scale(\"x\", 0.85 * datum[\"month_date\"] + 0.15000000000000002 * datum[\"month_date_end\"])", + "signal": "scale(\"x\", 0.85 * datum[\"month_date_offsetted_rect_start\"] + 0.15000000000000002 * datum[\"month_date_offsetted_rect_end\"])", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : 0.5)" } }, "x": { - "signal": "scale(\"x\", 0.15000000000000002 * datum[\"month_date\"] + 0.85 * datum[\"month_date_end\"])", + "signal": "scale(\"x\", 0.15000000000000002 * datum[\"month_date_offsetted_rect_start\"] + 0.85 * datum[\"month_date_offsetted_rect_end\"])", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : -0.5)" } @@ -68,7 +83,10 @@ "type": "time", "domain": { "data": "source_0", - "fields": ["month_date", "month_date_end"] + "fields": [ + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, diff --git a/examples/compiled/bar_month_band_config.png b/examples/compiled/bar_month_band_config.png index c1210128889..b0ef9ccfd1a 100644 Binary files a/examples/compiled/bar_month_band_config.png and b/examples/compiled/bar_month_band_config.png differ diff --git a/examples/compiled/bar_month_band_config.svg b/examples/compiled/bar_month_band_config.svg index 552e1e03369..0244c81a3cc 100644 --- a/examples/compiled/bar_month_band_config.svg +++ b/examples/compiled/bar_month_band_config.svg @@ -1 +1 @@ -JanFebMarAprMayJunJulAugSepOctNovDecJandate (month)012345Mean of precipitation \ No newline at end of file +JanFebMarAprMayJunJulAugSepOctNovDecdate (month)012345Mean of precipitation \ No newline at end of file diff --git a/examples/compiled/bar_month_band_config.vg.json b/examples/compiled/bar_month_band_config.vg.json index 9165a52a807..fb9b6fb9288 100644 --- a/examples/compiled/bar_month_band_config.vg.json +++ b/examples/compiled/bar_month_band_config.vg.json @@ -17,9 +17,24 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["month_date", "month_date_end"], + "groupby": [ + "month_date", + "month_date_end", + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ], "ops": ["mean"], "fields": ["precipitation"], "as": ["mean_precipitation"] @@ -45,13 +60,13 @@ "signal": "\"date (month): \" + (timeFormat(datum[\"month_date\"], timeUnitSpecifier([\"month\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; Mean of precipitation: \" + (format(datum[\"mean_precipitation\"], \"\"))" }, "x2": { - "signal": "scale(\"x\", 0.85 * datum[\"month_date\"] + 0.15000000000000002 * datum[\"month_date_end\"])", + "signal": "scale(\"x\", 0.85 * datum[\"month_date_offsetted_rect_start\"] + 0.15000000000000002 * datum[\"month_date_offsetted_rect_end\"])", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : 0.5)" } }, "x": { - "signal": "scale(\"x\", 0.15000000000000002 * datum[\"month_date\"] + 0.85 * datum[\"month_date_end\"])", + "signal": "scale(\"x\", 0.15000000000000002 * datum[\"month_date_offsetted_rect_start\"] + 0.85 * datum[\"month_date_offsetted_rect_end\"])", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : -0.5)" } @@ -68,7 +83,10 @@ "type": "time", "domain": { "data": "source_0", - "fields": ["month_date", "month_date_end"] + "fields": [ + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, diff --git a/examples/compiled/bar_month_temporal.png b/examples/compiled/bar_month_temporal.png index 61c1c04fab5..62203cbc3b9 100644 Binary files a/examples/compiled/bar_month_temporal.png and b/examples/compiled/bar_month_temporal.png differ diff --git a/examples/compiled/bar_month_temporal.svg b/examples/compiled/bar_month_temporal.svg index cf84822e487..4c5776ae762 100644 --- a/examples/compiled/bar_month_temporal.svg +++ b/examples/compiled/bar_month_temporal.svg @@ -1 +1 @@ -JanFebMarAprMayJunJulAugSepOctNovDecJandate (month)012345Mean of precipitation \ No newline at end of file +JanFebMarAprMayJunJulAugSepOctNovDecdate (month)012345Mean of precipitation \ No newline at end of file diff --git a/examples/compiled/bar_month_temporal.vg.json b/examples/compiled/bar_month_temporal.vg.json index 25cac61d2bf..597691718b3 100644 --- a/examples/compiled/bar_month_temporal.vg.json +++ b/examples/compiled/bar_month_temporal.vg.json @@ -17,9 +17,24 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["month_date", "month_date_end"], + "groupby": [ + "month_date", + "month_date_end", + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ], "ops": ["mean"], "fields": ["precipitation"], "as": ["mean_precipitation"] @@ -46,14 +61,14 @@ }, "x2": { "scale": "x", - "field": "month_date", + "field": "month_date_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : 0.5)" } }, "x": { "scale": "x", - "field": "month_date_end", + "field": "month_date_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : -0.5)" } @@ -70,7 +85,10 @@ "type": "time", "domain": { "data": "source_0", - "fields": ["month_date", "month_date_end"] + "fields": [ + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, diff --git a/examples/compiled/bar_month_temporal_initial.png b/examples/compiled/bar_month_temporal_initial.png index 9cf91fe5d37..a156da5ddec 100644 Binary files a/examples/compiled/bar_month_temporal_initial.png and b/examples/compiled/bar_month_temporal_initial.png differ diff --git a/examples/compiled/bar_month_temporal_initial.svg b/examples/compiled/bar_month_temporal_initial.svg index a7b19c189ba..045c2bfdaba 100644 --- a/examples/compiled/bar_month_temporal_initial.svg +++ b/examples/compiled/bar_month_temporal_initial.svg @@ -1 +1 @@ -JFMAMJJASONDJdate (month)012345Mean of precipitation \ No newline at end of file +JFMAMJJASONDdate (month)012345Mean of precipitation \ No newline at end of file diff --git a/examples/compiled/bar_month_temporal_initial.vg.json b/examples/compiled/bar_month_temporal_initial.vg.json index 73328c7f46a..a877f6dcf01 100644 --- a/examples/compiled/bar_month_temporal_initial.vg.json +++ b/examples/compiled/bar_month_temporal_initial.vg.json @@ -18,9 +18,24 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["month_date", "month_date_end"], + "groupby": [ + "month_date", + "month_date_end", + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ], "ops": ["mean"], "fields": ["precipitation"], "as": ["mean_precipitation"] @@ -47,14 +62,14 @@ }, "x2": { "scale": "x", - "field": "month_date", + "field": "month_date_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : 0.5)" } }, "x": { "scale": "x", - "field": "month_date_end", + "field": "month_date_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : -0.5)" } @@ -71,7 +86,10 @@ "type": "time", "domain": { "data": "source_0", - "fields": ["month_date", "month_date_end"] + "fields": [ + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, diff --git a/examples/compiled/bar_simple_binned_timeunit_special_chars.png b/examples/compiled/bar_simple_binned_timeunit_special_chars.png index 3af3f68f654..9eb694864c1 100644 Binary files a/examples/compiled/bar_simple_binned_timeunit_special_chars.png and b/examples/compiled/bar_simple_binned_timeunit_special_chars.png differ diff --git a/examples/compiled/bar_simple_binned_timeunit_special_chars.svg b/examples/compiled/bar_simple_binned_timeunit_special_chars.svg index 822168923d3..853e6843c00 100644 --- a/examples/compiled/bar_simple_binned_timeunit_special_chars.svg +++ b/examples/compiled/bar_simple_binned_timeunit_special_chars.svg @@ -1 +1 @@ -020406080100bJan 02, 2022Jan 04, 2022Jan 06, 2022Jan 08, 2022Jan 10, 2022a.bA Simple Bar Chart with Lines at Extents \ No newline at end of file +020406080100bJan 02, 2022Jan 04, 2022Jan 06, 2022Jan 08, 2022a.bA Simple Bar Chart with Lines at Extents \ No newline at end of file diff --git a/examples/compiled/bar_simple_binned_timeunit_special_chars.vg.json b/examples/compiled/bar_simple_binned_timeunit_special_chars.vg.json index 2fb873170ff..a708222cbe7 100644 --- a/examples/compiled/bar_simple_binned_timeunit_special_chars.vg.json +++ b/examples/compiled/bar_simple_binned_timeunit_special_chars.vg.json @@ -34,6 +34,16 @@ "expr": "utcOffset('date', datum['a.b'], 1)", "as": "a.b_end" }, + { + "type": "formula", + "expr": "0.5 * utcOffset('date', datum['a.b'], -1) + 0.5 * datum['a.b']", + "as": "a.b_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['a.b'] + 0.5 * datum['a.b_end']", + "as": "a.b_offsetted_rect_end" + }, { "type": "stack", "groupby": ["a\\.b"], @@ -66,14 +76,14 @@ "x2": {"scale": "x", "field": "b_start"}, "y2": { "scale": "y", - "field": "a\\.b", + "field": "a\\.b_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"y\", datum[\"a.b_end\"]) - scale(\"y\", datum[\"a.b\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"y\", datum[\"a.b_end\"]) - scale(\"y\", datum[\"a.b\"])))) : -0.5)" } }, "y": { "scale": "y", - "field": "a\\.b_end", + "field": "a\\.b_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"y\", datum[\"a.b_end\"]) - scale(\"y\", datum[\"a.b\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"y\", datum[\"a.b_end\"]) - scale(\"y\", datum[\"a.b\"])))) : 0.5)" } @@ -94,7 +104,10 @@ { "name": "y", "type": "utc", - "domain": {"data": "data_0", "fields": ["a\\.b", "a\\.b_end"]}, + "domain": { + "data": "data_0", + "fields": ["a\\.b_offsetted_rect_start", "a\\.b_offsetted_rect_end"] + }, "range": [{"signal": "height"}, 0] } ], diff --git a/examples/compiled/bar_yearmonth.png b/examples/compiled/bar_yearmonth.png index 88354b541e7..4ac977a0c83 100644 Binary files a/examples/compiled/bar_yearmonth.png and b/examples/compiled/bar_yearmonth.png differ diff --git a/examples/compiled/bar_yearmonth.svg b/examples/compiled/bar_yearmonth.svg index 01afff80b15..4e3fa4a8cc7 100644 --- a/examples/compiled/bar_yearmonth.svg +++ b/examples/compiled/bar_yearmonth.svg @@ -1 +1 @@ -Jan 2012Jan 2013Jan 2014Jan 2015Jan 2016date (year-month)051015202530Mean of temp_max \ No newline at end of file +Jan 2012Jan 2013Jan 2014Jan 2015date (year-month)051015202530Mean of temp_max \ No newline at end of file diff --git a/examples/compiled/bar_yearmonth.vg.json b/examples/compiled/bar_yearmonth.vg.json index 3427f5e5de3..4886b6c607b 100644 --- a/examples/compiled/bar_yearmonth.vg.json +++ b/examples/compiled/bar_yearmonth.vg.json @@ -18,9 +18,24 @@ "units": ["year", "month"], "as": ["yearmonth_date", "yearmonth_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['yearmonth_date'], -1) + 0.5 * datum['yearmonth_date']", + "as": "yearmonth_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['yearmonth_date'] + 0.5 * datum['yearmonth_date_end']", + "as": "yearmonth_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["yearmonth_date", "yearmonth_date_end"], + "groupby": [ + "yearmonth_date", + "yearmonth_date_end", + "yearmonth_date_offsetted_rect_start", + "yearmonth_date_offsetted_rect_end" + ], "ops": ["mean"], "fields": ["temp_max"], "as": ["mean_temp_max"] @@ -47,14 +62,14 @@ }, "x2": { "scale": "x", - "field": "yearmonth_date", + "field": "yearmonth_date_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"yearmonth_date_end\"]) - scale(\"x\", datum[\"yearmonth_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"yearmonth_date_end\"]) - scale(\"x\", datum[\"yearmonth_date\"])))) : 0.5)" } }, "x": { "scale": "x", - "field": "yearmonth_date_end", + "field": "yearmonth_date_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"yearmonth_date_end\"]) - scale(\"x\", datum[\"yearmonth_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"yearmonth_date_end\"]) - scale(\"x\", datum[\"yearmonth_date\"])))) : -0.5)" } @@ -71,7 +86,10 @@ "type": "time", "domain": { "data": "source_0", - "fields": ["yearmonth_date", "yearmonth_date_end"] + "fields": [ + "yearmonth_date_offsetted_rect_start", + "yearmonth_date_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, diff --git a/examples/compiled/bar_yearmonth_custom_format.png b/examples/compiled/bar_yearmonth_custom_format.png index e68fb7c90b5..e1b56a7d9d0 100644 Binary files a/examples/compiled/bar_yearmonth_custom_format.png and b/examples/compiled/bar_yearmonth_custom_format.png differ diff --git a/examples/compiled/bar_yearmonth_custom_format.svg b/examples/compiled/bar_yearmonth_custom_format.svg index 3f0c17011f7..1916da65ed4 100644 --- a/examples/compiled/bar_yearmonth_custom_format.svg +++ b/examples/compiled/bar_yearmonth_custom_format.svg @@ -1 +1 @@ -January of 2012January of 2013January of 2014January of 2015January of 2016date (year-month)051015202530Mean of temp_max \ No newline at end of file +January of 2012January of 2013January of 2014January of 2015date (year-month)051015202530Mean of temp_max \ No newline at end of file diff --git a/examples/compiled/bar_yearmonth_custom_format.vg.json b/examples/compiled/bar_yearmonth_custom_format.vg.json index 5463902d4fc..a6409f322c8 100644 --- a/examples/compiled/bar_yearmonth_custom_format.vg.json +++ b/examples/compiled/bar_yearmonth_custom_format.vg.json @@ -18,9 +18,24 @@ "units": ["year", "month"], "as": ["yearmonth_date", "yearmonth_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['yearmonth_date'], -1) + 0.5 * datum['yearmonth_date']", + "as": "yearmonth_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['yearmonth_date'] + 0.5 * datum['yearmonth_date_end']", + "as": "yearmonth_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["yearmonth_date", "yearmonth_date_end"], + "groupby": [ + "yearmonth_date", + "yearmonth_date_end", + "yearmonth_date_offsetted_rect_start", + "yearmonth_date_offsetted_rect_end" + ], "ops": ["mean"], "fields": ["temp_max"], "as": ["mean_temp_max"] @@ -47,14 +62,14 @@ }, "x2": { "scale": "x", - "field": "yearmonth_date", + "field": "yearmonth_date_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"yearmonth_date_end\"]) - scale(\"x\", datum[\"yearmonth_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"yearmonth_date_end\"]) - scale(\"x\", datum[\"yearmonth_date\"])))) : 0.5)" } }, "x": { "scale": "x", - "field": "yearmonth_date_end", + "field": "yearmonth_date_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"yearmonth_date_end\"]) - scale(\"x\", datum[\"yearmonth_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"yearmonth_date_end\"]) - scale(\"x\", datum[\"yearmonth_date\"])))) : -0.5)" } @@ -71,7 +86,10 @@ "type": "time", "domain": { "data": "source_0", - "fields": ["yearmonth_date", "yearmonth_date_end"] + "fields": [ + "yearmonth_date_offsetted_rect_start", + "yearmonth_date_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, diff --git a/examples/compiled/bar_yearmonthdate_minBandSize.png b/examples/compiled/bar_yearmonthdate_minBandSize.png index d4ded550f76..59822677452 100644 Binary files a/examples/compiled/bar_yearmonthdate_minBandSize.png and b/examples/compiled/bar_yearmonthdate_minBandSize.png differ diff --git a/examples/compiled/bar_yearmonthdate_minBandSize.svg b/examples/compiled/bar_yearmonthdate_minBandSize.svg index 7a68bb07271..4a24820c6b0 100644 --- a/examples/compiled/bar_yearmonthdate_minBandSize.svg +++ b/examples/compiled/bar_yearmonthdate_minBandSize.svg @@ -1 +1 @@ -Jan 01, 2012Apr 01, 2012Jul 01, 2012Oct 01, 2012Jan 01, 2013Apr 01, 2013Jul 01, 2013Oct 01, 2013Jan 01, 2014Apr 01, 2014Jul 01, 2014Oct 01, 2014Jan 01, 2015Apr 01, 2015Jul 01, 2015Oct 01, 2015date (year-month-date)010203040Mean of temp_max \ No newline at end of file +Jan 01, 2012Apr 01, 2012Jul 01, 2012Oct 01, 2012Jan 01, 2013Apr 01, 2013Jul 01, 2013Oct 01, 2013Jan 01, 2014Apr 01, 2014Jul 01, 2014Oct 01, 2014Jan 01, 2015Apr 01, 2015Jul 01, 2015Oct 01, 2015date (year-month-date)010203040Mean of temp_max \ No newline at end of file diff --git a/examples/compiled/bar_yearmonthdate_minBandSize.vg.json b/examples/compiled/bar_yearmonthdate_minBandSize.vg.json index bcf02a37417..1d8ad70f6a6 100644 --- a/examples/compiled/bar_yearmonthdate_minBandSize.vg.json +++ b/examples/compiled/bar_yearmonthdate_minBandSize.vg.json @@ -17,9 +17,24 @@ "units": ["year", "month", "date"], "as": ["yearmonthdate_date", "yearmonthdate_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('date', datum['yearmonthdate_date'], -1) + 0.5 * datum['yearmonthdate_date']", + "as": "yearmonthdate_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['yearmonthdate_date'] + 0.5 * datum['yearmonthdate_date_end']", + "as": "yearmonthdate_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["yearmonthdate_date", "yearmonthdate_date_end"], + "groupby": [ + "yearmonthdate_date", + "yearmonthdate_date_end", + "yearmonthdate_date_offsetted_rect_start", + "yearmonthdate_date_offsetted_rect_end" + ], "ops": ["mean"], "fields": ["temp_max"], "as": ["mean_temp_max"] @@ -46,14 +61,14 @@ }, "x2": { "scale": "x", - "field": "yearmonthdate_date", + "field": "yearmonthdate_date_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"yearmonthdate_date_end\"]) - scale(\"x\", datum[\"yearmonthdate_date\"])) < 2 ? -0.5 * (2 - (abs(scale(\"x\", datum[\"yearmonthdate_date_end\"]) - scale(\"x\", datum[\"yearmonthdate_date\"])))) : 0.5)" } }, "x": { "scale": "x", - "field": "yearmonthdate_date_end", + "field": "yearmonthdate_date_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"yearmonthdate_date_end\"]) - scale(\"x\", datum[\"yearmonthdate_date\"])) < 2 ? 0.5 * (2 - (abs(scale(\"x\", datum[\"yearmonthdate_date_end\"]) - scale(\"x\", datum[\"yearmonthdate_date\"])))) : -0.5)" } @@ -70,7 +85,10 @@ "type": "time", "domain": { "data": "source_0", - "fields": ["yearmonthdate_date", "yearmonthdate_date_end"] + "fields": [ + "yearmonthdate_date_offsetted_rect_start", + "yearmonthdate_date_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, diff --git a/examples/compiled/concat_weather.vg.json b/examples/compiled/concat_weather.vg.json index 7db19ec2151..b78537c0782 100644 --- a/examples/compiled/concat_weather.vg.json +++ b/examples/compiled/concat_weather.vg.json @@ -20,6 +20,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date"], diff --git a/examples/compiled/hconcat_weather.vg.json b/examples/compiled/hconcat_weather.vg.json index 240bcd9e94b..7f15cbe1e76 100644 --- a/examples/compiled/hconcat_weather.vg.json +++ b/examples/compiled/hconcat_weather.vg.json @@ -21,6 +21,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date"], diff --git a/examples/compiled/layer_bar_month.vg.json b/examples/compiled/layer_bar_month.vg.json index 98c23e75f6c..4f1ab24d140 100644 --- a/examples/compiled/layer_bar_month.vg.json +++ b/examples/compiled/layer_bar_month.vg.json @@ -20,6 +20,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date"], diff --git a/examples/compiled/layer_falkensee.vg.json b/examples/compiled/layer_falkensee.vg.json index 1a44900ffb3..6579b8be76f 100644 --- a/examples/compiled/layer_falkensee.vg.json +++ b/examples/compiled/layer_falkensee.vg.json @@ -104,6 +104,16 @@ "units": ["year"], "as": ["year_start", "year_start_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('year', datum['year_start'], -1) + 0.5 * datum['year_start']", + "as": "year_start_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['year_start'] + 0.5 * datum['year_start_end']", + "as": "year_start_offsetted_rect_end" + }, { "field": "end", "type": "timeunit", diff --git a/examples/compiled/layer_precipitation_mean.vg.json b/examples/compiled/layer_precipitation_mean.vg.json index 6d2e5e4be26..b46eab3c3d2 100644 --- a/examples/compiled/layer_precipitation_mean.vg.json +++ b/examples/compiled/layer_precipitation_mean.vg.json @@ -20,6 +20,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date"], diff --git a/examples/compiled/layer_timeunit_rect.png b/examples/compiled/layer_timeunit_rect.png index fc3fbb3d3e0..55443848514 100644 Binary files a/examples/compiled/layer_timeunit_rect.png and b/examples/compiled/layer_timeunit_rect.png differ diff --git a/examples/compiled/layer_timeunit_rect.svg b/examples/compiled/layer_timeunit_rect.svg index 4e1253bee34..6026d40227e 100644 --- a/examples/compiled/layer_timeunit_rect.svg +++ b/examples/compiled/layer_timeunit_rect.svg @@ -1 +1 @@ -JFMAMJJASONDJmonth012345Mean of precipitation \ No newline at end of file +JFMAMJJASONDmonth012345Mean of precipitation \ No newline at end of file diff --git a/examples/compiled/layer_timeunit_rect.vg.json b/examples/compiled/layer_timeunit_rect.vg.json index 48330e61127..7fcdbedebed 100644 --- a/examples/compiled/layer_timeunit_rect.vg.json +++ b/examples/compiled/layer_timeunit_rect.vg.json @@ -22,9 +22,24 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["month_date", "month_date_end"], + "groupby": [ + "month_date", + "month_date_end", + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ], "ops": ["mean"], "fields": ["precipitation"], "as": ["mean_precipitation"] @@ -51,6 +66,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "field": "date_end", "type": "timeunit", @@ -79,14 +104,14 @@ }, "x2": { "scale": "x", - "field": "month_date", + "field": "month_date_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : 0.5)" } }, "x": { "scale": "x", - "field": "month_date_end", + "field": "month_date_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : -0.5)" } @@ -122,8 +147,8 @@ "type": "time", "domain": { "fields": [ - {"data": "source_0", "field": "month_date"}, - {"data": "source_0", "field": "month_date_end"}, + {"data": "source_0", "field": "month_date_offsetted_rect_start"}, + {"data": "source_0", "field": "month_date_offsetted_rect_end"}, {"data": "data_0", "field": "month_date"}, {"data": "data_0", "field": "month_date_end"} ] diff --git a/examples/compiled/line_month_center_band_offset.png b/examples/compiled/line_month_center_band_offset.png index cdb769d34d3..14599f8a9a8 100644 Binary files a/examples/compiled/line_month_center_band_offset.png and b/examples/compiled/line_month_center_band_offset.png differ diff --git a/examples/compiled/line_month_center_band_offset.svg b/examples/compiled/line_month_center_band_offset.svg index 0465e434def..58bc35e6a2b 100644 --- a/examples/compiled/line_month_center_band_offset.svg +++ b/examples/compiled/line_month_center_band_offset.svg @@ -1 +1 @@ -JanFebMarAprMayJunJulAugSepOctNovDecJandate (month)012345Mean of precipitation \ No newline at end of file +JanFebMarAprMayJunJulAugSepOctNovDecdate (month)012345Mean of precipitation \ No newline at end of file diff --git a/examples/compiled/line_month_center_band_offset.vg.json b/examples/compiled/line_month_center_band_offset.vg.json index c89e0175633..27be1d52f69 100644 --- a/examples/compiled/line_month_center_band_offset.vg.json +++ b/examples/compiled/line_month_center_band_offset.vg.json @@ -17,9 +17,24 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["month_date", "month_date_end"], + "groupby": [ + "month_date", + "month_date_end", + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ], "ops": ["mean"], "fields": ["precipitation"], "as": ["mean_precipitation"] @@ -46,14 +61,14 @@ }, "x2": { "scale": "x", - "field": "month_date", + "field": "month_date_offsetted_rect_start", "offset": { "signal": "0.5 + (2 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : 0.5))" } }, "x": { "scale": "x", - "field": "month_date_end", + "field": "month_date_offsetted_rect_end", "offset": { "signal": "0.5 + (-2 + (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"month_date_end\"]) - scale(\"x\", datum[\"month_date\"])))) : -0.5))" } @@ -70,7 +85,10 @@ "type": "time", "domain": { "data": "source_0", - "fields": ["month_date", "month_date_end"] + "fields": [ + "month_date_offsetted_rect_start", + "month_date_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, diff --git a/examples/compiled/rect_heatmap_weather.vg.json b/examples/compiled/rect_heatmap_weather.vg.json index 6c00cfca801..0e0baa8e3e6 100644 --- a/examples/compiled/rect_heatmap_weather.vg.json +++ b/examples/compiled/rect_heatmap_weather.vg.json @@ -22,12 +22,32 @@ "units": ["date"], "as": ["date_date", "date_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('date', datum['date_date'], -1) + 0.5 * datum['date_date']", + "as": "date_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['date_date'] + 0.5 * datum['date_date_end']", + "as": "date_date_offsetted_rect_end" + }, { "field": "date", "type": "timeunit", "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["date_date", "month_date"], diff --git a/examples/compiled/rect_lasagna.vg.json b/examples/compiled/rect_lasagna.vg.json index 95f0ff9d877..efc7976664a 100644 --- a/examples/compiled/rect_lasagna.vg.json +++ b/examples/compiled/rect_lasagna.vg.json @@ -18,6 +18,16 @@ "units": ["year", "month", "date"], "as": ["yearmonthdate_date", "yearmonthdate_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('date', datum['yearmonthdate_date'], -1) + 0.5 * datum['yearmonthdate_date']", + "as": "yearmonthdate_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['yearmonthdate_date'] + 0.5 * datum['yearmonthdate_date_end']", + "as": "yearmonthdate_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["yearmonthdate_date", "symbol"], diff --git a/examples/compiled/selection_layer_bar_month.vg.json b/examples/compiled/selection_layer_bar_month.vg.json index bf4b4c590d3..aecb7eacad1 100644 --- a/examples/compiled/selection_layer_bar_month.vg.json +++ b/examples/compiled/selection_layer_bar_month.vg.json @@ -16,6 +16,22 @@ "type": "timeunit", "units": ["month"], "as": ["month_date", "month_date_end"] + }, + { + "field": "date", + "type": "timeunit", + "units": ["month"], + "as": ["month_date", "month_date_end"] + }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" } ] }, diff --git a/examples/compiled/stacked_bar_count.vg.json b/examples/compiled/stacked_bar_count.vg.json index 122e0b7c50e..163b53c4f71 100644 --- a/examples/compiled/stacked_bar_count.vg.json +++ b/examples/compiled/stacked_bar_count.vg.json @@ -16,6 +16,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date", "weather"], diff --git a/examples/compiled/stacked_bar_count_corner_radius_config.vg.json b/examples/compiled/stacked_bar_count_corner_radius_config.vg.json index 71509e63d75..08a449aee0c 100644 --- a/examples/compiled/stacked_bar_count_corner_radius_config.vg.json +++ b/examples/compiled/stacked_bar_count_corner_radius_config.vg.json @@ -16,6 +16,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date", "weather"], diff --git a/examples/compiled/stacked_bar_count_corner_radius_mark.vg.json b/examples/compiled/stacked_bar_count_corner_radius_mark.vg.json index 0c06b8c8ecc..cb147c3d49b 100644 --- a/examples/compiled/stacked_bar_count_corner_radius_mark.vg.json +++ b/examples/compiled/stacked_bar_count_corner_radius_mark.vg.json @@ -16,6 +16,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date", "weather"], diff --git a/examples/compiled/stacked_bar_count_corner_radius_mark_x.vg.json b/examples/compiled/stacked_bar_count_corner_radius_mark_x.vg.json index 984baf0d179..acdbb8fa491 100644 --- a/examples/compiled/stacked_bar_count_corner_radius_mark_x.vg.json +++ b/examples/compiled/stacked_bar_count_corner_radius_mark_x.vg.json @@ -16,6 +16,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date", "weather"], diff --git a/examples/compiled/stacked_bar_count_corner_radius_stroke.vg.json b/examples/compiled/stacked_bar_count_corner_radius_stroke.vg.json index 15bd6cdf6cf..67da150fd27 100644 --- a/examples/compiled/stacked_bar_count_corner_radius_stroke.vg.json +++ b/examples/compiled/stacked_bar_count_corner_radius_stroke.vg.json @@ -16,6 +16,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date", "weather"], diff --git a/examples/compiled/stacked_bar_size.vg.json b/examples/compiled/stacked_bar_size.vg.json index 7008e2f7901..cb96993aac4 100644 --- a/examples/compiled/stacked_bar_size.vg.json +++ b/examples/compiled/stacked_bar_size.vg.json @@ -16,6 +16,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date", "weather"], diff --git a/examples/compiled/stacked_bar_weather.vg.json b/examples/compiled/stacked_bar_weather.vg.json index 14721fff3bd..8341b9f0eac 100644 --- a/examples/compiled/stacked_bar_weather.vg.json +++ b/examples/compiled/stacked_bar_weather.vg.json @@ -16,6 +16,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date", "weather"], diff --git a/examples/compiled/time_custom_step.png b/examples/compiled/time_custom_step.png index 09ac809ba00..472cfe97085 100644 Binary files a/examples/compiled/time_custom_step.png and b/examples/compiled/time_custom_step.png differ diff --git a/examples/compiled/time_custom_step.svg b/examples/compiled/time_custom_step.svg index ff9d209909f..68157409c9d 100644 --- a/examples/compiled/time_custom_step.svg +++ b/examples/compiled/time_custom_step.svg @@ -1 +1 @@ -00:0000:0500:1000:1500:20date (minutes)05101520Sum of distance \ No newline at end of file +00:0000:0500:1000:15date (minutes)05101520Sum of distance \ No newline at end of file diff --git a/examples/compiled/time_custom_step.vg.json b/examples/compiled/time_custom_step.vg.json index f6ed2a1bf36..f355eb92358 100644 --- a/examples/compiled/time_custom_step.vg.json +++ b/examples/compiled/time_custom_step.vg.json @@ -40,9 +40,24 @@ "step": 5, "as": ["minutes_step_5_date", "minutes_step_5_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('minutes', datum['minutes_step_5_date'], -5) + 0.5 * datum['minutes_step_5_date']", + "as": "minutes_step_5_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['minutes_step_5_date'] + 0.5 * datum['minutes_step_5_date_end']", + "as": "minutes_step_5_date_offsetted_rect_end" + }, { "type": "aggregate", - "groupby": ["minutes_step_5_date", "minutes_step_5_date_end"], + "groupby": [ + "minutes_step_5_date", + "minutes_step_5_date_end", + "minutes_step_5_date_offsetted_rect_start", + "minutes_step_5_date_offsetted_rect_end" + ], "ops": ["sum"], "fields": ["distance"], "as": ["sum_distance"] @@ -69,14 +84,14 @@ }, "x2": { "scale": "x", - "field": "minutes_step_5_date", + "field": "minutes_step_5_date_offsetted_rect_start", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"minutes_step_5_date_end\"]) - scale(\"x\", datum[\"minutes_step_5_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"minutes_step_5_date_end\"]) - scale(\"x\", datum[\"minutes_step_5_date\"])))) : 0.5)" } }, "x": { "scale": "x", - "field": "minutes_step_5_date_end", + "field": "minutes_step_5_date_offsetted_rect_end", "offset": { "signal": "0.5 + (abs(scale(\"x\", datum[\"minutes_step_5_date_end\"]) - scale(\"x\", datum[\"minutes_step_5_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"minutes_step_5_date_end\"]) - scale(\"x\", datum[\"minutes_step_5_date\"])))) : -0.5)" } @@ -93,7 +108,10 @@ "type": "time", "domain": { "data": "data_0", - "fields": ["minutes_step_5_date", "minutes_step_5_date_end"] + "fields": [ + "minutes_step_5_date_offsetted_rect_start", + "minutes_step_5_date_offsetted_rect_end" + ] }, "range": [0, {"signal": "width"}] }, diff --git a/examples/compiled/time_parse_binnedutc.vg.json b/examples/compiled/time_parse_binnedutc.vg.json index 55dc8f7d78d..96fb9eecd63 100644 --- a/examples/compiled/time_parse_binnedutc.vg.json +++ b/examples/compiled/time_parse_binnedutc.vg.json @@ -18,6 +18,16 @@ "type": "formula", "expr": "utcOffset('hours', datum['date'], 1)", "as": "date_end" + }, + { + "type": "formula", + "expr": "0.5 * utcOffset('hours', datum['date'], -1) + 0.5 * datum['date']", + "as": "date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['date'] + 0.5 * datum['date_end']", + "as": "date_offsetted_rect_end" } ] } diff --git a/examples/compiled/vconcat_weather.vg.json b/examples/compiled/vconcat_weather.vg.json index 3db6ba2d6b6..c9e2c3b9e1b 100644 --- a/examples/compiled/vconcat_weather.vg.json +++ b/examples/compiled/vconcat_weather.vg.json @@ -20,6 +20,16 @@ "units": ["month"], "as": ["month_date", "month_date_end"] }, + { + "type": "formula", + "expr": "0.5 * timeOffset('month', datum['month_date'], -1) + 0.5 * datum['month_date']", + "as": "month_date_offsetted_rect_start" + }, + { + "type": "formula", + "expr": "0.5 * datum['month_date'] + 0.5 * datum['month_date_end']", + "as": "month_date_offsetted_rect_end" + }, { "type": "aggregate", "groupby": ["month_date"],