Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello,
I have a 100% stacked bar chart that displays per country the product sales. (I've reduced my products in the top 3, so that for each country i have these only). I want to add next to each line (country) the value that corresponds to the revenue per country but in total for all products. Is it possible?
Not with the standard visuals. Use Deneb or similar to create your own visual .
So, the only option I actually have is to create a custom visual. Do you think that i could it maybe using python code?
if that Python code renders the chart, yes.
I tried this code, but it does not display the visual as I expect:
I want in axe Y the countries and then display the apples, lemons and oranges in a 100% stacked bar chart. At the end of each bar to display as label the revenue for each country
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"name": "dataset"},
"transform": [
{
"calculate": "datum['apples'] + datum['oranges'] + datum.lemons",
"as": "total"
},
{
"stack": "total",
"as": ["bottom", "top"]
}
],
"mark": "bar",
"encoding": {
"y": {
"field": "Country",
"type": "nominal"
},
"x": {
"field": [
"apples",
"oranges",
"lemons"
],
"type": "quantitative",
"stack": "normalize",
"axis": {"format": ".0%"}
},
"color": {
"field": "revenue",
"scale": {"scheme": "redblue"}
},
"opacity": {
"condition": {
"test": {
"field": "__selected__",
"equal": "off"
},
"value": 0.3
},
"value": 1
},
"tooltip": [
{
"field": "apples",
"title": "apples"
},
{
"field": "oranges",
"title": "oranges"
},
{
"field": "lemons",
"title": "lemons"
}
]
}
}