diff --git a/examples/compiled/bar_conditional_opacity.png b/examples/compiled/bar_conditional_opacity.png new file mode 100644 index 0000000000..457b6045ec Binary files /dev/null and b/examples/compiled/bar_conditional_opacity.png differ diff --git a/examples/compiled/bar_conditional_opacity.svg b/examples/compiled/bar_conditional_opacity.svg new file mode 100644 index 0000000000..83121d3d5b --- /dev/null +++ b/examples/compiled/bar_conditional_opacity.svg @@ -0,0 +1 @@ +a2c1c2c3C20102030405060708090Q1_Null \ No newline at end of file diff --git a/examples/compiled/bar_conditional_opacity.vg.json b/examples/compiled/bar_conditional_opacity.vg.json new file mode 100644 index 0000000000..79d8962c2d --- /dev/null +++ b/examples/compiled/bar_conditional_opacity.vg.json @@ -0,0 +1,209 @@ +{ + "$schema": "https://vega.github.io/schema/vega/v5.json", + "background": "white", + "padding": 5, + "width": 400, + "height": 400, + "style": "cell", + "data": [ + { + "name": "source_0", + "values": [ + { + "Q1": 12.3, + "Q2": 63.5, + "Q1_Null": null, + "Q2_Null": 63.5, + "C1": "A", + "C1_Null": null, + "C2": "a1", + "C2_Null": "a1", + "T": "2022-09-07T00:00:00.000Z", + "T_Null": "2022-09-07T00:00:00.000Z" + }, + { + "Q1": 62.3, + "Q2": 34.5, + "Q1_Null": null, + "Q2_Null": 34.5, + "C1": "A", + "C1_Null": "A", + "C2": "b1", + "C2_Null": "b1", + "T": "2022-09-08T00:00:00.000Z", + "T_Null": null + }, + { + "Q1": 82.3, + "Q2": 77.7, + "Q1_Null": 82.3, + "C1": "A", + "C1_Null": "A", + "C2": "c1", + "C2_Null": "c1", + "T": "2022-09-09T00:00:00.000Z", + "T_Null": "2022-09-09T00:00:00.000Z" + }, + { + "Q1": 41.1, + "Q2": 29.1, + "Q1_Null": 41.1, + "Q2_Null": null, + "C1": "B", + "C1_Null": "B", + "C2": "a2", + "C2_Null": "a2", + "T": "2022-09-17T00:00:00.000Z", + "T_Null": "2022-09-17T00:00:00.000Z" + }, + { + "Q1": 31.1, + "Q2": 39.1, + "Q1_Null": 31.1, + "Q2_Null": null, + "C1": "A", + "C1_Null": "A", + "C2": "a2", + "C2_Null": "a2", + "T": "2022-09-07T00:00:00.000Z", + "T_Null": "2022-09-07T00:00:00.000Z" + }, + { + "Q1": 15.1, + "Q2": 50.1, + "Q1_Null": 15.1, + "Q2_Null": 50.1, + "C1": "B", + "C1_Null": null, + "C2": "c2", + "C2_Null": null, + "T": "2022-09-18T00:00:00.000Z", + "T_Null": "2022-09-18T00:00:00.000Z" + }, + { + "Q1": 48.1, + "Q2": 94.1, + "Q1_Null": 48.1, + "Q2_Null": 94.1, + "C1": "B", + "C1_Null": "B", + "C2": "c3", + "C2_Null": "c3", + "T": "2022-09-19T00:00:00.000Z", + "T_Null": "2022-09-19T00:00:00.000Z" + }, + { + "Q1": 48.1, + "Q2": 94.1, + "Q1_Null": null, + "Q2_Null": null, + "C1": "B", + "C1_Null": "B", + "C2": "c4", + "C2_Null": "c4", + "T": "2022-09-20T00:00:00.000Z", + "T_Null": "2022-09-30T00:00:00.000Z" + } + ] + }, + { + "name": "data_0", + "source": "source_0", + "transform": [ + { + "type": "stack", + "groupby": ["C2"], + "field": "Q1_Null", + "sort": {"field": [], "order": []}, + "as": ["Q1_Null_start", "Q1_Null_end"], + "offset": "zero" + }, + { + "type": "filter", + "expr": "isValid(datum[\"Q1_Null\"]) && isFinite(+datum[\"Q1_Null\"])" + } + ] + } + ], + "marks": [ + { + "name": "layer_0_marks", + "type": "rect", + "style": ["bar"], + "from": {"data": "data_0"}, + "encode": { + "update": { + "fill": {"value": "#4c78a8"}, + "opacity": { + "test": "selection.kind === 'values' && indexof(selection.values, datum['C2']) === -1", + "value": 0.2 + }, + "tooltip": { + "signal": "{\"C2\": isValid(datum[\"C2\"]) ? datum[\"C2\"] : \"\"+datum[\"C2\"], \"Q1_Null\": format(datum[\"Q1_Null\"], \"\")}" + }, + "ariaRoleDescription": {"value": "bar"}, + "description": { + "signal": "\"C2: \" + (isValid(datum[\"C2\"]) ? datum[\"C2\"] : \"\"+datum[\"C2\"]) + \"; Q1_Null: \" + (format(datum[\"Q1_Null\"], \"\"))" + }, + "x": {"scale": "x", "field": "C2"}, + "width": {"signal": "max(0.25, bandwidth('x'))"}, + "y": {"scale": "y", "field": "Q1_Null_end"}, + "y2": {"scale": "y", "field": "Q1_Null_start"} + } + } + } + ], + "scales": [ + { + "name": "x", + "type": "band", + "domain": {"data": "data_0", "field": "C2", "sort": true}, + "range": [0, {"signal": "width"}], + "paddingInner": 0.1, + "paddingOuter": 0.05 + }, + { + "name": "y", + "type": "linear", + "domain": {"data": "data_0", "fields": ["Q1_Null_start", "Q1_Null_end"]}, + "range": [{"signal": "height"}, 0], + "nice": true, + "zero": true + } + ], + "axes": [ + { + "scale": "y", + "orient": "left", + "gridScale": "x", + "grid": true, + "tickCount": {"signal": "ceil(height/40)"}, + "domain": false, + "labels": false, + "aria": false, + "maxExtent": 0, + "minExtent": 0, + "ticks": false, + "zindex": 0 + }, + { + "scale": "x", + "orient": "bottom", + "grid": false, + "title": "C2", + "labelAlign": "right", + "labelAngle": 270, + "labelBaseline": "middle", + "zindex": 0 + }, + { + "scale": "y", + "orient": "left", + "grid": false, + "title": "Q1_Null", + "labelOverlap": true, + "tickCount": {"signal": "ceil(height/40)"}, + "zindex": 0 + } + ] +}