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

Ordinal scale can interpolate scheme, but not range #995

Closed
kanitw opened this issue Aug 21, 2017 · 1 comment · Fixed by #1561
Closed

Ordinal scale can interpolate scheme, but not range #995

kanitw opened this issue Aug 21, 2017 · 1 comment · Fixed by #1561
Labels
feature-request For requesting new features or transforms

Comments

@kanitw
Copy link
Member

kanitw commented Aug 21, 2017

Vega's ordinal scales accept scheme and seems to be able to interpolate sequential color scheme

For example, using the following scale works (full spec)

{ 
  "name": "color",
  "type": "ordinal",
  "domain": {"data": "source_0","field": "Cylinders","sort": true},
  "range": {"scheme": "blues"}
}

image

Full spec: https://pastebin.com/KzifPxmJ.

However, when we specify an array "range": ["pink", "red"], there is no way to force it to interpolate like it does with scheme (to the best of my knowledge).
Of course, it makes sense not to interpolate the color by default, since this is D3 ordinal scale's default behavior. However, since Vega's ordinal scales, unlike D3's, allow interpolation with range.scheme, shouldn't there be a way to enable interpolation when range is an array of color? For example, maybe we could support interpolate property for ordinal scales?

This is not really a pressing issue, but it seems like we're a bit inconsistent here (unless I misunderstand something) so it's worth reporting. :)

@kanitw kanitw changed the title Ordinal scale Ordinal scale can interpolate scheme, but not range Aug 21, 2017
@jheer jheer added the feature-request For requesting new features or transforms label Aug 24, 2017
@jheer
Copy link
Member

jheer commented Aug 24, 2017

Yes, this is currently unsupported. I think one way to approach this would be to allow "inline" scheme definitions: in addition to scheme name strings, one might provide an explicit color array as the value of the "scheme" property. Then everything else could proceed unchanged. This update would involve modifying a few lines of code in vega-encode's Scale operator, plus modifications to the Vega JSON schema generator in vega-parser.

This was referenced Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request For requesting new features or transforms
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants