Search code examples
powerbivisualizationvega-litedeneb

how to create a shape with min and max values power bi


I have a data below:

xmin    xmax     ymin   ymax
 2        4      1       2
 4        6      2       3

I wanted to generate a shape which I can use to fill in values. Please assist.

Thank you


Solution

  • enter image description here

    Create your data like this.

    enter image description here

    Make sure every column says do not aggregate. Import the Deneb visual from marketplace. Add the fields to the Deneb visual well as follows:

    enter image description here

    Paste the following code into Deneb.

    {
      "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
      "width": 300,
      "height": 240,
      "background": "white",
       "data": {"name": "dataset"},
      "layer": [
          {
          
          "mark": {"type": "rect", "color": "#9bc2e6"}
        }
      ],
      "encoding": {
        "x": {
          "field": "xmin",
          "type": "quantitative",
          "scale": {"domain": [0, 10]}
        },
        "x2": {"field": "xmax"},
        "y": {
          "field": "ymin",
          "type": "quantitative",
          "scale": {"domain": [8, 0]}
        },
        "y2": {"field": "ymax"},
        "color":{"field": "id"}
      }
    }
    

    That's it.