Crash after adding sort to encoding (cannot destructure property 'aggregate' of 'n' as it is undefined)
See original GitHub issueAdding the sort: "-x"
causes the chart to crash, removing it fixes it.
Notably, using sort: {field}
seems to work.
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"width": "container",
"data": {
"values": [
{
"label": "Food",
"amount": 1200,
"percent": 0.2901353965,
"color": "red"
},
{
"label": "Drink",
"amount": 230,
"percent": 0.05560928433,
"color": "green"
},
{
"label": "Accomodation",
"amount": 1500,
"percent": 0.3626692456,
"color": "blue"
},
{
"label": "Flight",
"amount": 240,
"percent": 0.0580270793,
"color": "red"
},
{
"label": "Entertainment",
"amount": 542,
"percent": 0.1310444874,
"color": "green"
},
{
"label": "Trips",
"amount": 334,
"percent": 0.08075435203,
"color": "blue"
},
{"label": "Misc", "amount": 90, "percent": 0.02176015474, "color": "teal"}
]
},
"title": "By category",
"encoding": {
"y": {
"field": "label",
"sort": "-x",
"title": null,
"axis": null
}
},
"layer": [
{
"mark": {"type": "bar", "tooltip": true, "cursor": "pointer"},
"encoding": {
"x": {
"field": "amount",
"type": "quantitative",
"title": null,
"axis": {"domain": false, "grid": false}
},
"color": {"field": "label", "legend": null},
"opacity": {
"condition": {"param": "selected", "value": 1},
"value": 0.3
}
},
"params": [
{
"name": "selected2",
"select": {"type": "point", "encodings": ["y"], "toggle": false}
}
]
},
{
"mark": {
"type": "text",
"align": "right",
"x": -5,
"cursor": "pointer",
"tooltip": true
},
"encoding": {
"text": {"field": "label"},
"opacity": {
"condition": {"param": "selected", "value": 1},
"value": 0.3
}
},
"params": [
{
"name": "selected",
"select": {"type": "point", "encodings": ["y"], "toggle": false}
}
]
}
]
}
Open the Chart in the Vega Editor
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
'Cannot destructure property of as it is undefined' during map
I need to pass through all the properties of this object and send them to other React component. But, not all objetcs have...
Read more >Cannot destructure Property of Undefined Error in JS
The "Cannot destructure property of undefined" error occurs when we try to destructure a property from a value that is equal to `undefined`....
Read more >SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
SyntaxError: JSON.parse: bad parsing. The JavaScript exceptions thrown by JSON.parse() occur when string failed to be parsed as JSON.
Read more >ChangeLog-2018-09-11 - Apple Open Source
Windows ports can't compile Reverted changeset: "Use a Variant ... Crashes when using computed properties with rest destructuring and object spread.
Read more >Prevent Error with Default {} when Destructuring
Why does it throw an Error? This is because you can't destructure undefined and null values. const { age } ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s a separate issue but yes!
It does not crash, but neither does it sort by
x
…, remove the text layer to get the order what OP wants.