Forum Discussion
trelli/multiple scatter plot and pie chart
- 3 years ago
I coded the facets to dynamically handle the row/column layout, so adding/removing charts within reason should not be an issue.
ā
Regarding my comment about adjusting those width/height/radius percentage values in deneb, I meant that one would only need to do that if they modify the visual's width and height in the formatting properties (see below screenshot). This is a limitation of faceting in vega-lite; currently the facet cell size cannot dynamically change based on the size of the canvas (yet). I cannot think of a scenario where a user could adjust the visual dimensions but would not have access to being able to update the spec in Deneb...ā
| Type | Voice | Result |
| A | Power | 10 |
| A | Then | 5 |
| A | Zeld | 32 |
| A | Link | 8 |
| A | Nintend | 2 |
| A | Sega | 7 |
| B | Power | 8 |
| B | Then | 4 |
| B | Zeld | 6 |
| B | Link | 8 |
| B | Nintend | 20 |
| B | Sega | 52 |
| C | Power | 9 |
| C | Then | 13 |
| C | Zeld | 25 |
| C | Link | 2 |
| C | Nintend | 2 |
| C | Sega | 3 |
| D | Power | 10 |
| D | Then | 20 |
| D | Zeld | 54 |
| D | Link | 10 |
| D | Nintend | 30 |
| D | Sega | 10 |
| E | Power | 3 |
| E | Then | 65 |
| E | Zeld | 9 |
| E | Link | 24 |
| E | Nintend | 35 |
| E | Sega | 22 |
| F | Power | 70 |
| F | Then | 17 |
| F | Zeld | 21 |
| F | Link | 80 |
| F | Nintend | 7 |
| F | Sega | 10 |
| G | Power | 9 |
| G | Then | 90 |
| G | Zeld | 20 |
| G | Link | 20 |
| G | Nintend | 100 |
| G | Sega | 20 |
| H | Power | 5 |
| H | Then | 5 |
| H | Zeld | 120 |
| H | Link | 5 |
| H | Nintend | 5 |
| H | Sega | 75 |
| I | Power | 33 |
| I | Then | 130 |
| I | Zeld | 33 |
| I | Link | 1 |
| I | Nintend | 0 |
| I | Sega | 0 |
| J | Power | 40 |
| J | Then | 11 |
| J | Zeld | 22 |
| J | Link | 11 |
| J | Nintend | 50 |
| J | Sega | 24 |
| K | Power | 3 |
| K | Then | 7 |
| K | Zeld | 60 |
| K | Link | 21 |
| K | Nintend | 12 |
| K | Sega | 22 |
| L | Power | 70 |
| L | Then | 10 |
| L | Zeld | 0 |
| L | Link | 10 |
| L | Nintend | 20 |
| L | Sega | 80 |
| M | Power | 30 |
| M | Then | 22 |
| M | Zeld | 25 |
| M | Link | 1 |
| M | Nintend | 140 |
| M | Sega | 19 |
| N | Power | 22 |
| N | Then | 27 |
| N | Zeld | 30 |
| N | Link | 5 |
| N | Nintend | 30 |
| N | Sega | 6 |
| O | Power | 22 |
| O | Then | 33 |
| O | Zeld | 8 |
| O | Link | 9 |
| O | Nintend | 38 |
| O | Sega | 31 |
Anonymous, while I personally don't love pie charts, I do like your choice of dummy data š.
There's a lot that can be configured and formatted here, but I kept it simple. Let me know if you need any tweaks.
You should be able to copy the spec into Deneb. You'll want to drag in the Type, Voice, and Result fields into the data pane, and remove the url and format properties under the data property in the spec.
If this gets you going, please consider liking this reply and choosing it as the solution so others can find it. If you need additional help, just let me know.
spec:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"name": "dataset",
"url": "https://raw.githubusercontent.com/Giammaria/PublicFiles/master/pbi/pbi_community_help/trellis_pie/data/data.tsv",
"format": {"parse": {"Result": "number"}}
},
"transform": [
{"joinaggregate": [{"op": "distinct", "field": "Type", "as": "type_count"}]},
{"joinaggregate": [{"op": "sum", "field": "Result", "as": "result_total"}], "groupby": ["Type"]},
{"calculate": "toString(datum['Result'])+' out of '+toString(datum['result_total'])", "as": "result_out_of"},
{"calculate": "format(datum['Result']/datum['result_total'],'.0%')", "as": "percentage"}
],
"mark": {"type": "arc"},
"encoding": {
"facet": {
"field": "Type",
"type": "ordinal",
"columns": 5,
"sort": {"field": "Type"}
},
"theta": {"field": "Result", "type": "quantitative"},
"color": {"field": "Voice", "type": "nominal"},
"tooltip": [
{"title": "Voice", "field": "Voice"},
{"title": "Result", "field": "result_out_of"},
{"title": "Result %", "field": "percentage"}
]
}
}
- Anonymous3 years agoNot applicable
thanks a lot this looks great. But i dont see anything appearing in Power BI. Maybe because i dont have any configuration? Could you please provide me also the config? Sorry i am very bad at this.
I have added the 3 fields and remoove the url to obtain something starting with this : {
"data": {"name": "dataset"},
"transform":Could you also please add a percentage in each pie per voice (legend)? fi
- Anonymous3 years agoNot applicable
Hi,
Is that possible to have also a bar to set the graphs dimension? As you have done for the multiple treilli? This could be great!!
Jim
- giammariam3 years agoSolution Sage
Please make a new post and tag me with this request. I'd be happy to.