我提前感谢您提供的任何线索。在下面的简短示例中,PMT2(来自“Pmt Type”字段)和 RX(来自“Measure”字段)的组合不是数据的一部分。所以我想消除这种组合出现在我的可视化中。但它仍然出现。什么规范会阻止它发生?"resolve": {"axis": {"y": "independent"}} 没有像我预期的那样工作。
{
"$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"}}
}