如何在查找转换中转换辅助数据源?
How to transform a secondary data source inside a lookup transform?
我们如何在查找转换中转换辅助数据源?我想在辅助数据源本身内部应用转换,即 test.csv
.
这是包含少量示例数据的 test.csv
文件
country_txt
success
Australia
1
Australia
2
England
0
这是没有 mark
属性 的不完整 vega.json
文件,但应该足够了
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": "OK",
"width": 1080,
"height": 1080,
"data": {
"url": "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json",
"format": {
"type": "topojson",
"feature": "countries"
}
},
"transform": [
{
"lookup": "properties.name",
"from": {
"data": {
"url": "data\test.csv"
},
"key": "country_txt",
"fields": [
"country_txt"
]
}
}
]
我想在使用我的主要数据源执行查找转换之前汇总 test.csv
中出现的国家/地区的计数。那我们该怎么做呢?我尝试在 key
属性 声明之前直接转换它,但它不受支持。我刚开始使用 Vega Lite 并尝试阅读文档,但那里没有我可以使用的东西,因此非常感谢您的帮助。
"data": [
{
"name": "test",
"url": "data\test.csv",
"format": {"type": "csv", "parse": "auto"},
"transform": [
{"type": "aggregate","groupby":["country_txt"]}
]
},
{
"name": "map",
"url": "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json",
"format": {"type": "topojson", "feature": "countries"},
"transform": [
{ "type": "lookup", "from": "test", "key": "country_txt", "fields": ["properties.name"],"as":["Count"] }
]
}
],
通过在数据数组中声明我的数据集来解决它 属性。
我们如何在查找转换中转换辅助数据源?我想在辅助数据源本身内部应用转换,即 test.csv
.
这是包含少量示例数据的 test.csv
文件
country_txt | success |
---|---|
Australia | 1 |
Australia | 2 |
England | 0 |
这是没有 mark
属性 的不完整 vega.json
文件,但应该足够了
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": "OK",
"width": 1080,
"height": 1080,
"data": {
"url": "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json",
"format": {
"type": "topojson",
"feature": "countries"
}
},
"transform": [
{
"lookup": "properties.name",
"from": {
"data": {
"url": "data\test.csv"
},
"key": "country_txt",
"fields": [
"country_txt"
]
}
}
]
我想在使用我的主要数据源执行查找转换之前汇总 test.csv
中出现的国家/地区的计数。那我们该怎么做呢?我尝试在 key
属性 声明之前直接转换它,但它不受支持。我刚开始使用 Vega Lite 并尝试阅读文档,但那里没有我可以使用的东西,因此非常感谢您的帮助。
"data": [
{
"name": "test",
"url": "data\test.csv",
"format": {"type": "csv", "parse": "auto"},
"transform": [
{"type": "aggregate","groupby":["country_txt"]}
]
},
{
"name": "map",
"url": "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json",
"format": {"type": "topojson", "feature": "countries"},
"transform": [
{ "type": "lookup", "from": "test", "key": "country_txt", "fields": ["properties.name"],"as":["Count"] }
]
}
],
通过在数据数组中声明我的数据集来解决它 属性。