From 9977a8611654d75c2e5008400c4a2e264b2a7563 Mon Sep 17 00:00:00 2001 From: Younghoon Kim Date: Mon, 12 Sep 2022 18:43:12 -0700 Subject: [PATCH] fix(#8327): Boxplot set null quantitative to 0 (#8409) * add example * Take markDef.invalid into boxplot's markdef. * chore: update schema [CI] * update doc * refactor * chore: update examples [CI] Co-authored-by: GitHub Actions Bot --- build/vega-lite-schema.json | 11 + .../compiled/boxplot_1D_horizontal.vg.json | 116 ++++--- .../boxplot_1D_horizontal_custom_mark.vg.json | 147 ++++----- .../boxplot_1D_horizontal_explicit.vg.json | 116 ++++--- examples/compiled/boxplot_1D_invalid.png | Bin 0 -> 5707 bytes examples/compiled/boxplot_1D_invalid.svg | 1 + examples/compiled/boxplot_1D_invalid.vg.json | 311 ++++++++++++++++++ examples/compiled/boxplot_1D_vertical.vg.json | 116 ++++--- .../compiled/boxplot_2D_horizontal.vg.json | 122 +++---- .../boxplot_2D_horizontal_color_size.vg.json | 122 +++---- examples/compiled/boxplot_2D_vertical.vg.json | 124 +++---- examples/compiled/boxplot_groupped.vg.json | 130 ++++---- .../boxplot_minmax_2D_horizontal.vg.json | 127 +++---- ...2D_horizontal_custom_midtick_color.vg.json | 127 +++---- .../boxplot_minmax_2D_vertical.vg.json | 129 ++++---- .../boxplot_tooltip_aggregate.vg.json | 122 +++---- .../boxplot_tooltip_not_aggregate.vg.json | 122 +++---- .../compiled/layer_boxplot_circle.vg.json | 128 +++---- examples/specs/boxplot_1D_invalid.vl.json | 14 + ..._horizontal_custom_mark_normalized.vl.json | 18 +- ..._1D_horizontal_explicit_normalized.vl.json | 16 +- .../boxplot_1D_horizontal_normalized.vl.json | 16 +- .../boxplot_1D_invalid_normalized.vl.json | 224 +++++++++++++ .../boxplot_1D_vertical_normalized.vl.json | 16 +- ...D_horizontal_color_size_normalized.vl.json | 16 +- .../boxplot_2D_horizontal_normalized.vl.json | 16 +- .../boxplot_2D_vertical_normalized.vl.json | 16 +- .../boxplot_groupped_normalized.vl.json | 16 +- ...al_custom_midtick_color_normalized.vl.json | 16 +- ...ot_minmax_2D_horizontal_normalized.vl.json | 16 +- ...plot_minmax_2D_vertical_normalized.vl.json | 16 +- ...xplot_tooltip_aggregate_normalized.vl.json | 16 +- ...t_tooltip_not_aggregate_normalized.vl.json | 16 +- .../layer_boxplot_circle_normalized.vl.json | 16 +- site/docs/mark/boxplot.md | 2 +- src/compositemark/boxplot.ts | 17 +- src/mark.ts | 18 +- test/compositemark/boxplot.test.ts | 1 - 38 files changed, 1491 insertions(+), 1082 deletions(-) create mode 100644 examples/compiled/boxplot_1D_invalid.png create mode 100644 examples/compiled/boxplot_1D_invalid.svg create mode 100644 examples/compiled/boxplot_1D_invalid.vg.json create mode 100644 examples/specs/boxplot_1D_invalid.vl.json create mode 100644 examples/specs/normalized/boxplot_1D_invalid_normalized.vl.json diff --git a/build/vega-lite-schema.json b/build/vega-lite-schema.json index 9f675c30818..7b18a01766f 100644 --- a/build/vega-lite-schema.json +++ b/build/vega-lite-schema.json @@ -4536,6 +4536,17 @@ ], "description": "The extent of the whiskers. Available options include: - `\"min-max\"`: min and max are the lower and upper whiskers respectively. - A number representing multiple of the interquartile range. This number will be multiplied by the IQR to determine whisker boundary, which spans from the smallest data to the largest data within the range _[Q1 - k * IQR, Q3 + k * IQR]_ where _Q1_ and _Q3_ are the first and third quartiles while _IQR_ is the interquartile range (_Q3-Q1_).\n\n__Default value:__ `1.5`." }, + "invalid": { + "description": "Defines how Vega-Lite should handle marks for invalid values (`null` and `NaN`).\n- If set to `\"filter\"` (default), all data items with null values will be skipped (for line, trail, and area marks) or filtered (for other marks).\n- If `null`, all data items are included. In this case, invalid values will be interpreted as zeroes.", + "enum": [ + "filter", + null + ], + "type": [ + "string", + "null" + ] + }, "median": { "anyOf": [ { diff --git a/examples/compiled/boxplot_1D_horizontal.vg.json b/examples/compiled/boxplot_1D_horizontal.vg.json index 8399bd256f4..b7dd9248884 100644 --- a/examples/compiled/boxplot_1D_horizontal.vg.json +++ b/examples/compiled/boxplot_1D_horizontal.vg.json @@ -68,6 +68,26 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_5", "source": "source_0", "transform": [ { @@ -90,6 +110,26 @@ ] } ] + }, + { + "name": "data_6", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_7", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "marks": [ @@ -117,27 +157,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\")}" }, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, + "x2": {"scale": "x", "field": "lower_box_Body Mass (g)"}, "y": {"signal": "height", "mult": 0.5} } } @@ -147,27 +175,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\")}" }, - "x": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "upper_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "y": {"signal": "height", "mult": 0.5} } } @@ -176,7 +192,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_6"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -187,20 +203,8 @@ "description": { "signal": "\"Body Mass (g): \" + (format(datum[\"lower_box_Body Mass (g)\"], \"\")) + \"; upper_box_Body Mass (g): \" + (format(datum[\"upper_box_Body Mass (g)\"], \"\")) + \"; 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)\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_box_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 14} } @@ -211,7 +215,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -219,13 +223,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 14}, "width": {"value": 1} @@ -240,13 +238,13 @@ "domain": { "fields": [ {"data": "data_1", "field": "Body Mass (g)"}, - {"data": "data_2", "field": "lower_whisker_Body Mass (g)"}, - {"data": "data_2", "field": "lower_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_3", "field": "lower_whisker_Body Mass (g)"}, {"data": "data_3", "field": "lower_box_Body Mass (g)"}, - {"data": "data_3", "field": "upper_box_Body Mass (g)"}, - {"data": "data_3", "field": "mid_box_Body Mass (g)"} + {"data": "data_4", "field": "upper_box_Body Mass (g)"}, + {"data": "data_4", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_6", "field": "lower_box_Body Mass (g)"}, + {"data": "data_6", "field": "upper_box_Body Mass (g)"}, + {"data": "data_7", "field": "mid_box_Body Mass (g)"} ] }, "range": [0, {"signal": "width"}], diff --git a/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json b/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json index 83fc349470b..37c52929e71 100644 --- a/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json +++ b/examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json @@ -68,6 +68,36 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_5", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_whisker_Body Mass (g)\"]) && isFinite(+datum[\"upper_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_6", "source": "source_0", "transform": [ { @@ -90,6 +120,26 @@ ] } ] + }, + { + "name": "data_7", + "source": "data_6", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_8", + "source": "data_6", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "marks": [ @@ -117,27 +167,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\")}" }, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, + "x2": {"scale": "x", "field": "lower_box_Body Mass (g)"}, "y": {"signal": "height", "mult": 0.5} } } @@ -147,27 +185,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\")}" }, - "x": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "upper_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "y": {"signal": "height", "mult": 0.5} } } @@ -177,7 +203,7 @@ "type": "rect", "style": ["tick", "boxplot-ticks"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "opacity": {"value": 1}, @@ -185,13 +211,7 @@ "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": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 15}, "width": {"value": 1} @@ -203,7 +223,7 @@ "type": "rect", "style": ["tick", "boxplot-ticks"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_5"}, "encode": { "update": { "opacity": {"value": 1}, @@ -211,13 +231,7 @@ "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": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 15}, "width": {"value": 1} @@ -228,7 +242,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -239,20 +253,8 @@ "description": { "signal": "\"Body Mass (g): \" + (format(datum[\"lower_box_Body Mass (g)\"], \"\")) + \"; upper_box_Body Mass (g): \" + (format(datum[\"upper_box_Body Mass (g)\"], \"\")) + \"; 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)\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_box_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 14} } @@ -263,7 +265,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_8"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -271,13 +273,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 14}, "width": {"value": 1} @@ -292,13 +288,14 @@ "domain": { "fields": [ {"data": "data_1", "field": "Body Mass (g)"}, - {"data": "data_2", "field": "lower_whisker_Body Mass (g)"}, - {"data": "data_2", "field": "lower_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_3", "field": "lower_whisker_Body Mass (g)"}, {"data": "data_3", "field": "lower_box_Body Mass (g)"}, - {"data": "data_3", "field": "upper_box_Body Mass (g)"}, - {"data": "data_3", "field": "mid_box_Body Mass (g)"} + {"data": "data_4", "field": "upper_box_Body Mass (g)"}, + {"data": "data_4", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_5", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_7", "field": "lower_box_Body Mass (g)"}, + {"data": "data_7", "field": "upper_box_Body Mass (g)"}, + {"data": "data_8", "field": "mid_box_Body Mass (g)"} ] }, "range": [0, {"signal": "width"}], diff --git a/examples/compiled/boxplot_1D_horizontal_explicit.vg.json b/examples/compiled/boxplot_1D_horizontal_explicit.vg.json index 8399bd256f4..b7dd9248884 100644 --- a/examples/compiled/boxplot_1D_horizontal_explicit.vg.json +++ b/examples/compiled/boxplot_1D_horizontal_explicit.vg.json @@ -68,6 +68,26 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_5", "source": "source_0", "transform": [ { @@ -90,6 +110,26 @@ ] } ] + }, + { + "name": "data_6", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_7", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "marks": [ @@ -117,27 +157,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\")}" }, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, + "x2": {"scale": "x", "field": "lower_box_Body Mass (g)"}, "y": {"signal": "height", "mult": 0.5} } } @@ -147,27 +175,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\")}" }, - "x": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "upper_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "y": {"signal": "height", "mult": 0.5} } } @@ -176,7 +192,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_6"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -187,20 +203,8 @@ "description": { "signal": "\"Body Mass (g): \" + (format(datum[\"lower_box_Body Mass (g)\"], \"\")) + \"; upper_box_Body Mass (g): \" + (format(datum[\"upper_box_Body Mass (g)\"], \"\")) + \"; 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)\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_box_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 14} } @@ -211,7 +215,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -219,13 +223,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"signal": "height", "mult": 0.5}, "height": {"value": 14}, "width": {"value": 1} @@ -240,13 +238,13 @@ "domain": { "fields": [ {"data": "data_1", "field": "Body Mass (g)"}, - {"data": "data_2", "field": "lower_whisker_Body Mass (g)"}, - {"data": "data_2", "field": "lower_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_3", "field": "lower_whisker_Body Mass (g)"}, {"data": "data_3", "field": "lower_box_Body Mass (g)"}, - {"data": "data_3", "field": "upper_box_Body Mass (g)"}, - {"data": "data_3", "field": "mid_box_Body Mass (g)"} + {"data": "data_4", "field": "upper_box_Body Mass (g)"}, + {"data": "data_4", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_6", "field": "lower_box_Body Mass (g)"}, + {"data": "data_6", "field": "upper_box_Body Mass (g)"}, + {"data": "data_7", "field": "mid_box_Body Mass (g)"} ] }, "range": [0, {"signal": "width"}], diff --git a/examples/compiled/boxplot_1D_invalid.png b/examples/compiled/boxplot_1D_invalid.png new file mode 100644 index 0000000000000000000000000000000000000000..4cd355eb56a5d8bc9717d08a67855188d7b69d61 GIT binary patch literal 5707 zcmb_gcRbZ?|No*SDMw@`DcMvuIYdUru}jF_WN#rEAuGyWS?Q3K&EeR4Bzx~;(+d2l$R&xd(gn}@&6>IJj8UuvY2Udg7K|Z^n#=c01T!mK!p4Kao6amY@VPGg_ z*T0xR@b>Ln?(q}-gC0k+}nCb7wOLhKBgwGhU45)p^!r` zP({Z-=3?iKFnVTjtL@qD-nq)i_wVsUMbVSV_z^Pa&Yzz-*qo!}F;gl_nOj@)oT?Gg zUXF~s+LIoOhaCtMS;-5XIi!9<+{m zCuL>D(Hu@ktfi&JF&oqw&zLz`Xm~*cyQ3-~D2M|Me$nt{N_NE^E46y0sY#veb!3iN zH5K($$ZDv4jaL$j8!_@dqu{_KnFZWjK z(j`y{keKDuvo?rm?lPg&^Tm%=Wh>N7s|X#SORZFR7_G z>+9?7&aSQk^$iUhRBU(d_@nPX@{!NmoT|y@hd#UioIB|Qr`@2LGD08DH;2+t!rghY zb8_sC_pFReO>c8?T@4EhqvW+9JK2gsPmh*ZK2}t0`Jz$OAI8M>GCKviwzd`#AOH63 zC{pPpMJ8SKD7S40+CZO*cwy$~40o3Yo}patAIhY^#GvTIul(FI z>F4{u2ikE%Lkvb z7j2?L?KdWED9^hlFh@9^;rCBmHK>rvy!lt)p$`38{oY*p`l$AE_r?`VYwPCeI^W)W zUG#BS#RJjNHKOSFR=;{FV(Hw^|M#}W+a8cO3F@aYn!i0o`w)3qdxd6@4jG5LpHqzqaxPZ1% zo(Ke@+;#I7h%z{wXlEREfUc!n1`a|N`y;_-c0gU%KOrIEYd!$Pqkt<3ZI@Jf z(BIz&R(?9NN^5Fr60n_yJUl#X*T)6bo<5xg*YsDuDWr&mF7;)x^;{w*mUeYLfE#9JWYmt0X|1t1BT=aFjJQwTE1~jv%2l1+pLHxu zO-(&ckEbr!E>5h!XHvWcfC&A{(Zv!fD=SlSn-FmVz6(11_)M#4w8w*G;Sd!SH8L_{ z9@}2*Y3WC*_KuH-6dJbF*Za`DCq*LqRJ1fT>nA5ql05<8e*OCOjVrqK%ch#lUuEz= zg!un-^1mCvbI6%nSt;c4tL}oCg+;wX4?N3bWuYs9ztCY(p})WXCMV~Wy1F{eM$$N5 zM0dZ#kIvV*xg2R}X$7`3;vTyL>X5ge-#IlkHNEc{GC(ypxOKlH7)S?t`uVNLz4P<$ zMzd?+LX`a0*W26M@7d2ko}ZupSXoIuI5^16&fb`EvcvS{d4@7q6XMa6C)dWu$MvkNE z!wuRZ@5}-fsc&nOp(Mhm_k&pumy!1rri(BU`WZ?&tOamu&vN2R3DiHnOXDJ#DQ`4_b}YRQ$!7f{EHz$=SV268_H=;SU-vSMNMDSV{ zGfUCh)g@_S!ibBD`z|RdS5i1aqc5ZXEbjt^!ht|~rsR7;2{M+xscDu6({7)lXsE+t zw>gQT(IC&E*K%MWLI2Q@Vbj}dWKUejm{L4cR;SRqBSXW(%m6`AYgS{WLHtu5MICm0FNQxh z?NkE6WOUN8F|rT+)TM^q8Z+aWl@>iB;o{~dp`r?kjwUZIDXAM7p~}n4YwhUpt z^eMSXXKd;jvsAHLRe5<=z|X-9@vG0P2>@nZhaI{Gi`_}j3iNP@@bPq9XU>PviR!Gm z-YUv+M@~#kY!0DMO8N}x>FJr7nUx+y2CmmXXb)ugw`B9D!TaCD{LH%jWeJ2FEgfBW z0>2IG7_fw{dn2YK*RO|gXqB2#A&g3SSez6Tt}r6v{W?449UUE+k9FM^uAz>WbAU$~ zu5!8SD3nCLDPe+muW|t&-vFqOt+Vsfy^`YMk7;SRMW#K?-Z*$L3W@;V3&a+`1IkiT zRrSEf*B4MHcQq#`$2T}Q_$%D;rxFhz-|rD>r{51R6c!aVEOf*~t(BJY2?z)<|0zw2 zAjAnqUe$4JyzLPqG?uF&ZL)BW1Ka0lFIo-`4oYFyd)>+K;DUmC3$A}yCN~9HSwd8G zHG)?Xayc=Ok27CJO}5Tcmvo#>wlX&MH|~g@i8DUjk}DH^E}!y zC!)Ofa73rZLl9_`lCExeC=GvobF)+jh+~F15)OxNj8VW~AB`CzM&@XZ|LKkYa>4&< z(*L(HY&M#5zX$=(HZn4DuwJ!s&$Rn`$aTT*A3#9rGEA2n8zn&csO{|~>Fw=38z4`m zXhbgW{0Z2OmH;}hKpQlcoR5$1b6#F^GW=zM$DzF{;&m%~?5e!BhQ>v8b@hb@Na;{& z|L@;be&5LZB;*4jp-SPrzNL>tD;p!GK>j{_AmhlA+g3;4w%@NFFOFG*jq$ye=;0 zX>4weXH9N>5xX<7(ciDe!^=C9ew>CDjuwdK{u3hhY50aLaw$N?cL{;i)9BoJ0 zr29(lWU_?%jhCzUm$)mW1i6mesgEzx`?Z;hOT^DqPf0}HU$R_2eS=)5=xJ}S2gt&K z9=##z-AOvUEgg3A=1u6#Q|-|TIT8RLb*67VK0az)+>}HIKhwhjezR6PfQW%g0IF?o zCj<^fonxahh!muZ008G7T?rTD)|Wd zTWw4@keizu@PVkUa&TUf($dmwqhw*XtESzFb%x>aH?gsl&om~GDt31F?HwGziT%MR zJ1ax^(sN*}!BmZ>88E=W9o;wSq=X*I$Xo;j+$xXbHmx5RDCxU@goztf+YipyD8dJH zFf%t7v$V`%qyq0-yStk^?xI70doe!kPI^#i+(BMmUOv4LquUIot95`pCt+Z4%XxL! zuID5pgTc7^^r%Pva$H>8vkLn=!f?3V&u{b$3=9wy1~MCPG3Aw&2B0)`;gp|}5R1^un|j_k$YZ;UKlXtO z=Nlp_pPd~?1}3I`*Hv)d57E)}0JNYIQCY9-?Cg{f6MOxY+_&!6w3z&nxf}6BrIQ>H z4WImYx!ofI`o?%(%SPZ2)OyU#%wQmKJne>xk^em0RkBO zUJCzd?tAl4+zj#3g*hZ?auRpulLPxPOn5)XGNI)+nBqX7t5_z_qIKj-^ z+-(a>OMjSnad9z$qN3se_sYtOKN^kxwz3O$JU%heRBkudNUA7IPkvX2Jwz%!+l_^V zW{&ABnmkZ1_cF`J1#}ad_|NrS7~T!o;i-D#gtcJ z_4VRLCML7v6%N^37=QN;CLhOjK7r2)*LD$`Ql|Y4u}s-eEM7JBgi{b zF6OLeVrFHn|25N4=(I9;K?JQBGuqX4nU|Lrc8clG&CZs6&)+^eHg?~6^%>-19qHoY zBJJQ%v@DoZ`1NZ&D8qY)hY225@lLLRE&~A((K%>%c(`_Iif(szH#;OLCMJMF#}x+@ zS;M7PG^?wt(D*%zP{>>jSDb14F}z zckjGOnG`>P~NHiF1BRywUnczM-;)fV3FsG4h>3}1>t;`^t#{ba`?+Fwhnhgsgd2&FC`j!@Ha4DOIiz&e^bg!O&h>Ai+Rv0u9ZjM^! z2iepdN?}g+(G=i-Wa0#Nm;*atVAz2RU;{3c^=aPok#sxIKWYNpYn*8akkr>tjTNv< zJJ?P+Ww)NFyaTL3Q|hCDMnJ|URYmxnFgnqbTDv0*t+8sBLKB#=Ibxck4}|WFlJEu) zOMG7(&|&~)wB^ADDjk#m*q83*RzSVqAoCLbu3A!3VrFF}sjW@Byu56CxMeIMA#wBGJy;B@U8ne53Z%Isp4nV(<;` zn5i8l5fPDAp!>jj0@nq0g`7;j>h${T8wCZ0gTtOzVZee3AN@=RWm`4;&N6OKe}5+U z2s6(lD)!>Vm#vpYpKT10NI7zH@`BRRW~6FX0RYVEL=}ZpdZD^k1)dYJ96}qEg7sh* zAkCgEqy5$Fy>GLi}sdE$CL F{{Z3>7t8 \ No newline at end of file diff --git a/examples/compiled/boxplot_1D_invalid.vg.json b/examples/compiled/boxplot_1D_invalid.vg.json new file mode 100644 index 00000000000..9bca1863b74 --- /dev/null +++ b/examples/compiled/boxplot_1D_invalid.vg.json @@ -0,0 +1,311 @@ +{ + "$schema": "https://vega.github.io/schema/vega/v5.json", + "background": "white", + "padding": 5, + "width": 200, + "height": 200, + "style": "cell", + "data": [ + { + "name": "source_0", + "values": [ + {"a": "null", "b": 28}, + {"a": 33, "b": 55}, + {"a": 33, "b": 43}, + {"a": "null", "b": 91}, + {"a": "null", "b": 81}, + {"a": "null", "b": 53} + ] + }, + { + "name": "data_1", + "source": "source_0", + "transform": [ + { + "type": "joinaggregate", + "as": ["lower_box_b", "upper_box_b"], + "ops": ["q1", "q3"], + "fields": ["b", "b"], + "groupby": ["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[\"a\"]) && isFinite(+datum[\"a\"]) && 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": "data_3", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"a\"]) && isFinite(+datum[\"a\"]) && isValid(datum[\"lower_whisker_b\"]) && isFinite(+datum[\"lower_whisker_b\"])" + } + ] + }, + { + "name": "data_5", + "source": "data_3", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"a\"]) && isFinite(+datum[\"a\"]) && isValid(datum[\"upper_box_b\"]) && isFinite(+datum[\"upper_box_b\"])" + } + ] + }, + { + "name": "data_6", + "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"] + } + ] + }, + { + "name": "data_7", + "source": "data_6", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"a\"]) && isFinite(+datum[\"a\"]) && isValid(datum[\"lower_box_b\"]) && isFinite(+datum[\"lower_box_b\"])" + } + ] + }, + { + "name": "data_8", + "source": "data_6", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"a\"]) && isFinite(+datum[\"a\"]) && isValid(datum[\"mid_box_b\"]) && isFinite(+datum[\"mid_box_b\"])" + } + ] + } + ], + "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": {"value": "#4c78a8"}, + "ariaRoleDescription": {"value": "point"}, + "description": { + "signal": "\"a: \" + (format(datum[\"a\"], \"\")) + \"; b: \" + (format(datum[\"b\"], \"\"))" + }, + "x": {"scale": "x", "field": "a"}, + "y": {"scale": "y", "field": "b"} + } + } + }, + { + "name": "layer_0_layer_1_layer_0_marks", + "type": "rule", + "style": ["rule", "boxplot-rule"], + "aria": false, + "from": {"data": "data_4"}, + "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\": format(datum[\"a\"], \"\")}" + }, + "x": {"scale": "x", "field": "a"}, + "y": {"scale": "y", "field": "lower_whisker_b"}, + "y2": {"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_5"}, + "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\": format(datum[\"a\"], \"\")}" + }, + "x": {"scale": "x", "field": "a"}, + "y": {"scale": "y", "field": "upper_box_b"}, + "y2": {"scale": "y", "field": "upper_whisker_b"} + } + } + }, + { + "name": "layer_1_layer_0_marks", + "type": "rect", + "style": ["bar", "boxplot-box"], + "from": {"data": "data_7"}, + "encode": { + "update": { + "ariaRoleDescription": {"value": "box"}, + "fill": {"value": "#4c78a8"}, + "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\": format(datum[\"a\"], \"\")}" + }, + "description": { + "signal": "\"a: \" + (format(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"}, + "width": {"value": 14}, + "y": {"scale": "y", "field": "lower_box_b"}, + "y2": {"scale": "y", "field": "upper_box_b"} + } + } + }, + { + "name": "layer_1_layer_1_marks", + "type": "rect", + "style": ["tick", "boxplot-median"], + "aria": false, + "from": {"data": "data_8"}, + "encode": { + "update": { + "opacity": {"value": 0.7}, + "fill": {"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\": format(datum[\"a\"], \"\")}" + }, + "xc": {"scale": "x", "field": "a"}, + "yc": {"scale": "y", "field": "mid_box_b"}, + "width": {"value": 14}, + "height": {"value": 1} + } + } + } + ], + "scales": [ + { + "name": "x", + "type": "linear", + "domain": { + "fields": [ + {"data": "data_2", "field": "a"}, + {"data": "data_4", "field": "a"}, + {"data": "data_5", "field": "a"}, + {"data": "data_7", "field": "a"}, + {"data": "data_8", "field": "a"} + ] + }, + "range": [0, {"signal": "width"}], + "nice": true, + "zero": true, + "padding": 5 + }, + { + "name": "y", + "type": "linear", + "domain": { + "fields": [ + {"data": "data_2", "field": "b"}, + {"data": "data_4", "field": "lower_whisker_b"}, + {"data": "data_4", "field": "lower_box_b"}, + {"data": "data_5", "field": "upper_box_b"}, + {"data": "data_5", "field": "upper_whisker_b"}, + {"data": "data_7", "field": "lower_box_b"}, + {"data": "data_7", "field": "upper_box_b"}, + {"data": "data_8", "field": "mid_box_b"} + ] + }, + "range": [{"signal": "height"}, 0], + "nice": true, + "zero": true + } + ], + "axes": [ + { + "scale": "x", + "orient": "bottom", + "gridScale": "y", + "grid": true, + "tickCount": {"signal": "ceil(width/40)"}, + "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": "a", + "labelAngle": 0, + "labelBaseline": "top", + "labelFlush": true, + "labelOverlap": true, + "tickCount": {"signal": "ceil(width/40)"}, + "zindex": 0 + }, + { + "scale": "y", + "orient": "left", + "grid": false, + "title": "b", + "labelOverlap": true, + "tickCount": {"signal": "ceil(height/40)"}, + "zindex": 0 + } + ] +} diff --git a/examples/compiled/boxplot_1D_vertical.vg.json b/examples/compiled/boxplot_1D_vertical.vg.json index ddafb2e29f9..fcf60d6c8f1 100644 --- a/examples/compiled/boxplot_1D_vertical.vg.json +++ b/examples/compiled/boxplot_1D_vertical.vg.json @@ -68,6 +68,26 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_5", "source": "source_0", "transform": [ { @@ -90,6 +110,26 @@ ] } ] + }, + { + "name": "data_6", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_7", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "marks": [ @@ -117,7 +157,7 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, @@ -125,20 +165,8 @@ "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)\"], \"\")}" }, "x": {"signal": "width", "mult": 0.5}, - "y": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_whisker_Body Mass (g)"} - ], - "y2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_box_Body Mass (g)"} - ] + "y": {"scale": "y", "field": "lower_whisker_Body Mass (g)"}, + "y2": {"scale": "y", "field": "lower_box_Body Mass (g)"} } } }, @@ -147,7 +175,7 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, @@ -155,20 +183,8 @@ "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)\"], \"\")}" }, "x": {"signal": "width", "mult": 0.5}, - "y": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_box_Body Mass (g)"} - ], - "y2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_whisker_Body Mass (g)"} - ] + "y": {"scale": "y", "field": "upper_box_Body Mass (g)"}, + "y2": {"scale": "y", "field": "upper_whisker_Body Mass (g)"} } } }, @@ -176,7 +192,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_6"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -189,20 +205,8 @@ }, "xc": {"signal": "width", "mult": 0.5}, "width": {"value": 14}, - "y": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_box_Body Mass (g)"} - ], - "y2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_box_Body Mass (g)"} - ] + "y": {"scale": "y", "field": "lower_box_Body Mass (g)"}, + "y2": {"scale": "y", "field": "upper_box_Body Mass (g)"} } } }, @@ -211,7 +215,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -220,13 +224,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "mid_box_Body Mass (g)"} - ], + "yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}, "width": {"value": 14}, "height": {"value": 1} } @@ -240,13 +238,13 @@ "domain": { "fields": [ {"data": "data_1", "field": "Body Mass (g)"}, - {"data": "data_2", "field": "lower_whisker_Body Mass (g)"}, - {"data": "data_2", "field": "lower_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_3", "field": "lower_whisker_Body Mass (g)"}, {"data": "data_3", "field": "lower_box_Body Mass (g)"}, - {"data": "data_3", "field": "upper_box_Body Mass (g)"}, - {"data": "data_3", "field": "mid_box_Body Mass (g)"} + {"data": "data_4", "field": "upper_box_Body Mass (g)"}, + {"data": "data_4", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_6", "field": "lower_box_Body Mass (g)"}, + {"data": "data_6", "field": "upper_box_Body Mass (g)"}, + {"data": "data_7", "field": "mid_box_Body Mass (g)"} ] }, "range": [{"signal": "height"}, 0], diff --git a/examples/compiled/boxplot_2D_horizontal.vg.json b/examples/compiled/boxplot_2D_horizontal.vg.json index 6b457a7c122..657e0434dd7 100644 --- a/examples/compiled/boxplot_2D_horizontal.vg.json +++ b/examples/compiled/boxplot_2D_horizontal.vg.json @@ -67,6 +67,26 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_5", "source": "source_0", "transform": [ { @@ -89,6 +109,26 @@ ] } ] + }, + { + "name": "data_6", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_7", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "signals": [ @@ -120,27 +160,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, + "x2": {"scale": "x", "field": "lower_box_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -150,27 +178,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "upper_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -179,7 +195,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_6"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -190,20 +206,8 @@ "description": { "signal": "\"Body Mass (g): \" + (format(datum[\"lower_box_Body Mass (g)\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]) + \"; upper_box_Body Mass (g): \" + (format(datum[\"upper_box_Body Mass (g)\"], \"\")) + \"; 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)\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14} } @@ -214,7 +218,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -222,13 +226,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, "width": {"value": 1} @@ -243,13 +241,13 @@ "domain": { "fields": [ {"data": "data_1", "field": "Body Mass (g)"}, - {"data": "data_2", "field": "lower_whisker_Body Mass (g)"}, - {"data": "data_2", "field": "lower_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_3", "field": "lower_whisker_Body Mass (g)"}, {"data": "data_3", "field": "lower_box_Body Mass (g)"}, - {"data": "data_3", "field": "upper_box_Body Mass (g)"}, - {"data": "data_3", "field": "mid_box_Body Mass (g)"} + {"data": "data_4", "field": "upper_box_Body Mass (g)"}, + {"data": "data_4", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_6", "field": "lower_box_Body Mass (g)"}, + {"data": "data_6", "field": "upper_box_Body Mass (g)"}, + {"data": "data_7", "field": "mid_box_Body Mass (g)"} ] }, "range": [0, {"signal": "width"}], @@ -262,8 +260,10 @@ "domain": { "fields": [ {"data": "data_1", "field": "Species"}, - {"data": "data_2", "field": "Species"}, - {"data": "data_3", "field": "Species"} + {"data": "data_3", "field": "Species"}, + {"data": "data_4", "field": "Species"}, + {"data": "data_6", "field": "Species"}, + {"data": "data_7", "field": "Species"} ], "sort": true }, diff --git a/examples/compiled/boxplot_2D_horizontal_color_size.vg.json b/examples/compiled/boxplot_2D_horizontal_color_size.vg.json index fa1e7460c29..aa06950bc54 100644 --- a/examples/compiled/boxplot_2D_horizontal_color_size.vg.json +++ b/examples/compiled/boxplot_2D_horizontal_color_size.vg.json @@ -67,6 +67,26 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_5", "source": "source_0", "transform": [ { @@ -89,6 +109,26 @@ ] } ] + }, + { + "name": "data_6", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_7", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "signals": [ @@ -120,27 +160,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, + "x2": {"scale": "x", "field": "lower_box_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -150,27 +178,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "upper_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -179,7 +195,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_6"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -190,20 +206,8 @@ "description": { "signal": "\"Body Mass (g): \" + (format(datum[\"lower_box_Body Mass (g)\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]) + \"; upper_box_Body Mass (g): \" + (format(datum[\"upper_box_Body Mass (g)\"], \"\")) + \"; 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)\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 10} } @@ -214,7 +218,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -222,13 +226,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 10}, "width": {"value": 1} @@ -243,13 +241,13 @@ "domain": { "fields": [ {"data": "data_1", "field": "Body Mass (g)"}, - {"data": "data_2", "field": "lower_whisker_Body Mass (g)"}, - {"data": "data_2", "field": "lower_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_3", "field": "lower_whisker_Body Mass (g)"}, {"data": "data_3", "field": "lower_box_Body Mass (g)"}, - {"data": "data_3", "field": "upper_box_Body Mass (g)"}, - {"data": "data_3", "field": "mid_box_Body Mass (g)"} + {"data": "data_4", "field": "upper_box_Body Mass (g)"}, + {"data": "data_4", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_6", "field": "lower_box_Body Mass (g)"}, + {"data": "data_6", "field": "upper_box_Body Mass (g)"}, + {"data": "data_7", "field": "mid_box_Body Mass (g)"} ] }, "range": [0, {"signal": "width"}], @@ -262,8 +260,10 @@ "domain": { "fields": [ {"data": "data_1", "field": "Species"}, - {"data": "data_2", "field": "Species"}, - {"data": "data_3", "field": "Species"} + {"data": "data_3", "field": "Species"}, + {"data": "data_4", "field": "Species"}, + {"data": "data_6", "field": "Species"}, + {"data": "data_7", "field": "Species"} ], "sort": true }, diff --git a/examples/compiled/boxplot_2D_vertical.vg.json b/examples/compiled/boxplot_2D_vertical.vg.json index 4d8fe487197..d79f793f822 100644 --- a/examples/compiled/boxplot_2D_vertical.vg.json +++ b/examples/compiled/boxplot_2D_vertical.vg.json @@ -67,6 +67,26 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_5", "source": "source_0", "transform": [ { @@ -89,6 +109,26 @@ ] } ] + }, + { + "name": "data_6", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_7", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "signals": [ @@ -120,7 +160,7 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, @@ -128,20 +168,8 @@ "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)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, "x": {"scale": "x", "field": "Species", "band": 0.5}, - "y": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_whisker_Body Mass (g)"} - ], - "y2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_box_Body Mass (g)"} - ] + "y": {"scale": "y", "field": "lower_whisker_Body Mass (g)"}, + "y2": {"scale": "y", "field": "lower_box_Body Mass (g)"} } } }, @@ -150,7 +178,7 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, @@ -158,20 +186,8 @@ "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)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, "x": {"scale": "x", "field": "Species", "band": 0.5}, - "y": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_box_Body Mass (g)"} - ], - "y2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_whisker_Body Mass (g)"} - ] + "y": {"scale": "y", "field": "upper_box_Body Mass (g)"}, + "y2": {"scale": "y", "field": "upper_whisker_Body Mass (g)"} } } }, @@ -179,7 +195,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_6"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -192,20 +208,8 @@ }, "xc": {"scale": "x", "field": "Species", "band": 0.5}, "width": {"value": 14}, - "y": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_box_Body Mass (g)"} - ], - "y2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_box_Body Mass (g)"} - ] + "y": {"scale": "y", "field": "lower_box_Body Mass (g)"}, + "y2": {"scale": "y", "field": "upper_box_Body Mass (g)"} } } }, @@ -214,7 +218,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -223,13 +227,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "mid_box_Body Mass (g)"} - ], + "yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}, "width": {"value": 14}, "height": {"value": 1} } @@ -243,8 +241,10 @@ "domain": { "fields": [ {"data": "data_1", "field": "Species"}, - {"data": "data_2", "field": "Species"}, - {"data": "data_3", "field": "Species"} + {"data": "data_3", "field": "Species"}, + {"data": "data_4", "field": "Species"}, + {"data": "data_6", "field": "Species"}, + {"data": "data_7", "field": "Species"} ], "sort": true }, @@ -258,13 +258,13 @@ "domain": { "fields": [ {"data": "data_1", "field": "Body Mass (g)"}, - {"data": "data_2", "field": "lower_whisker_Body Mass (g)"}, - {"data": "data_2", "field": "lower_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_3", "field": "lower_whisker_Body Mass (g)"}, {"data": "data_3", "field": "lower_box_Body Mass (g)"}, - {"data": "data_3", "field": "upper_box_Body Mass (g)"}, - {"data": "data_3", "field": "mid_box_Body Mass (g)"} + {"data": "data_4", "field": "upper_box_Body Mass (g)"}, + {"data": "data_4", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_6", "field": "lower_box_Body Mass (g)"}, + {"data": "data_6", "field": "upper_box_Body Mass (g)"}, + {"data": "data_7", "field": "mid_box_Body Mass (g)"} ] }, "range": [{"signal": "height"}, 0], @@ -277,7 +277,7 @@ "domain": { "fields": [ {"data": "data_1", "field": "Species"}, - {"data": "data_3", "field": "Species"} + {"data": "data_6", "field": "Species"} ], "sort": true }, diff --git a/examples/compiled/boxplot_groupped.vg.json b/examples/compiled/boxplot_groupped.vg.json index 4d5c0158521..71cd079b7db 100644 --- a/examples/compiled/boxplot_groupped.vg.json +++ b/examples/compiled/boxplot_groupped.vg.json @@ -63,6 +63,26 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Acceleration\"]) && isFinite(+datum[\"lower_whisker_Acceleration\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Acceleration\"]) && isFinite(+datum[\"upper_box_Acceleration\"])" + } + ] + }, + { + "name": "data_5", "source": "source_0", "transform": [ { @@ -85,6 +105,26 @@ ] } ] + }, + { + "name": "data_6", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Acceleration\"]) && isFinite(+datum[\"lower_box_Acceleration\"])" + } + ] + }, + { + "name": "data_7", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Acceleration\"]) && isFinite(+datum[\"mid_box_Acceleration\"])" + } + ] } ], "signals": [ @@ -126,7 +166,7 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, @@ -138,20 +178,8 @@ "field": "Cylinders", "offset": {"scale": "xOffset", "field": "Origin", "band": 0.5} }, - "y": [ - { - "test": "!isValid(datum[\"lower_whisker_Acceleration\"]) || !isFinite(+datum[\"lower_whisker_Acceleration\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_whisker_Acceleration"} - ], - "y2": [ - { - "test": "!isValid(datum[\"lower_box_Acceleration\"]) || !isFinite(+datum[\"lower_box_Acceleration\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_box_Acceleration"} - ] + "y": {"scale": "y", "field": "lower_whisker_Acceleration"}, + "y2": {"scale": "y", "field": "lower_box_Acceleration"} } } }, @@ -160,7 +188,7 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, @@ -172,20 +200,8 @@ "field": "Cylinders", "offset": {"scale": "xOffset", "field": "Origin", "band": 0.5} }, - "y": [ - { - "test": "!isValid(datum[\"upper_box_Acceleration\"]) || !isFinite(+datum[\"upper_box_Acceleration\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_box_Acceleration"} - ], - "y2": [ - { - "test": "!isValid(datum[\"upper_whisker_Acceleration\"]) || !isFinite(+datum[\"upper_whisker_Acceleration\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_whisker_Acceleration"} - ] + "y": {"scale": "y", "field": "upper_box_Acceleration"}, + "y2": {"scale": "y", "field": "upper_whisker_Acceleration"} } } }, @@ -193,7 +209,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_6"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -210,20 +226,8 @@ "offset": {"scale": "xOffset", "field": "Origin", "band": 0.5} }, "width": {"value": 14}, - "y": [ - { - "test": "!isValid(datum[\"lower_box_Acceleration\"]) || !isFinite(+datum[\"lower_box_Acceleration\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_box_Acceleration"} - ], - "y2": [ - { - "test": "!isValid(datum[\"upper_box_Acceleration\"]) || !isFinite(+datum[\"upper_box_Acceleration\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_box_Acceleration"} - ] + "y": {"scale": "y", "field": "lower_box_Acceleration"}, + "y2": {"scale": "y", "field": "upper_box_Acceleration"} } } }, @@ -232,7 +236,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -245,13 +249,7 @@ "field": "Cylinders", "offset": {"scale": "xOffset", "field": "Origin", "band": 0.5} }, - "yc": [ - { - "test": "!isValid(datum[\"mid_box_Acceleration\"]) || !isFinite(+datum[\"mid_box_Acceleration\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "mid_box_Acceleration"} - ], + "yc": {"scale": "y", "field": "mid_box_Acceleration"}, "width": {"value": 14}, "height": {"value": 1} } @@ -265,8 +263,10 @@ "domain": { "fields": [ {"data": "data_1", "field": "Cylinders"}, - {"data": "data_2", "field": "Cylinders"}, - {"data": "data_3", "field": "Cylinders"} + {"data": "data_3", "field": "Cylinders"}, + {"data": "data_4", "field": "Cylinders"}, + {"data": "data_6", "field": "Cylinders"}, + {"data": "data_7", "field": "Cylinders"} ], "sort": true }, @@ -280,13 +280,13 @@ "domain": { "fields": [ {"data": "data_1", "field": "Acceleration"}, - {"data": "data_2", "field": "lower_whisker_Acceleration"}, - {"data": "data_2", "field": "lower_box_Acceleration"}, - {"data": "data_2", "field": "upper_box_Acceleration"}, - {"data": "data_2", "field": "upper_whisker_Acceleration"}, + {"data": "data_3", "field": "lower_whisker_Acceleration"}, {"data": "data_3", "field": "lower_box_Acceleration"}, - {"data": "data_3", "field": "upper_box_Acceleration"}, - {"data": "data_3", "field": "mid_box_Acceleration"} + {"data": "data_4", "field": "upper_box_Acceleration"}, + {"data": "data_4", "field": "upper_whisker_Acceleration"}, + {"data": "data_6", "field": "lower_box_Acceleration"}, + {"data": "data_6", "field": "upper_box_Acceleration"}, + {"data": "data_7", "field": "mid_box_Acceleration"} ] }, "range": [{"signal": "height"}, 0], @@ -299,8 +299,10 @@ "domain": { "fields": [ {"data": "data_1", "field": "Origin"}, - {"data": "data_2", "field": "Origin"}, - {"data": "data_3", "field": "Origin"} + {"data": "data_3", "field": "Origin"}, + {"data": "data_4", "field": "Origin"}, + {"data": "data_6", "field": "Origin"}, + {"data": "data_7", "field": "Origin"} ], "sort": true }, @@ -312,7 +314,7 @@ "domain": { "fields": [ {"data": "data_1", "field": "Origin"}, - {"data": "data_3", "field": "Origin"} + {"data": "data_6", "field": "Origin"} ], "sort": true }, diff --git a/examples/compiled/boxplot_minmax_2D_horizontal.vg.json b/examples/compiled/boxplot_minmax_2D_horizontal.vg.json index 1ebd2892bdd..b6a8859e670 100644 --- a/examples/compiled/boxplot_minmax_2D_horizontal.vg.json +++ b/examples/compiled/boxplot_minmax_2D_horizontal.vg.json @@ -31,6 +31,46 @@ ] } ] + }, + { + "name": "data_0", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_1", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_2", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_3", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "signals": [ @@ -43,27 +83,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "source_0"}, + "from": {"data": "data_0"}, "encode": { "update": { "stroke": {"value": "black"}, "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\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, + "x2": {"scale": "x", "field": "lower_box_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -73,27 +101,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "source_0"}, + "from": {"data": "data_1"}, "encode": { "update": { "stroke": {"value": "black"}, "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\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "upper_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -102,7 +118,7 @@ "name": "layer_2_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "source_0"}, + "from": {"data": "data_2"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -113,20 +129,8 @@ "description": { "signal": "\"Body Mass (g): \" + (format(datum[\"lower_box_Body Mass (g)\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]) + \"; upper_box_Body Mass (g): \" + (format(datum[\"upper_box_Body Mass (g)\"], \"\")) + \"; 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)\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14} } @@ -137,7 +141,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "source_0"}, + "from": {"data": "data_3"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -145,13 +149,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, "width": {"value": 1} @@ -164,13 +162,14 @@ "name": "x", "type": "linear", "domain": { - "data": "source_0", "fields": [ - "lower_whisker_Body Mass (g)", - "lower_box_Body Mass (g)", - "upper_box_Body Mass (g)", - "upper_whisker_Body Mass (g)", - "mid_box_Body Mass (g)" + {"data": "data_0", "field": "lower_whisker_Body Mass (g)"}, + {"data": "data_0", "field": "lower_box_Body Mass (g)"}, + {"data": "data_1", "field": "upper_box_Body Mass (g)"}, + {"data": "data_1", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_2", "field": "lower_box_Body Mass (g)"}, + {"data": "data_2", "field": "upper_box_Body Mass (g)"}, + {"data": "data_3", "field": "mid_box_Body Mass (g)"} ] }, "range": [0, {"signal": "width"}], @@ -180,7 +179,15 @@ { "name": "y", "type": "band", - "domain": {"data": "source_0", "field": "Species", "sort": true}, + "domain": { + "fields": [ + {"data": "data_0", "field": "Species"}, + {"data": "data_1", "field": "Species"}, + {"data": "data_2", "field": "Species"}, + {"data": "data_3", "field": "Species"} + ], + "sort": true + }, "range": {"step": {"signal": "y_step"}}, "paddingInner": 0, "paddingOuter": 0 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 8e14f41ab1a..cbbf3ea9044 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 @@ -31,6 +31,46 @@ ] } ] + }, + { + "name": "data_0", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_1", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_2", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_3", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "signals": [ @@ -43,27 +83,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "source_0"}, + "from": {"data": "data_0"}, "encode": { "update": { "stroke": {"value": "black"}, "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\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, + "x2": {"scale": "x", "field": "lower_box_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -73,27 +101,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "source_0"}, + "from": {"data": "data_1"}, "encode": { "update": { "stroke": {"value": "black"}, "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\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "upper_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -102,7 +118,7 @@ "name": "layer_2_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "source_0"}, + "from": {"data": "data_2"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -113,20 +129,8 @@ "description": { "signal": "\"Body Mass (g): \" + (format(datum[\"lower_box_Body Mass (g)\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]) + \"; upper_box_Body Mass (g): \" + (format(datum[\"upper_box_Body Mass (g)\"], \"\")) + \"; 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)\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14} } @@ -137,7 +141,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "source_0"}, + "from": {"data": "data_3"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -145,13 +149,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, "width": {"value": 1} @@ -164,13 +162,14 @@ "name": "x", "type": "linear", "domain": { - "data": "source_0", "fields": [ - "lower_whisker_Body Mass (g)", - "lower_box_Body Mass (g)", - "upper_box_Body Mass (g)", - "upper_whisker_Body Mass (g)", - "mid_box_Body Mass (g)" + {"data": "data_0", "field": "lower_whisker_Body Mass (g)"}, + {"data": "data_0", "field": "lower_box_Body Mass (g)"}, + {"data": "data_1", "field": "upper_box_Body Mass (g)"}, + {"data": "data_1", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_2", "field": "lower_box_Body Mass (g)"}, + {"data": "data_2", "field": "upper_box_Body Mass (g)"}, + {"data": "data_3", "field": "mid_box_Body Mass (g)"} ] }, "range": [0, {"signal": "width"}], @@ -180,7 +179,15 @@ { "name": "y", "type": "band", - "domain": {"data": "source_0", "field": "Species", "sort": true}, + "domain": { + "fields": [ + {"data": "data_0", "field": "Species"}, + {"data": "data_1", "field": "Species"}, + {"data": "data_2", "field": "Species"}, + {"data": "data_3", "field": "Species"} + ], + "sort": true + }, "range": {"step": {"signal": "y_step"}}, "paddingInner": 0, "paddingOuter": 0 diff --git a/examples/compiled/boxplot_minmax_2D_vertical.vg.json b/examples/compiled/boxplot_minmax_2D_vertical.vg.json index c8445a58415..ebff85d15d9 100644 --- a/examples/compiled/boxplot_minmax_2D_vertical.vg.json +++ b/examples/compiled/boxplot_minmax_2D_vertical.vg.json @@ -31,6 +31,46 @@ ] } ] + }, + { + "name": "data_0", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_1", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_2", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_3", + "source": "source_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "signals": [ @@ -43,7 +83,7 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "source_0"}, + "from": {"data": "data_0"}, "encode": { "update": { "stroke": {"value": "black"}, @@ -51,20 +91,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\"]}" }, "x": {"scale": "x", "field": "Species", "band": 0.5}, - "y": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_whisker_Body Mass (g)"} - ], - "y2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_box_Body Mass (g)"} - ] + "y": {"scale": "y", "field": "lower_whisker_Body Mass (g)"}, + "y2": {"scale": "y", "field": "lower_box_Body Mass (g)"} } } }, @@ -73,7 +101,7 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "source_0"}, + "from": {"data": "data_1"}, "encode": { "update": { "stroke": {"value": "black"}, @@ -81,20 +109,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\"]}" }, "x": {"scale": "x", "field": "Species", "band": 0.5}, - "y": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_box_Body Mass (g)"} - ], - "y2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_whisker_Body Mass (g)"} - ] + "y": {"scale": "y", "field": "upper_box_Body Mass (g)"}, + "y2": {"scale": "y", "field": "upper_whisker_Body Mass (g)"} } } }, @@ -102,7 +118,7 @@ "name": "layer_2_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "source_0"}, + "from": {"data": "data_2"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -115,20 +131,8 @@ }, "xc": {"scale": "x", "field": "Species", "band": 0.5}, "width": {"value": 14}, - "y": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "lower_box_Body Mass (g)"} - ], - "y2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "upper_box_Body Mass (g)"} - ] + "y": {"scale": "y", "field": "lower_box_Body Mass (g)"}, + "y2": {"scale": "y", "field": "upper_box_Body Mass (g)"} } } }, @@ -137,7 +141,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "source_0"}, + "from": {"data": "data_3"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -146,13 +150,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "field": {"group": "height"} - }, - {"scale": "y", "field": "mid_box_Body Mass (g)"} - ], + "yc": {"scale": "y", "field": "mid_box_Body Mass (g)"}, "width": {"value": 14}, "height": {"value": 1} } @@ -163,7 +161,15 @@ { "name": "x", "type": "band", - "domain": {"data": "source_0", "field": "Species", "sort": true}, + "domain": { + "fields": [ + {"data": "data_0", "field": "Species"}, + {"data": "data_1", "field": "Species"}, + {"data": "data_2", "field": "Species"}, + {"data": "data_3", "field": "Species"} + ], + "sort": true + }, "range": {"step": {"signal": "x_step"}}, "paddingInner": 0, "paddingOuter": 0 @@ -172,13 +178,14 @@ "name": "y", "type": "linear", "domain": { - "data": "source_0", "fields": [ - "lower_whisker_Body Mass (g)", - "lower_box_Body Mass (g)", - "upper_box_Body Mass (g)", - "upper_whisker_Body Mass (g)", - "mid_box_Body Mass (g)" + {"data": "data_0", "field": "lower_whisker_Body Mass (g)"}, + {"data": "data_0", "field": "lower_box_Body Mass (g)"}, + {"data": "data_1", "field": "upper_box_Body Mass (g)"}, + {"data": "data_1", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_2", "field": "lower_box_Body Mass (g)"}, + {"data": "data_2", "field": "upper_box_Body Mass (g)"}, + {"data": "data_3", "field": "mid_box_Body Mass (g)"} ] }, "range": [{"signal": "height"}, 0], @@ -188,7 +195,7 @@ { "name": "color", "type": "ordinal", - "domain": {"data": "source_0", "field": "Species", "sort": true}, + "domain": {"data": "data_2", "field": "Species", "sort": true}, "range": "category" } ], diff --git a/examples/compiled/boxplot_tooltip_aggregate.vg.json b/examples/compiled/boxplot_tooltip_aggregate.vg.json index 8f8eb2afa1d..3639739c61c 100644 --- a/examples/compiled/boxplot_tooltip_aggregate.vg.json +++ b/examples/compiled/boxplot_tooltip_aggregate.vg.json @@ -69,6 +69,26 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_5", "source": "source_0", "transform": [ { @@ -93,6 +113,26 @@ ] } ] + }, + { + "name": "data_6", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_7", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "signals": [ @@ -124,25 +164,13 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, "tooltip": {"signal": "format(datum[\"mean_Body Mass (g)\"], \"\")"}, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, + "x2": {"scale": "x", "field": "lower_box_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -152,25 +180,13 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, "tooltip": {"signal": "format(datum[\"mean_Body Mass (g)\"], \"\")"}, - "x": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "upper_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -179,7 +195,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_6"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -188,20 +204,8 @@ "description": { "signal": "\"Body Mass (g): \" + (format(datum[\"lower_box_Body Mass (g)\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]) + \"; upper_box_Body Mass (g): \" + (format(datum[\"upper_box_Body Mass (g)\"], \"\")) + \"; Mean of Body Mass (g): \" + (format(datum[\"mean_Body Mass (g)\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14} } @@ -212,19 +216,13 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "white"}, "tooltip": {"signal": "format(datum[\"mean_Body Mass (g)\"], \"\")"}, - "xc": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, "width": {"value": 1} @@ -239,13 +237,13 @@ "domain": { "fields": [ {"data": "data_1", "field": "Body Mass (g)"}, - {"data": "data_2", "field": "lower_whisker_Body Mass (g)"}, - {"data": "data_2", "field": "lower_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_3", "field": "lower_whisker_Body Mass (g)"}, {"data": "data_3", "field": "lower_box_Body Mass (g)"}, - {"data": "data_3", "field": "upper_box_Body Mass (g)"}, - {"data": "data_3", "field": "mid_box_Body Mass (g)"} + {"data": "data_4", "field": "upper_box_Body Mass (g)"}, + {"data": "data_4", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_6", "field": "lower_box_Body Mass (g)"}, + {"data": "data_6", "field": "upper_box_Body Mass (g)"}, + {"data": "data_7", "field": "mid_box_Body Mass (g)"} ] }, "range": [0, {"signal": "width"}], @@ -258,8 +256,10 @@ "domain": { "fields": [ {"data": "data_1", "field": "Species"}, - {"data": "data_2", "field": "Species"}, - {"data": "data_3", "field": "Species"} + {"data": "data_3", "field": "Species"}, + {"data": "data_4", "field": "Species"}, + {"data": "data_6", "field": "Species"}, + {"data": "data_7", "field": "Species"} ], "sort": true }, diff --git a/examples/compiled/boxplot_tooltip_not_aggregate.vg.json b/examples/compiled/boxplot_tooltip_not_aggregate.vg.json index 17d3cd99648..fdc830314a9 100644 --- a/examples/compiled/boxplot_tooltip_not_aggregate.vg.json +++ b/examples/compiled/boxplot_tooltip_not_aggregate.vg.json @@ -67,6 +67,26 @@ }, { "name": "data_3", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_Body Mass (g)\"]) && isFinite(+datum[\"lower_whisker_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_4", + "source": "data_2", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_Body Mass (g)\"]) && isFinite(+datum[\"upper_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_5", "source": "source_0", "transform": [ { @@ -89,6 +109,26 @@ ] } ] + }, + { + "name": "data_6", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_Body Mass (g)\"]) && isFinite(+datum[\"lower_box_Body Mass (g)\"])" + } + ] + }, + { + "name": "data_7", + "source": "data_5", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_Body Mass (g)\"]) && isFinite(+datum[\"mid_box_Body Mass (g)\"])" + } + ] } ], "signals": [ @@ -121,27 +161,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_3"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"lower_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_whisker_Body Mass (g)"}, + "x2": {"scale": "x", "field": "lower_box_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -151,27 +179,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "black"}, "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)\"], \"\"), \"Species\": isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_Body Mass (g)\"]) || !isFinite(+datum[\"upper_whisker_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "upper_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_whisker_Body Mass (g)"}, "y": {"scale": "y", "field": "Species", "band": 0.5} } } @@ -180,7 +196,7 @@ "name": "layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_3"}, + "from": {"data": "data_6"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -191,20 +207,8 @@ "description": { "signal": "\"Body Mass (g): \" + (format(datum[\"lower_box_Body Mass (g)\"], \"\")) + \"; Species: \" + (isValid(datum[\"Species\"]) ? datum[\"Species\"] : \"\"+datum[\"Species\"]) + \"; upper_box_Body Mass (g): \" + (format(datum[\"upper_box_Body Mass (g)\"], \"\")) + \"; 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)\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_Body Mass (g)\"]) || !isFinite(+datum[\"lower_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_Body Mass (g)"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_Body Mass (g)\"]) || !isFinite(+datum[\"upper_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_Body Mass (g)"} - ], + "x": {"scale": "x", "field": "lower_box_Body Mass (g)"}, + "x2": {"scale": "x", "field": "upper_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14} } @@ -215,7 +219,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_3"}, + "from": {"data": "data_7"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -223,13 +227,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_Body Mass (g)\"]) || !isFinite(+datum[\"mid_box_Body Mass (g)\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_Body Mass (g)"} - ], + "xc": {"scale": "x", "field": "mid_box_Body Mass (g)"}, "yc": {"scale": "y", "field": "Species", "band": 0.5}, "height": {"value": 14}, "width": {"value": 1} @@ -244,13 +242,13 @@ "domain": { "fields": [ {"data": "data_1", "field": "Body Mass (g)"}, - {"data": "data_2", "field": "lower_whisker_Body Mass (g)"}, - {"data": "data_2", "field": "lower_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_box_Body Mass (g)"}, - {"data": "data_2", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_3", "field": "lower_whisker_Body Mass (g)"}, {"data": "data_3", "field": "lower_box_Body Mass (g)"}, - {"data": "data_3", "field": "upper_box_Body Mass (g)"}, - {"data": "data_3", "field": "mid_box_Body Mass (g)"} + {"data": "data_4", "field": "upper_box_Body Mass (g)"}, + {"data": "data_4", "field": "upper_whisker_Body Mass (g)"}, + {"data": "data_6", "field": "lower_box_Body Mass (g)"}, + {"data": "data_6", "field": "upper_box_Body Mass (g)"}, + {"data": "data_7", "field": "mid_box_Body Mass (g)"} ] }, "range": [0, {"signal": "width"}], @@ -263,8 +261,10 @@ "domain": { "fields": [ {"data": "data_1", "field": "Species"}, - {"data": "data_2", "field": "Species"}, - {"data": "data_3", "field": "Species"} + {"data": "data_3", "field": "Species"}, + {"data": "data_4", "field": "Species"}, + {"data": "data_6", "field": "Species"}, + {"data": "data_7", "field": "Species"} ], "sort": true }, diff --git a/examples/compiled/layer_boxplot_circle.vg.json b/examples/compiled/layer_boxplot_circle.vg.json index 91b3571ebd2..bf1b80bc528 100644 --- a/examples/compiled/layer_boxplot_circle.vg.json +++ b/examples/compiled/layer_boxplot_circle.vg.json @@ -47,6 +47,26 @@ }, { "name": "data_1", + "source": "data_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_whisker_people\"]) && isFinite(+datum[\"lower_whisker_people\"])" + } + ] + }, + { + "name": "data_2", + "source": "data_0", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"upper_box_people\"]) && isFinite(+datum[\"upper_box_people\"])" + } + ] + }, + { + "name": "data_3", "source": "source_0", "transform": [ { @@ -65,7 +85,27 @@ ] }, { - "name": "data_2", + "name": "data_4", + "source": "data_3", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"lower_box_people\"]) && isFinite(+datum[\"lower_box_people\"])" + } + ] + }, + { + "name": "data_5", + "source": "data_3", + "transform": [ + { + "type": "filter", + "expr": "isValid(datum[\"mid_box_people\"]) && isFinite(+datum[\"mid_box_people\"])" + } + ] + }, + { + "name": "data_6", "source": "source_0", "transform": [ { @@ -85,27 +125,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_0"}, + "from": {"data": "data_1"}, "encode": { "update": { "stroke": {"value": "black"}, "tooltip": { "signal": "{\"Upper Whisker of population\": format(datum[\"upper_whisker_people\"], \"\"), \"Lower Whisker of population\": format(datum[\"lower_whisker_people\"], \"\"), \"age\": isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"lower_whisker_people\"]) || !isFinite(+datum[\"lower_whisker_people\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_whisker_people"} - ], - "x2": [ - { - "test": "!isValid(datum[\"lower_box_people\"]) || !isFinite(+datum[\"lower_box_people\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_people"} - ], + "x": {"scale": "x", "field": "lower_whisker_people"}, + "x2": {"scale": "x", "field": "lower_box_people"}, "y": {"scale": "y", "field": "age", "band": 0.5} } } @@ -115,27 +143,15 @@ "type": "rule", "style": ["rule", "boxplot-rule"], "aria": false, - "from": {"data": "data_0"}, + "from": {"data": "data_2"}, "encode": { "update": { "stroke": {"value": "black"}, "tooltip": { "signal": "{\"Upper Whisker of population\": format(datum[\"upper_whisker_people\"], \"\"), \"Lower Whisker of population\": format(datum[\"lower_whisker_people\"], \"\"), \"age\": isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]}" }, - "x": [ - { - "test": "!isValid(datum[\"upper_box_people\"]) || !isFinite(+datum[\"upper_box_people\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_people"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_whisker_people\"]) || !isFinite(+datum[\"upper_whisker_people\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_whisker_people"} - ], + "x": {"scale": "x", "field": "upper_box_people"}, + "x2": {"scale": "x", "field": "upper_whisker_people"}, "y": {"scale": "y", "field": "age", "band": 0.5} } } @@ -144,7 +160,7 @@ "name": "layer_0_layer_1_layer_0_marks", "type": "rect", "style": ["bar", "boxplot-box"], - "from": {"data": "data_1"}, + "from": {"data": "data_4"}, "encode": { "update": { "ariaRoleDescription": {"value": "box"}, @@ -155,20 +171,8 @@ "description": { "signal": "\"population: \" + (format(datum[\"lower_box_people\"], \"\")) + \"; age: \" + (isValid(datum[\"age\"]) ? datum[\"age\"] : \"\"+datum[\"age\"]) + \"; upper_box_people: \" + (format(datum[\"upper_box_people\"], \"\")) + \"; 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\"], \"\"))" }, - "x": [ - { - "test": "!isValid(datum[\"lower_box_people\"]) || !isFinite(+datum[\"lower_box_people\"])", - "value": 0 - }, - {"scale": "x", "field": "lower_box_people"} - ], - "x2": [ - { - "test": "!isValid(datum[\"upper_box_people\"]) || !isFinite(+datum[\"upper_box_people\"])", - "value": 0 - }, - {"scale": "x", "field": "upper_box_people"} - ], + "x": {"scale": "x", "field": "lower_box_people"}, + "x2": {"scale": "x", "field": "upper_box_people"}, "yc": {"scale": "y", "field": "age", "band": 0.5}, "height": {"value": 14} } @@ -179,7 +183,7 @@ "type": "rect", "style": ["tick", "boxplot-median"], "aria": false, - "from": {"data": "data_1"}, + "from": {"data": "data_5"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -187,13 +191,7 @@ "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": [ - { - "test": "!isValid(datum[\"mid_box_people\"]) || !isFinite(+datum[\"mid_box_people\"])", - "value": 0 - }, - {"scale": "x", "field": "mid_box_people"} - ], + "xc": {"scale": "x", "field": "mid_box_people"}, "yc": {"scale": "y", "field": "age", "band": 0.5}, "height": {"value": 14}, "width": {"value": 1} @@ -204,7 +202,7 @@ "name": "layer_1_marks", "type": "symbol", "style": ["circle"], - "from": {"data": "data_2"}, + "from": {"data": "data_6"}, "encode": { "update": { "opacity": {"value": 0.2}, @@ -226,14 +224,14 @@ "type": "linear", "domain": { "fields": [ - {"data": "data_0", "field": "lower_whisker_people"}, - {"data": "data_0", "field": "lower_box_people"}, - {"data": "data_0", "field": "upper_box_people"}, - {"data": "data_0", "field": "upper_whisker_people"}, + {"data": "data_1", "field": "lower_whisker_people"}, {"data": "data_1", "field": "lower_box_people"}, - {"data": "data_1", "field": "upper_box_people"}, - {"data": "data_1", "field": "mid_box_people"}, - {"data": "data_2", "field": "people"} + {"data": "data_2", "field": "upper_box_people"}, + {"data": "data_2", "field": "upper_whisker_people"}, + {"data": "data_4", "field": "lower_box_people"}, + {"data": "data_4", "field": "upper_box_people"}, + {"data": "data_5", "field": "mid_box_people"}, + {"data": "data_6", "field": "people"} ] }, "range": [0, {"signal": "width"}], @@ -245,9 +243,11 @@ "type": "band", "domain": { "fields": [ - {"data": "data_0", "field": "age"}, {"data": "data_1", "field": "age"}, - {"data": "data_2", "field": "age"} + {"data": "data_2", "field": "age"}, + {"data": "data_4", "field": "age"}, + {"data": "data_5", "field": "age"}, + {"data": "data_6", "field": "age"} ], "sort": true }, diff --git a/examples/specs/boxplot_1D_invalid.vl.json b/examples/specs/boxplot_1D_invalid.vl.json new file mode 100644 index 00000000000..0c4f0506be3 --- /dev/null +++ b/examples/specs/boxplot_1D_invalid.vl.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", + "data": { + "values": [ + {"a": "null", "b": 28}, {"a": 33, "b": 55}, {"a": 33, "b": 43}, + {"a": "null", "b": 91}, {"a": "null", "b": 81}, {"a": "null", "b": 53} + ] + }, + "mark": {"type": "boxplot", "invalid": "filter"}, + "encoding": { + "x": {"field": "a", "type": "quantitative", "axis": {"labelAngle": 0}}, + "y": {"field": "b", "type": "quantitative"} + } +} 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 d35ff7f3327..c7f8120a72c 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 @@ -71,12 +71,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_Body Mass (g)", @@ -100,12 +95,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_Body Mass (g)", @@ -134,7 +124,6 @@ "color": "black", "opacity": 1, "orient": "vertical", - "invalid": null, "aria": false, "style": "boxplot-ticks" }, @@ -165,7 +154,6 @@ "color": "black", "opacity": 1, "orient": "vertical", - "invalid": null, "aria": false, "style": "boxplot-ticks" }, @@ -225,7 +213,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -270,7 +257,6 @@ "mark": { "color": "red", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, 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 9dacc22be64..7f5e5ba2178 100644 --- a/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json +++ b/examples/specs/normalized/boxplot_1D_horizontal_explicit_normalized.vl.json @@ -71,12 +71,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_Body Mass (g)", @@ -100,12 +95,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_Body Mass (g)", @@ -163,7 +153,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -208,7 +197,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, diff --git a/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json b/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json index 9dacc22be64..7f5e5ba2178 100644 --- a/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json +++ b/examples/specs/normalized/boxplot_1D_horizontal_normalized.vl.json @@ -71,12 +71,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_Body Mass (g)", @@ -100,12 +95,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_Body Mass (g)", @@ -163,7 +153,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -208,7 +197,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, diff --git a/examples/specs/normalized/boxplot_1D_invalid_normalized.vl.json b/examples/specs/normalized/boxplot_1D_invalid_normalized.vl.json new file mode 100644 index 00000000000..ff48fdcb037 --- /dev/null +++ b/examples/specs/normalized/boxplot_1D_invalid_normalized.vl.json @@ -0,0 +1,224 @@ +{ + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", + "data": { + "values": [ + {"a": "null", "b": 28}, + {"a": 33, "b": 55}, + {"a": 33, "b": 43}, + {"a": "null", "b": 91}, + {"a": "null", "b": 81}, + {"a": "null", "b": 53} + ] + }, + "layer": [ + { + "transform": [ + { + "joinaggregate": [ + {"op": "q1", "field": "b", "as": "lower_box_b"}, + {"op": "q3", "field": "b", "as": "upper_box_b"} + ], + "groupby": ["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": "quantitative", + "axis": {"labelAngle": 0} + } + } + }, + { + "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"] + } + ], + "layer": [ + { + "mark": { + "type": "rule", + "invalid": "filter", + "aria": false, + "style": "boxplot-rule" + }, + "encoding": { + "y": { + "field": "lower_whisker_b", + "type": "quantitative", + "title": "b" + }, + "y2": {"field": "lower_box_b"}, + "x": { + "field": "a", + "type": "quantitative", + "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": "quantitative"} + ] + } + }, + { + "mark": { + "type": "rule", + "invalid": "filter", + "aria": false, + "style": "boxplot-rule" + }, + "encoding": { + "y": { + "field": "upper_box_b", + "type": "quantitative", + "title": "b" + }, + "y2": {"field": "upper_whisker_b"}, + "x": { + "field": "a", + "type": "quantitative", + "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": "quantitative"} + ] + } + } + ] + } + ] + }, + { + "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"] + } + ], + "layer": [ + { + "mark": { + "type": "bar", + "size": 14, + "orient": "vertical", + "invalid": "filter", + "ariaRoleDescription": "box", + "style": "boxplot-box" + }, + "encoding": { + "y": {"field": "lower_box_b", "type": "quantitative", "title": "b"}, + "y2": {"field": "upper_box_b"}, + "x": { + "field": "a", + "type": "quantitative", + "axis": {"labelAngle": 0} + }, + "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": "quantitative"} + ] + } + }, + { + "mark": { + "color": "white", + "type": "tick", + "invalid": "filter", + "size": 14, + "orient": "horizontal", + "aria": false, + "style": "boxplot-median" + }, + "encoding": { + "y": {"field": "mid_box_b", "type": "quantitative", "title": "b"}, + "x": { + "field": "a", + "type": "quantitative", + "axis": {"labelAngle": 0} + }, + "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": "quantitative"} + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json b/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json index 9d2f8e16d4b..32161bd1e8c 100644 --- a/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json +++ b/examples/specs/normalized/boxplot_1D_vertical_normalized.vl.json @@ -71,12 +71,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "y": { "field": "lower_whisker_Body Mass (g)", @@ -100,12 +95,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "y": { "field": "upper_box_Body Mass (g)", @@ -163,7 +153,6 @@ "type": "bar", "size": 14, "orient": "vertical", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -208,7 +197,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "horizontal", "aria": false, 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 7730f82b447..427ef196b88 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 @@ -73,12 +73,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_Body Mass (g)", @@ -104,12 +99,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_Body Mass (g)", @@ -169,7 +159,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -218,7 +207,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, diff --git a/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json b/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json index 76d77b1ae75..204779636fa 100644 --- a/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json +++ b/examples/specs/normalized/boxplot_2D_horizontal_normalized.vl.json @@ -72,12 +72,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_Body Mass (g)", @@ -103,12 +98,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_Body Mass (g)", @@ -168,7 +158,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -215,7 +204,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, diff --git a/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json b/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json index 66dcf7d06c1..f8e447b54a8 100644 --- a/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json +++ b/examples/specs/normalized/boxplot_2D_vertical_normalized.vl.json @@ -73,12 +73,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "y": { "field": "lower_whisker_Body Mass (g)", @@ -104,12 +99,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "y": { "field": "upper_box_Body Mass (g)", @@ -169,7 +159,6 @@ "type": "bar", "size": 14, "orient": "vertical", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -217,7 +206,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "horizontal", "aria": false, diff --git a/examples/specs/normalized/boxplot_groupped_normalized.vl.json b/examples/specs/normalized/boxplot_groupped_normalized.vl.json index 778f4311617..b8e359d43db 100644 --- a/examples/specs/normalized/boxplot_groupped_normalized.vl.json +++ b/examples/specs/normalized/boxplot_groupped_normalized.vl.json @@ -73,12 +73,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "y": { "field": "lower_whisker_Acceleration", @@ -105,12 +100,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "y": { "field": "upper_box_Acceleration", @@ -171,7 +161,6 @@ "type": "bar", "size": 14, "orient": "vertical", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -220,7 +209,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "horizontal", "aria": false, 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 83fc32340e7..2e4c5232b2c 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 @@ -29,12 +29,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_Body Mass (g)", @@ -75,12 +70,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_Body Mass (g)", @@ -125,7 +115,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -172,7 +161,6 @@ "mark": { "color": "orange", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, 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 05892e98083..0276d49ba52 100644 --- a/examples/specs/normalized/boxplot_minmax_2D_horizontal_normalized.vl.json +++ b/examples/specs/normalized/boxplot_minmax_2D_horizontal_normalized.vl.json @@ -28,12 +28,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_Body Mass (g)", @@ -74,12 +69,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_Body Mass (g)", @@ -124,7 +114,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -171,7 +160,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, 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 3258b8fd28d..2e73bc37352 100644 --- a/examples/specs/normalized/boxplot_minmax_2D_vertical_normalized.vl.json +++ b/examples/specs/normalized/boxplot_minmax_2D_vertical_normalized.vl.json @@ -28,12 +28,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "y": { "field": "lower_whisker_Body Mass (g)", @@ -74,12 +69,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "y": { "field": "upper_box_Body Mass (g)", @@ -124,7 +114,6 @@ "type": "bar", "size": 14, "orient": "vertical", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -172,7 +161,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "horizontal", "aria": false, diff --git a/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json b/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json index b56924dfd31..a98791a2ab3 100644 --- a/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json +++ b/examples/specs/normalized/boxplot_tooltip_aggregate_normalized.vl.json @@ -77,12 +77,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_Body Mass (g)", @@ -100,12 +95,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_Body Mass (g)", @@ -162,7 +152,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -186,7 +175,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, 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 c5df6abe368..62849019039 100644 --- a/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json +++ b/examples/specs/normalized/boxplot_tooltip_not_aggregate_normalized.vl.json @@ -73,12 +73,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_Body Mass (g)", @@ -104,12 +99,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_Body Mass (g)", @@ -169,7 +159,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -216,7 +205,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, diff --git a/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json b/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json index fd12c7d0802..e389345385a 100644 --- a/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json +++ b/examples/specs/normalized/layer_boxplot_circle_normalized.vl.json @@ -38,12 +38,7 @@ ], "layer": [ { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "lower_whisker_people", @@ -68,12 +63,7 @@ } }, { - "mark": { - "type": "rule", - "invalid": null, - "aria": false, - "style": "boxplot-rule" - }, + "mark": {"type": "rule", "aria": false, "style": "boxplot-rule"}, "encoding": { "x": { "field": "upper_box_people", @@ -118,7 +108,6 @@ "type": "bar", "size": 14, "orient": "horizontal", - "invalid": null, "ariaRoleDescription": "box", "style": "boxplot-box" }, @@ -164,7 +153,6 @@ "mark": { "color": "white", "type": "tick", - "invalid": null, "size": 14, "orient": "vertical", "aria": false, diff --git a/site/docs/mark/boxplot.md b/site/docs/mark/boxplot.md index ef13e62abd8..915eb81be28 100644 --- a/site/docs/mark/boxplot.md +++ b/site/docs/mark/boxplot.md @@ -34,7 +34,7 @@ To create a box plot, set `mark` to `"boxplot"`. A boxplot's mark definition contain the following properties: -{% include table.html props="type,extent,orient,size,color,opacity" source="BoxPlotDef" %} +{% include table.html props="type,extent,orient,size,color,opacity,invalid" source="BoxPlotDef" %} Besides the properties listed above, `"box"`, `"median"`, `"rule"`, `"outliers"`, and `"ticks"` can be used to specify the underlying [mark properties](mark.html#mark-def) for different [parts of the box plots](#parts) as well. diff --git a/src/compositemark/boxplot.ts b/src/compositemark/boxplot.ts index 8fbedcd82dc..b07a3cbd24e 100644 --- a/src/compositemark/boxplot.ts +++ b/src/compositemark/boxplot.ts @@ -4,7 +4,7 @@ import {getMarkPropOrConfig} from '../compile/common'; import {Config} from '../config'; import {Encoding, extractTransformsFromEncoding, normalizeEncoding} from '../encoding'; import * as log from '../log'; -import {isMarkDef, MarkDef} from '../mark'; +import {isMarkDef, MarkDef, MarkInvalidMixins} from '../mark'; import {NormalizerParams} from '../normalize'; import {GenericUnitSpec, NormalizedLayerSpec, NormalizedUnitSpec} from '../spec'; import {AggregatedFieldDef, CalculateTransform, JoinAggregateTransform, Transform} from '../transform'; @@ -46,7 +46,8 @@ export interface BoxPlotConfig extends BoxPlotPartsMixins { } export type BoxPlotDef = GenericCompositeMarkDef & - BoxPlotConfig & { + BoxPlotConfig & + MarkInvalidMixins & { /** * Type of the mark. For box plots, this should always be `"boxplot"`. * [boxplot](https://vega.github.io/vega-lite/docs/boxplot.html) @@ -102,6 +103,8 @@ export function normalizeBoxPlot( config ); + const invalid = markDef.invalid; + const boxPlotType = getBoxPlotType(extent); const { bins, @@ -147,7 +150,7 @@ export function normalizeBoxPlot( // ## Whisker Layers - const endTick: MarkDef = {type: 'tick', color: 'black', opacity: 1, orient: ticksOrient, invalid: null, aria: false}; + const endTick: MarkDef = {type: 'tick', color: 'black', opacity: 1, orient: ticksOrient, invalid, aria: false}; const whiskerTooltipEncoding: Encoding = boxPlotType === 'min-max' ? fiveSummaryTooltipEncoding // for min-max, show five-summary tooltip for whisker @@ -164,14 +167,14 @@ export function normalizeBoxPlot( const whiskerLayers = [ ...makeBoxPlotExtent({ partName: 'rule', - mark: {type: 'rule', invalid: null, aria: false}, + mark: {type: 'rule', invalid, aria: false}, positionPrefix: 'lower_whisker', endPositionPrefix: 'lower_box', extraEncoding: whiskerTooltipEncoding }), ...makeBoxPlotExtent({ partName: 'rule', - mark: {type: 'rule', invalid: null, aria: false}, + mark: {type: 'rule', invalid, aria: false}, positionPrefix: 'upper_box', endPositionPrefix: 'upper_whisker', extraEncoding: whiskerTooltipEncoding @@ -201,7 +204,7 @@ export function normalizeBoxPlot( type: 'bar', ...(sizeValue ? {size: sizeValue} : {}), orient: boxOrient, - invalid: null, + invalid, ariaRoleDescription: 'box' }, positionPrefix: 'lower_box', @@ -212,7 +215,7 @@ export function normalizeBoxPlot( partName: 'median', mark: { type: 'tick', - invalid: null, + invalid, ...(isObject(config.boxplot.median) && config.boxplot.median.color ? {color: config.boxplot.median.color} : {}), ...(sizeValue ? {size: sizeValue} : {}), orient: ticksOrient, diff --git a/src/mark.ts b/src/mark.ts index 12706863c24..dc0d4eaacda 100644 --- a/src/mark.ts +++ b/src/mark.ts @@ -75,7 +75,16 @@ export interface TooltipContent { /** @hidden */ export type Hide = 'hide'; -export interface VLOnlyMarkConfig extends ColorMixins { +export interface MarkInvalidMixins { + /** + * Defines how Vega-Lite should handle marks for invalid values (`null` and `NaN`). + * - If set to `"filter"` (default), all data items with null values will be skipped (for line, trail, and area marks) or filtered (for other marks). + * - If `null`, all data items are included. In this case, invalid values will be interpreted as zeroes. + */ + invalid?: 'filter' | Hide | null; +} + +export interface VLOnlyMarkConfig extends ColorMixins, MarkInvalidMixins { /** * Whether the mark's color should be used as fill color instead of stroke color. * @@ -86,13 +95,6 @@ export interface VLOnlyMarkConfig extends ColorM */ filled?: boolean; - /** - * Defines how Vega-Lite should handle marks for invalid values (`null` and `NaN`). - * - If set to `"filter"` (default), all data items with null values will be skipped (for line, trail, and area marks) or filtered (for other marks). - * - If `null`, all data items are included. In this case, invalid values will be interpreted as zeroes. - */ - invalid?: 'filter' | Hide | null; - /** * For line and trail marks, this `order` property can be set to `null` or `false` to make the lines use the original order in the data sources. */ diff --git a/test/compositemark/boxplot.test.ts b/test/compositemark/boxplot.test.ts index 6b19c5e1871..b555fb6164b 100644 --- a/test/compositemark/boxplot.test.ts +++ b/test/compositemark/boxplot.test.ts @@ -858,7 +858,6 @@ describe('normalizeBoxIQR', () => { style: 'boxplot-box', size: 14, orient: 'vertical', - invalid: null, ariaRoleDescription: 'box' }, encoding: {