New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Line Chart with ordinal or nominal Values as Y Axis #7026
Comments
Hmm, good question. I would have expected this to work: {
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{"build": 1, "result": "PASSED"},
{"build": 2, "result": "PASSED"},
{"build": 3, "result": "FAILED"},
{"build": 4, "result": "FAILED"},
{"build": 5, "result": "SKIPPED"},
{"build": 6, "result": "PASSED"},
{"build": 7, "result": "PASSED"},
{"build": 8, "result": "FAILED"},
{"build": 9, "result": "PASSED"},
{"build": 10, "result": "PASSED"},
{"build": 11, "result": "SKIPPED"},
{"build": 12, "result": "PASSED"},
{"build": 13, "result": "PASSED"},
{"build": 14, "result": "FAILED"},
{"build": 15, "result": "PASSED"},
{"build": 16, "result": "SKIPPED"}
]
},
"mark": {"type": "line", "point": true, "orient": "vertical"},
"encoding": {
"x": {"field": "build", "type": "quantitative"},
"y": {"field": "result", "type": "nominal"}
}
} @kanitw is this a bug? Setting the order works, though. {
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{"build": 1, "result": "PASSED"},
{"build": 2, "result": "PASSED"},
{"build": 3, "result": "FAILED"},
{"build": 4, "result": "FAILED"},
{"build": 5, "result": "SKIPPED"},
{"build": 6, "result": "PASSED"},
{"build": 7, "result": "PASSED"},
{"build": 8, "result": "FAILED"},
{"build": 9, "result": "PASSED"},
{"build": 10, "result": "PASSED"},
{"build": 11, "result": "SKIPPED"},
{"build": 12, "result": "PASSED"},
{"build": 13, "result": "PASSED"},
{"build": 14, "result": "FAILED"},
{"build": 15, "result": "PASSED"},
{"build": 16, "result": "SKIPPED"}
]
},
"mark": {"type": "line", "point": true},
"encoding": {
"x": {"field": "build", "type": "quantitative"},
"y": {"field": "result", "type": "nominal"},
"order": {"field": "build", "type": "quantitative"}
}
} |
Thanks so much for responding so quickly! I also found the order key very helpful! Thats awesome! This is quite a funny one. I was experimenting a bit with it and found some other problems: {
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {"values":[
{"build": 1, "result": "PASSED"},
{"build": 2, "result": "PASSED"},
{"build": 3, "result": "FAILED"},
{"build": 4, "result": "FAILED"},
{"build": 5, "result": "SKIPPED"},
{"build": 6, "result": "PASSED"},
{"build": 7, "result": "PASSED"},
{"build": 8, "result": "FAILED"},
{"build": 9, "result": "PASSED"},
{"build": 10, "result": "PASSED"},
{"build": 11, "result": "SKIPPED"},
{"build": 12, "result": "PASSED"},
{"build": 13, "result": "PASSED"},
{"build": 14, "result": "FAILED"},
{"build": 15, "result": "PASSED"},
{"build": 16, "result": "SKIPPED"}
]},
"mark": {
"type": "line",
"point": true
},
"encoding": {
"x": {"field": "build", "type": "quantitative"},
"y": {
"field": "result",
"type": "ordinal",
"sort": ["FAILED", "SKIPPED", "PASSED"]
},
"color": {
"field": "result",
"type": "nominal",
"scale": {
"domain": ["FAILED", "SKIPPED", "PASSED"],
"range": ["#ff0000", "#ffff00", "#00ff00"]
}
},
"order": {"field": "build", "type": "quantitative"}
}
} This gives me the following: Maybe this is because it is unclear which color the line should be when connecting two points from different Y? |
That's expected behavior with the grammar of graphics. You could only color the points and not color the line to get what you want. |
Ok, thank you! This is very helpful. For me this is done, I don't know if you guys want to keep it open? |
See my question to @kanitw about orient above. |
Yes this is a bug. Will be fixed in #7142 |
Hey everyone,
I was trying to do a visualization in Vega-Lite, but I'm stuck at a point. I have a couple of builds (quantitiative, from 0 to N) and each build has a result. The results have an priority order, so basically "PASSED" has a lower priority then "FAILED". This means these values are ordinal.
I was trying to plot the result as a line chart over the builds. So Y Axis is the result and X Axis is the build. Now it shows the correct points, however it does not connect them correctly. I want to connect the first value on the X-Axis to the next value on the X-Axis and so on. It does connect the values on their occurance on the Y-Axis.
This also happens with nominal values. Is this not yet implemented? Or am I using it wrong? In the doc it says Using line with one temporal or ordinal field (typically on x) and another quantitative field (typically on y) produces a simple line chart with a single line. However, what does "typically" mean here? How do I change it?
To showcase it: online editor example
The text was updated successfully, but these errors were encountered: