-
Notifications
You must be signed in to change notification settings - Fork 621
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
feat: Improve color scheme type #9015
Conversation
package.json
Outdated
@@ -127,6 +127,7 @@ | |||
"vega-datasets": "^2.7.0", | |||
"vega-embed": "^6.22.1", | |||
"vega-tooltip": "^0.32.0", | |||
"vega-typings": "^0.24.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we already depend on Vega, I don’t think we need this. It just makes updates more annoying.
src/scale.ts
Outdated
@@ -458,7 +459,7 @@ export interface SchemeParams { | |||
* | |||
* For the full list of supported schemes, please refer to the [Vega Scheme](https://vega.github.io/vega/docs/schemes/#reference) reference. | |||
*/ | |||
name: string | SignalRef; | |||
name: string | ColorScheme | SignalRef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Should we even allow string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I went with a more permissive type because I wasn't sure what the down stream deps were from this type, but if this seems fine to you then a more assertive type is great!
Thank you! |
Will this still allow the following which I can do in Vega?
|
I filed #9022 |
Co-authored-by: GitHub Actions Bot <[email protected]>
@PBI-David you can already set the range to a list: https://vega.github.io/vega-lite/docs/scale.html#2-setting-the-range-property-to-an-array-of-valid-css-color-strings |
The JSON Schema that vega-lite generates is wonderful, but there are a few places where the types are slightly under-defined because they are defined as part of the vega type system.
One such example is color schemes, which are more permissive than should be allowing any string. While the included description is helpful for identifying the allow values (
"A string indicating a color [scheme](https://vega.github.io/vega-lite/docs/scale.html#scheme) name (e.g.,
"category10"or
"blues") or a [scheme parameter object](https://vega.github.io/vega-lite/docs/scale.html#scheme-params)...."
), this is not very helpful systems ingesting the schema computationally, such as for structure editing.Fortunately, a possible workaround is to explicitly import the wonderful vega-typings package (which was already an implied dependency, cf yarn.lock). This allows use of the more explicit type described by vega-typings.
Please:
Fixes #1
/Fixes part of #1
).yarn test
).site/docs/
+ add examples.Tips: