-
Notifications
You must be signed in to change notification settings - Fork 87
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: Expose expression functions #935
Conversation
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.
-
Let's make visitor optional
-
Add doc to README.md? (Add
expressionFunction: ...
to option object list and to the table below)
test/embed.test.ts
Outdated
mark: 'point', | ||
transform: [ | ||
{calculate: "simpleFunction()", as: "result1"}, | ||
{calculate: "visitorFunction()", as: "result2"}, |
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.
visitorFunction -> functionWithVisitor?
src/types.ts
Outdated
@@ -4,6 +4,8 @@ import {Config as VlConfig} from 'vega-lite'; | |||
export type Mode = 'vega' | 'vega-lite'; | |||
export type Config = VlConfig | VgConfig; | |||
|
|||
export type ExpressionFunction = Record<string, Function | {fn: Function, visitor: Function}>; |
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.
Ah my bad, I think visitor
should be optional
src/embed.ts
Outdated
if (opts.expressionFunctions) { | ||
for (const name in opts.expressionFunctions) { | ||
const expressionFunction = opts.expressionFunctions[name]; | ||
if ('fn' in expressionFunction && 'visitor' in expressionFunction) { |
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 won't work correctly if visitor
is optional.
use isObject(expressionFunction)
instead ?
(you can import isObject
from vega, for consistency with other isString, etc.)
🚀 PR was released in |
Exposes
vega.expressionFunction
to allow consumers to create custom functions/formatters.Follow up to this ticket: #934
Version
Published prerelease version:
v6.21.0-next.0
Changelog
🎉 This release contains work from a new contributor! 🎉
Thank you, Zachary Bys (@ZacharyBys), for all your work!
🚀 Enhancement
🐛 Bug Fix
next
🔩 Dependency Updates
Authors: 4