diff --git a/examples/compiled/boxplot_1D_horizontal.vg.json b/examples/compiled/boxplot_1D_horizontal.vg.json index b7dd924888..19831de56e 100644 --- a/examples/compiled/boxplot_1D_horizontal.vg.json +++ b/examples/compiled/boxplot_1D_horizontal.vg.json @@ -219,7 +219,12 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + }, + {"value": "white"} + ], "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)\"], \"\")}" }, diff --git a/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json b/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json index 37c52929e7..9dad4b7b9b 100644 --- a/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json +++ b/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json @@ -269,7 +269,12 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "red"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + }, + {"value": "red"} + ], "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)\"], \"\")}" }, diff --git a/examples/compiled/boxplot_1D_horizontal_explicit.vg.json b/examples/compiled/boxplot_1D_horizontal_explicit.vg.json index b7dd924888..19831de56e 100644 --- a/examples/compiled/boxplot_1D_horizontal_explicit.vg.json +++ b/examples/compiled/boxplot_1D_horizontal_explicit.vg.json @@ -219,7 +219,12 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + }, + {"value": "white"} + ], "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)\"], \"\")}" }, diff --git a/examples/compiled/boxplot_1D_vertical.vg.json b/examples/compiled/boxplot_1D_vertical.vg.json index fcf60d6c8f..3f760974d5 100644 --- a/examples/compiled/boxplot_1D_vertical.vg.json +++ b/examples/compiled/boxplot_1D_vertical.vg.json @@ -219,7 +219,12 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + }, + {"value": "white"} + ], "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)\"], \"\")}" }, diff --git a/examples/compiled/boxplot_2D_horizontal.vg.json b/examples/compiled/boxplot_2D_horizontal.vg.json index 657e0434dd..20c4c4d374 100644 --- a/examples/compiled/boxplot_2D_horizontal.vg.json +++ b/examples/compiled/boxplot_2D_horizontal.vg.json @@ -222,7 +222,12 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + }, + {"value": "white"} + ], "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\"]}" }, diff --git a/examples/compiled/boxplot_2D_horizontal_color_size.vg.json b/examples/compiled/boxplot_2D_horizontal_color_size.vg.json index aa06950bc5..8bc85b5725 100644 --- a/examples/compiled/boxplot_2D_horizontal_color_size.vg.json +++ b/examples/compiled/boxplot_2D_horizontal_color_size.vg.json @@ -222,7 +222,13 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']", + "value": "teal" + }, + {"value": "white"} + ], "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\"]}" }, diff --git a/examples/compiled/boxplot_2D_vertical.vg.json b/examples/compiled/boxplot_2D_vertical.vg.json index d79f793f82..a56aa9356c 100644 --- a/examples/compiled/boxplot_2D_vertical.vg.json +++ b/examples/compiled/boxplot_2D_vertical.vg.json @@ -222,7 +222,14 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']", + "scale": "color", + "field": "Species" + }, + {"value": "white"} + ], "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\"]}" }, diff --git a/examples/compiled/boxplot_2D_vertical_single_per_group.png b/examples/compiled/boxplot_2D_vertical_single_per_group.png index bfef7d24e7..b3407bba57 100644 Binary files a/examples/compiled/boxplot_2D_vertical_single_per_group.png and b/examples/compiled/boxplot_2D_vertical_single_per_group.png differ diff --git a/examples/compiled/boxplot_2D_vertical_single_per_group.svg b/examples/compiled/boxplot_2D_vertical_single_per_group.svg index 01a44347ff..a11ca023eb 100644 --- a/examples/compiled/boxplot_2D_vertical_single_per_group.svg +++ b/examples/compiled/boxplot_2D_vertical_single_per_group.svg @@ -1 +1 @@ -ABa01020304050b \ No newline at end of file +ABa01020304050b \ No newline at end of file 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 0c956676b1..e261fea590 100644 --- a/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json +++ b/examples/compiled/boxplot_2D_vertical_single_per_group.vg.json @@ -200,7 +200,10 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + {"test": "datum['lower_box_b'] >= datum['upper_box_b']"}, + {"value": "white"} + ], "tooltip": { "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\"]}" }, diff --git a/examples/compiled/boxplot_2D_vertical_single_per_group_color.png b/examples/compiled/boxplot_2D_vertical_single_per_group_color.png new file mode 100644 index 0000000000..d87d47dbec Binary files /dev/null and b/examples/compiled/boxplot_2D_vertical_single_per_group_color.png differ diff --git a/examples/compiled/boxplot_2D_vertical_single_per_group_color.svg b/examples/compiled/boxplot_2D_vertical_single_per_group_color.svg new file mode 100644 index 0000000000..3941ca96fa --- /dev/null +++ b/examples/compiled/boxplot_2D_vertical_single_per_group_color.svg @@ -0,0 +1 @@ +ABa01020304050bABa \ No newline at end of file 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 new file mode 100644 index 0000000000..b35940b20a --- /dev/null +++ b/examples/compiled/boxplot_2D_vertical_single_per_group_color.vg.json @@ -0,0 +1,319 @@ +{ + "$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": "A", "b": 30}, {"a": "B", "b": 55}] + }, + { + "name": "data_1", + "source": "source_0", + "transform": [ + { + "type": "joinaggregate", + "as": ["lower_box_b", "upper_box_b"], + "ops": ["q1", "q3"], + "fields": ["b", "b"], + "groupby": ["a", "a"] + } + ] + }, + { + "name": "data_2", + "source": "data_1", + "transform": [ + { + "type": "filter", + "expr": "(datum[\"b\"] < datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"])) || (datum[\"b\"] > datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))" + }, + { + "type": "filter", + "expr": "isValid(datum[\"b\"]) && isFinite(+datum[\"b\"])" + } + ] + }, + { + "name": "data_3", + "source": "data_1", + "transform": [ + { + "type": "filter", + "expr": "(datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]) <= datum[\"b\"]) && (datum[\"b\"] <= datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))" + }, + { + "type": "aggregate", + "groupby": ["a"], + "ops": ["min", "max", "min", "max"], + "fields": ["b", "b", "lower_box_b", "upper_box_b"], + "as": [ + "lower_whisker_b", + "upper_whisker_b", + "lower_box_b", + "upper_box_b" + ] + } + ] + }, + { + "name": "data_4", + "source": "source_0", + "transform": [ + { + "type": "aggregate", + "groupby": ["a"], + "ops": ["q1", "q3", "median", "min", "max"], + "fields": ["b", "b", "b", "b", "b"], + "as": ["lower_box_b", "upper_box_b", "mid_box_b", "min_b", "max_b"] + } + ] + } + ], + "signals": [ + {"name": "x_step", "value": 20}, + {"name": "width", "update": "bandspace(domain('x').length, 0, 0) * x_step"} + ], + "marks": [ + { + "name": "layer_0_layer_0_marks", + "type": "symbol", + "style": ["point", "boxplot-outliers"], + "from": {"data": "data_2"}, + "encode": { + "update": { + "opacity": {"value": 0.7}, + "fill": {"value": "transparent"}, + "stroke": {"scale": "color", "field": "a"}, + "ariaRoleDescription": {"value": "point"}, + "description": { + "signal": "\"a: \" + (isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]) + \"; b: \" + (format(datum[\"b\"], \"\"))" + }, + "x": {"scale": "x", "field": "a", "band": 0.5}, + "y": {"scale": "y", "field": "b"} + } + } + }, + { + "name": "layer_0_layer_1_layer_0_marks", + "type": "rule", + "style": ["rule", "boxplot-rule"], + "aria": false, + "from": {"data": "data_3"}, + "encode": { + "update": { + "stroke": {"value": "black"}, + "tooltip": { + "signal": "{\"Upper Whisker of b\": format(datum[\"upper_whisker_b\"], \"\"), \"Lower Whisker of b\": format(datum[\"lower_whisker_b\"], \"\"), \"a\": isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]}" + }, + "x": {"scale": "x", "field": "a", "band": 0.5}, + "y": [ + { + "test": "!isValid(datum[\"lower_whisker_b\"]) || !isFinite(+datum[\"lower_whisker_b\"])", + "field": {"group": "height"} + }, + {"scale": "y", "field": "lower_whisker_b"} + ], + "y2": [ + { + "test": "!isValid(datum[\"lower_box_b\"]) || !isFinite(+datum[\"lower_box_b\"])", + "field": {"group": "height"} + }, + {"scale": "y", "field": "lower_box_b"} + ] + } + } + }, + { + "name": "layer_0_layer_1_layer_1_marks", + "type": "rule", + "style": ["rule", "boxplot-rule"], + "aria": false, + "from": {"data": "data_3"}, + "encode": { + "update": { + "stroke": {"value": "black"}, + "tooltip": { + "signal": "{\"Upper Whisker of b\": format(datum[\"upper_whisker_b\"], \"\"), \"Lower Whisker of b\": format(datum[\"lower_whisker_b\"], \"\"), \"a\": isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]}" + }, + "x": {"scale": "x", "field": "a", "band": 0.5}, + "y": [ + { + "test": "!isValid(datum[\"upper_box_b\"]) || !isFinite(+datum[\"upper_box_b\"])", + "field": {"group": "height"} + }, + {"scale": "y", "field": "upper_box_b"} + ], + "y2": [ + { + "test": "!isValid(datum[\"upper_whisker_b\"]) || !isFinite(+datum[\"upper_whisker_b\"])", + "field": {"group": "height"} + }, + {"scale": "y", "field": "upper_whisker_b"} + ] + } + } + }, + { + "name": "layer_1_layer_0_marks", + "type": "rect", + "style": ["bar", "boxplot-box"], + "from": {"data": "data_4"}, + "encode": { + "update": { + "ariaRoleDescription": {"value": "box"}, + "fill": {"scale": "color", "field": "a"}, + "tooltip": { + "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\"]}" + }, + "description": { + "signal": "\"a: \" + (isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]) + \"; b: \" + (format(datum[\"lower_box_b\"], \"\")) + \"; upper_box_b: \" + (format(datum[\"upper_box_b\"], \"\")) + \"; 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\"], \"\"))" + }, + "xc": {"scale": "x", "field": "a", "band": 0.5}, + "width": {"value": 14}, + "y": [ + { + "test": "!isValid(datum[\"lower_box_b\"]) || !isFinite(+datum[\"lower_box_b\"])", + "field": {"group": "height"} + }, + {"scale": "y", "field": "lower_box_b"} + ], + "y2": [ + { + "test": "!isValid(datum[\"upper_box_b\"]) || !isFinite(+datum[\"upper_box_b\"])", + "field": {"group": "height"} + }, + {"scale": "y", "field": "upper_box_b"} + ] + } + } + }, + { + "name": "layer_1_layer_1_marks", + "type": "rect", + "style": ["tick", "boxplot-median"], + "aria": false, + "from": {"data": "data_4"}, + "encode": { + "update": { + "opacity": {"value": 0.7}, + "fill": [ + { + "test": "datum['lower_box_b'] >= datum['upper_box_b']", + "scale": "color", + "field": "a" + }, + {"value": "white"} + ], + "tooltip": { + "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": [ + { + "test": "!isValid(datum[\"mid_box_b\"]) || !isFinite(+datum[\"mid_box_b\"])", + "field": {"group": "height"} + }, + {"scale": "y", "field": "mid_box_b"} + ], + "width": {"value": 14}, + "height": {"value": 1} + } + } + } + ], + "scales": [ + { + "name": "x", + "type": "band", + "domain": { + "fields": [ + {"data": "data_2", "field": "a"}, + {"data": "data_3", "field": "a"}, + {"data": "data_4", "field": "a"} + ], + "sort": true + }, + "range": {"step": {"signal": "x_step"}}, + "paddingInner": 0, + "paddingOuter": 0 + }, + { + "name": "y", + "type": "linear", + "domain": { + "fields": [ + {"data": "data_2", "field": "b"}, + {"data": "data_3", "field": "lower_whisker_b"}, + {"data": "data_3", "field": "lower_box_b"}, + {"data": "data_3", "field": "upper_box_b"}, + {"data": "data_3", "field": "upper_whisker_b"}, + {"data": "data_4", "field": "lower_box_b"}, + {"data": "data_4", "field": "upper_box_b"}, + {"data": "data_4", "field": "mid_box_b"} + ] + }, + "range": [{"signal": "height"}, 0], + "nice": true, + "zero": true + }, + { + "name": "color", + "type": "ordinal", + "domain": { + "fields": [ + {"data": "data_2", "field": "a"}, + {"data": "data_4", "field": "a"} + ], + "sort": true + }, + "range": "category" + } + ], + "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 + } + ], + "legends": [ + { + "stroke": "color", + "symbolType": "circle", + "title": "a", + "encode": {"symbols": {"update": {"opacity": {"value": 0.7}}}}, + "fill": "color" + } + ] +} diff --git a/examples/compiled/boxplot_groupped.vg.json b/examples/compiled/boxplot_groupped.vg.json index 71cd079b7d..3b5e2df00c 100644 --- a/examples/compiled/boxplot_groupped.vg.json +++ b/examples/compiled/boxplot_groupped.vg.json @@ -240,7 +240,14 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Acceleration'] >= datum['upper_box_Acceleration']", + "scale": "color", + "field": "Origin" + }, + {"value": "white"} + ], "tooltip": { "signal": "{\"Max of Acceleration\": format(datum[\"max_Acceleration\"], \"\"), \"Q3 of Acceleration\": format(datum[\"upper_box_Acceleration\"], \"\"), \"Median of Acceleration\": format(datum[\"mid_box_Acceleration\"], \"\"), \"Q1 of Acceleration\": format(datum[\"lower_box_Acceleration\"], \"\"), \"Min of Acceleration\": format(datum[\"min_Acceleration\"], \"\"), \"Cylinders\": isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"], \"Origin\": isValid(datum[\"Origin\"]) ? datum[\"Origin\"] : \"\"+datum[\"Origin\"]}" }, diff --git a/examples/compiled/boxplot_minmax_2D_horizontal.vg.json b/examples/compiled/boxplot_minmax_2D_horizontal.vg.json index b6a8859e67..fee50539ea 100644 --- a/examples/compiled/boxplot_minmax_2D_horizontal.vg.json +++ b/examples/compiled/boxplot_minmax_2D_horizontal.vg.json @@ -145,7 +145,12 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + }, + {"value": "white"} + ], "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\"]}" }, 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 cbbf3ea904..ae1602f5cd 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 @@ -145,7 +145,12 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "orange"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + }, + {"value": "orange"} + ], "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\"]}" }, diff --git a/examples/compiled/boxplot_minmax_2D_vertical.vg.json b/examples/compiled/boxplot_minmax_2D_vertical.vg.json index ebff85d15d..0b3e2d8c19 100644 --- a/examples/compiled/boxplot_minmax_2D_vertical.vg.json +++ b/examples/compiled/boxplot_minmax_2D_vertical.vg.json @@ -145,7 +145,14 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']", + "scale": "color", + "field": "Species" + }, + {"value": "white"} + ], "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\"]}" }, diff --git a/examples/compiled/boxplot_tooltip_aggregate.vg.json b/examples/compiled/boxplot_tooltip_aggregate.vg.json index 3639739c61..696cc8bb47 100644 --- a/examples/compiled/boxplot_tooltip_aggregate.vg.json +++ b/examples/compiled/boxplot_tooltip_aggregate.vg.json @@ -220,7 +220,12 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + }, + {"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}, diff --git a/examples/compiled/boxplot_tooltip_not_aggregate.vg.json b/examples/compiled/boxplot_tooltip_not_aggregate.vg.json index fdc830314a..84dbab16c4 100644 --- a/examples/compiled/boxplot_tooltip_not_aggregate.vg.json +++ b/examples/compiled/boxplot_tooltip_not_aggregate.vg.json @@ -223,7 +223,12 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + }, + {"value": "white"} + ], "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\"]}" }, diff --git a/examples/compiled/layer_boxplot_circle.vg.json b/examples/compiled/layer_boxplot_circle.vg.json index bf1b80bc52..386e8955fb 100644 --- a/examples/compiled/layer_boxplot_circle.vg.json +++ b/examples/compiled/layer_boxplot_circle.vg.json @@ -187,7 +187,10 @@ "encode": { "update": { "opacity": {"value": 0.7}, - "fill": {"value": "white"}, + "fill": [ + {"test": "datum['lower_box_people'] >= datum['upper_box_people']"}, + {"value": "white"} + ], "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\"]}" }, diff --git a/examples/specs/normalized/boxplot_1D_horizontal_custom_mark_normalized.vl.json b/examples/specs/normalized/boxplot_1D_horizontal_custom_mark_normalized.vl.json index c7f8120a72..fa364a348a 100644 --- a/examples/specs/normalized/boxplot_1D_horizontal_custom_mark_normalized.vl.json +++ b/examples/specs/normalized/boxplot_1D_horizontal_custom_mark_normalized.vl.json @@ -269,6 +269,11 @@ "title": "Body Mass (g)", "scale": {"zero": false} }, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + } + }, "tooltip": [ { "field": "max_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json b/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json index 7f5e5ba217..9eeb8acce6 100644 --- a/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json +++ b/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json @@ -209,6 +209,11 @@ "title": "Body Mass (g)", "scale": {"zero": false} }, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + } + }, "tooltip": [ { "field": "max_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json b/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json index 7f5e5ba217..9eeb8acce6 100644 --- a/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json +++ b/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json @@ -209,6 +209,11 @@ "title": "Body Mass (g)", "scale": {"zero": false} }, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + } + }, "tooltip": [ { "field": "max_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json b/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json index 32161bd1e8..2d4af81c94 100644 --- a/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json +++ b/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json @@ -209,6 +209,11 @@ "title": "Body Mass (g)", "scale": {"zero": false} }, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + } + }, "tooltip": [ { "field": "max_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_2D_horizontal_color_size_normalized.vl.json b/examples/specs/normalized/boxplot_2D_horizontal_color_size_normalized.vl.json index 427ef196b8..e7c86be774 100644 --- a/examples/specs/normalized/boxplot_2D_horizontal_color_size_normalized.vl.json +++ b/examples/specs/normalized/boxplot_2D_horizontal_color_size_normalized.vl.json @@ -221,6 +221,12 @@ }, "y": {"field": "Species", "type": "nominal"}, "size": {"value": 10}, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']", + "value": "teal" + } + }, "tooltip": [ { "field": "max_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json b/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json index 204779636f..c9f12d5df1 100644 --- a/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json +++ b/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json @@ -217,6 +217,11 @@ "scale": {"zero": false} }, "y": {"field": "Species", "type": "nominal"}, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + } + }, "tooltip": [ { "field": "max_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json b/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json index f8e447b54a..6acebbfc1b 100644 --- a/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json +++ b/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json @@ -219,6 +219,14 @@ "scale": {"zero": false} }, "x": {"field": "Species", "type": "nominal"}, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']", + "field": "Species", + "type": "nominal", + "legend": null + } + }, "tooltip": [ { "field": "max_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_2D_vertical_single_per_group_color_normalized.vl.json b/examples/specs/normalized/boxplot_2D_vertical_single_per_group_color_normalized.vl.json new file mode 100644 index 0000000000..9f55ed691b --- /dev/null +++ b/examples/specs/normalized/boxplot_2D_vertical_single_per_group_color_normalized.vl.json @@ -0,0 +1,215 @@ +{ + "$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": "A", "b": 30}, {"a": "B", "b": 55}] + }, + "layer": [ + { + "transform": [ + { + "joinaggregate": [ + {"op": "q1", "field": "b", "as": "lower_box_b"}, + {"op": "q3", "field": "b", "as": "upper_box_b"} + ], + "groupby": ["a", "a"] + } + ], + "layer": [ + { + "transform": [ + { + "filter": "(datum[\"b\"] < datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"])) || (datum[\"b\"] > datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))" + } + ], + "mark": {"type": "point", "style": "boxplot-outliers"}, + "encoding": { + "y": {"field": "b", "type": "quantitative", "title": "b"}, + "x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}}, + "color": {"field": "a", "type": "nominal"} + } + }, + { + "transform": [ + { + "filter": "(datum[\"lower_box_b\"] - 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]) <= datum[\"b\"]) && (datum[\"b\"] <= datum[\"upper_box_b\"] + 1.5 * (datum[\"upper_box_b\"] - datum[\"lower_box_b\"]))" + }, + { + "aggregate": [ + {"op": "min", "field": "b", "as": "lower_whisker_b"}, + {"op": "max", "field": "b", "as": "upper_whisker_b"}, + {"op": "min", "field": "lower_box_b", "as": "lower_box_b"}, + {"op": "max", "field": "upper_box_b", "as": "upper_box_b"} + ], + "groupby": ["a", "a"] + } + ], + "layer": [ + { + "mark": { + "type": "rule", + "invalid": null, + "aria": false, + "style": "boxplot-rule" + }, + "encoding": { + "y": { + "field": "lower_whisker_b", + "type": "quantitative", + "title": "b" + }, + "y2": {"field": "lower_box_b"}, + "x": { + "field": "a", + "type": "nominal", + "axis": {"labelAngle": 0} + }, + "tooltip": [ + { + "field": "upper_whisker_b", + "type": "quantitative", + "title": "Upper Whisker of b" + }, + { + "field": "lower_whisker_b", + "type": "quantitative", + "title": "Lower Whisker of b" + }, + {"field": "a", "type": "nominal"} + ] + } + }, + { + "mark": { + "type": "rule", + "invalid": null, + "aria": false, + "style": "boxplot-rule" + }, + "encoding": { + "y": { + "field": "upper_box_b", + "type": "quantitative", + "title": "b" + }, + "y2": {"field": "upper_whisker_b"}, + "x": { + "field": "a", + "type": "nominal", + "axis": {"labelAngle": 0} + }, + "tooltip": [ + { + "field": "upper_whisker_b", + "type": "quantitative", + "title": "Upper Whisker of b" + }, + { + "field": "lower_whisker_b", + "type": "quantitative", + "title": "Lower Whisker of b" + }, + {"field": "a", "type": "nominal"} + ] + } + } + ] + } + ] + }, + { + "transform": [ + { + "aggregate": [ + {"op": "q1", "field": "b", "as": "lower_box_b"}, + {"op": "q3", "field": "b", "as": "upper_box_b"}, + {"op": "median", "field": "b", "as": "mid_box_b"}, + {"op": "min", "field": "b", "as": "min_b"}, + {"op": "max", "field": "b", "as": "max_b"} + ], + "groupby": ["a", "a"] + } + ], + "layer": [ + { + "mark": { + "type": "bar", + "size": 14, + "orient": "vertical", + "invalid": null, + "ariaRoleDescription": "box", + "style": "boxplot-box" + }, + "encoding": { + "y": {"field": "lower_box_b", "type": "quantitative", "title": "b"}, + "y2": {"field": "upper_box_b"}, + "x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}}, + "color": {"field": "a", "type": "nominal"}, + "tooltip": [ + {"field": "max_b", "type": "quantitative", "title": "Max of b"}, + { + "field": "upper_box_b", + "type": "quantitative", + "title": "Q3 of b" + }, + { + "field": "mid_box_b", + "type": "quantitative", + "title": "Median of b" + }, + { + "field": "lower_box_b", + "type": "quantitative", + "title": "Q1 of b" + }, + {"field": "min_b", "type": "quantitative", "title": "Min of b"}, + {"field": "a", "type": "nominal"} + ] + } + }, + { + "mark": { + "color": "white", + "type": "tick", + "invalid": null, + "size": 14, + "orient": "horizontal", + "aria": false, + "style": "boxplot-median" + }, + "encoding": { + "y": {"field": "mid_box_b", "type": "quantitative", "title": "b"}, + "x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}}, + "color": { + "condition": { + "test": "datum['lower_box_b'] >= datum['upper_box_b']", + "field": "a", + "type": "nominal" + } + }, + "tooltip": [ + {"field": "max_b", "type": "quantitative", "title": "Max of b"}, + { + "field": "upper_box_b", + "type": "quantitative", + "title": "Q3 of b" + }, + { + "field": "mid_box_b", + "type": "quantitative", + "title": "Median of b" + }, + { + "field": "lower_box_b", + "type": "quantitative", + "title": "Q1 of b" + }, + {"field": "min_b", "type": "quantitative", "title": "Min of b"}, + {"field": "a", "type": "nominal"} + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/examples/specs/normalized/boxplot_2D_vertical_single_per_group_normalized.vl.json b/examples/specs/normalized/boxplot_2D_vertical_single_per_group_normalized.vl.json index a041df16a8..cc4f271410 100644 --- a/examples/specs/normalized/boxplot_2D_vertical_single_per_group_normalized.vl.json +++ b/examples/specs/normalized/boxplot_2D_vertical_single_per_group_normalized.vl.json @@ -178,6 +178,11 @@ "encoding": { "y": {"field": "mid_box_b", "type": "quantitative", "title": "b"}, "x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}}, + "color": { + "condition": { + "test": "datum['lower_box_b'] >= datum['upper_box_b']" + } + }, "tooltip": [ {"field": "max_b", "type": "quantitative", "title": "Max of b"}, { diff --git a/examples/specs/normalized/boxplot_groupped_normalized.vl.json b/examples/specs/normalized/boxplot_groupped_normalized.vl.json index b8e359d43d..668b0f1257 100644 --- a/examples/specs/normalized/boxplot_groupped_normalized.vl.json +++ b/examples/specs/normalized/boxplot_groupped_normalized.vl.json @@ -222,6 +222,13 @@ }, "x": {"field": "Cylinders", "type": "nominal"}, "xOffset": {"field": "Origin", "type": "nominal"}, + "color": { + "condition": { + "test": "datum['lower_box_Acceleration'] >= datum['upper_box_Acceleration']", + "field": "Origin", + "type": "nominal" + } + }, "tooltip": [ { "field": "max_Acceleration", diff --git a/examples/specs/normalized/boxplot_minmax_2D_horizontal_custom_midtick_color_normalized.vl.json b/examples/specs/normalized/boxplot_minmax_2D_horizontal_custom_midtick_color_normalized.vl.json index 2e4c5232b2..20f6802356 100644 --- a/examples/specs/normalized/boxplot_minmax_2D_horizontal_custom_midtick_color_normalized.vl.json +++ b/examples/specs/normalized/boxplot_minmax_2D_horizontal_custom_midtick_color_normalized.vl.json @@ -174,6 +174,11 @@ "scale": {"zero": false} }, "y": {"field": "Species", "type": "nominal"}, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + } + }, "tooltip": [ { "field": "upper_whisker_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_minmax_2D_horizontal_normalized.vl.json b/examples/specs/normalized/boxplot_minmax_2D_horizontal_normalized.vl.json index 0276d49ba5..a2bd095aa2 100644 --- a/examples/specs/normalized/boxplot_minmax_2D_horizontal_normalized.vl.json +++ b/examples/specs/normalized/boxplot_minmax_2D_horizontal_normalized.vl.json @@ -173,6 +173,11 @@ "scale": {"zero": false} }, "y": {"field": "Species", "type": "nominal"}, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + } + }, "tooltip": [ { "field": "upper_whisker_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_minmax_2D_vertical_normalized.vl.json b/examples/specs/normalized/boxplot_minmax_2D_vertical_normalized.vl.json index 2e73bc3735..fbea4bbf68 100644 --- a/examples/specs/normalized/boxplot_minmax_2D_vertical_normalized.vl.json +++ b/examples/specs/normalized/boxplot_minmax_2D_vertical_normalized.vl.json @@ -174,6 +174,14 @@ "scale": {"zero": false} }, "x": {"field": "Species", "type": "nominal"}, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']", + "field": "Species", + "type": "nominal", + "legend": null + } + }, "tooltip": [ { "field": "upper_whisker_Body Mass (g)", diff --git a/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json b/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json index a98791a2ab..0d8664fc53 100644 --- a/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json +++ b/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json @@ -192,6 +192,11 @@ "title": "Mean of Body Mass (g)", "type": "quantitative", "field": "mean_Body Mass (g)" + }, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + } } } } diff --git a/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json b/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json index 6284901903..e0825b8d5d 100644 --- a/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json +++ b/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json @@ -218,6 +218,11 @@ "scale": {"zero": false} }, "y": {"field": "Species", "type": "nominal"}, + "color": { + "condition": { + "test": "datum['lower_box_Body Mass (g)'] >= datum['upper_box_Body Mass (g)']" + } + }, "tooltip": [ { "field": "max_Body Mass (g)", diff --git a/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json b/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json index e389345385..ac597db0dc 100644 --- a/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json +++ b/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json @@ -165,6 +165,11 @@ "title": "population" }, "y": {"field": "age", "type": "ordinal"}, + "color": { + "condition": { + "test": "datum['lower_box_people'] >= datum['upper_box_people']" + } + }, "tooltip": [ { "field": "max_people",