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

Threshold scale does not work with shape channel #7167

Closed
tuner opened this issue Jan 11, 2021 · 7 comments · Fixed by #7170
Closed

Threshold scale does not work with shape channel #7167

tuner opened this issue Jan 11, 2021 · 7 comments · Fixed by #7170

Comments

@tuner
Copy link

tuner commented Jan 11, 2021

Hi,

Vega-Lite seems to output an incorrect Vega spec when threshold scale is used on the shape channel.

Vega-Lite snippet:

"shape": {
  "field": "b",
  "type": "quantitative",
  "scale": {
    "type": "threshold",
    "domain": [30, 70]
  }
}

Compiled Vega snippet (the scale type has changed into ordinal):

{
  "name": "shape",
  "type": "ordinal",
  "domain": [30, 70],
  "range": "symbol"
}

Here's a full VL spec modified from the example in the documentation: https://vega.github.io/editor/#/url/vega-lite/N4IgJghgLhIFygG4QDYFcCmBneBtUscIAgiADQgBG8ATABwC+ZB8IAQuVfAKzdMtEAwp2pwALAGZ+IQiAAiI+AE4AjNNkBRRXDprmM1gDFt3KftkBxbSqXrWACW10A7HaIBJEzQYBdJiABbCAAnAGtWAAcAewBLADsoTgw4gGMosHiAc3hQAE8ckAAzGIwUMFZqCihciIxWOKiA+NROLCjgxLg4tBQUCggADxicBBAoGJTQkcLULAwKMEaIePgZlDmqmKgUOq6elAZ-LBiAL13QYtLyokqxmt2QAEc0CASt6BjEOoosFNRzu61VhQAAWwWwIKiZU4iyCKzguAkAAYyM4kT4KMFXpldrg6CiaEiURJCX5-GkUO0CpdoTdONUgURnq9xjBxl9Wn8dgUGQ9QeCsJDoQslvDESi0RiQL8QRgAg9EDFgjEMjh-DscXFrqBWdyiAAVMEQqHlQ4-EEQRkXEq0rhVe6sZlvNmfb7SrkA3nAo2Ck0w0VxPDI1How6HIA

Threshold+shape appears to have been functional at some point: #4161 (comment)

I can try to fix this issue if it is indeed a bug and not a feature.

@tuner tuner added the Bug 🐛 label Jan 11, 2021
@domoritz
Copy link
Member

There are a couple of warnings in the editor console so I think this is working as intended.

[Warning] Shape channel should be used with only either discrete or geojson data.
[Warning] Using discrete channel "shape" to encode "quantitative" field can be misleading as it does not encode magnitude.
[Warning] Channel "shape" does not work with "threshold" scale. We are using "ordinal" scale instead.

If you think this is a mistake, please file an enhancement request with what Vega code we should generate. Thanks for helping us with improving Vega-Lite.

@tuner
Copy link
Author

tuner commented Jan 11, 2021

Ah, ok.

My web browser (Chrome) appears to swallow all warnings. I only see "[Info] No error, infos, or warnings" on the console. Firefox and Safari appear to display those (and other) warnings. Have to check this on another computer...

@domoritz
Copy link
Member

I think there is a bug in the editor where the warnings don't show up if you open the URL. Also, make sure to add the schema URL so that you get warnings about other validation issues.

@domoritz
Copy link
Member

If I support threshold scales with this changes
Screen Shot 2021-01-11 at 16 08 30

You get this chart, which I would argue is misleading and therefore I think it's right not to support threshold scales for now.

Screen Shot 2021-01-11 at 16 07 36

If you have a compelling example, we can easily add support for threshold scales.

@domoritz
Copy link
Member

domoritz commented Jan 11, 2021

Actually, this should be the diff. However, I think we intentionally limited shape to only support nominal data since shape only supports effective lookup. I could maybe be convinced that shapes can be used to encode ordinal data but there are better encodings (color and size).

Screen Shot 2021-01-11 at 16 10 51

@tuner
Copy link
Author

tuner commented Jan 11, 2021

I stumbled upon this issue when trying to sketch a decorated lollipop plot:
lollipop

This example is quite an artificial one, and I agree that shape should generally be used only for encoding nominal data. However, use cases may exist, and perhaps artificial restrictions are not necessary(?). Of course, this particular example could be worked around by calculating a new "sign" field.

A more practical use case could be highlighting extreme values together with color (redundancy).

@domoritz
Copy link
Member

Enabled support in #7170.

@domoritz domoritz changed the title Threshold scale is broken on the shape channel Threshold scale does not work with shape channel Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants