I am trying to create a parcel plot with a secondary y axis in Vega. I am building from the example area diagram depicted here in the editor. I added a βcolβ field for the data and use facet transform to organize the data into groups with βcolβ as the key. I added an auxiliary axis and a scale for each group, but I canβt understand how when declaring labels to match the data column with the corresponding scale. In other words, I donβt know how to have βyβ and βy2β in the βenterβ property, use the βAβ scale if the current label is COL = A or the βBβ scale if the current label is COL = B. Here is the vega object I'm working on:
{ "width": 500, "height": 200, "padding": {"top": 10, "left": 30, "bottom": 30, "right": 30}, "data": [ { "name": "table", "values": [ {"x": 1, "y": 28, "col": "A"}, {"x": 2, "y": 55, "col": "A"}, {"x": 3, "y": 43, "col": "A"}, {"x": 4, "y": 91, "col": "A"}, {"x": 5, "y": 81, "col": "A"}, {"x": 6, "y": 53, "col": "A"}, {"x": 7, "y": 19, "col": "A"}, {"x": 8, "y": 87, "col": "A"}, {"x": 9, "y": 52, "col": "A"}, {"x": 10, "y": 48, "col": "A"}, {"x": 11, "y": 24, "col": "A"}, {"x": 12, "y": 49, "col": "A"}, {"x": 13, "y": 87, "col": "A"}, {"x": 14, "y": 66, "col": "A"}, {"x": 15, "y": 17, "col": "A"}, {"x": 16, "y": 27, "col": "A"}, {"x": 17, "y": 68, "col": "A"}, {"x": 18, "y": 16, "col": "A"}, {"x": 19, "y": 49, "col": "A"}, {"x": 20, "y": 15, "col": "A"}, {"x": 1, "y": 26, "col": "B"}, {"x": 2, "y": 59, "col": "B"}, {"x": 3, "y": 50, "col": "B"}, {"x": 4, "y": 94, "col": "B"}, {"x": 5, "y": 83, "col": "B"}, {"x": 6, "y": 50, "col": "B"}, {"x": 7, "y": 17, "col": "B"}, {"x": 8, "y": 81, "col": "B"}, {"x": 9, "y": 48, "col": "B"}, {"x": 10, "y": 20, "col": "B"}, {"x": 11, "y": 20, "col": "B"}, {"x": 12, "y": 80, "col": "B"}, {"x": 13, "y": 90, "col": "B"}, {"x": 14, "y": 22, "col": "B"}, {"x": 15, "y": 20, "col": "B"}, {"x": 16, "y": 19, "col": "B"}, {"x": 17, "y": 2, "col": "B"}, {"x": 18, "y": 4, "col": "B"}, {"x": 19, "y": 3, "col": "B"}, {"x": 20, "y": 1, "col": "B"} ] } ], "scales": [ { "name": "x", "type": "linear", "range": "width", "zero": false, "domain": {"data": "table", "field": "data.x"} }, { "name": "A", "type": "linear", "range": "height", "nice": true, "domain": {"data": "table", "field": "data.y"} }, { "name": "B", "type": "linear", "range": "height", "nice": true, "domain": {"data": "table", "field": "data.y"} }, { "name": "color", "type": "ordinal", "range": "category10" } ], "axes": [ {"type": "x", "scale": "x", "ticks": 20}, {"type": "y", "scale": "A"}, {"type": "y", "scale": "B", "orient":"right"} ], "marks": [ { "type": "group", "from": { "data": "table", "transform": [{"type": "facet", "keys": ["data.col"]}] }, "marks": [ { "type": "area", "properties": { "enter": { "interpolate": {"value": "monotone"}, "x": {"scale": "x", "field": "data.x"}, "y": {"scale": "A", "field": "data.y"}, "y2": {"scale": "A", "value": 0}, "fill": {"scale": "color", "field": "data.col"} }, "update": { "fillOpacity": {"value": 1} }, "hover": { "fillOpacity": {"value": 0.5} } } } ] } ] }