diff --git a/build/vega-lite-schema.json b/build/vega-lite-schema.json index 32ba92d003a..056f1af2e00 100644 --- a/build/vega-lite-schema.json +++ b/build/vega-lite-schema.json @@ -1045,7 +1045,7 @@ "bandPosition": { "anyOf": [ { - "description": "An interpolation fraction indicating where, for `band` scales, axis ticks should be positioned. A value of `0` places ticks at the left edge of their bands. A value of `0.5` places ticks in the middle of their bands.\n\n __Default value:__ `0.5`", + "description": "An interpolation fraction indicating where, for `band` scales, axis ticks should be positioned. A value of `0` places ticks at the left edge of their bands. A value of `0.5` places ticks in the middle of their bands.\n\n __Default value:__ `0.5`", "type": "number" }, { @@ -1998,7 +1998,7 @@ "bandPosition": { "anyOf": [ { - "description": "An interpolation fraction indicating where, for `band` scales, axis ticks should be positioned. A value of `0` places ticks at the left edge of their bands. A value of `0.5` places ticks in the middle of their bands.\n\n __Default value:__ `0.5`", + "description": "An interpolation fraction indicating where, for `band` scales, axis ticks should be positioned. A value of `0` places ticks at the left edge of their bands. A value of `0.5` places ticks in the middle of their bands.\n\n __Default value:__ `0.5`", "type": "number" }, { @@ -3176,9 +3176,16 @@ ] }, "discreteBandSize": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/RelativeBandSize" + } + ], "description": "The default size of the bars with discrete dimensions. If unspecified, the default size is `step-2`, which provides 2 pixel offset between bars.", - "minimum": 0, - "type": "number" + "minimum": 0 }, "dx": { "anyOf": [ @@ -4901,7 +4908,7 @@ }, "shape": { "$ref": "#/definitions/ShapeDef", - "description": "Shape of the mark.\n\n1. For `point` marks the supported values include: - plotting shapes: `\"circle\"`, `\"square\"`, `\"cross\"`, `\"diamond\"`, `\"triangle-up\"`, `\"triangle-down\"`, `\"triangle-right\"`, or `\"triangle-left\"`. - the line symbol `\"stroke\"` - centered directional shapes `\"arrow\"`, `\"wedge\"`, or `\"triangle\"` - a custom [SVG path string](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths) (For correct sizing, custom shape paths should be defined within a square bounding box with coordinates ranging from -1 to 1 along both the x and y dimensions.)\n\n2. For `geoshape` marks it should be a field definition of the geojson data\n\n__Default value:__ If undefined, the default shape depends on [mark config](https://vega.github.io/vega-lite/docs/config.html#point-config)'s `shape` property. (`\"circle\"` if unset.)" + "description": "Shape of the mark.\n\n1. For `point` marks the supported values include: - plotting shapes: `\"circle\"`, `\"square\"`, `\"cross\"`, `\"diamond\"`, `\"triangle-up\"`, `\"triangle-down\"`, `\"triangle-right\"`, or `\"triangle-left\"`. - the line symbol `\"stroke\"` - centered directional shapes `\"arrow\"`, `\"wedge\"`, or `\"triangle\"` - a custom [SVG path string](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths) (For correct sizing, custom shape paths should be defined within a square bounding box with coordinates ranging from -1 to 1 along both the x and y dimensions.)\n\n2. For `geoshape` marks it should be a field definition of the geojson data\n\n__Default value:__ If undefined, the default shape depends on [mark config](https://vega.github.io/vega-lite/docs/config.html#point-config)'s `shape` property. (`\"circle\"` if unset.)" }, "size": { "$ref": "#/definitions/NumericMarkPropDef", @@ -6088,8 +6095,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -6177,8 +6184,8 @@ { "additionalProperties": false, "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -6247,8 +6254,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -6336,8 +6343,8 @@ { "additionalProperties": false, "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -6404,8 +6411,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -6672,8 +6679,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -6761,8 +6768,8 @@ { "additionalProperties": false, "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -6831,8 +6838,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -6920,8 +6927,8 @@ { "additionalProperties": false, "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -6988,8 +6995,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -7744,8 +7751,8 @@ "DatumDef": { "additionalProperties": false, "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -8532,8 +8539,8 @@ ], "description": "The alignment to apply to grid rows and columns. The supported string values are `\"all\"`, `\"each\"`, and `\"none\"`.\n\n- For `\"none\"`, a flow layout will be used, in which adjacent subviews are simply placed one after the other. - For `\"each\"`, subviews will be aligned into a clean grid structure, but each row or column may be of variable size. - For `\"all\"`, subviews will be aligned and each row or column will be sized identically based on the maximum observed size. String values for this property will be applied to both grid rows and columns.\n\nAlternatively, an object value of the form `{\"row\": string, \"column\": string}` can be used to supply different alignments for rows and columns.\n\n__Default value:__ `\"all\"`." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -8654,8 +8661,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -8867,7 +8874,7 @@ }, "shape": { "$ref": "#/definitions/ShapeDef", - "description": "Shape of the mark.\n\n1. For `point` marks the supported values include: - plotting shapes: `\"circle\"`, `\"square\"`, `\"cross\"`, `\"diamond\"`, `\"triangle-up\"`, `\"triangle-down\"`, `\"triangle-right\"`, or `\"triangle-left\"`. - the line symbol `\"stroke\"` - centered directional shapes `\"arrow\"`, `\"wedge\"`, or `\"triangle\"` - a custom [SVG path string](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths) (For correct sizing, custom shape paths should be defined within a square bounding box with coordinates ranging from -1 to 1 along both the x and y dimensions.)\n\n2. For `geoshape` marks it should be a field definition of the geojson data\n\n__Default value:__ If undefined, the default shape depends on [mark config](https://vega.github.io/vega-lite/docs/config.html#point-config)'s `shape` property. (`\"circle\"` if unset.)" + "description": "Shape of the mark.\n\n1. For `point` marks the supported values include: - plotting shapes: `\"circle\"`, `\"square\"`, `\"cross\"`, `\"diamond\"`, `\"triangle-up\"`, `\"triangle-down\"`, `\"triangle-right\"`, or `\"triangle-left\"`. - the line symbol `\"stroke\"` - centered directional shapes `\"arrow\"`, `\"wedge\"`, or `\"triangle\"` - a custom [SVG path string](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths) (For correct sizing, custom shape paths should be defined within a square bounding box with coordinates ranging from -1 to 1 along both the x and y dimensions.)\n\n2. For `geoshape` marks it should be a field definition of the geojson data\n\n__Default value:__ If undefined, the default shape depends on [mark config](https://vega.github.io/vega-lite/docs/config.html#point-config)'s `shape` property. (`\"circle\"` if unset.)" }, "size": { "$ref": "#/definitions/NumericMarkPropDef", @@ -9426,10 +9433,10 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -9474,10 +9481,10 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -9522,10 +9529,10 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -9570,10 +9577,10 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -9618,14 +9625,14 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { "aggregate": { "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -9719,14 +9726,14 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { "aggregate": { "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -9820,14 +9827,14 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { "aggregate": { "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -9921,14 +9928,14 @@ }, "FieldOrDatumDefWithCondition,(string|null)>": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { "aggregate": { "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -10022,10 +10029,10 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -10085,14 +10092,14 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { "aggregate": { "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -10179,14 +10186,14 @@ }, "FieldOrDatumDefWithCondition": { "additionalProperties": false, - "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", + "description": "A FieldDef with Condition { condition: {value: ...}, field: ..., ... }", "properties": { "aggregate": { "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -11854,6 +11861,8 @@ "step-before", "step-after" ], + "maximum": 900, + "minimum": 100, "type": "string" }, "IntervalSelection": { @@ -12135,8 +12144,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -16332,9 +16341,16 @@ ] }, "discreteBandSize": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/RelativeBandSize" + } + ], "description": "The default size of the bars with discrete dimensions. If unspecified, the default size is `step-2`, which provides 2 pixel offset between bars.", - "minimum": 0, - "type": "number" + "minimum": 0 }, "dx": { "anyOf": [ @@ -16451,13 +16467,16 @@ "height": { "anyOf": [ { - "description": "Height of the marks.", "type": "number" }, { "$ref": "#/definitions/ExprRef" + }, + { + "$ref": "#/definitions/RelativeBandSize" } - ] + ], + "description": "Width of the marks, either a number or a relative band size definition (`{band: 0.5}`, for example, means half of the band)." }, "href": { "anyOf": [ @@ -16940,13 +16959,16 @@ "width": { "anyOf": [ { - "description": "Width of the marks.", "type": "number" }, { "$ref": "#/definitions/ExprRef" + }, + { + "$ref": "#/definitions/RelativeBandSize" } - ] + ], + "description": "Width of the marks, either a number or a relative band size definition (`{band: 0.5}`, for example, means half of the band)." }, "x": { "anyOf": [ @@ -17531,8 +17553,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -18706,8 +18728,8 @@ ], "description": "An object defining properties of axis's gridlines, ticks and labels. If `null`, the axis for the encoding channel will be removed.\n\n__Default value:__ If undefined, default [axis properties](https://vega.github.io/vega-lite/docs/axis.html) are applied.\n\n__See also:__ [`axis`](https://vega.github.io/vega-lite/docs/axis.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -18775,8 +18797,8 @@ "PositionDatumDefBase": { "additionalProperties": false, "properties": { - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -18861,8 +18883,8 @@ ], "description": "An object defining properties of axis's gridlines, ticks and labels. If `null`, the axis for the encoding channel will be removed.\n\n__Default value:__ If undefined, default [axis properties](https://vega.github.io/vega-lite/docs/axis.html) are applied.\n\n__See also:__ [`axis`](https://vega.github.io/vega-lite/docs/axis.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -18965,8 +18987,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -19873,9 +19895,16 @@ ] }, "discreteBandSize": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/RelativeBandSize" + } + ], "description": "The default size of the bars with discrete dimensions. If unspecified, the default size is `step-2`, which provides 2 pixel offset between bars.", - "minimum": 0, - "type": "number" + "minimum": 0 }, "dx": { "anyOf": [ @@ -20554,6 +20583,19 @@ ], "type": "object" }, + "RelativeBandSize": { + "additionalProperties": false, + "properties": { + "band": { + "description": "The relative band size. For example `0.5` means half of the band scale's band width.", + "type": "number" + } + }, + "required": [ + "band" + ], + "type": "object" + }, "RepeatMapping": { "additionalProperties": false, "properties": { @@ -20673,8 +20715,8 @@ "$ref": "#/definitions/LayoutAlign", "description": "The alignment to apply to row/column facet's subplot. The supported string values are `\"all\"`, `\"each\"`, and `\"none\"`.\n\n- For `\"none\"`, a flow layout will be used, in which adjacent subviews are simply placed one after the other. - For `\"each\"`, subviews will be aligned into a clean grid structure, but each row or column may be of variable size. - For `\"all\"`, subviews will be aligned and each row or column will be sized identically based on the maximum observed size. String values for this property will be applied to both grid rows and columns.\n\n__Default value:__ `\"all\"`." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -21468,8 +21510,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -21520,7 +21562,7 @@ }, "single": { "$ref": "#/definitions/SingleSelectionConfig", - "description": "The default definition for a [`single`](https://vega.github.io/vega-lite/docs/selection.html#type) selection. All properties and transformations for a single selection definition (except `type`) may be specified here.\n\nFor instance, setting `single` to `{\"on\": \"dblclick\"}` populates single selections on double-click by default." + "description": "The default definition for a [`single`](https://vega.github.io/vega-lite/docs/selection.html#type) selection. All properties and transformations for a single selection definition (except `type`) may be specified here.\n\nFor instance, setting `single` to `{\"on\": \"dblclick\"}` populates single selections on double-click by default." } }, "type": "object" @@ -21911,8 +21953,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -22070,8 +22112,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -22235,8 +22277,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -22378,8 +22420,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -22543,8 +22585,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -22702,8 +22744,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -22831,8 +22873,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -22895,8 +22937,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -22972,8 +23014,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -23058,8 +23100,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -23135,8 +23177,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -23221,8 +23263,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -23397,8 +23439,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -23535,8 +23577,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -23621,8 +23663,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -23783,8 +23825,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -23942,8 +23984,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -24107,8 +24149,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -24269,8 +24311,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -24428,8 +24470,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -24587,8 +24629,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -24739,8 +24781,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -24877,8 +24919,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -24983,8 +25025,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -25123,8 +25165,8 @@ ], "description": "An object defining properties of axis's gridlines, ticks and labels. If `null`, the axis for the encoding channel will be removed.\n\n__Default value:__ If undefined, default [axis properties](https://vega.github.io/vega-lite/docs/axis.html) are applied.\n\n__See also:__ [`axis`](https://vega.github.io/vega-lite/docs/axis.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -25272,8 +25314,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -25358,8 +25400,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -25408,8 +25450,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -25469,8 +25511,8 @@ ], "description": "An object defining properties of axis's gridlines, ticks and labels. If `null`, the axis for the encoding channel will be removed.\n\n__Default value:__ If undefined, default [axis properties](https://vega.github.io/vega-lite/docs/axis.html) are applied.\n\n__See also:__ [`axis`](https://vega.github.io/vega-lite/docs/axis.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -25618,8 +25660,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -25704,8 +25746,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -25754,8 +25796,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -26287,8 +26329,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -29135,7 +29177,7 @@ "type": "string" }, "mesh": { - "description": "The name of the TopoJSON object set to convert to mesh. Similar to the `feature` option, `mesh` extracts a named TopoJSON object set. Unlike the `feature` option, the corresponding geo data is returned as a single, unified mesh instance, not as individual GeoJSON features. Extracting a mesh is useful for more efficiently drawing borders or other geographic elements that you do not need to associate with specific regions such as individual countries, states or counties.", + "description": "The name of the TopoJSON object set to convert to mesh. Similar to the `feature` option, `mesh` extracts a named TopoJSON object set. Unlike the `feature` option, the corresponding geo data is returned as a single, unified mesh instance, not as individual GeoJSON features. Extracting a mesh is useful for more efficiently drawing borders or other geographic elements that you do not need to associate with specific regions such as individual countries, states or counties.", "type": "string" }, "parse": { @@ -29242,8 +29284,8 @@ "$ref": "#/definitions/Aggregate", "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." }, - "band": { - "description": "For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.\n\nFor other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.", "maximum": 1, "minimum": 0, "type": "number" @@ -30316,4 +30358,4 @@ "type": "object" } } -} +} \ No newline at end of file diff --git a/examples/specs/bar_axis_space_saving.vl.json b/examples/specs/bar_axis_space_saving.vl.json index 69d165608b6..607f1e2557d 100644 --- a/examples/specs/bar_axis_space_saving.vl.json +++ b/examples/specs/bar_axis_space_saving.vl.json @@ -3,12 +3,11 @@ "description": "Bar Chart with a spacing-saving y-axis", "data": {"url": "data/cars.json"}, "height": {"step": 50}, - "mark": {"type": "bar", "yOffset": 5, "cornerRadiusEnd": 2}, + "mark": {"type": "bar", "yOffset": 5, "cornerRadiusEnd": 2, "height": {"band": 0.5}}, "encoding": { "y": { "field": "Origin", "scale": {"padding": 0}, - "band": 0.5, "axis": { "bandPosition": 0, "grid": true, diff --git a/examples/specs/bar_month_band.vl.json b/examples/specs/bar_month_band.vl.json index 26e5e2a011a..9dfc4fc434c 100644 --- a/examples/specs/bar_month_band.vl.json +++ b/examples/specs/bar_month_band.vl.json @@ -1,12 +1,11 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v4.json", "data": {"url": "data/seattle-weather.csv"}, - "mark": "bar", + "mark": {"type": "bar", "width": {"band": 0.7}}, "encoding": { "x": { "timeUnit": "month", - "field": "date", - "band": 0.7 + "field": "date" }, "y": { "aggregate": "mean", diff --git a/examples/specs/circle_wilkinson_dotplot_stacked.vl.json b/examples/specs/circle_wilkinson_dotplot_stacked.vl.json index 4d3d0b54743..773fe067431 100644 --- a/examples/specs/circle_wilkinson_dotplot_stacked.vl.json +++ b/examples/specs/circle_wilkinson_dotplot_stacked.vl.json @@ -16,7 +16,7 @@ "mark": "circle", "encoding": { "x": {"field": "data", "type": "ordinal"}, - "y": {"aggregate": "count", "stack": true, "band": 0.5}, + "y": {"aggregate": "count", "stack": true, "bandPosition": 0.5}, "detail": {"field": "id"} } } diff --git a/examples/specs/line_month_center_band.vl.json b/examples/specs/line_month_center_band.vl.json index 4eff003dd6a..d0a5894eec4 100644 --- a/examples/specs/line_month_center_band.vl.json +++ b/examples/specs/line_month_center_band.vl.json @@ -7,7 +7,7 @@ "interpolate": "monotone" }, "encoding": { - "x": {"timeUnit": "month", "field": "date", "band": 0.5}, + "x": {"timeUnit": "month", "field": "date", "bandPosition": 0.5}, "y": {"aggregate": "mean", "field": "temp_max"} } } diff --git a/site/docs/mark/bar.md b/site/docs/mark/bar.md index 3b21812be1d..ecd56d8ab0b 100644 --- a/site/docs/mark/bar.md +++ b/site/docs/mark/bar.md @@ -47,7 +47,7 @@ Bar marks are useful in many visualizations, including bar charts, [stacked bar A bar mark definition can contain any [standard mark properties](mark.html#mark-def) and the following special properties: -{% include table.html props="orient,align,baseline,binSpacing,cornerRadius,cornerRadiusEnd,cornerRadiusTopLeft,cornerRadiusTopRight,cornerRadiusBottomRight,cornerRadiusBottomLeft" source="MarkDef" %} +{% include table.html props="width,height,orient,align,baseline,binSpacing,cornerRadius,cornerRadiusEnd,cornerRadiusTopLeft,cornerRadiusTopRight,cornerRadiusBottomRight,cornerRadiusBottomLeft" source="MarkDef" %} ## Examples @@ -63,10 +63,22 @@ If we map a different discrete field to the `y` channel, we can produce a horizo +### Bar Chart with a Temporal Axis + While the `bar` mark typically uses the x and y channels to encode a pair of discrete and continuous fields, it can also be used with continuous fields on both channels. For example, given a bar chart with a temporal field on x, we can see that the x-scale is a continuous scale. By default, the size of bars on continuous scales will be set based on the [`continuousBandSize` config](#config). +{.#bar-width} + +### Relative Bar Width + +To adjust the bar to be smaller than the time unit step, you can adjust the bar's width to be a proportion of band. For example, the following chart sets the width to be 70% of the x band width. + + + +### Bar Chart with a Discrete Temporal Axis + If you want to use a discrete scale instead, you can cast the field to have an `"ordinal"` type. This casting strategy can be useful for time units with low cardinality such as `"month"`. diff --git a/src/channeldef.ts b/src/channeldef.ts index 15f61dbfef8..c5a2526f7d6 100644 --- a/src/channeldef.ts +++ b/src/channeldef.ts @@ -1,4 +1,4 @@ -import {Gradient, SignalRef, Text} from 'vega'; +import {Gradient, ScaleType, SignalRef, Text} from 'vega'; import {isArray, isBoolean, isNumber, isString} from 'vega-util'; import {Aggregate, isAggregateOp, isArgmaxDef, isArgminDef, isCountingAggregateOp} from './aggregate'; import {Axis} from './axis'; @@ -14,6 +14,7 @@ import { FACET, FILL, FILLOPACITY, + getSizeChannel, HREF, isScaleChannel, isSecondaryRangeChannel, @@ -25,6 +26,8 @@ import { LONGITUDE2, OPACITY, ORDER, + PolarPositionScaleChannel, + PositionScaleChannel, RADIUS, RADIUS2, ROW, @@ -56,9 +59,9 @@ import {ImputeParams} from './impute'; import {Legend} from './legend'; import * as log from './log'; import {LogicalComposition} from './logical'; -import {isRectBasedMark, Mark, MarkDef} from './mark'; +import {isRectBasedMark, Mark, MarkDef, RelativeBandSize} from './mark'; import {Predicate} from './predicate'; -import {isContinuousToDiscrete, Scale, SCALE_CATEGORY_INDEX} from './scale'; +import {hasDiscreteDomain, isContinuousToDiscrete, Scale, SCALE_CATEGORY_INDEX} from './scale'; import {isSortByChannel, Sort, SortOrder} from './sort'; import {isFacetFieldDef} from './spec/facet'; import {StackOffset, StackProperties} from './stack'; @@ -472,14 +475,12 @@ export interface PositionBaseMixins { export interface BandMixins { /** - * For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval. - * - * For other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band. + * Relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band. * * @minimum 0 * @maximum 1 */ - band?: number; + bandPosition?: number; } export type PositionFieldDef = PositionFieldDefBase & PositionMixins; @@ -511,16 +512,14 @@ export interface PositionMixins { export type PolarDef = PositionFieldDefBase | PositionDatumDefBase | PositionValueDef; -export function getBand({ +export function getBandPosition({ channel, fieldDef, fieldDef2, markDef: mark, stack, - config, - isMidPoint + config }: { - isMidPoint?: boolean; channel: Channel; fieldDef: FieldDef | DatumDef; fieldDef2?: SecondaryChannelDef; @@ -528,29 +527,69 @@ export function getBand({ markDef: MarkDef; config: Config; }): number { - if (isFieldOrDatumDef(fieldDef) && fieldDef.band !== undefined) { - return fieldDef.band; + if (isFieldOrDatumDef(fieldDef) && fieldDef.bandPosition !== undefined) { + return fieldDef.bandPosition; } if (isFieldDef(fieldDef)) { const {timeUnit, bin} = fieldDef; - if (timeUnit && !fieldDef2) { - if (isMidPoint) { - return getMarkConfig('timeUnitBandPosition', mark, config); - } else { - return isRectBasedMark(mark.type) ? getMarkConfig('timeUnitBand', mark, config) : 0; - } + return isRectBasedMark(mark.type) ? getMarkConfig('timeUnitBand', mark, config) : 0; } else if (isBinning(bin)) { - return isRectBasedMark(mark.type) && !isMidPoint ? 1 : 0.5; + return 0.5; } } - if (stack?.fieldChannel === channel && isMidPoint) { + if (stack?.fieldChannel === channel) { return 0.5; } + + return undefined; +} + +export function getBandSize({ + channel, + fieldDef, + fieldDef2, + markDef: mark, + config, + scaleType +}: { + channel: PositionScaleChannel | PolarPositionScaleChannel; + fieldDef: ChannelDef; + fieldDef2?: SecondaryChannelDef; + markDef: MarkDef; + config: Config; + scaleType: ScaleType; +}): number | RelativeBandSize | SignalRef { + const dimensionSize = mark[getSizeChannel(channel)]; + if (dimensionSize !== undefined) { + return dimensionSize; + } + + if (isFieldDef(fieldDef)) { + const {timeUnit, bin} = fieldDef; + + if (timeUnit && !fieldDef2) { + return {band: getMarkConfig('timeUnitBand', mark, config)}; + } else if (isBinning(bin) && !hasDiscreteDomain(scaleType)) { + return {band: 1}; + } + } + + if (isRectBasedMark(mark.type)) { + if (scaleType) { + if (hasDiscreteDomain(scaleType)) { + return config[mark.type]?.discreteBandSize || {band: 1}; + } else { + return config[mark.type]?.continuousBandSize; + } + } + return config[mark.type]?.discreteBandSize; + } + return undefined; } -export function hasBand( +export function hasBandEnd( channel: Channel, fieldDef: FieldDef, fieldDef2: SecondaryChannelDef, @@ -559,7 +598,9 @@ export function hasBand( config: Config ): boolean { if (isBinning(fieldDef.bin) || (fieldDef.timeUnit && isTypedFieldDef(fieldDef) && fieldDef.type === 'temporal')) { - return !!getBand({channel, fieldDef, fieldDef2, stack, markDef, config}); + // Need to check bandPosition because non-rect marks (e.g., point) with timeUnit + // doesn't have to use bandEnd if there is no bandPosition. + return !!getBandPosition({channel, fieldDef, fieldDef2, stack, markDef, config}); } return false; } diff --git a/src/compile/data/aggregate.ts b/src/compile/data/aggregate.ts index c0466fe2897..099a7d6120a 100644 --- a/src/compile/data/aggregate.ts +++ b/src/compile/data/aggregate.ts @@ -7,7 +7,7 @@ import { isGeoPositionChannel, isScaleChannel } from '../../channel'; -import {binRequiresRange, FieldDef, hasBand, isTypedFieldDef, vgField} from '../../channeldef'; +import {binRequiresRange, FieldDef, hasBandEnd, isTypedFieldDef, vgField} from '../../channeldef'; import * as log from '../../log'; import {AggregateTransform} from '../../transform'; import {Dict, duplicate, hash, keys, replacePathInField, setEqual} from '../../util'; @@ -23,7 +23,7 @@ function addDimension(dims: Set, channel: Channel, fieldDef: FieldDef { + const formula = model.reduceFieldDef((timeUnitComponent: TimeUnitComponent, fieldDef) => { const {field, timeUnit} = fieldDef; - const channelDef2 = isUnitModel(model) ? model.encoding[getSecondaryRangeChannel(channel)] : undefined; - - const band = - isUnitModel(model) && hasBand(channel, fieldDef, channelDef2, model.stack, model.markDef, model.config); - if (timeUnit) { const as = vgField(fieldDef, {forAs: true}); timeUnitComponent[ @@ -41,8 +32,7 @@ export class TimeUnitNode extends DataFlowNode { ] = { as, field, - timeUnit, - ...(band ? {band: true} : {}) + timeUnit }; } return timeUnitComponent; @@ -77,10 +67,10 @@ export class TimeUnitNode extends DataFlowNode { public merge(other: TimeUnitNode) { this.formula = {...this.formula}; - // if the same hash happen twice, merge "band" + // if the same hash happen twice, merge for (const key in other.formula) { - if (!this.formula[key] || other.formula[key].band) { - // copy if it's not a duplicate or if we need to copy band over + if (!this.formula[key]) { + // copy if it's not a duplicate this.formula[key] = other.formula[key]; } } diff --git a/src/compile/mark/encode/position-point.ts b/src/compile/mark/encode/position-point.ts index 066374a76cd..c43f88c0d3b 100644 --- a/src/compile/mark/encode/position-point.ts +++ b/src/compile/mark/encode/position-point.ts @@ -7,7 +7,7 @@ import { PolarPositionChannel, PositionChannel } from '../../../channel'; -import {getBand, isFieldDef, isFieldOrDatumDef, TypedFieldDef} from '../../../channeldef'; +import {isFieldDef, isFieldOrDatumDef, TypedFieldDef} from '../../../channeldef'; import {ScaleType} from '../../../scale'; import {contains} from '../../../util'; import {VgValueRef} from '../../../vega.schema'; @@ -25,12 +25,10 @@ export function pointPosition( model: UnitModel, { defaultPos, - vgChannel, - isMidPoint + vgChannel }: { defaultPos: 'mid' | 'zeroOrMin' | 'zeroOrMax' | null; vgChannel?: 'x' | 'y' | 'xc' | 'yc'; - isMidPoint?: boolean; } ) { const {encoding, markDef, config, stack} = model; @@ -61,7 +59,6 @@ export function pointPosition( channel2Def, markDef, config, - isMidPoint, scaleName, scale, stack, @@ -81,28 +78,27 @@ export function pointPosition( export function positionRef( params: ref.MidPointParams & { channel: 'x' | 'y' | 'radius' | 'theta'; - isMidPoint?: boolean; } ): VgValueRef | VgValueRef[] { - const {channel, channelDef, isMidPoint, scaleName, stack, offset, markDef, config} = params; + const {channel, channelDef, scaleName, stack, offset, markDef} = params; // This isn't a part of midPoint because we use midPoint for non-position too if (isFieldOrDatumDef(channelDef) && stack && channel === stack.fieldChannel) { if (isFieldDef(channelDef)) { - const band = getBand({ - channel, - fieldDef: channelDef, - isMidPoint, - markDef, - stack, - config - }); - if (band !== undefined) { + let bandPosition = channelDef.bandPosition; + + if (bandPosition === undefined && markDef.type === 'text' && (channel === 'radius' || channel === 'theta')) { + // theta and radius of text mark should use bandPosition = 0.5 by default + // so that labels for arc marks are centered automatically + bandPosition = 0.5; + } + + if (bandPosition !== undefined) { return ref.interpolatedSignalRef({ scaleName, fieldOrDatumDef: channelDef as TypedFieldDef, // positionRef always have type startSuffix: 'start', - band, + bandPosition, offset }); } diff --git a/src/compile/mark/encode/position-range.ts b/src/compile/mark/encode/position-range.ts index 7aff238f5b1..3e56093aa31 100644 --- a/src/compile/mark/encode/position-range.ts +++ b/src/compile/mark/encode/position-range.ts @@ -1,7 +1,8 @@ import {SignalRef} from 'vega'; import {getMainRangeChannel, getSecondaryRangeChannel, getSizeChannel, getVgPositionChannel} from '../../../channel'; import {isFieldOrDatumDef} from '../../../channeldef'; -import {MarkConfig} from '../../../mark'; +import * as log from '../../../log'; +import {isRelativeBandSize, Mark, MarkConfig, MarkDef} from '../../../mark'; import {VgEncodeEntry, VgValueRef} from '../../../vega.schema'; import {getMarkStyleConfig} from '../../common'; import {UnitModel} from '../../unit'; @@ -166,7 +167,10 @@ export function position2Ref({ }); } -function position2orSize(channel: 'x2' | 'y2' | 'radius2' | 'theta2', markDef: MarkConfig) { +function position2orSize( + channel: 'x2' | 'y2' | 'radius2' | 'theta2', + markDef: MarkConfig | MarkDef +) { const sizeChannel = getSizeChannel(channel); const vgChannel = getVgPositionChannel(channel); if (markDef[vgChannel] !== undefined) { @@ -174,7 +178,12 @@ function position2orSize(channel: 'x2' | 'y2' | 'radius2' | 'theta2', markDef: M } else if (markDef[channel] !== undefined) { return {[vgChannel]: ref.widthHeightValueOrSignalRef(channel, markDef[channel])}; } else if (markDef[sizeChannel]) { - return {[sizeChannel]: ref.widthHeightValueOrSignalRef(channel, markDef[sizeChannel])}; + const dimensionSize = markDef[sizeChannel]; + if (isRelativeBandSize(dimensionSize)) { + log.warn(log.message.relativeBandSizeNotSupported(sizeChannel)); + } else { + return {[sizeChannel]: ref.widthHeightValueOrSignalRef(channel, dimensionSize)}; + } } return undefined; } diff --git a/src/compile/mark/encode/position-rect.ts b/src/compile/mark/encode/position-rect.ts index b9ae021d22e..0825abfe7a1 100644 --- a/src/compile/mark/encode/position-rect.ts +++ b/src/compile/mark/encode/position-rect.ts @@ -10,15 +10,14 @@ import { PolarPositionChannel, PositionChannel } from '../../../channel'; -import {getBand, isFieldDef, isFieldOrDatumDef, TypedFieldDef, vgField} from '../../../channeldef'; -import {Config, DEFAULT_STEP, getViewConfigDiscreteStep} from '../../../config'; +import {getBandSize, isFieldDef, isFieldOrDatumDef, TypedFieldDef, vgField} from '../../../channeldef'; +import {Config, getViewConfigDiscreteStep} from '../../../config'; import {Encoding} from '../../../encoding'; import * as log from '../../../log'; -import {Mark, MarkDef} from '../../../mark'; -import {hasDiscreteDomain, ScaleType} from '../../../scale'; -import {getFirstDefined} from '../../../util'; +import {BandSize, isRelativeBandSize, Mark, MarkDef, RelativeBandSize} from '../../../mark'; +import {hasDiscreteDomain} from '../../../scale'; import {isSignalRef, isVgRangeStep, VgEncodeEntry, VgValueRef} from '../../../vega.schema'; -import {getMarkPropOrConfig, signalOrStringValue} from '../../common'; +import {getMarkPropOrConfig, signalOrStringValue, signalOrValueRef} from '../../common'; import {ScaleComponent} from '../../scale/component'; import {UnitModel} from '../../unit'; import {nonPosition} from './nonposition'; @@ -33,7 +32,7 @@ export function rectPosition( channel: 'x' | 'y' | 'theta' | 'radius', mark: 'bar' | 'rect' | 'image' | 'arc' ): VgEncodeEntry { - const {config, encoding, markDef, stack} = model; + const {config, encoding, markDef} = model; const channel2 = getSecondaryRangeChannel(channel); const sizeChannel = getSizeChannel(channel); @@ -57,7 +56,7 @@ export function rectPosition( !hasSizeDef && !hasDiscreteDomain(scaleType) ) { - const band = getBand({channel, fieldDef: channelDef, stack, markDef, config}); + const bandSize = getBandSize({channel, fieldDef: channelDef, markDef, config, scaleType}); const axis = model.component.axes[channel]?.[0]; const axisTranslate = axis?.get('translate') ?? 0.5; // vega default is 0.5 @@ -67,7 +66,7 @@ export function rectPosition( channel, markDef, scaleName, - band, + bandSize, axisTranslate, spacing: isXorY(channel) ? getMarkPropOrConfig('binSpacing', markDef, config) : undefined, reverse: scale.get('reverse'), @@ -80,44 +79,42 @@ export function rectPosition( } } function defaultSizeRef( - mark: 'bar' | 'rect' | 'image' | 'arc', sizeChannel: 'width' | 'height', scaleName: string, scale: ScaleComponent, config: Config, - band: number | true + bandSize: BandSize ): VgValueRef { - if (scale) { - const scaleType = scale.get('type'); - if (scaleType === 'point' || scaleType === 'band') { - if (config[mark].discreteBandSize !== undefined) { - return {value: config[mark].discreteBandSize}; - } - if (scaleType === ScaleType.POINT) { - const scaleRange = scale.get('range'); - if (isVgRangeStep(scaleRange) && isNumber(scaleRange.step)) { - return {value: scaleRange.step - 2}; - } - return {value: DEFAULT_STEP - 2}; - } else { - // BAND - return {scale: scaleName, band}; + if (isRelativeBandSize(bandSize)) { + if (scale) { + const scaleType = scale.get('type'); + if (scaleType === 'band') { + return {scale: scaleName, band: bandSize.band}; + } else if (bandSize.band !== 1) { + log.warn(log.message.cannotUseRelativeBandSizeWithNonBandScale(scaleType)); + bandSize = undefined; } } else { - // continuous scale - return {value: config[mark].continuousBandSize}; + return { + mult: bandSize.band, + field: {group: sizeChannel} + }; } + } else if (isSignalRef(bandSize)) { + return bandSize; + } else if (bandSize) { + return {value: bandSize}; } - // No Scale - const step = getViewConfigDiscreteStep(config.view, sizeChannel); - - const value = getFirstDefined( - // No scale is like discrete bar (with one item) - config[mark].discreteBandSize, - step - 2 - ); - return value !== undefined ? {value} : undefined; + // no valid band size + if (scale) { + const scaleRange = scale.get('range'); + if (isVgRangeStep(scaleRange) && isNumber(scaleRange.step)) { + return {value: scaleRange.step - 2}; + } + } + const defaultStep = getViewConfigDiscreteStep(config.view, sizeChannel); + return {value: defaultStep - 2}; } /** @@ -148,15 +145,24 @@ function positionAndSize( let sizeMixins; if (encoding.size || sizeFromMarkOrConfig !== undefined) { if (useVlSizeChannel) { - sizeMixins = nonPosition('size', model, {vgChannel: vgSizeChannel, defaultValue: sizeFromMarkOrConfig}); + sizeMixins = nonPosition('size', model, { + vgChannel: vgSizeChannel, + defaultRef: isRelativeBandSize(sizeFromMarkOrConfig) + ? { + scale: scaleName, + band: sizeFromMarkOrConfig.band + } + : signalOrValueRef(sizeFromMarkOrConfig) + }); } else { log.warn(log.message.cannotApplySizeToNonOrientedMark(markDef.type)); } } // Otherwise, apply default value - const band = (isFieldOrDatumDef(fieldDef) ? getBand({channel, fieldDef, markDef, stack, config}) : undefined) ?? 1; - sizeMixins = sizeMixins || {[vgSizeChannel]: defaultSizeRef(mark, vgSizeChannel, scaleName, scale, config, band)}; + const bandSize = getBandSize({channel, fieldDef, markDef, config, scaleType: scale?.get('type')}); + + sizeMixins = sizeMixins || {[vgSizeChannel]: defaultSizeRef(vgSizeChannel, scaleName, scale, config, bandSize)}; /* Band scales with size value and all point scales, use xc/yc + band=0.5 @@ -167,9 +173,10 @@ function positionAndSize( If band is 0.6, the the x/y position in such case should be `(1 - band) / 2` = 0.2 */ - const center = scale?.get('type') !== 'band' || !('band' in sizeMixins[vgSizeChannel]); + const defaultBandAlign = scale?.get('type') !== 'band' || !('band' in sizeMixins[vgSizeChannel]) ? 'middle' : 'top'; - const vgChannel = vgAlignedPositionChannel(channel, markDef, config, center ? 'middle' : 'top'); + const vgChannel = vgAlignedPositionChannel(channel, markDef, config, defaultBandAlign); + const center = vgChannel === 'xc' || vgChannel === 'yc'; const offset = getOffset(channel, markDef); const posRef = ref.midPointRefWithPositionInvalidTest({ @@ -182,7 +189,13 @@ function positionAndSize( stack, offset, defaultRef: pointPositionDefaultRef({model, defaultPos: 'mid', channel, scaleName, scale}), - band: center ? 0.5 : (1 - band) / 2 + bandPosition: center + ? 0.5 + : isSignalRef(bandSize) + ? {signal: `(1-${bandSize})/2`} + : isRelativeBandSize(bandSize) + ? (1 - bandSize.band) / 2 + : 0 }); if (vgSizeChannel) { @@ -242,7 +255,7 @@ export function rectBinPosition({ fieldDef, fieldDef2, channel, - band, + bandSize, scaleName, markDef, spacing = 0, @@ -253,7 +266,7 @@ export function rectBinPosition({ fieldDef: TypedFieldDef; fieldDef2?: Encoding['x2' | 'y2']; channel: 'x' | 'y' | 'theta' | 'radius'; - band: number; + bandSize: number | RelativeBandSize | SignalRef | undefined; scaleName: string; markDef: MarkDef; spacing?: number; @@ -268,6 +281,12 @@ export function rectBinPosition({ const offset = getOffset(channel, markDef); + const bandPosition = isSignalRef(bandSize) + ? {signal: `(1-${bandSize.signal})/2`} + : isRelativeBandSize(bandSize) + ? (1 - bandSize.band) / 2 + : 0.5; + if (isBinning(fieldDef.bin) || fieldDef.timeUnit) { return { [vgChannel2]: rectBinRef({ @@ -275,7 +294,7 @@ export function rectBinPosition({ fieldDef, scaleName, markDef, - band: (1 - band) / 2, + bandPosition, offset: getBinSpacing(channel2, spacing, reverse, axisTranslate, offset), config }), @@ -284,7 +303,7 @@ export function rectBinPosition({ fieldDef, scaleName, markDef, - band: 1 - (1 - band) / 2, + bandPosition: isSignalRef(bandPosition) ? {signal: `1-${bandPosition.signal}`} : 1 - bandPosition, offset: getBinSpacing(channel, spacing, reverse, axisTranslate, offset), config }) @@ -329,7 +348,7 @@ export function rectBinRef({ fieldDef, scaleName, markDef, - band, + bandPosition, offset, config }: { @@ -337,14 +356,14 @@ export function rectBinRef({ fieldDef: TypedFieldDef; scaleName: string; markDef: MarkDef; - band: number; + bandPosition: number | SignalRef; offset?: number | SignalRef; config?: Config; }) { const r = ref.interpolatedSignalRef({ scaleName, fieldOrDatumDef: fieldDef, - band, + bandPosition, offset }); diff --git a/src/compile/mark/encode/valueref.ts b/src/compile/mark/encode/valueref.ts index 3b0ba84ce29..bd709c5b31f 100644 --- a/src/compile/mark/encode/valueref.ts +++ b/src/compile/mark/encode/valueref.ts @@ -14,7 +14,7 @@ import { FieldDefBase, FieldName, FieldRefOption, - getBand, + getBandPosition, isDatumDef, isFieldDef, isFieldOrDatumDef, @@ -125,7 +125,7 @@ export function valueRefForFieldOrDatumDef( fieldDef: FieldDefBase | DatumDef, scaleName: string, opt: FieldRefOption, - encode: {offset?: number | VgValueRef; band?: number | boolean} + encode: {offset?: number | VgValueRef; band?: number | boolean | SignalRef} ): VgValueRef { const ref: VgValueRef = {}; @@ -169,16 +169,16 @@ export function interpolatedSignalRef({ fieldOrDatumDef2, offset, startSuffix, - band = 0.5 + bandPosition = 0.5 }: { scaleName: string; fieldOrDatumDef: TypedFieldDef; fieldOrDatumDef2?: SecondaryFieldDef; startSuffix?: string; offset: number | SignalRef; - band: number; + bandPosition: number | SignalRef; }): VgValueRef { - const expr = 0 < band && band < 1 ? 'datum' : undefined; + const expr = 0 < bandPosition && bandPosition < 1 ? 'datum' : undefined; const start = vgField(fieldOrDatumDef, {expr, suffix: startSuffix}); const end = fieldOrDatumDef2 !== undefined @@ -187,12 +187,14 @@ export function interpolatedSignalRef({ const ref: VgValueRef = {}; - if (band === 0 || band === 1) { + if (bandPosition === 0 || bandPosition === 1) { ref.scale = scaleName; - const val = band === 0 ? start : end; + const val = bandPosition === 0 ? start : end; ref.field = val; } else { - const datum = `${band} * ${start} + ${1 - band} * ${end}`; + const datum = isSignalRef(bandPosition) + ? `${bandPosition.signal} * ${start} + (1-${bandPosition.signal}) * ${end}` + : `${bandPosition} * ${start} + ${1 - bandPosition} * ${end}`; ref.signal = `scale("${scaleName}", ${datum})`; } @@ -216,10 +218,7 @@ export interface MidPointParams { offset?: number | SignalRef; defaultRef: VgValueRef | (() => VgValueRef); - /** - * Allow overriding band instead of reading to field def since band is applied to size (width/height) instead of the position for x/y-position with band scales. - */ - band?: number; + bandPosition?: number | SignalRef; } /** @@ -236,7 +235,7 @@ export function midPoint({ stack, offset, defaultRef, - band + bandPosition }: MidPointParams): VgValueRef { // TODO: datum support if (channelDef) { @@ -244,30 +243,31 @@ export function midPoint({ if (isFieldOrDatumDef(channelDef)) { if (isTypedFieldDef(channelDef)) { - band = - band ?? - getBand({ + // FIXME: why should we allow passing bandPosition in? + bandPosition = + bandPosition ?? + getBandPosition({ channel, fieldDef: channelDef, fieldDef2: channel2Def, markDef, stack, - config, - isMidPoint: true + config }); const {bin, timeUnit, type} = channelDef; - if (isBinning(bin) || (band && timeUnit && type === TEMPORAL)) { + if (isBinning(bin) || (bandPosition && timeUnit && type === TEMPORAL)) { // Use middle only for x an y to place marks in the center between start and end of the bin range. // We do not use the mid point for other channels (e.g. size) so that properties of legends and marks match. if (stack && stack.impute) { // For stack, we computed bin_mid so we can impute. return valueRefForFieldOrDatumDef(channelDef, scaleName, {binSuffix: 'mid'}, {offset}); } - if (band) { + + if (bandPosition) { // if band = 0, no need to call interpolation // For non-stack, we can just calculate bin mid on the fly using signal. - return interpolatedSignalRef({scaleName, fieldOrDatumDef: channelDef, band, offset}); + return interpolatedSignalRef({scaleName, fieldOrDatumDef: channelDef, bandPosition, offset}); } return valueRefForFieldOrDatumDef( channelDef, @@ -283,7 +283,7 @@ export function midPoint({ scaleName, fieldOrDatumDef: channelDef, fieldOrDatumDef2: channel2Def, - band, + bandPosition, offset }); } else { @@ -301,7 +301,7 @@ export function midPoint({ { offset, // For band, to get mid point, need to offset by half of the band - band: scaleType === 'band' ? band ?? channelDef.band ?? 0.5 : undefined + band: scaleType === 'band' ? bandPosition ?? channelDef.bandPosition ?? 0.5 : undefined } ); } else if (isValueDef(channelDef)) { diff --git a/src/compile/mark/text.ts b/src/compile/mark/text.ts index 40a6a17e26e..cf1b2265cee 100644 --- a/src/compile/mark/text.ts +++ b/src/compile/mark/text.ts @@ -31,8 +31,8 @@ export const text: MarkCompiler = { ...encode.nonPosition('angle', model), ...encode.valueIfDefined('align', align(model.markDef, encoding, config)), ...encode.valueIfDefined('baseline', baseline(model.markDef, encoding, config)), - ...encode.pointPosition('radius', model, {defaultPos: null, isMidPoint: true}), - ...encode.pointPosition('theta', model, {defaultPos: null, isMidPoint: true}) + ...encode.pointPosition('radius', model, {defaultPos: null}), + ...encode.pointPosition('theta', model, {defaultPos: null}) }; } }; diff --git a/src/compile/scale/domain.ts b/src/compile/scale/domain.ts index d783f6fb09e..10e15a4f8ec 100644 --- a/src/compile/scale/domain.ts +++ b/src/compile/scale/domain.ts @@ -13,7 +13,7 @@ import {getSecondaryRangeChannel, isScaleChannel, ScaleChannel} from '../../chan import { binRequiresRange, getFieldOrDatumDef, - hasBand, + hasBandEnd, isDatumDef, isFieldDef, ScaleDatumDef, @@ -348,7 +348,7 @@ function parseSingleChannelDomain( } else if ( fieldDef.timeUnit && util.contains(['time', 'utc'], scaleType) && - hasBand( + hasBandEnd( channel, fieldDef, isUnitModel(model) ? model.encoding[getSecondaryRangeChannel(channel)] : undefined, diff --git a/src/compile/scale/parse.ts b/src/compile/scale/parse.ts index e74fc9ff41b..e1401ef7aa5 100644 --- a/src/compile/scale/parse.ts +++ b/src/compile/scale/parse.ts @@ -43,7 +43,7 @@ export function parseScaleCore(model: Model) { * Parse scales for all channels of a model. */ function parseUnitScaleCore(model: UnitModel): ScaleComponentIndex { - const {encoding, mark} = model; + const {encoding, mark, markDef} = model; return SCALE_CHANNELS.reduce((scaleComponents: ScaleComponentIndex, channel: ScaleChannel) => { const fieldOrDatumDef = getFieldOrDatumDef(encoding[channel]) as TypedFieldDef | ScaleDatumDef; // must be typed def to have scale @@ -57,7 +57,7 @@ function parseUnitScaleCore(model: UnitModel): ScaleComponentIndex { if (fieldOrDatumDef && specifiedScale !== null && specifiedScale !== false) { specifiedScale = specifiedScale ?? {}; - const sType = scaleType(specifiedScale, channel, fieldOrDatumDef, mark); + const sType = scaleType(specifiedScale, channel, fieldOrDatumDef, markDef); scaleComponents[channel] = new ScaleComponent(model.scaleName(`${channel}`, true), { value: sType, explicit: specifiedScale.type === sType diff --git a/src/compile/scale/type.ts b/src/compile/scale/type.ts index ba9a90ac15c..53465689bac 100644 --- a/src/compile/scale/type.ts +++ b/src/compile/scale/type.ts @@ -1,8 +1,8 @@ import {isBinning} from '../../bin'; -import {Channel, isColorChannel, isScaleChannel, rangeType} from '../../channel'; +import {Channel, getSizeChannel, isColorChannel, isScaleChannel, rangeType} from '../../channel'; import {DatumDef, isFieldDef, isPositionFieldOrDatumDef, ScaleDatumDef, TypedFieldDef} from '../../channeldef'; import * as log from '../../log'; -import {Mark} from '../../mark'; +import {isRelativeBandSize, MarkDef} from '../../mark'; import {channelSupportScaleType, Scale, ScaleType, scaleTypeSupportDataType} from '../../scale'; import {normalizeTimeUnit} from '../../timeunit'; import * as util from '../../util'; @@ -19,7 +19,7 @@ export function scaleType( specifiedScale: Scale, channel: Channel, fieldDef: TypedFieldDef | DatumDef, - mark: Mark + mark: MarkDef ): ScaleType { const defaultScaleType = defaultType(channel, fieldDef, mark); const {type} = specifiedScale; @@ -51,10 +51,10 @@ export function scaleType( * Determine appropriate default scale type. */ // NOTE: Voyager uses this method. -function defaultType(channel: Channel, fieldDef: TypedFieldDef | ScaleDatumDef, mark: Mark): ScaleType { +function defaultType(channel: Channel, fieldDef: TypedFieldDef | ScaleDatumDef, mark: MarkDef): ScaleType { switch (fieldDef.type) { case 'nominal': - case 'ordinal': + case 'ordinal': { if (isColorChannel(channel) || rangeType(channel) === 'discrete') { if (channel === 'shape' && fieldDef.type === 'ordinal') { log.warn(log.message.discreteChannelCannotEncode(channel, 'ordinal')); @@ -63,20 +63,26 @@ function defaultType(channel: Channel, fieldDef: TypedFieldDef | ScaleDa } if (channel in POSITION_SCALE_CHANNEL_INDEX) { - if (util.contains(['rect', 'bar', 'image', 'rule'], mark)) { + if (util.contains(['rect', 'bar', 'image', 'rule'], mark.type)) { // The rect/bar mark should fit into a band. // For rule, using band scale to make rule align with axis ticks better https://github.com/vega/vega-lite/issues/3429 return 'band'; } - } else if (mark === 'arc' && channel in POLAR_POSITION_SCALE_CHANNEL_INDEX) { + } else if (mark.type === 'arc' && channel in POLAR_POSITION_SCALE_CHANNEL_INDEX) { return 'band'; } - if (fieldDef.band !== undefined || (isPositionFieldOrDatumDef(fieldDef) && fieldDef.axis?.tickBand)) { + const dimensionSize = mark[getSizeChannel(channel)]; + if (isRelativeBandSize(dimensionSize)) { + return 'band'; + } + + if (isPositionFieldOrDatumDef(fieldDef) && fieldDef.axis?.tickBand) { return 'band'; } // Otherwise, use ordinal point scale so we can easily get center positions of the marks. return 'point'; + } case 'temporal': if (isColorChannel(channel)) { diff --git a/src/log/message.ts b/src/log/message.ts index bd79c7ced30..c1bc15a3a05 100644 --- a/src/log/message.ts +++ b/src/log/message.ts @@ -167,6 +167,10 @@ export function droppingColor(type: 'encoding' | 'property', opt: {fill?: boolea }.`; } +export function relativeBandSizeNotSupported(sizeChannel: 'width' | 'height') { + return `Position range does not support relative band size for ${sizeChannel}.`; +} + export function emptyFieldDef(fieldDef: unknown, channel: ExtendedChannel) { return `Dropping ${stringify( fieldDef @@ -229,6 +233,10 @@ export function cannotUseScalePropertyWithNonColor(prop: string) { return `Cannot use the scale property "${prop}" with non-color channel.`; } +export function cannotUseRelativeBandSizeWithNonBandScale(scaleType: ScaleType) { + return `Cannot use the relative band size with ${scaleType} scale.`; +} + export function unaggregateDomainHasNoEffectForRawField(fieldDef: TypedFieldDef) { return `Using unaggregated domain with raw field has no effect (${stringify(fieldDef)}).`; } diff --git a/src/mark.ts b/src/mark.ts index 063d3c1658a..087e0097554 100644 --- a/src/mark.ts +++ b/src/mark.ts @@ -443,15 +443,26 @@ export interface RectConfig extends RectBinSpaci * The default size of the bars with discrete dimensions. If unspecified, the default size is `step-2`, which provides 2 pixel offset between bars. * @minimum 0 */ - discreteBandSize?: number; + discreteBandSize?: number | RelativeBandSize; } -export const BAR_CORNER_RADIUS_INDEX: Partial< - Record< - Orientation, - ('cornerRadiusTopLeft' | 'cornerRadiusTopRight' | 'cornerRadiusBottomLeft' | 'cornerRadiusBottomRight')[] - > -> = { +export type BandSize = number | RelativeBandSize | SignalRef; + +export interface RelativeBandSize { + /** + * The relative band size. For example `0.5` means half of the band scale's band width. + */ + band: number; +} + +export function isRelativeBandSize(o: number | RelativeBandSize | ExprRef | SignalRef): o is RelativeBandSize { + return o && o['band'] != undefined; +} + +export const BAR_CORNER_RADIUS_INDEX: Partial> = { horizontal: ['cornerRadiusTopRight', 'cornerRadiusBottomRight'], vertical: ['cornerRadiusTopLeft', 'cornerRadiusTopRight'] }; @@ -459,6 +470,7 @@ export const BAR_CORNER_RADIUS_INDEX: Partial< export interface BarCornerRadiusMixins { /** * - For vertical bars, top-left and top-right corner radius. + * * - For horizontal bars, top-right and bottom-right corner radius. */ cornerRadiusEnd?: number | ES; @@ -581,7 +593,12 @@ export interface MarkDefMixins { radius2Offset?: number | ES; } -// Point/Line OverlayMixins are only for area, line, and trail but we don't want to declare multiple types of MarkDef +export interface RelativeBandSize { + /** + * The relative band size. For example `0.5` means half of the band scale's band width. + */ + band: number; +} // Point/Line OverlayMixins are only for area, line, and trail but we don't want to declare multiple types of MarkDef export interface MarkDef< @@ -594,7 +611,7 @@ export interface MarkDef< BarConfig & // always extends RectConfig LineConfig & TickConfig, - 'startAngle' | 'endAngle' + 'startAngle' | 'endAngle' | 'width' | 'height' >, MarkDefMixins { // Omit startAngle/endAngle since we use theta/theta2 from Vega-Lite schema to avoid confusion @@ -608,6 +625,26 @@ export interface MarkDef< * @hidden */ endAngle?: number | ES; + + // Replace width / height to include relative band size + + /** + * Width of the marks. One of: + * + * - A number representing a fixed pixel width. + * + * - A relative band size definition. For example, `{band: 0.5}` represents half of the band. + */ + width?: number | ES | RelativeBandSize; + + /** + * Height of the marks. One of: + * + * - A number representing a fixed pixel height. + * + * - A relative band size definition. For example, `{band: 0.5}` represents half of the band + */ + height?: number | ES | RelativeBandSize; } const DEFAULT_RECT_BAND_SIZE = 5; diff --git a/test/compile/data/timeunit.test.ts b/test/compile/data/timeunit.test.ts index b0c0e87b249..05cb1ab17fc 100644 --- a/test/compile/data/timeunit.test.ts +++ b/test/compile/data/timeunit.test.ts @@ -105,7 +105,7 @@ describe('compile/data/timeunit', () => { }); const timeUnitNode = TimeUnitNode.makeFromEncoding(null, model); expect(timeUnitNode.hash()).toBe( - 'TimeUnit {"{\\"as\\":\\"month_a\\",\\"field\\":\\"a\\",\\"timeUnit\\":{\\"unit\\":\\"month\\"}}":{"as":"month_a","band":true,"field":"a","timeUnit":{"unit":"month"}}}' + 'TimeUnit {"{\\"as\\":\\"month_a\\",\\"field\\":\\"a\\",\\"timeUnit\\":{\\"unit\\":\\"month\\"}}":{"as":"month_a","field":"a","timeUnit":{"unit":"month"}}}' ); }); @@ -119,7 +119,7 @@ describe('compile/data/timeunit', () => { }); const timeUnitNode = TimeUnitNode.makeFromEncoding(null, model); expect(timeUnitNode.hash()).toBe( - 'TimeUnit {"{\\"as\\":\\"utcmonth_step_10_a\\",\\"field\\":\\"a\\",\\"timeUnit\\":{\\"step\\":10,\\"unit\\":\\"month\\",\\"utc\\":true}}":{"as":"utcmonth_step_10_a","band":true,"field":"a","timeUnit":{"step":10,"unit":"month","utc":true}}}' + 'TimeUnit {"{\\"as\\":\\"utcmonth_step_10_a\\",\\"field\\":\\"a\\",\\"timeUnit\\":{\\"step\\":10,\\"unit\\":\\"month\\",\\"utc\\":true}}":{"as":"utcmonth_step_10_a","field":"a","timeUnit":{"step":10,"unit":"month","utc":true}}}' ); }); }); diff --git a/test/compile/mark/bar.test.ts b/test/compile/mark/bar.test.ts index bcff13b034a..8eee158b59f 100644 --- a/test/compile/mark/bar.test.ts +++ b/test/compile/mark/bar.test.ts @@ -153,12 +153,12 @@ describe('Mark: Bar', () => { }); }); - describe('simple horizontal with band', () => { + describe('simple horizontal with height band', () => { const model = parseUnitModelWithScaleAndLayoutSize({ data: {url: 'data/cars.json'}, - mark: 'bar', + mark: {type: 'bar', height: {band: 0.6}}, encoding: { - y: {field: 'Origin', type: 'nominal', band: 0.6}, + y: {field: 'Origin', type: 'nominal'}, x: {aggregate: 'mean', field: 'Acceleration', type: 'quantitative'} } }); @@ -266,7 +266,7 @@ describe('Mark: Bar', () => { }); const props = bar.encodeEntry(model); - it('should draw bar from zero to field value and with band value for x/width', () => { + it('should draw bar from zero to field value and with band value for yc/height', () => { expect(props.yc).toEqual({scale: 'y', field: 'Origin', band: 0.5}); expect(props.height).toEqual({scale: 'size', field: 'mean_Horsepower'}); expect(props.x).toEqual({scale: 'x', field: 'mean_Acceleration'}); diff --git a/test/compile/mark/encode/position-rect.test.ts b/test/compile/mark/encode/position-rect.test.ts index 5f5e817deba..3cb8b002cc8 100644 --- a/test/compile/mark/encode/position-rect.test.ts +++ b/test/compile/mark/encode/position-rect.test.ts @@ -11,7 +11,7 @@ describe('compile/mark/encode/position-rect', () => { const props = rectBinPosition({ fieldDef, channel: 'x', - band: 1, + bandSize: 1, scaleName: undefined, reverse: {signal: 'r'}, axisTranslate: 0.5, // Vega default @@ -32,7 +32,7 @@ describe('compile/mark/encode/position-rect', () => { const props = rectBinPosition({ fieldDef, channel: 'x', - band: 1, + bandSize: 1, scaleName: 'x', reverse: false, axisTranslate: 0.5, // Vega default @@ -51,7 +51,7 @@ describe('compile/mark/encode/position-rect', () => { const props = rectBinPosition({ fieldDef, channel: 'y', - band: 1, + bandSize: 1, scaleName: undefined, axisTranslate: 0.5, // Vega default reverse: {signal: 'r'}, @@ -72,7 +72,7 @@ describe('compile/mark/encode/position-rect', () => { const props = rectBinPosition({ fieldDef, channel: 'x', - band: 1, + bandSize: 1, scaleName: undefined, axisTranslate: 0.5, // Vega default reverse: {signal: 'r'}, @@ -93,7 +93,7 @@ describe('compile/mark/encode/position-rect', () => { const props = rectBinPosition({ fieldDef, channel: 'y', - band: 1, + bandSize: 1, scaleName: undefined, axisTranslate: 0.5, // Vega default reverse: {signal: 'r'}, @@ -116,7 +116,7 @@ describe('compile/mark/encode/position-rect', () => { const props = rectBinPosition({ fieldDef, channel: 'x', - band: 1, + bandSize: 1, scaleName: undefined, axisTranslate: 0.5, // Vega default reverse: false, @@ -135,7 +135,7 @@ describe('compile/mark/encode/position-rect', () => { const props = rectBinPosition({ fieldDef, channel: 'y', - band: 1, + bandSize: 1, scaleName: undefined, axisTranslate: 0.5, // Vega default reverse: false, @@ -152,7 +152,7 @@ describe('compile/mark/encode/position-rect', () => { const props = rectBinPosition({ fieldDef, channel: 'x', - band: 1, + bandSize: 1, scaleName: undefined, axisTranslate: {signal: 't'}, // Vega default reverse: false, @@ -173,7 +173,7 @@ describe('compile/mark/encode/position-rect', () => { const props = rectBinPosition({ fieldDef, channel: 'x', - band: 1, + bandSize: 1, scaleName: undefined, axisTranslate: {signal: 't'}, // Vega default reverse: {signal: 'r'}, diff --git a/test/compile/mark/point.test.ts b/test/compile/mark/point.test.ts index eb015ac03e1..b31cebdf033 100644 --- a/test/compile/mark/point.test.ts +++ b/test/compile/mark/point.test.ts @@ -83,7 +83,7 @@ describe('Mark: Point', () => { const model = parseUnitModelWithScaleAndLayoutSize({ mark: 'point', encoding: { - x: {field: 'a', type: 'quantitative', band: 0.5, stack: 'zero'}, + x: {field: 'a', type: 'quantitative', bandPosition: 0.5, stack: 'zero'}, color: {field: 'b', type: 'ordinal'} }, data: {url: 'data/barley.json'} @@ -100,7 +100,7 @@ describe('Mark: Point', () => { const model = parseUnitModelWithScaleAndLayoutSize({ mark: 'point', encoding: { - x: {bin: true, field: 'a', type: 'quantitative', band: 0.6} + x: {bin: true, field: 'a', type: 'quantitative', bandPosition: 0.6} }, data: {url: 'data/barley.json'} }); @@ -119,7 +119,7 @@ describe('Mark: Point', () => { const model = parseUnitModelWithScaleAndLayoutSize({ mark: 'point', encoding: { - x: {field: 'a', type: 'nominal', band: 0.6, scale: {type: 'band'}} + x: {field: 'a', type: 'nominal', bandPosition: 0.6, scale: {type: 'band'}} }, data: {url: 'data/barley.json'} }); diff --git a/test/compile/scale/type.test.ts b/test/compile/scale/type.test.ts index ab1bfe4c6ff..ec23a393d16 100644 --- a/test/compile/scale/type.test.ts +++ b/test/compile/scale/type.test.ts @@ -1,8 +1,9 @@ -import {rangeType, SCALE_CHANNELS, X, Y} from '../../../src/channel'; -import {scaleType} from '../../../src/compile/scale/type'; +import {Channel, rangeType, SCALE_CHANNELS, X, Y} from '../../../src/channel'; +import {DatumDef, TypedFieldDef} from '../../../src/channeldef'; +import {scaleType as _scaleType} from '../../../src/compile/scale/type'; import * as log from '../../../src/log'; -import {BAR, PRIMITIVE_MARKS, RECT, RULE} from '../../../src/mark'; -import {ScaleType} from '../../../src/scale'; +import {BAR, Mark, PRIMITIVE_MARKS, RECT, RULE} from '../../../src/mark'; +import {Scale, ScaleType} from '../../../src/scale'; import { isUTCTimeUnit, LOCAL_MULTI_TIMEUNIT_INDEX, @@ -24,6 +25,15 @@ const TIMEUNIT_INDEX: Flag = { const TIMEUNITS = keys(TIMEUNIT_INDEX); +function scaleType( + specifiedScale: Scale, + channel: Channel, + fieldDef: TypedFieldDef | DatumDef, + mark: Mark +): ScaleType { + return _scaleType(specifiedScale, channel, fieldDef, {type: mark}); +} + describe('compile/scale', () => { describe('type()', () => { it('should return null for channel without scale', () => {