-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
label based slicer to select nested object #1316
Comments
+1 I think this feature is really needed, mosto of systems return data using nested objects (ie elasticsearch aggregations) And you cannot select nested objects to visualize them. This is new feature request that will be very usefull |
I certainly understand the desire for convenience here, but also want to point out that you can already accomplish un-nesting of semi-structured data with the existing Vega transforms. For example, in the example provided above, you can simply provide explicit nested field names to the
While the above example is slightly more verbose, it doesn't add a disproportional costs: if you are going to project them, I assume you already have to reference these fields by name elsewhere in your specification in order to visualize them. I've updated the Also, in addition to Nevertheless, the idea of a slicer syntax -- either under the data |
I have another example that come from elasticsearch The ouput should be [{"a": 5, "b": "string_0"}, if ne nested value is an array or an object containing other objects I think project wont work. Best |
As I noted in my previous reply, you can use the {
"$schema": "https://vega.github.io/schema/vega/v4.json",
"data": [
{
"name": "data",
"values": [
{"foo": [{"a": 5, "b": "string_0"},{"a": 5, "b": "string_2"},{"a": 5, "b": "string_2"}], "bah": 0},
{"foo": [{"a": 6, "b": "string_1"},{"a": 6, "b": "string_2"},{"a": 6, "b": "string_2"}], "bah": 1},
{"foo": [{"a": 7, "b": "string_1"},{"a": 7, "b": "string_2"},{"a": 7, "b": "string_2"}], "bah": 2}
],
"transform": [
{
"type": "flatten",
"fields": ["foo"],
"as": ["foo"]
},
{
"type": "project",
"fields": ["bah", "foo.a", "foo.b"],
"as": ["bah", "a", "b"]
}
]
}
]
} |
Thanks!! |
I'm closing out this issue for now, as the needed functionality is already provided. If someone would like to propose a more complete design for alternative un-nesting procedures, please feel free to share them in a new feature request issue. |
It would be nice to make a label based slice to select a nested object. I can use the existing
project
transform as such:but this still returns a nested object:
Where I was hoping for:
Maybe in the
project
transform theas
can acceptnull
value to make this possible?"transform": [{"type": "project", "fields": ["foo"], "as": null}]
Or, completely different, as a real slicer under the data
format
:"format": {"type": "json", "property": "[:,'foo']"}
The text was updated successfully, but these errors were encountered: