Forum Discussion
100% Clustered Stacked Column Chart with data labels
no idea what that means.
Table:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckktyMmvTE1R0lEyNjQBkkaWFoZKsTrRSsGpRWWpRcVAIUsgNoCLZSanggRBao1NwaKORckZmWWpQAFDiMpYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [System = _t, Alerts = _t, OK = _t]),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"System"}, "Attribute", "Value"),
#"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", type number}})
in
#"Changed Type"
Vega Lite:
{
"data": {"name": "dataset"},
"encoding": {
"x": {
"field": "System",
"type": "nominal"
},
"y": {
"field": "Sum of Value",
"type": "quantitative",
"stack":"normalize"
},
"yOffset": {"field": "Attribute"},
"color": {"field": "Attribute"},
"opacity": {
"condition": {
"test": {
"field": "__selected__",
"equal": "off"
},
"value": 0.3
},
"value": 1
}
},
"layer": [
{
"mark": {
"type": "bar",
"tooltip": true
}
},
{
"mark": {
"type": "text",
"color": "black",
"dx": -15,
"dy": -15
},
"encoding": {
"detail": {
"type": "nominal",
"field": "Attribute"
},
"text": {
"type": "quantitative",
"aggregate": "sum",
"field": "Sum of Value",
"format": ".0f"
}
}
}
]
}
lbendlin I was able to open the file. I see this Deneb control for the first time, please explain where this Vega code is stored and how do I get real data into it?
- lbendlin3 years ago
Super User
click the ellipsis, then "Edit". Put the fields you want into the values well and then adjust the Vega Lite code as needed.
It's a bit of a learning curve (and I'm still at the bottom of the hill) but worth spending time with.
- Markzolotoy3 years ago
Impactful Individual
lbendlin So, you manually created a table, right? Also, what would you recommend to read in order to hook up real data?
- lbendlin3 years ago
Super User
The visual doesn't care where the data comes from. Specify the fields you need from your appropriate source. If the fields have different names you'll have to adjust the Vega Lite code accordingly.
- Markzolotoy3 years ago
Impactful Individual
lbendlin Fine, but I dont even see how data is going into Vega code.
- lbendlin3 years ago
Super User
The very first line
"data": {"name": "dataset"},"dataset" is the collection of columns and measures you put into the Values well of the Deneb visual. Like a dataframe in Python or R visuals, but without the deduplication.
- Markzolotoy3 years ago
Impactful Individual
lbendlin I see. So, once I add a field from a table that tables becomes "dataset", right? Interesting, the table itself is not called "dataset". Also, in the code there is no reference to either word "data" or word "dataset". However, I am getting the idea of hooking up data.
- lbendlin3 years ago
Super User
a field from a table that tables becomes "dataset", right?Close but no. Columns and measures from the current filter context become the "dataset" when you put them in the values well. These columns can come from different tables.