diff --git a/build/vega-lite-schema.json b/build/vega-lite-schema.json index 446bb1cd95..c99b9e876e 100644 --- a/build/vega-lite-schema.json +++ b/build/vega-lite-schema.json @@ -28308,6 +28308,11 @@ ], "description": "For text marks, the vertical text baseline. One of `\"alphabetic\"` (default), `\"top\"`, `\"middle\"`, `\"bottom\"`, `\"line-top\"`, `\"line-bottom\"`, or an expression reference that provides one of the valid values. The `\"line-top\"` and `\"line-bottom\"` values operate similarly to `\"top\"` and `\"bottom\"`, but are calculated relative to the `lineHeight` rather than `fontSize` alone.\n\nFor range marks, the vertical alignment of the marks. One of `\"top\"`, `\"middle\"`, `\"bottom\"`.\n\n__Note:__ Expression reference is *not* supported for range marks." }, + "binSpacing": { + "description": "Offset between bars for binned field. The ideal value for this is either 0 (preferred by statisticians) or 1 (Vega-Lite default, D3 example style).\n\n__Default value:__ `1`", + "minimum": 0, + "type": "number" + }, "blend": { "anyOf": [ { @@ -28333,6 +28338,11 @@ ], "description": "Default color.\n\n__Default value:__ `\"#4682b4\"`\n\n__Note:__\n- This property cannot be used in a [style config](https://vega.github.io/vega-lite/docs/mark.html#style-config).\n- The `fill` and `stroke` properties have higher precedence than `color` and will override `color`." }, + "continuousBandSize": { + "description": "The default size of the bars on continuous scales.\n\n__Default value:__ `5`", + "minimum": 0, + "type": "number" + }, "cornerRadius": { "anyOf": [ { @@ -28421,6 +28431,18 @@ } ] }, + "discreteBandSize": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/RelativeBandSize" + } + ], + "description": "The default size of the bars with discrete dimensions. If unspecified, the default size is `step-2`, which provides 2 pixel offset between bars.", + "minimum": 0 + }, "dx": { "anyOf": [ { @@ -28633,6 +28655,17 @@ } ] }, + "minBandSize": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "The minimum band size for bar and rectangle marks. __Default value:__ `0.25`" + }, "opacity": { "anyOf": [ { diff --git a/examples/compiled/bar_bullet_expr_bind.vg.json b/examples/compiled/bar_bullet_expr_bind.vg.json index c23e4af0f5..0259ad7d25 100644 --- a/examples/compiled/bar_bullet_expr_bind.vg.json +++ b/examples/compiled/bar_bullet_expr_bind.vg.json @@ -272,9 +272,9 @@ "description": { "signal": "\"markers[0]: \" + (format(datum[\"markers.0\"], \"\"))" }, - "xc": {"scale": "x", "field": "markers\\.0"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"signal": "height"}, + "xc": {"scale": "x", "field": "markers\\.0"}, "width": {"value": 2} } } diff --git a/examples/compiled/bar_tooltip_aggregate.vg.json b/examples/compiled/bar_tooltip_aggregate.vg.json index 3abf49fbc0..297d873921 100644 --- a/examples/compiled/bar_tooltip_aggregate.vg.json +++ b/examples/compiled/bar_tooltip_aggregate.vg.json @@ -40,8 +40,8 @@ "signal": "\"Mean of data: \" + (format(datum[\"mean_data\"], \"\"))" }, "xc": {"signal": "width", "mult": 0.5}, + "width": {"signal": "0.75 * width"}, "yc": {"scale": "y", "field": "mean_data"}, - "width": {"signal": "(1 - 0.25) * width"}, "height": {"value": 1} } } diff --git a/examples/compiled/bar_tooltip_groupby.vg.json b/examples/compiled/bar_tooltip_groupby.vg.json index 70a15cebcb..df04a69780 100644 --- a/examples/compiled/bar_tooltip_groupby.vg.json +++ b/examples/compiled/bar_tooltip_groupby.vg.json @@ -42,8 +42,8 @@ "signal": "\"Mean of data: \" + (format(datum[\"mean_data\"], \"\")) + \"; data: \" + (isValid(datum[\"data\"]) ? datum[\"data\"] : \"\"+datum[\"data\"])" }, "xc": {"signal": "width", "mult": 0.5}, + "width": {"signal": "0.75 * width"}, "yc": {"scale": "y", "field": "mean_data"}, - "width": {"signal": "(1 - 0.25) * width"}, "height": {"value": 1} } } diff --git a/examples/compiled/boxplot_1D_horizontal.vg.json b/examples/compiled/boxplot_1D_horizontal.vg.json index 989dcbfbf3..717f0f259f 100644 --- a/examples/compiled/boxplot_1D_horizontal.vg.json +++ b/examples/compiled/boxplot_1D_horizontal.vg.json @@ -229,9 +229,9 @@ "tooltip": { "signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\")}" }, - "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json b/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json index 6822bb72b3..776537f73c 100644 --- a/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json +++ b/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json @@ -211,9 +211,9 @@ "tooltip": { "signal": "{\"Upper Whisker of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Lower Whisker of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\")}" }, - "xc": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, - "height": {"signal": "(1 - 0.25) * height"}, + "height": {"signal": "0.75 * height"}, + "xc": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, "width": {"value": 1} } } @@ -231,9 +231,9 @@ "tooltip": { "signal": "{\"Upper Whisker of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Lower Whisker of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\")}" }, - "xc": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, - "height": {"signal": "(1 - 0.25) * height"}, + "height": {"signal": "0.75 * height"}, + "xc": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "width": {"value": 1} } } @@ -279,9 +279,9 @@ "tooltip": { "signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\")}" }, - "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_1D_horizontal_explicit.vg.json b/examples/compiled/boxplot_1D_horizontal_explicit.vg.json index 989dcbfbf3..717f0f259f 100644 --- a/examples/compiled/boxplot_1D_horizontal_explicit.vg.json +++ b/examples/compiled/boxplot_1D_horizontal_explicit.vg.json @@ -229,9 +229,9 @@ "tooltip": { "signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\")}" }, - "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_1D_invalid.vg.json b/examples/compiled/boxplot_1D_invalid.vg.json index cdaf4a8f35..ff84dca834 100644 --- a/examples/compiled/boxplot_1D_invalid.vg.json +++ b/examples/compiled/boxplot_1D_invalid.vg.json @@ -218,8 +218,8 @@ "signal": "{\"Max of b\": format(datum[\"max_b\"], \"\"), \"Q3 of b\": format(datum[\"upper_box_b\"], \"\"), \"Median of b\": format(datum[\"mid_box_b\"], \"\"), \"Q1 of b\": format(datum[\"lower_box_b\"], \"\"), \"Min of b\": format(datum[\"min_b\"], \"\"), \"a\": format(datum[\"a\"], \"\")}" }, "xc": {"scale": "x", "field": "a"}, - "yc": {"scale": "y", "field": "mid_box_b"}, "width": {"value": 14}, + "yc": {"scale": "y", "field": "mid_box_b"}, "height": {"value": 1} } } diff --git a/examples/compiled/boxplot_1D_vertical.vg.json b/examples/compiled/boxplot_1D_vertical.vg.json index 4e5ceedd6f..ae064d4290 100644 --- a/examples/compiled/boxplot_1D_vertical.vg.json +++ b/examples/compiled/boxplot_1D_vertical.vg.json @@ -230,8 +230,8 @@ "signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\")}" }, "xc": {"signal": "width", "mult": 0.5}, - "yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}, "width": {"value": 14}, + "yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}, "height": {"value": 1} } } diff --git a/examples/compiled/boxplot_2D_horizontal.vg.json b/examples/compiled/boxplot_2D_horizontal.vg.json index 5ae134dabb..eddb366808 100644 --- a/examples/compiled/boxplot_2D_horizontal.vg.json +++ b/examples/compiled/boxplot_2D_horizontal.vg.json @@ -232,9 +232,9 @@ "tooltip": { "signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_2D_horizontal_color_size.vg.json b/examples/compiled/boxplot_2D_horizontal_color_size.vg.json index 8bc85b5725..9b69f67750 100644 --- a/examples/compiled/boxplot_2D_horizontal_color_size.vg.json +++ b/examples/compiled/boxplot_2D_horizontal_color_size.vg.json @@ -232,9 +232,9 @@ "tooltip": { "signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 10}, + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_2D_vertical.vg.json b/examples/compiled/boxplot_2D_vertical.vg.json index 7dbbd0d072..c3e870d09d 100644 --- a/examples/compiled/boxplot_2D_vertical.vg.json +++ b/examples/compiled/boxplot_2D_vertical.vg.json @@ -234,8 +234,8 @@ "signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, "xc": {"scale": "x", "field": "Species", "band": 0.5}, - "yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}, "width": {"value": 14}, + "yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}, "height": {"value": 1} } } diff --git a/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json b/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json index 0ea2889ea3..aaf6d6723e 100644 --- a/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json +++ b/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json @@ -215,8 +215,8 @@ "signal": "{\"Max of b\": format(datum[\"max_b\"], \"\"), \"Q3 of b\": format(datum[\"upper_box_b\"], \"\"), \"Median of b\": format(datum[\"mid_box_b\"], \"\"), \"Q1 of b\": format(datum[\"lower_box_b\"], \"\"), \"Min of b\": format(datum[\"min_b\"], \"\"), \"a\": isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]}" }, "xc": {"scale": "x", "field": "a", "band": 0.5}, - "yc": {"scale": "y", "field": "mid_box_b"}, "width": {"value": 14}, + "yc": {"scale": "y", "field": "mid_box_b"}, "height": {"value": 1} } } diff --git a/examples/compiled/boxplot_2D_vertical_single_per_group_color.vg.json b/examples/compiled/boxplot_2D_vertical_single_per_group_color.vg.json index d1313bdca4..3d46d99a2e 100644 --- a/examples/compiled/boxplot_2D_vertical_single_per_group_color.vg.json +++ b/examples/compiled/boxplot_2D_vertical_single_per_group_color.vg.json @@ -216,8 +216,8 @@ "signal": "{\"Max of b\": format(datum[\"max_b\"], \"\"), \"Q3 of b\": format(datum[\"upper_box_b\"], \"\"), \"Median of b\": format(datum[\"mid_box_b\"], \"\"), \"Q1 of b\": format(datum[\"lower_box_b\"], \"\"), \"Min of b\": format(datum[\"min_b\"], \"\"), \"a\": isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]}" }, "xc": {"scale": "x", "field": "a", "band": 0.5}, - "yc": {"scale": "y", "field": "mid_box_b"}, "width": {"value": 14}, + "yc": {"scale": "y", "field": "mid_box_b"}, "height": {"value": 1} } } diff --git a/examples/compiled/boxplot_groupped.vg.json b/examples/compiled/boxplot_groupped.vg.json index 2b0b85159b..258c7b6518 100644 --- a/examples/compiled/boxplot_groupped.vg.json +++ b/examples/compiled/boxplot_groupped.vg.json @@ -256,8 +256,8 @@ "field": "Cylinders", "offset": {"scale": "xOffset", "field": "Origin", "band": 0.5} }, - "yc": {"scale": "y", "field": "mid_box_Acceleration"}, "width": {"value": 14}, + "yc": {"scale": "y", "field": "mid_box_Acceleration"}, "height": {"value": 1} } } diff --git a/examples/compiled/boxplot_minmax_2D_horizontal.vg.json b/examples/compiled/boxplot_minmax_2D_horizontal.vg.json index 1cfb790cf9..f156ed7608 100644 --- a/examples/compiled/boxplot_minmax_2D_horizontal.vg.json +++ b/examples/compiled/boxplot_minmax_2D_horizontal.vg.json @@ -155,9 +155,9 @@ "tooltip": { "signal": "{\"Max of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_minmax_2D_horizontal_custom_midtick_color.vg.json b/examples/compiled/boxplot_minmax_2D_horizontal_custom_midtick_color.vg.json index 3be74d5c6a..750d604ccc 100644 --- a/examples/compiled/boxplot_minmax_2D_horizontal_custom_midtick_color.vg.json +++ b/examples/compiled/boxplot_minmax_2D_horizontal_custom_midtick_color.vg.json @@ -155,9 +155,9 @@ "tooltip": { "signal": "{\"Max of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_minmax_2D_vertical.vg.json b/examples/compiled/boxplot_minmax_2D_vertical.vg.json index f8f5dfbde6..d430580c34 100644 --- a/examples/compiled/boxplot_minmax_2D_vertical.vg.json +++ b/examples/compiled/boxplot_minmax_2D_vertical.vg.json @@ -157,8 +157,8 @@ "signal": "{\"Max of Body Mass (g)\": format(datum[\"upper_whisker_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"lower_whisker_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, "xc": {"scale": "x", "field": "Species", "band": 0.5}, - "yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}, "width": {"value": 14}, + "yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}, "height": {"value": 1} } } diff --git a/examples/compiled/boxplot_preaggregated.vg.json b/examples/compiled/boxplot_preaggregated.vg.json index 90a007ded0..44d130665e 100644 --- a/examples/compiled/boxplot_preaggregated.vg.json +++ b/examples/compiled/boxplot_preaggregated.vg.json @@ -134,9 +134,9 @@ "description": { "signal": "\"median: \" + (format(datum[\"median\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"])" }, - "xc": {"scale": "x", "field": "median"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "median"}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_preaggregated_with_height.vg.json b/examples/compiled/boxplot_preaggregated_with_height.vg.json index efeea34c41..0a0839e155 100644 --- a/examples/compiled/boxplot_preaggregated_with_height.vg.json +++ b/examples/compiled/boxplot_preaggregated_with_height.vg.json @@ -131,9 +131,9 @@ "description": { "signal": "\"median: \" + (format(datum[\"median\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"])" }, + "y": {"scale": "y", "field": "Species"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "median"}, - "yc": {"scale": "y", "field": "Species", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_tooltip_aggregate.vg.json b/examples/compiled/boxplot_tooltip_aggregate.vg.json index f2597fbe5b..21dbd804b4 100644 --- a/examples/compiled/boxplot_tooltip_aggregate.vg.json +++ b/examples/compiled/boxplot_tooltip_aggregate.vg.json @@ -228,9 +228,9 @@ {"value": "white"} ], "tooltip": {"signal": "format(datum[\"mean_Body Mass (g)\"], \"\")"}, - "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "width": {"value": 1} } } diff --git a/examples/compiled/boxplot_tooltip_not_aggregate.vg.json b/examples/compiled/boxplot_tooltip_not_aggregate.vg.json index f845845978..8c5512a3ba 100644 --- a/examples/compiled/boxplot_tooltip_not_aggregate.vg.json +++ b/examples/compiled/boxplot_tooltip_not_aggregate.vg.json @@ -233,9 +233,9 @@ "tooltip": { "signal": "{\"Max of Body Mass (g)\": format(datum[\"max_Body Mass (g)\"], \"\"), \"Q3 of Body Mass (g)\": format(datum[\"upper_box_Body Mass (g)\"], \"\"), \"Median of Body Mass (g)\": format(datum[\"mid_box_Body Mass (g)\"], \"\"), \"Q1 of Body Mass (g)\": format(datum[\"lower_box_Body Mass (g)\"], \"\"), \"Min of Body Mass (g)\": format(datum[\"min_Body Mass (g)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "width": {"value": 1} } } diff --git a/examples/compiled/errorbar_2d_vertical_ticks.png b/examples/compiled/errorbar_2d_vertical_ticks.png index 78ad1fcbeb..447e5ae468 100644 Binary files a/examples/compiled/errorbar_2d_vertical_ticks.png and b/examples/compiled/errorbar_2d_vertical_ticks.png differ diff --git a/examples/compiled/errorbar_2d_vertical_ticks.svg b/examples/compiled/errorbar_2d_vertical_ticks.svg index f1d06c2fb4..2b8c767d59 100644 --- a/examples/compiled/errorbar_2d_vertical_ticks.svg +++ b/examples/compiled/errorbar_2d_vertical_ticks.svg @@ -1 +1 @@ -197019721974197619781980Year (year)1520253035Miles per Gallon (95% CIs) \ No newline at end of file +197019721974197619781980Year (year)1520253035Miles per Gallon (95% CIs) \ No newline at end of file diff --git a/examples/compiled/errorbar_2d_vertical_ticks.vg.json b/examples/compiled/errorbar_2d_vertical_ticks.vg.json index eb3bcf8ccd..2393cdd06d 100644 --- a/examples/compiled/errorbar_2d_vertical_ticks.vg.json +++ b/examples/compiled/errorbar_2d_vertical_ticks.vg.json @@ -70,8 +70,8 @@ "signal": "{\"Ci1 of Miles_per_Gallon\": format(datum[\"upper_Miles_per_Gallon\"], \"\"), \"Ci0 of Miles_per_Gallon\": format(datum[\"lower_Miles_per_Gallon\"], \"\"), \"Mean of Miles_per_Gallon\": format(datum[\"center_Miles_per_Gallon\"], \"\"), \"Year (year)\": timeFormat(datum[\"year_Year\"], '%b %d, %Y')}" }, "xc": {"scale": "x", "field": "year_Year"}, + "width": {"value": 5}, "yc": {"scale": "y", "field": "lower_Miles_per_Gallon"}, - "width": {"signal": "(1 - 0.25) * width"}, "height": {"value": 1} } } @@ -90,8 +90,8 @@ "signal": "{\"Ci1 of Miles_per_Gallon\": format(datum[\"upper_Miles_per_Gallon\"], \"\"), \"Ci0 of Miles_per_Gallon\": format(datum[\"lower_Miles_per_Gallon\"], \"\"), \"Mean of Miles_per_Gallon\": format(datum[\"center_Miles_per_Gallon\"], \"\"), \"Year (year)\": timeFormat(datum[\"year_Year\"], '%b %d, %Y')}" }, "xc": {"scale": "x", "field": "year_Year"}, + "width": {"value": 5}, "yc": {"scale": "y", "field": "upper_Miles_per_Gallon"}, - "width": {"signal": "(1 - 0.25) * width"}, "height": {"value": 1} } } diff --git a/examples/compiled/errorbar_aggregate.vg.json b/examples/compiled/errorbar_aggregate.vg.json index 70df548211..ccae78530c 100644 --- a/examples/compiled/errorbar_aggregate.vg.json +++ b/examples/compiled/errorbar_aggregate.vg.json @@ -87,8 +87,8 @@ "signal": "\"age: \" + (isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]) + \"; population: \" + (format(datum[\"min_people\"], \"\"))" }, "xc": {"scale": "x", "field": "age", "band": 0.5}, - "yc": {"scale": "y", "field": "min_people"}, "width": {"value": 5}, + "yc": {"scale": "y", "field": "min_people"}, "height": {"value": 1} } } @@ -106,8 +106,8 @@ "signal": "\"age: \" + (isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]) + \"; population: \" + (format(datum[\"max_people\"], \"\"))" }, "xc": {"scale": "x", "field": "age", "band": 0.5}, - "yc": {"scale": "y", "field": "max_people"}, "width": {"value": 5}, + "yc": {"scale": "y", "field": "max_people"}, "height": {"value": 1} } } diff --git a/examples/compiled/errorbar_horizontal_aggregate.vg.json b/examples/compiled/errorbar_horizontal_aggregate.vg.json index e1c5a726d4..435e28acd1 100644 --- a/examples/compiled/errorbar_horizontal_aggregate.vg.json +++ b/examples/compiled/errorbar_horizontal_aggregate.vg.json @@ -86,9 +86,9 @@ "description": { "signal": "\"population: \" + (format(datum[\"min_people\"], \"\")) + \"; age: \" + (isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"])" }, - "xc": {"scale": "x", "field": "min_people"}, "yc": {"scale": "y", "field": "age", "band": 0.5}, "height": {"value": 5}, + "xc": {"scale": "x", "field": "min_people"}, "width": {"value": 1} } } @@ -105,9 +105,9 @@ "description": { "signal": "\"population: \" + (format(datum[\"max_people\"], \"\")) + \"; age: \" + (isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"])" }, - "xc": {"scale": "x", "field": "max_people"}, "yc": {"scale": "y", "field": "age", "band": 0.5}, "height": {"value": 5}, + "xc": {"scale": "x", "field": "max_people"}, "width": {"value": 1} } } diff --git a/examples/compiled/facet_bullet.vg.json b/examples/compiled/facet_bullet.vg.json index 353bcc5a24..65588214e4 100644 --- a/examples/compiled/facet_bullet.vg.json +++ b/examples/compiled/facet_bullet.vg.json @@ -437,9 +437,9 @@ "description": { "signal": "\"markers[0]: \" + (format(datum[\"markers.0\"], \"\"))" }, - "xc": {"scale": "child_x", "field": "markers\\.0"}, "yc": {"signal": "child_height", "mult": 0.5}, - "height": {"signal": "(1 - 0.25) * child_height"}, + "height": {"signal": "0.75 * height"}, + "xc": {"scale": "child_x", "field": "markers\\.0"}, "width": {"value": 2} } } diff --git a/examples/compiled/joinaggregate_mean_difference_by_year.vg.json b/examples/compiled/joinaggregate_mean_difference_by_year.vg.json index f43bf72226..58e59fc211 100644 --- a/examples/compiled/joinaggregate_mean_difference_by_year.vg.json +++ b/examples/compiled/joinaggregate_mean_difference_by_year.vg.json @@ -101,9 +101,9 @@ "description": { "signal": "\"AverageYearRating: \" + (format(datum[\"AverageYearRating\"], \"\")) + \"; Title: \" + (isValid(datum[\"Title\"]) ? datum[\"Title\"] : \"\"+datum[\"Title\"])" }, + "y": {"scale": "y", "field": "Title"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "AverageYearRating"}, - "yc": {"scale": "y", "field": "Title", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } diff --git a/examples/compiled/layer_bar_tick_datum_grouped.vg.json b/examples/compiled/layer_bar_tick_datum_grouped.vg.json index ec3051af03..1c3aa693d4 100644 --- a/examples/compiled/layer_bar_tick_datum_grouped.vg.json +++ b/examples/compiled/layer_bar_tick_datum_grouped.vg.json @@ -72,13 +72,13 @@ "description": { "signal": "\"Cylinders: \" + (isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"]) + \"; Origin: \" + (isValid(datum[\"Origin\"]) ? datum[\"Origin\"] : \"\"+datum[\"Origin\"])" }, - "xc": { + "x": { "scale": "x", "field": "Cylinders", - "offset": {"scale": "xOffset", "field": "Origin", "band": 0.5} + "offset": {"scale": "xOffset", "field": "Origin"} }, + "width": {"signal": "max(0.25, bandwidth('xOffset'))"}, "yc": {"scale": "y", "value": 10}, - "width": {"scale": "xOffset", "band": 1}, "height": {"value": 1} } } diff --git a/examples/compiled/layer_boxplot_circle.vg.json b/examples/compiled/layer_boxplot_circle.vg.json index 3186d3f671..96d93c3eb2 100644 --- a/examples/compiled/layer_boxplot_circle.vg.json +++ b/examples/compiled/layer_boxplot_circle.vg.json @@ -197,9 +197,9 @@ "tooltip": { "signal": "{\"Max of population\": format(datum[\"max_people\"], \"\"), \"Q3 of population\": format(datum[\"upper_box_people\"], \"\"), \"Median of population\": format(datum[\"mid_box_people\"], \"\"), \"Q1 of population\": format(datum[\"lower_box_people\"], \"\"), \"Min of population\": format(datum[\"min_people\"], \"\"), \"age\": isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]}" }, - "xc": {"scale": "x", "field": "mid_box_people"}, "yc": {"scale": "y", "field": "age", "band": 0.5}, "height": {"value": 14}, + "xc": {"scale": "x", "field": "mid_box_people"}, "width": {"value": 1} } } diff --git a/examples/compiled/layer_likert.vg.json b/examples/compiled/layer_likert.vg.json index b7e6cbdd80..37e697f5e8 100644 --- a/examples/compiled/layer_likert.vg.json +++ b/examples/compiled/layer_likert.vg.json @@ -290,9 +290,9 @@ "description": { "signal": "\"median: \" + (format(datum[\"median\"], \"\")) + \"; name: \" + (isValid(datum[\"name\"]) ? datum[\"name\"] : \"\"+datum[\"name\"])" }, + "y": {"scale": "y", "field": "name"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "median"}, - "yc": {"scale": "y", "field": "name", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } diff --git a/examples/compiled/layer_point_errorbar_2d_horizontal_color_encoding.vg.json b/examples/compiled/layer_point_errorbar_2d_horizontal_color_encoding.vg.json index 812201fc09..443e0c3f29 100644 --- a/examples/compiled/layer_point_errorbar_2d_horizontal_color_encoding.vg.json +++ b/examples/compiled/layer_point_errorbar_2d_horizontal_color_encoding.vg.json @@ -87,9 +87,9 @@ "tooltip": { "signal": "{\"Mean of yield\": format(datum[\"center_yield\"], \"\"), \"Mean + stderr of yield\": format(datum[\"upper_yield\"], \"\"), \"Mean - stderr of yield\": format(datum[\"lower_yield\"], \"\"), \"variety\": isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"]}" }, + "y": {"scale": "y", "field": "variety"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "lower_yield"}, - "yc": {"scale": "y", "field": "variety", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } @@ -107,9 +107,9 @@ "tooltip": { "signal": "{\"Mean of yield\": format(datum[\"center_yield\"], \"\"), \"Mean + stderr of yield\": format(datum[\"upper_yield\"], \"\"), \"Mean - stderr of yield\": format(datum[\"lower_yield\"], \"\"), \"variety\": isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"]}" }, + "y": {"scale": "y", "field": "variety"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "upper_yield"}, - "yc": {"scale": "y", "field": "variety", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } diff --git a/examples/compiled/layer_point_errorbar_2d_horizontal_custom_ticks.vg.json b/examples/compiled/layer_point_errorbar_2d_horizontal_custom_ticks.vg.json index a81a866b7b..77a39ccee1 100644 --- a/examples/compiled/layer_point_errorbar_2d_horizontal_custom_ticks.vg.json +++ b/examples/compiled/layer_point_errorbar_2d_horizontal_custom_ticks.vg.json @@ -87,9 +87,9 @@ "tooltip": { "signal": "{\"Mean of yield\": format(datum[\"center_yield\"], \"\"), \"Mean + stderr of yield\": format(datum[\"upper_yield\"], \"\"), \"Mean - stderr of yield\": format(datum[\"lower_yield\"], \"\"), \"variety\": isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"]}" }, + "y": {"scale": "y", "field": "variety"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "lower_yield"}, - "yc": {"scale": "y", "field": "variety", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } @@ -107,9 +107,9 @@ "tooltip": { "signal": "{\"Mean of yield\": format(datum[\"center_yield\"], \"\"), \"Mean + stderr of yield\": format(datum[\"upper_yield\"], \"\"), \"Mean - stderr of yield\": format(datum[\"lower_yield\"], \"\"), \"variety\": isValid(datum[\"variety\"]) ? datum[\"variety\"] : \"\"+datum[\"variety\"]}" }, + "y": {"scale": "y", "field": "variety"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "upper_yield"}, - "yc": {"scale": "y", "field": "variety", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } diff --git a/examples/compiled/parallel_coordinate.vg.json b/examples/compiled/parallel_coordinate.vg.json index 35d0cb7a13..eecad0aedc 100644 --- a/examples/compiled/parallel_coordinate.vg.json +++ b/examples/compiled/parallel_coordinate.vg.json @@ -152,8 +152,8 @@ "signal": "\"key: \" + (isValid(datum[\"key\"]) ? datum[\"key\"] : \"\"+datum[\"key\"])" }, "xc": {"scale": "x", "field": "key", "band": 0.5}, - "yc": {"value": 0}, "width": {"value": 8}, + "yc": {"value": 0}, "height": {"value": 1} } } @@ -189,8 +189,8 @@ "signal": "\"key: \" + (isValid(datum[\"key\"]) ? datum[\"key\"] : \"\"+datum[\"key\"])" }, "xc": {"scale": "x", "field": "key", "band": 0.5}, - "yc": {"value": 150}, "width": {"value": 8}, + "yc": {"value": 150}, "height": {"value": 1} } } @@ -226,8 +226,8 @@ "signal": "\"key: \" + (isValid(datum[\"key\"]) ? datum[\"key\"] : \"\"+datum[\"key\"])" }, "xc": {"scale": "x", "field": "key", "band": 0.5}, - "yc": {"value": 300}, "width": {"value": 8}, + "yc": {"value": 300}, "height": {"value": 1} } } diff --git a/examples/compiled/tick_dot.vg.json b/examples/compiled/tick_dot.vg.json index 1ee300c2df..74f5b585e5 100644 --- a/examples/compiled/tick_dot.vg.json +++ b/examples/compiled/tick_dot.vg.json @@ -32,9 +32,9 @@ "description": { "signal": "\"precipitation: \" + (format(datum[\"precipitation\"], \"\"))" }, - "xc": {"scale": "x", "field": "precipitation"}, "yc": {"signal": "height", "mult": 0.5}, - "height": {"signal": "(1 - 0.25) * height"}, + "height": {"signal": "0.75 * height"}, + "xc": {"scale": "x", "field": "precipitation"}, "width": {"value": 1} } } diff --git a/examples/compiled/tick_dot_thickness.png b/examples/compiled/tick_dot_thickness.png index ee3030636e..bcf665cfb1 100644 Binary files a/examples/compiled/tick_dot_thickness.png and b/examples/compiled/tick_dot_thickness.png differ diff --git a/examples/compiled/tick_dot_thickness.svg b/examples/compiled/tick_dot_thickness.svg index 676fc14a39..50ad2b9ddb 100644 --- a/examples/compiled/tick_dot_thickness.svg +++ b/examples/compiled/tick_dot_thickness.svg @@ -1 +1 @@ -050100150200Horsepower \ No newline at end of file +050100150200Horsepower \ No newline at end of file diff --git a/examples/compiled/tick_dot_thickness.vg.json b/examples/compiled/tick_dot_thickness.vg.json index 962912839c..9c6fe9d8f7 100644 --- a/examples/compiled/tick_dot_thickness.vg.json +++ b/examples/compiled/tick_dot_thickness.vg.json @@ -32,9 +32,9 @@ "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\"))" }, - "xc": {"scale": "x", "field": "Horsepower"}, "yc": {"signal": "height", "mult": 0.5}, - "height": {"value": 10}, + "height": {"signal": "0.75 * height"}, + "xc": {"scale": "x", "field": "Horsepower"}, "width": {"value": 2} } } diff --git a/examples/compiled/tick_grouped.vg.json b/examples/compiled/tick_grouped.vg.json index 883742b42b..28a1a3ec34 100644 --- a/examples/compiled/tick_grouped.vg.json +++ b/examples/compiled/tick_grouped.vg.json @@ -54,13 +54,13 @@ "description": { "signal": "\"category: \" + (isValid(datum[\"category\"]) ? datum[\"category\"] : \"\"+datum[\"category\"]) + \"; value: \" + (format(datum[\"value\"], \"\")) + \"; group: \" + (isValid(datum[\"group\"]) ? datum[\"group\"] : \"\"+datum[\"group\"])" }, - "xc": { + "x": { "scale": "x", "field": "category", - "offset": {"scale": "xOffset", "field": "group", "band": 0.5} + "offset": {"scale": "xOffset", "field": "group"} }, + "width": {"signal": "max(0.25, bandwidth('xOffset'))"}, "yc": {"scale": "y", "field": "value"}, - "width": {"scale": "xOffset", "band": 1}, "height": {"value": 1} } } diff --git a/examples/compiled/tick_histogram.png b/examples/compiled/tick_histogram.png new file mode 100644 index 0000000000..5499896975 Binary files /dev/null and b/examples/compiled/tick_histogram.png differ diff --git a/examples/compiled/tick_histogram.svg b/examples/compiled/tick_histogram.svg new file mode 100644 index 0000000000..51900ac013 --- /dev/null +++ b/examples/compiled/tick_histogram.svg @@ -0,0 +1 @@ +1.02.03.04.05.06.07.08.09.010.0IMDB Rating (binned)02004006008001,000Count of Records \ No newline at end of file diff --git a/examples/compiled/tick_histogram.vg.json b/examples/compiled/tick_histogram.vg.json new file mode 100644 index 0000000000..5445b26d48 --- /dev/null +++ b/examples/compiled/tick_histogram.vg.json @@ -0,0 +1,135 @@ +{ + "$schema": "https://vega.github.io/schema/vega/v5.json", + "background": "white", + "padding": 5, + "width": 200, + "height": 200, + "style": "cell", + "data": [ + { + "name": "source_0", + "url": "data/movies.json", + "format": {"type": "json"}, + "transform": [ + { + "type": "extent", + "field": "IMDB Rating", + "signal": "bin_maxbins_10_IMDB_Rating_extent" + }, + { + "type": "bin", + "field": "IMDB Rating", + "as": [ + "bin_maxbins_10_IMDB Rating", + "bin_maxbins_10_IMDB Rating_end" + ], + "signal": "bin_maxbins_10_IMDB_Rating_bins", + "extent": {"signal": "bin_maxbins_10_IMDB_Rating_extent"}, + "maxbins": 10 + }, + { + "type": "aggregate", + "groupby": [ + "bin_maxbins_10_IMDB Rating", + "bin_maxbins_10_IMDB Rating_end" + ], + "ops": ["count"], + "fields": [null], + "as": ["__count"] + }, + { + "type": "filter", + "expr": "isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) && isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"])" + } + ] + } + ], + "marks": [ + { + "name": "marks", + "type": "rect", + "style": ["tick"], + "from": {"data": "source_0"}, + "encode": { + "update": { + "fill": {"value": "#4c78a8"}, + "ariaRoleDescription": {"value": "tick"}, + "description": { + "signal": "\"IMDB Rating (binned): \" + (!isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"null\" : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\")) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\"))" + }, + "x2": { + "scale": "x", + "field": "bin_maxbins_10_IMDB Rating", + "offset": { + "signal": "0.5 + (abs(scale(\"x\", datum[\"bin_maxbins_10_IMDB Rating_end\"]) - scale(\"x\", datum[\"bin_maxbins_10_IMDB Rating\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"bin_maxbins_10_IMDB Rating_end\"]) - scale(\"x\", datum[\"bin_maxbins_10_IMDB Rating\"])))) : 0)" + } + }, + "x": { + "scale": "x", + "field": "bin_maxbins_10_IMDB Rating_end", + "offset": { + "signal": "0.5 + (abs(scale(\"x\", datum[\"bin_maxbins_10_IMDB Rating_end\"]) - scale(\"x\", datum[\"bin_maxbins_10_IMDB Rating\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"bin_maxbins_10_IMDB Rating_end\"]) - scale(\"x\", datum[\"bin_maxbins_10_IMDB Rating\"])))) : 0)" + } + }, + "yc": {"scale": "y", "field": "__count"}, + "height": {"value": 1} + } + } + } + ], + "scales": [ + { + "name": "x", + "type": "linear", + "domain": { + "signal": "[bin_maxbins_10_IMDB_Rating_bins.start, bin_maxbins_10_IMDB_Rating_bins.stop]" + }, + "range": [0, {"signal": "width"}], + "bins": {"signal": "bin_maxbins_10_IMDB_Rating_bins"}, + "zero": false + }, + { + "name": "y", + "type": "linear", + "domain": {"data": "source_0", "field": "__count"}, + "range": [{"signal": "height"}, 0], + "nice": true, + "zero": true + } + ], + "axes": [ + { + "scale": "y", + "orient": "left", + "gridScale": "x", + "grid": true, + "tickCount": {"signal": "ceil(height/40)"}, + "domain": false, + "labels": false, + "aria": false, + "maxExtent": 0, + "minExtent": 0, + "ticks": false, + "zindex": 0 + }, + { + "scale": "x", + "orient": "bottom", + "grid": false, + "title": "IMDB Rating (binned)", + "labelFlush": true, + "labelOverlap": true, + "tickCount": {"signal": "ceil(width/10)"}, + "zindex": 0 + }, + { + "scale": "y", + "orient": "left", + "grid": false, + "title": "Count of Records", + "labelOverlap": true, + "tickCount": {"signal": "ceil(height/40)"}, + "zindex": 0 + } + ] +} diff --git a/examples/compiled/tick_sort.vg.json b/examples/compiled/tick_sort.vg.json index 05a2fd5cfb..6ef43bf036 100644 --- a/examples/compiled/tick_sort.vg.json +++ b/examples/compiled/tick_sort.vg.json @@ -32,9 +32,9 @@ "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\"))" }, - "xc": {"scale": "x", "field": "Horsepower"}, "yc": {"signal": "height", "mult": 0.5}, - "height": {"signal": "(1 - 0.25) * height"}, + "height": {"signal": "0.75 * height"}, + "xc": {"scale": "x", "field": "Horsepower"}, "width": {"value": 1} } } diff --git a/examples/compiled/tick_strip.vg.json b/examples/compiled/tick_strip.vg.json index 30898730b9..5ec3cdd7a6 100644 --- a/examples/compiled/tick_strip.vg.json +++ b/examples/compiled/tick_strip.vg.json @@ -39,9 +39,9 @@ "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Cylinders: \" + (isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"])" }, + "y": {"scale": "y", "field": "Cylinders"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "Horsepower"}, - "yc": {"scale": "y", "field": "Cylinders", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } diff --git a/examples/compiled/tick_strip_1D_with_height.vg.json b/examples/compiled/tick_strip_1D_with_height.vg.json index 921930cb87..bb9bc5ad61 100644 --- a/examples/compiled/tick_strip_1D_with_height.vg.json +++ b/examples/compiled/tick_strip_1D_with_height.vg.json @@ -32,9 +32,9 @@ "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\"))" }, - "xc": {"scale": "x", "field": "Horsepower"}, "yc": {"signal": "height", "mult": 0.5}, - "height": {"signal": "(1 - 0.25) * height"}, + "height": {"signal": "0.75 * height"}, + "xc": {"scale": "x", "field": "Horsepower"}, "width": {"value": 1} } } diff --git a/examples/compiled/tick_strip_tick_band.vg.json b/examples/compiled/tick_strip_tick_band.vg.json index 03f8c606a8..a9683dd1ca 100644 --- a/examples/compiled/tick_strip_tick_band.vg.json +++ b/examples/compiled/tick_strip_tick_band.vg.json @@ -38,9 +38,9 @@ "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Cylinders: \" + (isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"])" }, + "y": {"scale": "y", "field": "Cylinders"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "Horsepower"}, - "yc": {"scale": "y", "field": "Cylinders", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } diff --git a/examples/compiled/tick_strip_with_height.vg.json b/examples/compiled/tick_strip_with_height.vg.json index 4991e6d247..9d4e96fbfa 100644 --- a/examples/compiled/tick_strip_with_height.vg.json +++ b/examples/compiled/tick_strip_with_height.vg.json @@ -33,9 +33,9 @@ "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Cylinders: \" + (isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"])" }, + "y": {"scale": "y", "field": "Cylinders"}, + "height": {"signal": "max(0.25, bandwidth('y'))"}, "xc": {"scale": "x", "field": "Horsepower"}, - "yc": {"scale": "y", "field": "Cylinders", "band": 0.5}, - "height": {"scale": "y", "band": 1}, "width": {"value": 1} } } diff --git a/examples/compiled/tick_timeunit.png b/examples/compiled/tick_timeunit.png new file mode 100644 index 0000000000..e0a4e8e498 Binary files /dev/null and b/examples/compiled/tick_timeunit.png differ diff --git a/examples/compiled/tick_timeunit.svg b/examples/compiled/tick_timeunit.svg new file mode 100644 index 0000000000..efd48ab69e --- /dev/null +++ b/examples/compiled/tick_timeunit.svg @@ -0,0 +1 @@ +20042005200620072008200920102011date (year)01,0002,0003,0004,0005,0006,0007,000Sum of price \ No newline at end of file diff --git a/examples/compiled/tick_timeunit.vg.json b/examples/compiled/tick_timeunit.vg.json new file mode 100644 index 0000000000..2120d002ad --- /dev/null +++ b/examples/compiled/tick_timeunit.vg.json @@ -0,0 +1,143 @@ +{ + "$schema": "https://vega.github.io/schema/vega/v5.json", + "description": "Google's stock price over time.", + "background": "white", + "padding": 5, + "width": 200, + "height": 200, + "style": "cell", + "data": [ + { + "name": "source_0", + "url": "data/stocks.csv", + "format": {"type": "csv", "parse": {"date": "date"}}, + "transform": [ + {"type": "filter", "expr": "datum.symbol==='GOOG'"}, + { + "field": "date", + "type": "timeunit", + "units": ["year"], + "as": ["year_date", "year_date_end"] + }, + { + "type": "aggregate", + "groupby": ["year_date", "year_date_end"], + "ops": ["sum"], + "fields": ["price"], + "as": ["sum_price"] + }, + { + "type": "filter", + "expr": "(isDate(datum[\"year_date\"]) || (isValid(datum[\"year_date\"]) && isFinite(+datum[\"year_date\"]))) && isValid(datum[\"sum_price\"]) && isFinite(+datum[\"sum_price\"])" + } + ] + } + ], + "marks": [ + { + "name": "marks", + "type": "rect", + "style": ["tick"], + "from": {"data": "source_0"}, + "encode": { + "update": { + "fill": {"value": "#4c78a8"}, + "ariaRoleDescription": {"value": "tick"}, + "description": { + "signal": "\"date (year): \" + (timeFormat(datum[\"year_date\"], timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; Sum of price: \" + (format(datum[\"sum_price\"], \"\"))" + }, + "x2": { + "scale": "x", + "field": "year_date", + "offset": { + "signal": "0.5 + (abs(scale(\"x\", datum[\"year_date_end\"]) - scale(\"x\", datum[\"year_date\"])) < 0.25 ? -0.5 * (0.25 - (abs(scale(\"x\", datum[\"year_date_end\"]) - scale(\"x\", datum[\"year_date\"])))) : 0)" + } + }, + "x": { + "scale": "x", + "field": "year_date_end", + "offset": { + "signal": "0.5 + (abs(scale(\"x\", datum[\"year_date_end\"]) - scale(\"x\", datum[\"year_date\"])) < 0.25 ? 0.5 * (0.25 - (abs(scale(\"x\", datum[\"year_date_end\"]) - scale(\"x\", datum[\"year_date\"])))) : 0)" + } + }, + "yc": {"scale": "y", "field": "sum_price"}, + "height": {"value": 1} + } + } + } + ], + "scales": [ + { + "name": "x", + "type": "time", + "domain": {"data": "source_0", "fields": ["year_date", "year_date_end"]}, + "range": [0, {"signal": "width"}] + }, + { + "name": "y", + "type": "linear", + "domain": {"data": "source_0", "field": "sum_price"}, + "range": [{"signal": "height"}, 0], + "nice": true, + "zero": true + } + ], + "axes": [ + { + "scale": "x", + "orient": "bottom", + "gridScale": "y", + "grid": true, + "tickCount": {"signal": "ceil(width/40)"}, + "tickMinStep": { + "signal": "datetime(2002, 0, 1, 0, 0, 0, 0) - datetime(2001, 0, 1, 0, 0, 0, 0)" + }, + "domain": false, + "labels": false, + "aria": false, + "maxExtent": 0, + "minExtent": 0, + "ticks": false, + "zindex": 0 + }, + { + "scale": "y", + "orient": "left", + "gridScale": "x", + "grid": true, + "tickCount": {"signal": "ceil(height/40)"}, + "domain": false, + "labels": false, + "aria": false, + "maxExtent": 0, + "minExtent": 0, + "ticks": false, + "zindex": 0 + }, + { + "scale": "x", + "orient": "bottom", + "grid": false, + "title": "date (year)", + "format": { + "signal": "timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})" + }, + "labelFlush": true, + "labelOverlap": true, + "tickCount": {"signal": "ceil(width/40)"}, + "tickMinStep": { + "signal": "datetime(2002, 0, 1, 0, 0, 0, 0) - datetime(2001, 0, 1, 0, 0, 0, 0)" + }, + "zindex": 0 + }, + { + "scale": "y", + "orient": "left", + "grid": false, + "title": "Sum of price", + "labelOverlap": true, + "tickCount": {"signal": "ceil(height/40)"}, + "zindex": 0 + } + ] +} diff --git a/examples/compiled/tick_width_band.png b/examples/compiled/tick_width_band.png new file mode 100644 index 0000000000..731903b4bf Binary files /dev/null and b/examples/compiled/tick_width_band.png differ diff --git a/examples/compiled/tick_width_band.svg b/examples/compiled/tick_width_band.svg new file mode 100644 index 0000000000..7254e1955c --- /dev/null +++ b/examples/compiled/tick_width_band.svg @@ -0,0 +1 @@ +ABCDEFGHIa020406080100b \ No newline at end of file diff --git a/examples/compiled/tick_width_band.vg.json b/examples/compiled/tick_width_band.vg.json new file mode 100644 index 0000000000..82ab7c4dab --- /dev/null +++ b/examples/compiled/tick_width_band.vg.json @@ -0,0 +1,115 @@ +{ + "$schema": "https://vega.github.io/schema/vega/v5.json", + "description": "A simple bar chart with embedded data.", + "background": "white", + "padding": 5, + "height": 200, + "style": "cell", + "data": [ + { + "name": "source_0", + "values": [ + {"a": "A", "b": 28}, + {"a": "B", "b": 55}, + {"a": "C", "b": 43}, + {"a": "D", "b": 91}, + {"a": "E", "b": 81}, + {"a": "F", "b": 53}, + {"a": "G", "b": 19}, + {"a": "H", "b": 87}, + {"a": "I", "b": 52} + ] + }, + { + "name": "data_0", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"b\"]) && isFinite(+datum[\"b\"])" + } + ] + } + ], + "signals": [ + {"name": "x_step", "value": 50}, + { + "name": "width", + "update": "bandspace(domain('x').length, 0.25, 0.125) * x_step" + } + ], + "marks": [ + { + "name": "marks", + "type": "rect", + "style": ["tick"], + "from": {"data": "data_0"}, + "encode": { + "update": { + "opacity": {"value": 0.7}, + "fill": {"value": "#4c78a8"}, + "ariaRoleDescription": {"value": "tick"}, + "description": { + "signal": "\"a: \" + (isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]) + \"; b: \" + (format(datum[\"b\"], \"\"))" + }, + "x": {"scale": "x", "field": "a", "band": 0.25}, + "width": {"signal": "max(0.25, 0.5 * bandwidth('x'))"}, + "yc": {"scale": "y", "field": "b"}, + "height": {"value": 1} + } + } + } + ], + "scales": [ + { + "name": "x", + "type": "band", + "domain": {"data": "data_0", "field": "a", "sort": true}, + "range": {"step": {"signal": "x_step"}}, + "paddingInner": 0.25, + "paddingOuter": 0.125 + }, + { + "name": "y", + "type": "linear", + "domain": {"data": "data_0", "field": "b"}, + "range": [{"signal": "height"}, 0], + "nice": true, + "zero": true + } + ], + "axes": [ + { + "scale": "y", + "orient": "left", + "gridScale": "x", + "grid": true, + "tickCount": {"signal": "ceil(height/40)"}, + "domain": false, + "labels": false, + "aria": false, + "maxExtent": 0, + "minExtent": 0, + "ticks": false, + "zindex": 0 + }, + { + "scale": "x", + "orient": "bottom", + "grid": false, + "title": "a", + "labelAngle": 0, + "labelBaseline": "top", + "zindex": 0 + }, + { + "scale": "y", + "orient": "left", + "grid": false, + "title": "b", + "labelOverlap": true, + "tickCount": {"signal": "ceil(height/40)"}, + "zindex": 0 + } + ] +} diff --git a/examples/specs/tick_histogram.vl.json b/examples/specs/tick_histogram.vl.json new file mode 100644 index 0000000000..6dcde28932 --- /dev/null +++ b/examples/specs/tick_histogram.vl.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", + "data": {"url": "data/movies.json"}, + "mark": "tick", + "encoding": { + "x": { + "bin": true, + "field": "IMDB Rating" + }, + "y": {"aggregate": "count"} + } +} diff --git a/examples/specs/tick_timeunit.vl.json b/examples/specs/tick_timeunit.vl.json new file mode 100644 index 0000000000..6cb3a7d92d --- /dev/null +++ b/examples/specs/tick_timeunit.vl.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", + "description": "Google's stock price over time.", + "data": {"url": "data/stocks.csv"}, + "transform": [{"filter": "datum.symbol==='GOOG'"}], + "mark": "tick", + "encoding": { + "x": {"timeUnit": "year", "field": "date", "type": "temporal"}, + "y": {"aggregate": "sum", "field": "price", "type": "quantitative"} + } +} diff --git a/examples/specs/tick_width_band.vl.json b/examples/specs/tick_width_band.vl.json new file mode 100644 index 0000000000..6b9500197a --- /dev/null +++ b/examples/specs/tick_width_band.vl.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", + "description": "A simple bar chart with embedded data.", + "data": { + "values": [ + {"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43}, + {"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53}, + {"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52} + ] + }, + "width": {"step": 50}, + "mark": {"type": "tick", "width": {"band": 0.5}}, + "encoding": { + "x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}}, + "y": {"field": "b", "type": "quantitative"} + } +} diff --git a/src/compile/mark/encode/position-rect.ts b/src/compile/mark/encode/position-rect.ts index 05bd00bdc2..9b2e131140 100644 --- a/src/compile/mark/encode/position-rect.ts +++ b/src/compile/mark/encode/position-rect.ts @@ -52,7 +52,9 @@ export function rectPosition(model: UnitModel, channel: 'x' | 'y' | 'theta' | 'r const offsetScaleChannel = getOffsetChannel(channel); - const isBarBand = mark === 'bar' && (channel === 'x' ? orient === 'vertical' : orient === 'horizontal'); + const isBarOrTickBand = + (mark === 'bar' && (channel === 'x' ? orient === 'vertical' : orient === 'horizontal')) || + (mark === 'tick' && (channel === 'y' ? orient === 'vertical' : orient === 'horizontal')); // x, x2, and width -- we must specify two of these in all conditions if ( @@ -68,7 +70,7 @@ export function rectPosition(model: UnitModel, channel: 'x' | 'y' | 'theta' | 'r channel, model }); - } else if (((isFieldOrDatumDef(channelDef) && hasDiscreteDomain(scaleType)) || isBarBand) && !channelDef2) { + } else if (((isFieldOrDatumDef(channelDef) && hasDiscreteDomain(scaleType)) || isBarOrTickBand) && !channelDef2) { return positionAndSize(channelDef, channel, model); } else { return rangePosition(channel, model, {defaultPos: 'zeroOrMax', defaultPos2: 'zeroOrMin'}); @@ -118,8 +120,11 @@ function defaultSizeRef( } } if (!hasFieldDef) { - const {bandPaddingInner, barBandPaddingInner, rectBandPaddingInner} = config.scale; - const padding = getFirstDefined(bandPaddingInner, mark === 'bar' ? barBandPaddingInner : rectBandPaddingInner); // this part is like paddingInner in scale.ts + const {bandPaddingInner, barBandPaddingInner, rectBandPaddingInner, tickBandPaddingInner} = config.scale; + const padding = getFirstDefined( + bandPaddingInner, + mark === 'tick' ? tickBandPaddingInner : mark === 'bar' ? barBandPaddingInner : rectBandPaddingInner + ); // this part is like paddingInner in scale.ts if (isSignalRef(padding)) { return {signal: `(1 - (${padding.signal})) * ${sizeChannel}`}; } else if (isNumber(padding)) { @@ -150,8 +155,12 @@ function positionAndSize( const offsetScaleName = model.scaleName(offsetScaleChannel); const offsetScale = model.getScaleComponent(getOffsetScaleChannel(channel)); - // use "size" channel for bars, if there is orient and the channel matches the right orientation - const useVlSizeChannel = (orient === 'horizontal' && channel === 'y') || (orient === 'vertical' && channel === 'x'); + const useVlSizeChannel = + // Always uses size channel for ticks, because tick only calls rectPosition() for the size channel + markDef.type === 'tick' || + // use "size" channel for bars, if there is orient and the channel matches the right orientation + (orient === 'horizontal' && channel === 'y') || + (orient === 'vertical' && channel === 'x'); // Use size encoding / mark property / config if it exists let sizeMixins; diff --git a/src/compile/mark/tick.ts b/src/compile/mark/tick.ts index cf0654f657..2a2bae8238 100644 --- a/src/compile/mark/tick.ts +++ b/src/compile/mark/tick.ts @@ -1,10 +1,7 @@ -import {isNumber} from 'vega-util'; -import {isVgRangeStep, VgValueRef} from '../../vega.schema'; -import {exprFromSignalRefOrValue, getMarkPropOrConfig, signalOrValueRef} from '../common'; +import {getMarkPropOrConfig, signalOrValueRef} from '../common'; import {UnitModel} from '../unit'; import {MarkCompiler} from './base'; import * as encode from './encode'; -import {getOffsetScaleChannel} from '../../channel'; export const tick: MarkCompiler = { vgMark: 'rect', @@ -13,7 +10,8 @@ export const tick: MarkCompiler = { const {config, markDef} = model; const orient = markDef.orient; - const vgSizeChannel = orient === 'horizontal' ? 'width' : 'height'; + const vgSizeAxisChannel = orient === 'horizontal' ? 'x' : 'y'; + const vgThicknessAxisChannel = orient === 'horizontal' ? 'y' : 'x'; const vgThicknessChannel = orient === 'horizontal' ? 'height' : 'width'; return { @@ -26,49 +24,12 @@ export const tick: MarkCompiler = { theta: 'ignore' }), - ...encode.pointPosition('x', model, {defaultPos: 'mid', vgChannel: 'xc'}), - ...encode.pointPosition('y', model, {defaultPos: 'mid', vgChannel: 'yc'}), - - // size / thickness => width / height - ...encode.nonPosition('size', model, { - defaultRef: defaultSize(model), - vgChannel: vgSizeChannel + ...encode.rectPosition(model, vgSizeAxisChannel), + ...encode.pointPosition(vgThicknessAxisChannel, model, { + defaultPos: 'mid', + vgChannel: vgThicknessAxisChannel === 'y' ? 'yc' : 'xc' }), [vgThicknessChannel]: signalOrValueRef(getMarkPropOrConfig('thickness', markDef, config)) }; } }; - -function defaultSize(model: UnitModel): VgValueRef { - const {config, markDef} = model; - const {orient} = markDef; - - const vgSizeChannel = orient === 'horizontal' ? 'width' : 'height'; - const positionChannel = orient === 'horizontal' ? 'x' : 'y'; - - const offsetScaleChannel = getOffsetScaleChannel(positionChannel); - - // Use offset scale if exists - const scale = model.getScaleComponent(offsetScaleChannel) || model.getScaleComponent(positionChannel); - - const markPropOrConfig = - getMarkPropOrConfig('size', markDef, config, {vgChannel: vgSizeChannel}) ?? config.tick.bandSize; - - if (markPropOrConfig !== undefined) { - return signalOrValueRef(markPropOrConfig); - } else if (scale?.get('type') === 'band') { - const scaleName = model.scaleName(offsetScaleChannel) || model.scaleName(positionChannel); - return {scale: scaleName, band: 1}; - } - - const scaleRange = scale?.get('range'); - const {tickBandPaddingInner} = config.scale; - - const step = scaleRange && isVgRangeStep(scaleRange) ? scaleRange.step : model[vgSizeChannel]; - - if (isNumber(step) && isNumber(tickBandPaddingInner)) { - return {value: step * (1 - tickBandPaddingInner)}; - } else { - return {signal: `(1 - ${exprFromSignalRefOrValue(tickBandPaddingInner)}) * ${exprFromSignalRefOrValue(step)}`}; - } -} diff --git a/src/mark.ts b/src/mark.ts index 46a4cc23e5..dff3d63b81 100644 --- a/src/mark.ts +++ b/src/mark.ts @@ -55,8 +55,8 @@ export function isPathMark(m: Mark | CompositeMark): m is PathMark { return ['line', 'area', 'trail'].includes(m); } -export function isRectBasedMark(m: Mark | CompositeMark): m is 'rect' | 'bar' | 'image' | 'arc' { - return ['rect', 'bar', 'image', 'arc' /* arc is rect/interval in polar coordinate */].includes(m); +export function isRectBasedMark(m: Mark | CompositeMark): m is 'rect' | 'bar' | 'image' | 'arc' | 'tick' { + return ['rect', 'bar', 'image', 'arc', 'tick' /* arc is rect/interval in polar coordinate */].includes(m); } export const PRIMITIVE_MARKS = new Set(keys(Mark)); @@ -327,14 +327,21 @@ const VL_ONLY_MARK_CONFIG_INDEX: Flag> = { export const VL_ONLY_MARK_CONFIG_PROPERTIES = keys(VL_ONLY_MARK_CONFIG_INDEX); +const VL_ONLY_RECT_CONFIG: (keyof RectConfig)[] = [ + 'binSpacing', + 'continuousBandSize', + 'discreteBandSize', + 'minBandSize' +]; + export const VL_ONLY_MARK_SPECIFIC_CONFIG_PROPERTY_INDEX: { [k in Mark]?: (keyof Required>[k])[]; } = { area: ['line', 'point'], - bar: ['binSpacing', 'continuousBandSize', 'discreteBandSize', 'minBandSize'], - rect: ['binSpacing', 'continuousBandSize', 'discreteBandSize', 'minBandSize'], + bar: VL_ONLY_RECT_CONFIG, + rect: VL_ONLY_RECT_CONFIG, line: ['point'], - tick: ['bandSize', 'thickness'] + tick: ['bandSize', 'thickness', ...VL_ONLY_RECT_CONFIG] }; export const defaultMarkConfig: MarkConfig = { @@ -647,13 +654,6 @@ export interface MarkDef = { - binSpacing: 1, - continuousBandSize: DEFAULT_RECT_BAND_SIZE, - minBandSize: 0.25, - timeUnitBandPosition: 0.5 -}; - export const defaultRectConfig: RectConfig = { binSpacing: 0, continuousBandSize: DEFAULT_RECT_BAND_SIZE, @@ -661,7 +661,15 @@ export const defaultRectConfig: RectConfig = { timeUnitBandPosition: 0.5 }; -export interface TickConfig extends MarkConfig, TickThicknessMixins { +export const defaultBarConfig: RectConfig = { + ...defaultRectConfig, + binSpacing: 1 +}; + +export interface TickConfig + extends MarkConfig, + TickThicknessMixins, + RectConfig { /** * The width of the ticks. * @@ -672,6 +680,7 @@ export interface TickConfig extends MarkConfig = { + ...defaultRectConfig, thickness: 1 }; diff --git a/test/compile/mark/tick.test.ts b/test/compile/mark/tick.test.ts index bbc4e57761..7af4eefb33 100644 --- a/test/compile/mark/tick.test.ts +++ b/test/compile/mark/tick.test.ts @@ -111,7 +111,7 @@ describe('Mark: Tick', () => { }); it('should scale on y', () => { - expect(props.yc).toEqual({scale: Y, field: 'Cylinders', band: 0.5}); + expect(props.y).toEqual({scale: Y, field: 'Cylinders'}); }); it('width should be tick thickness with default orient vertical', () => { @@ -119,7 +119,7 @@ describe('Mark: Tick', () => { }); it('height should be matched to field with default orient vertical', () => { - expect(props.height).toEqual({scale: 'y', band: 1}); + expect(props.height).toEqual({signal: "max(0.25, bandwidth('y'))"}); }); }); describe('with quantitative x and ordinal y with yOffset', () => { @@ -139,11 +139,10 @@ describe('Mark: Tick', () => { }); it('should scale on y', () => { - expect(props.yc).toEqual({ + expect(props.y).toEqual({ scale: Y, field: 'Cylinders', offset: { - band: 0.5, field: 'Acceleration', scale: 'yOffset' } @@ -155,7 +154,7 @@ describe('Mark: Tick', () => { }); it('height should be matched to field with default orient vertical', () => { - expect(props.height).toEqual({scale: 'yOffset', band: 1}); + expect(props.height).toEqual({signal: "max(0.25, bandwidth('yOffset'))"}); }); }); @@ -217,7 +216,7 @@ describe('Mark: Tick', () => { }); const props = tick.encodeEntry(model); it('sets mark height to (1-tickBandPaddingInner) * plot_height', () => { - expect(props.height).toEqual({signal: '(1 - 0.25) * height'}); + expect(props.height).toEqual({signal: '0.75 * height'}); }); }); @@ -231,7 +230,7 @@ describe('Mark: Tick', () => { }); const props = tick.encodeEntry(model); it('sets mark width to (1-tickBandPaddingInner) * plot_width', () => { - expect(props.width).toEqual({signal: '(1 - 0.25) * width'}); + expect(props.width).toEqual({signal: '0.75 * width'}); }); }); });