过滤纯素食主义者的数据



我正在尝试筛选我的数据,这样它就不会包括图表中丢失的数据(记为0(。我想我需要添加的代码是

"transform": [
{"filter": "datum.Gross enrolment ratio for tertiary education both sexes (%) > 0"
}
],

但它似乎不起作用。

这是我的纯素食主义图表的代码

{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"title": {
"text": "Billionaires and Education Attainment",
"subtitle": "Sources: ",
"subtitleFontStyle": "italic",
"subtitleFontSize": 10,
"anchor": "start",
"color": "black"
},
"height": 300,
"width": 260,
"data": {
"url": "https://raw.githubusercontent.com/jamieprince/jamieprince.github.io/main/correlation.csv"
},
"selection": {
"paintbrush": {
"type": "multi",
"on": "mouseover",
"nearest": true
},
"grid": {
"type": "interval",
"bind": "scales"
}
},
"mark": {
"type": "circle",
"opacity": 0.4,
"color": "skyblue"
},
"encoding": {
"x": {
"field": "Number of Billionaires",
"type": "quantitative",
"axis": {
"title": "Number of Billionaires",
"grid": false,
"tickCount": 14,
"labelOverlap": "greedy"
}
},
"y": {
"field": "Gross enrolment ratio for tertiary education both sexes (%)",
"type": "quantitative",
"axis": {
"title": "Educational Attainment",
"grid": false
}
},
"size": {
"condition": {
"selection": "paintbrush",
"value": 300,
"init": {
"value": 70
}
},
"value": 70
},

"tooltip": [
{
"field": "Year",
"type": "nominal",
"title": "Year"
},
{
"field": "Country",
"type": "ordinal",
"title": "Country"
},
{
"field": "Number of Billionaires",
"type": "nominal",
"title": "No of Billionaires"
},
{
"field": "Gross enrolment ratio for tertiary education both sexes (%)",
"type": "nominal",
"title": "Gross enrolment ratio for tertiary education both sexes (%)"
}
]
}
}

有人知道我如何过滤数据,使其只包括变量不为0的点吗?

非常感谢!

您可以使用大于谓词来完成此操作:

"transform": [{
"filter": {
"field": "Gross enrolment ratio for tertiary education both sexes (%)",
"gt": 0
}
}],

最新更新