1

I appreciate in advance any lead you can provide. In the shortened example below, a combination of PMT2 (from Field "Pmt Type") and RX (from field "Measure") is not part of the data. So I want to eliminate that combination from appearing in my visualization. But it still shows up. What specification will prevent it from occurring? "resolve": {"axis": {"y": "independent"}} is not working as I will expect.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
      "values": [
{"Pmt Type":"PMT2","PRE POST":"PRE","Rx":0.8,"GP":52},
{"Pmt Type":"PMT2","PRE POST":"POST","GP":30},
{"Pmt Type":"PMT1","PRE POST":"PRE","GP":52},
{"Pmt Type":"PMT1","PRE POST":"POST","GP":36}
      ]
  },
  "transform": [
      {
          "aggregate" : [
              {"op":"sum","field":"Rx","as":"Rx"},
              {"op":"sum","field":"GP","as":"GP"}
          ],
          "groupby":["PRE POST","Pmt Type"]
      },
      {
        "comment":"This is to create the Measure dimension for nesting",    
        "fold": ["Rx","GP"], "as":["Measure","Value"]
      },
      {
        "comment":"This is to filter out the unwanted combinations",
        "filter":"datum['Pmt Type']=='PMT2' || datum['Measure']=='GP'"
      }
  ],
  "config": {
      "view": {
          "strokeWidth": 2,
          "width":{"step": 70}
      }
  },
  "mark": {"type":"text"},
  "encoding": {
        "row":{"field":["Pmt Type"]},
        "y": {
            "field": "Measure"
        },
        "x": {
            "field": "PRE POST"
        },
        "text": {"field":"Value"}   
  },
   "resolve": {"axis": {"y": "independent"}}
}

1 Answers1

0

I made it work like this: (1) Use voncat instead of "row" (2) Filter records within each view of the voncat. The result is this:

{"$schema": "https://vega.github.io/schema/vega-lite/v5.json","data": {"values": [{"Pmt Type":"PMT2","PRE POST":"PRE","Measure":"Rx", "Value":0.8},{"Pmt Type":"PMT2","PRE POST":"PRE","Measure":"GP","Value":52},{"Pmt Type":"PMT1","PRE POST":"PRE","Measure":"GP", "Value":48}]},"config": {"view": {"strokeWidth": 2,"width":{"step": 70}}},"vconcat":[{ "transform":[{"filter":"datum['Pmt Type']=='PMT1'"}],"mark": {"type":"text"},"encoding": {"y": {"field": "Measure"},"x": {"field": "PRE POST"},"text": {"field":"Value"} }},{ "transform":[{"filter":"datum['Pmt Type']=='PMT2'"}],"mark": {"type":"text"},"encoding": {"y": {"field": "Measure"},"x": {"field": "PRE POST"},"text": {"field":"Value"}}}]}