Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I have this chart
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.
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?
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
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?
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}
User | Count |
---|---|
93 | |
83 | |
77 | |
73 | |
66 |
User | Count |
---|---|
115 | |
104 | |
93 | |
64 | |
61 |