Skip to content

Commit

Permalink
feat: use any mark config for composite mark components (vega#8145)
Browse files Browse the repository at this point in the history
fixes vega#8144
  • Loading branch information
domoritz authored and BradyJ27 committed Oct 19, 2023
1 parent 4f3abe6 commit cf569c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
36 changes: 18 additions & 18 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4430,7 +4430,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -4452,7 +4452,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -4462,7 +4462,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -4472,7 +4472,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -4486,7 +4486,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
}
Expand All @@ -4502,7 +4502,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand Down Expand Up @@ -4553,7 +4553,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -4573,7 +4573,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -4583,7 +4583,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -4597,7 +4597,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand Down Expand Up @@ -8338,7 +8338,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -8348,7 +8348,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand Down Expand Up @@ -8378,7 +8378,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -8388,7 +8388,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand Down Expand Up @@ -8461,7 +8461,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -8479,7 +8479,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
}
Expand Down Expand Up @@ -8527,7 +8527,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand All @@ -8545,7 +8545,7 @@
"type": "boolean"
},
{
"$ref": "#/definitions/MarkConfig"
"$ref": "#/definitions/AnyMarkConfig"
}
]
},
Expand Down
9 changes: 5 additions & 4 deletions src/compositemark/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ import {
import {Encoding, fieldDefs} from '../encoding';
import {ExprRef} from '../expr';
import * as log from '../log';
import {ColorMixins, GenericMarkDef, isMarkDef, Mark, MarkConfig, MarkDef} from '../mark';
import {ColorMixins, GenericMarkDef, isMarkDef, Mark, AnyMarkConfig, MarkDef} from '../mark';
import {GenericUnitSpec, NormalizedUnitSpec} from '../spec';
import {getFirstDefined, hash, unique} from '../util';
import {isSignalRef} from '../vega.schema';
import {toStringFieldDef} from './../channeldef';

export type PartsMixins<P extends string> = Partial<Record<P, boolean | MarkConfig<ExprRef | SignalRef>>>;
// Parts mixins can be any mark type. We could make a more specific type for each part.
export type PartsMixins<P extends string> = Partial<Record<P, boolean | AnyMarkConfig<ExprRef | SignalRef>>>;

export type GenericCompositeMarkDef<T> = GenericMarkDef<T> &
ColorMixins<ExprRef | SignalRef> & {
Expand Down Expand Up @@ -207,13 +208,13 @@ export function partLayerMixins<P extends PartsMixins<any>>(
{
...partBaseSpec,
mark: {
...(compositeMarkConfig[part] as MarkConfig<ExprRef | SignalRef>),
...(compositeMarkConfig[part] as AnyMarkConfig<ExprRef | SignalRef>),
...(clip ? {clip} : {}),
...(color ? {color} : {}),
...(opacity ? {opacity} : {}),
...(isMarkDef(partBaseSpec.mark) ? partBaseSpec.mark : {type: partBaseSpec.mark}),
style: `${mark}-${String(part)}`,
...(isBoolean(markDef[part]) ? {} : (markDef[part] as MarkConfig<ExprRef | SignalRef>))
...(isBoolean(markDef[part]) ? {} : (markDef[part] as AnyMarkConfig<ExprRef | SignalRef>))
}
}
];
Expand Down

0 comments on commit cf569c3

Please sign in to comment.