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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
pbiXlsx
Frequent Visitor

Deneb / Vega-lite questions

Hi, 

 

I am trying to use a Deneb Visual.

 

pbiXlsx_0-1668610819447.png

 

{
  "data": {"name": "dataset"},
  "encoding": {
    "y": {
      "field": "Group",
      "type": "nominal",
      "title": null
    },
    "x": {
      "field": "LQ3",
      "type": "quantitative",
      "title": null,
      "stack": "zero"
    },
    "order": {
      "field": "Mgmt_Dashboard_LQ1"
    }
  },
  "layer": [
    {
      "mark": "bar",
      "encoding": {
        "color": {
          "field": "Content_LQ1",
          "title": "Legende",
          "type": "nominal",
          "scale": {
            "domain": [
              "Kurzfristige Forderungen",
              "Kurzfristige Verbindlichkeiten",
              "Liquide Mittel",
              "Liquidität 1. Grad Überschuss",
              "Vorräte",
              "Liquidität 1. Grad Defizit"
            ],
            "range": [
              "#085F82",
              "#7F7F7F",
              "#053C52",
              "#7ABC32",
              "#0A83B2",
              "#C00000"
            ]
          }
        }
      }
    },
    {
      "mark": {
        "type": "text",
        "align": "left",
        "x": -1,
        "color": "white",
        "xOffset": -30
      },
      "encoding": {
        "text": {
          "field": "LQ3",
          "type": "quantitative",
          "format": ".3s"
        }
      }
    }
  ]
}

 

 

I am struggling with 3 things:

 

1. How to align the bar-label (eg. 733k) right in the center of the bar?

2. How can I set the length of the x-axis dynamically to the measure "MaxLiquidityXaxis"

3. How to set the color for each bar based on the color-code given in the dataset itself

 

 

Thanks in advance!!

4 REPLIES 4
pbiXlsx
Frequent Visitor

Hi @giammariam ,

first of all thanks!

The color selection works!

The position of the bar label however is not perfect as I think it takes the middle of the x-value as a starting point so the label is rather right-aligned. It seems that the middle point of the "x-value-bar" and the middel point of the "text field" have to be aligned so that the label fits 

Sorry, I did not see the "align": "center" change. So that works perfectly fine 😉

 

How would you solve the last point with vega? I have to show 3 diagramms above each other and need the range of the x axis to be set by the maximum - measure. Or would that also be solved if i "facet" those 3 diagrams into one visual and extend just the dataset with groups (1 for each diagram)

 

pbiXlsx_0-1668698999611.png

 

 

@pbiXlsx Vega would allow me to create a signal that would essentially act as a variable for the max domain value of the x-axis. Also, yes, I would use faceting for the layout composition that you are after. Do you have a .pbix that you can share that either has your data (or if you can't share your data, a .pbix with mock data)?



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
Solution Sage
Solution Sage

Hello @pbiXlsx. I got your first and third items implemented. The second one is giving me trouble. Apparently because of the way vega-lite handles params (no access to setting signals), I'm not sure if this is possible in Vega-Lite. If you wanted to switch to Vega, we should be able to get that implemented. 

 

Here is a comment on stackoverflow discussing this

 

Happy to help more if you want to try going with Vega.


Updated Spec:

{
  "data": {"name": "dataset"},
  "encoding": {
    "y": {"field": "Group", "type": "nominal", "title": null},
    "x": {
      "field": "LQ3",
      "type": "quantitative",
      "title": null,
      "stack": "zero"
    },
    "order": {"field": "Mgmt_Dashboard_LQ1"}
  },
  "layer": [
    {
      "mark": "bar",
      "encoding": {
        "color": {
          "field": "Content_LQ1",
          "title": "Legende",
          "type": "nominal",
          "scale": {
            "domain": [
              "Kurzfristige Forderungen",
              "Kurzfristige Verbindlichkeiten",
              "Liquide Mittel",
              "Liquidität 1. Grad Überschuss",
              "Vorräte",
              "Liquidität 1. Grad Defizit"
            ],
            "range": {"field": "Color"}
          }
        }
      }
    },
    {
      "mark": {"type": "text", "align": "center", "x": -1, "color": "white"},
      "encoding": {
        "text": {"field": "LQ3", "type": "quantitative", "format": ".3s"},
        "x": {"field": "LQ3", "bandPosition": 0.5}
      }
    }
  ]
}

 



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!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.