Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
GlenWL
Frequent Visitor

Deneb Heatmap with Labels

I'm really struggling to get data labels to show in my deneb heatmap matrix. Very new to deneb and vega-lite so was following Daniel M-P's tutorial that he did on the Reid Havens YouTube channel. However, he didn't add the labels so I'm trying to get it to work myself, but knowing where to place the line of code is causing me problems.

Here's the code without the labels.

Any help would be much appreciated.

 

{
"data": {"name": "dataset"},
"resolve": {
"scale": {"color": "independent"}
},
"transform": [
{
"calculate": "datum['__selected__'] == 'off' ? 0 : datum['Transfers']",
"as": "Transfers_Selected"
}
],
"vconcat": [
{
"hconcat": [
{
"name": "Main matrix",
"mark": {
"type": "rect",
"tooltip": true
},
"encoding": {
"x": {
"field": "WeekDay",
"sort": null
},
"y": {
"field": "Hour",
"sort": null
},
"fill": {
"field": "Transfers",
"type": "quantitative",
"legend": null,
"scale": {
"range": [
"#D5E9F9",
"#FFE45E",
"#FD0E33"
]
}
},
"opacity": {
"condition": {
"test": {
"field": "__selected__",
"equal": "off"
},
"value": 0.3
},
"value": 1
}
}
},
{
"name": "Marginal bars (row)",
"width": 95,
"layer": [
{
"mark": {
"type": "bar",
"height": {"band": 0.9},
"opacity": 0.3
},
"encoding": {
"x": {
"field": "Transfers",
"aggregate": "sum"
}
}
},
{
"mark": {
"type": "text",
"color": "white",
"xOffset": 22
},
"encoding": {
"text": {
"field": "Transfers_Selected",
"type": "quantitative",
"aggregate": "sum",
"formatType": "pbiFormat",
"format": "#,0"
}
}
},
{
"mark": {
"type": "bar",
"height": {"band": 0.9},
"tooltip": true
}
}
],
"encoding": {
"y": {
"field": "Hour",
"sort": null,
"axis": null
},
"x": {
"field": "Transfers_Selected",
"type": "quantitative",
"aggregate": "sum"
},
"tooltip": [
{
"field": "Hour",
"title": "Hour of Day"
},
{
"field": "Transfers",
"aggregate": "sum"
},
{
"field": "Transfers_Selected",
"aggregate": "sum",
"title": "Transfers (Highlighted)",
"formatType": "pbiFormat",
"format": "#,0"
}
]
}
}
]
},
{
"hconcat": [
{
"name": "Marginal bars (col)",
"height": 65,
"layer": [
{
"mark": {
"type": "bar",
"width": {"band": 0.96},
"opacity": 0.3
},
"encoding": {
"y": {
"field": "Transfers",
"aggregate": "sum"
}
}
},
{
"mark": {
"type": "text",
"color": "white",
"yOffset": 14
},
"encoding": {
"text": {
"field": "Transfers_Selected",
"type": "quantitative",
"aggregate": "sum",
"formatType": "pbiFormat",
"format": "#,0"
}
}
},
{
"mark": {
"type": "bar",
"width": {"band": 0.96},
"tooltip": true
}
}
],
"encoding": {
"x": {
"field": "WeekDay",
"sort": null,
"axis": null
},
"y": {
"field": "Transfers_Selected",
"type": "quantitative",
"aggregate": "sum",
"scale": {"reverse": true}
},
"tooltip": [
{
"field": "WeekDay",
"title": "Day of Week"
},
{
"field": "Transfers",
"aggregate": "sum"
},
{
"field": "Transfers_Selected",
"aggregate": "sum",
"title": "Transfers (Highlighted)",
"formatType": "pbiFormat",
"format": "#,0"
}
]
}
}
]
}
]
}

1 ACCEPTED SOLUTION
giammariam
Super User
Super User

Hey @GlenWL The solution .pbix can be found here. You may have to tinker with things to get the cross-highlighting working with the outer bars.

giammariam_0-1675871230310.png

 



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!

View solution in original post

9 REPLIES 9
giammariam
Super User
Super User

Hey @GlenWL The solution .pbix can be found here. You may have to tinker with things to get the cross-highlighting working with the outer bars.

giammariam_0-1675871230310.png

 



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!

Amazing, thank you so much for this.

Tag me in the future if you ever need any Deneb help. I always enjoy getting practice in. 



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!
giammariam
Super User
Super User

Hey @GlenWL, unfortunately I cannot access that link.



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!

Really strange, just tested same link with a colleague and he can access and download the pbix without issues. I'll try it again with a zipped file.

GlenWL
Frequent Visitor

Here's a zipped version...

Zipped PBIX 

😕

giammariam_1-1675866890955.png

 



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!
giammariam
Super User
Super User

Hey @GlenWL. I just implemented this for someone else. Take a look at this thread.

If this helps you get the labels added, please consider kudoing and liking this message. If you still need additional help, please provide a santized dataset (see here) and I'll try to get back to you ASAP.



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!

Thanks for quick reply but still stuggling with it. Maybe I'm adding the text in the wrong place in the script? Tried lots of variations but can't get it to work 😞

Here's a link to the PBIX 

PBIX File 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.