Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Fixed spacing/padding for labels

I’m a Vega Lite newbie and using Vega Lite using Deneb in PowerBI. I’ve created a bar chart showing the responses to a survey – the labels are the questions themselves so are quite long (up to 150 characters). There is a filter in PowerBI that determines the questions shown – the maximum length of the question/labels varies and so the actual plot area expands/contracts to fill the space available. If possible I’d like to keep the plot area the same – I’ve tried adding padding spacing to the questions to make them all the same length but Vega Lite is clever and removes/trims excess spaces! I’ve experimented with "Customizing Size" but with no success.

Is there a way to explicitly define the plot area position? e.g. "width": 300, "x": 200 where x is the absolute position of the start of the plot? Or alternatively to set a fixed width to the axis label area?

Please below example images – in these the size and position of the plot area changes depending on the selected set of questions – I’d like the plot position and size to remain constant if possible. This is an example code [Example PowerBI File] (https://sendanywhe.re/AGKNXTQ7)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Set A

Set B

Many thanks in advance for any help!

>Solution :

Does adding a minExtent do what you want?

{
  "data": {"name": "dataset"},
  "mark": {"type": "bar"},
  "width":400,  
  "encoding": {
    "y": {
      "field": "Question",
      "type": "nominal",
        "axis": {
        "labelAlign": "right",
        "labelLimit": 900,
        "labelFontSize": 10, "minExtent":350
      }
    },
    "x": {
      "field": "Sum of Good",
      "type": "quantitative"
    }
  }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading