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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
patBear
Helper I
Helper I

Deneb - dynamic axes values

I have this chart 

patBear_0-1660858018105.png

Notice that the y-axis is not to scale (specifically the 0.15).  In theory, I could have data at any 0.05 multiple (up to 0.50) in the Y direction and any 0.10 multiple (0.1-0.9) in the X direction.  I'd like the user to be able to select which X and Y values to include using filters; in particular, any values with no values (like y=0.25 in this example).  This means I cannot include a scale in my Vega Lite.  I'm also not able to show the axes as quantitative (destroys overall shape plus eliminates nominal choosing).  What is a way to do this?

 

Also, bonus would be addition of gridlines that create appropriate boxes.  Grid only seems to go from the labels through the middle of the stacks.

 

Here is the code (ProjCount is a measure = COUNT(Table[ProjName]))

 

 

{
  "data": {"name": "dataset"},
  "transform": [
    {
      "window": [
        {
          "op": "row_number",
          "as": "cell_order"
        }
      ],
      "groupby": ["X", "Y"],
      "sort": [
        {
          "field": "Project Name",
          "order": "descending"
        }
      ]
    },
    {
      "stack": "cell_order",
      "groupby": ["X", "Y"],
      "sort": [
        {
          "field": "Project Name",
          "order": "descending"
        }
      ],
      "as": ["ymin", "ymax"]
    }
  ],
  "layer": [
    {
      "mark": {
        "type": "bar",
        "stroke": "black",
        "strokeWidth": 0.5,
        "tooltip": true
      },
      "encoding": {
        "y": {
          "field": "Y",
          "type": "nominal",
          "stack": true
        },
        "yOffset": {
          "field": "ymin",
          "scale": {"reverse": true}
        },
        "color": {
          "field": "Overall Score",
          "type": "nominal",
          "scale": {
            "domain": [
              "1",
              "2",
              "3",
              "4",
              "5"
            ],
            "range": [
              "#e15759",
              "#f28e2b",
              "#edc948",
              "#76b7b2",
              "#59a14f"
            ]
          },
          "legend": {
            "orient": "none",
            "legendX": 0,
            "legendY": 0,
            "strokeColor": "black",
            "padding": 4,
            "direction": "horizontal",
            "symbolType": "square",
            "symbolStrokeWidth": 0.5,
            "symbolOpacity": 1,
            "fillColor": "white",
            "title": "Overall Score"
          }
        }
      }
    },
    {
      "mark": {
        "type": "text",
        "color": "black",
        "fontSize": 9
      },
      "encoding": {
        "yOffset": {
          "field": "ymin",
          "scale": {"reverse": true}
        }
      }
    }
  ],
  "encoding": {
    "x": {
      "field": "X",
      "type": "nominal",
      "sort": "ascending",
      "axis": {
        "title": "X",
        "domain": true,
        "ticks": true,
        "labelAngle": 0
      }
    },
    "y": {
      "field": "Y",
      "type": "nominal",
      "sort": "descending",
      "axis": {
        "title": "Y",
        "domain": true,
        "ticks": true
      }
    }
  }
}

 

 

Thanks.

@KerKol @dm-p  

4 REPLIES 4
dm-p
Super User
Super User

Hi @patBear,

Just so I understand the challenge, I assume that you want to interpolate values into a categorical axis between min and max values of each domain?

Is this the kind of output you're looking for?

dmp_0-1661300743531.png

If so, I may have something, but it's expression-heavy, and assumes that your X and Y values are numeric (they're text in your supplied dataset). I just want to be sure I'm along the right track before I post a possible approach.

Thanks,

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)




@dm-p This is the general idea of the challenge.  What I don't see in your image is where the user would be able to select which y (or x) values to include/exclude.  So perhaps the user would like the y-axis to not show the 0.25 and 0.3 values (alternately, show only the 0.1, 0.15, 0.2, 0.35, and 0.4).  Can that be done in your approach?

lbendlin
Super User
Super User

Would you mind providing the sample data as well?

Here is a portion of it that should be sufficient

 

{"Project Name": "a", "X": "0.7", "Y": "0.1", "Overall Score": 2}, {"Project Name": "b", "X": "0.7", "Y": "0.2", "Overall Score": 3}, {"Project Name": "c", "X": "0.8", "Y": "0.4", "Overall Score": 5}, {"Project Name": "d", "X": "0.7", "Y": "0.2", "Overall Score": 3}, {"Project Name": "e", "X": "0.8", "Y": "0.2", "Overall Score": 4}, {"Project Name": "f", "X": "0.5", "Y": "0.2", "Overall Score": 3}, {"Project Name": "g", "X": "0.7", "Y": "0.2", "Overall Score": 3}, {"Project Name": "h", "X": "0.6", "Y": "0.2", "Overall Score": 3}, {"Project Name": "i", "X": "0.6", "Y": "0.3", "Overall Score": 4}, {"Project Name": "j", "X": "0.7", "Y": "0.1", "Overall Score": 2}, {"Project Name": "k", "X": "0.5", "Y": "0.3", "Overall Score": 3}, {"Project Name": "l", "X": "0.7", "Y": "0.2", "Overall Score": 3}, {"Project Name": "al", "X": "0.4", "Y": "0.15", "Overall Score": 2} 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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