Skip to content
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

Vega-lite : scale(null) produces wrong vega code; scale": {"type": null} ist not correct and not identical to scale: null #802

Open
mubu-med opened this issue Dec 29, 2024 · 1 comment

Comments

@mubu-med
Copy link

Best Example is from https://haifengl.github.io/vegalite.html: A Bar Chart Encoding Color Names in the Data

var bar = new View("Bar Chart Encoding Color Names in the Data");
bar.data().values("""
[
{"color": "red", "b": 28},
{"color": "green", "b": 55},
{"color": "blue", "b": 43}
]""");

bar.mark("bar");
bar.encode("x", "color").type("nominal");
bar.encode("y", "b").type("quantitative");
bar.encode("color", "color").type("nominal").scale(null);

Expected behavior
compiled with Java 21.0.5; JSON modified from "View Source" from the presented html file in FireFox 133.03
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"config": {"view": {"continuousWidth": 400, "continuousHeight": 400}},
"title": "Bar Chart Encoding Color Names in the Data",
"data": {
"values": "[\n {"color": "red", "b": 28},\n {"color": "green", "b": 55},\n {"color": "blue", "b": 43}\n]"
},
"mark": {"type": "bar"},
"encoding": {
"x": {"field": "color", "type": "nominal"},
"y": {"field": "b", "type": "quantitative"},
"color": {"field": "color", "type": "nominal", "scale": null}
}

Actual behavior
compiled with Java 21.0.5 and JSON copied from "View Source" from the presented html file in FireFox 133.03

{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"config": {"view": {"continuousWidth": 400, "continuousHeight": 400}},
"title": "Bar Chart Encoding Color Names in the Data",
"data": {
"values": "[\n {"color": "red", "b": 28},\n {"color": "green", "b": 55},\n {"color": "blue", "b": 43}\n]"
},
"mark": {"type": "bar"},
"encoding": {
"x": {"field": "color", "type": "nominal"},
"y": {"field": "b", "type": "quantitative"},
"color": {"field": "color", "type": "nominal", "scale": {"type": null}}
}

Result is: Color will be treated as nominal - and not as color information.
grafik
The legend is displayed. This is also a clear indication that scale=null is not being interpreted.
I suspect the error in VegaLite.html respectively in ObjectNode.toPrettyString.
Unfortunately, I am only an amateur programmer and therefore could not narrow down the cause more precisely.
But thank you very much for this outstanding project!

Additional context

  • What Java (OpenJDK, Orack JDK, etc.) are you using and which Java version: 21.0.5
  • Which Smile version: 4.0.0
  • What is your build system (e.g. Ubuntu, macOS, Windows, Debian ) : Windows 11, Eclipse 2024-12
  • Add any other context about the problem here.
@kklioss
Copy link
Collaborator

kklioss commented Dec 30, 2024

Thanks for reporting. The fix is in v4 branch. Please have a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants