From 0a9c26f471cf2df104f1567d5de3b85394e071a9 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sat, 11 Nov 2023 11:15:37 -0800 Subject: [PATCH] Add explicit option to control how densities are resolved --- src/compile/data/density.ts | 4 +--- src/transform.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/compile/data/density.ts b/src/compile/data/density.ts index 6b4317dc50..68ad8018fc 100644 --- a/src/compile/data/density.ts +++ b/src/compile/data/density.ts @@ -40,9 +40,7 @@ export class DensityTransformNode extends DataFlowNode { field: density, ...rest }; - if (this.transform.groupby) { - result.resolve = 'shared'; - } + result.resolve = this.transform.resolve; return result; } } diff --git a/src/transform.ts b/src/transform.ts index 33b10bb723..d6d6e2d890 100644 --- a/src/transform.ts +++ b/src/transform.ts @@ -496,6 +496,14 @@ export interface DensityTransform { * __Default value:__ `["value", "density"]` */ as?: [FieldName, FieldName]; + /** + * Indicates how parameters for multiple densities should be resolved. + * If "independent", each density may have its own domain extent and dynamic number of curve sample steps. + * If "shared", the KDE transform will ensure that all densities are defined over a shared domain and curve steps, enabling stacking. + * + * __Default value:__ `"independent"` + */ + resolve?: 'independent' | 'shared'; } export function isDensity(t: Transform): t is DensityTransform {