cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mahoneypat
Super User
Super User

Deneb Faceted Chart Size

I am building a chart with Deneb and can't work out part of it. I'd like faceted charts to have a different size. When I use "independent" "resolve" for the "x" axis, I get the look I want (different chart widths). However, the chart is too small and I can't change the overall chart size.

 

mahoneypat_0-1641738646498.png

{
"data": {"values": [
{"xvalue": 1, "yvalue": 1, "category": "a"}, {"xvalue": 1, "yvalue": 1, "category": "b"}, {"xvalue": 2, "yvalue": 2, "category": "b"}, {"xvalue": 1, "yvalue": 1, "category": "c"}, {"xvalue": 2, "yvalue": 2, "category": "c"}, {"xvalue": 3, "yvalue": 3, "category": "c"}, {"xvalue": 4, "yvalue": 4, "category": "c"}]},
"facet": {
"column": {"field": "category"}
},
"spec": {
"mark": {
"type": "point"
},
"encoding": {
"x": {
"field": "xvalue",
"type": "ordinal"
},
"y": {
"field": "yvalue",
"type": "ordinal"
}
}
},
"resolve": {
"scale": {"x": "independent"}
}
}

 

I added hard-coded "values" to make it easier to troubleshoot. I can set the "height" and "width" in the "spec", but then they all have the same size. I'd like to use a parameter to find the max "xvalue" in each, and then use that to calculate a dynamic chart width. However, I haven't been able to work out how to do that. Alternative approach would be welcomed too.

 

Pat

 

@dm-p @KerKol 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hey @mahoneypat,

I'm not 100% across what the final look should be as I assume you're looking to data-drive the widths? I'm not sure that this is possible in Vega-Lite currently, as it would appear that there is no expression support for height and width properties outside the special cases.

I believe that when you use the facet channel, you aren't able to have things dynamically size; manual heights/widths are needed for the spec to drive how each facet should resolve. I believe there are some ideas being discussed for Vega-Lite (here and here), although this may not be appropriate for your case. 

It's quite fascinating that you've been able to dynamically set width with the independent x-axis though 🙂

From a quick look, the closest I could manage is by using the height at a fixed value, and width having a given step value, e.g.:

dmp_0-1641754843502.png

I get that this might not work well as more (or less) categories are introduced, but does this get you closer towards where you need to go?

I think that anything else might need a change to Vega-Lite. It might be possible to switch your language to Vega and use signals to calculate everything though there though. This might take a bit more figuring out if it's a path you want to go down.

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

2 REPLIES 2
dm-p
Super User
Super User

Hey @mahoneypat,

I'm not 100% across what the final look should be as I assume you're looking to data-drive the widths? I'm not sure that this is possible in Vega-Lite currently, as it would appear that there is no expression support for height and width properties outside the special cases.

I believe that when you use the facet channel, you aren't able to have things dynamically size; manual heights/widths are needed for the spec to drive how each facet should resolve. I believe there are some ideas being discussed for Vega-Lite (here and here), although this may not be appropriate for your case. 

It's quite fascinating that you've been able to dynamically set width with the independent x-axis though 🙂

From a quick look, the closest I could manage is by using the height at a fixed value, and width having a given step value, e.g.:

dmp_0-1641754843502.png

I get that this might not work well as more (or less) categories are introduced, but does this get you closer towards where you need to go?

I think that anything else might need a change to Vega-Lite. It might be possible to switch your language to Vega and use signals to calculate everything though there though. This might take a bit more figuring out if it's a path you want to go down.

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Thank you, @dm-p . I've used "step" before, and should have thought to try that. I think your approach will get me there.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Power BI Show Ep 4 Post Show Carousel.jpg

The Power BI Community Show

Shabnam Watson demos Incremental refresh & Hybrid Tables and Leila Etaati demos Charticulator.

PBI April Release 2022 768x460.png

Check it out!

Click here to read more about the April 2022 updates!

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!