-
Notifications
You must be signed in to change notification settings - Fork 607
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
Correctly generate as
for nested fields. Note that in Vega as
cannot be nested so you have to provide a field name, not a field accessor. Fixes #3744
#4023
Conversation
…not be nested so you have to provide a field name, not a field accessor. Fixes #3744.
as
for nested fields. Note that in Vega as
cannot be nested so you have to provide a field name, not a field accessor. Fixes #3744
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.
Lucky we don't let it go.
These two names are super confusing: vgFieldName
vgField
. Both are field names. If one of them is transform output, better make that a parameter.
3501438
to
4a684d2
Compare
Updated the PR. |
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.
LGTM with a few minor knitpicks.
src/compile/data/stack.ts
Outdated
@@ -218,6 +218,7 @@ export class StackNode extends DataFlowNode { | |||
// Impute | |||
if (impute && dimensionFieldDef) { | |||
const dimensionField = dimensionFieldDef ? vgField(dimensionFieldDef, {binSuffix: 'mid'}) : undefined; | |||
const dimensionAs = dimensionFieldDef ? vgField(dimensionFieldDef, {binSuffix: 'mid', forAs: true}) : undefined; |
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.
Why should this be different from dimensionField?
especially given than you impute afterward.
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.
The key is a field reference in Vega and we have to escape nesting.
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.
I revides the code a bit since it's a bit superfluous to have a ternary with dimensionFieldDef
if it is already required to pass the if.
src/compile/facet.ts
Outdated
export function facetSortFieldName( | ||
fieldDef: FacetFieldDef<string>, | ||
sort: EncodingSortField<string>, | ||
expr?: 'datum', |
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.
Make {expr, forAs=true}: {expr?: datum, forAs:boolean}
?
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.
No, we want the default to be false.
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.
Anyway, revised.
src/fielddef.ts
Outdated
if (opt.forAs) { | ||
// Don't need to mess with nested field names because Vega transform outputs are never nested. | ||
return field; | ||
} |
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.
else if?
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.
Done
@@ -297,7 +297,8 @@ export function accessPathWithDatum(path: string, datum = 'datum') { | |||
} | |||
|
|||
/** | |||
* Return access with datum to the falttened field. | |||
* Return access with datum to the flattened field. |
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.
FYI, the datum
variable down there is a bit misleading as it can be parent too. (It confuses me for a bit)
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.
Fixed
src/fielddef.ts
Outdated
suffix?: string; | ||
/** Use the field name for `as` in a transform. */ |
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.
Add a comment how this affect the output.
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.
Done
src/fielddef.ts
Outdated
@@ -396,6 +401,11 @@ export function vgField( | |||
field = `${prefix}_${field}`; | |||
} | |||
|
|||
if (opt.forAs) { | |||
// Don't need to mess with nested field names because Vega transform outputs are never nested. |
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.
"mess with" => escape
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.
Done
7535c01
to
bc77b1e
Compare
No description provided.