diff --git a/_includes/docs_toc.md b/_includes/docs_toc.md
index 81c113f01a8..af0b9c69ade 100644
--- a/_includes/docs_toc.md
+++ b/_includes/docs_toc.md
@@ -6,6 +6,7 @@
- [Data]({{site.baseurl}}/docs/data.html)
- [Inline Data]({{site.baseurl}}/docs/data.html#inline)
- [Data from URL]({{site.baseurl}}/docs/data.html#url)
+ - [Format]({{site.baseurl}}/docs/data.html#format)
- [Transform]({{site.baseurl}}/docs/transform.html)
- [Top-level Transform Property]({{site.baseurl}}/docs/transform.html#top-level-transform-property)
- [Mark]({{site.baseurl}}/docs/mark.html)
@@ -25,6 +26,7 @@
- [Continuous Scale]({{site.baseurl}}/docs/sort.html#continuous-scale)
- [Ordinal Scale]({{site.baseurl}}/docs/sort.html#ordinal-scale)
- [Time Unit]({{site.baseurl}}/docs/timeunit.html)
+ - [Date/Time Units]({{site.baseurl}}/docs/timeunit.html#datetime-units)
- [Scale]({{site.baseurl}}/docs/scale.html)
- [Scale Type]({{site.baseurl}}/docs/scale.html#type)
- [Scale Domain]({{site.baseurl}}/docs/scale.html#domain)
@@ -37,11 +39,11 @@
- [Config]({{site.baseurl}}/docs/config.html)
- [Top-level Configuration (config.*)]({{site.baseurl}}/docs/config.html#top-level-config)
- [Cell Configuration (config.cell.*)]({{site.baseurl}}/docs/config.html#cell-config)
- - [Mark Configuration (config.mark.*)]({{site.baseurl}}/docs/config.html#mark-configuration-)
+ - [Mark Configuration (config.mark.*)]({{site.baseurl}}/docs/config.html#mark-config)
- [Scale Configuration (config.scale.*)]({{site.baseurl}}/docs/config.html#scale-config)
- [Axis Configuration (config.axis.*)]({{site.baseurl}}/docs/config.html#axis-config)
- [Legend Configuration (config.legend.*)]({{site.baseurl}}/docs/config.html#legend-config)
- - [Facet Configuration (config.facet.*)]({{site.baseurl}}/docs/config.html#facet-configuration--)
+ - [Facet Configuration (config.facet.*)]({{site.baseurl}}/docs/config.html#facet-config)
- [Customizing Size]({{site.baseurl}}/docs/size.html)
- [Width and Height of a Single Plot]({{site.baseurl}}/docs/size.html#width-and-height-of-a-single-plot)
- [Total Width and Height of a Trellis Plots]({{site.baseurl}}/docs/size.html#total-width-and-height-of-a-trellis-plots)
diff --git a/examples/specs/bar_1d_bandsize_config.json b/examples/specs/bar_1d_bandsize_config.json
new file mode 100644
index 00000000000..8b6cf789b6f
--- /dev/null
+++ b/examples/specs/bar_1d_bandsize_config.json
@@ -0,0 +1,13 @@
+{
+ "data": { "url": "data/population.json"},
+ "transform": {
+ "filter": "datum.year == 2000"
+ },
+ "mark": "bar",
+ "encoding": {
+ "x": {
+ "aggregate": "sum", "field": "people", "type": "quantitative",
+ "axis": {"title": "population"}}
+ },
+ "config": {"scale": {"bandSize": 21}}
+}
diff --git a/examples/specs/bar_size_bandsize_small.json b/examples/specs/bar_size_bandsize_small.json
new file mode 100644
index 00000000000..1fe2905050d
--- /dev/null
+++ b/examples/specs/bar_size_bandsize_small.json
@@ -0,0 +1,18 @@
+{
+ "description": "A simple bar chart with embedded data.",
+ "data": {
+ "values": [
+ {"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
+ {"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
+ {"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
+ ]
+ },
+ "mark": "bar",
+ "encoding": {
+ "x": {
+ "field": "a", "type": "ordinal",
+ "scale": {"bandSize": 11}
+ },
+ "y": {"field": "b", "type": "quantitative"}
+ }
+}
\ No newline at end of file
diff --git a/examples/specs/bar_size_default.json b/examples/specs/bar_size_default.json
new file mode 100644
index 00000000000..1ecb691dd71
--- /dev/null
+++ b/examples/specs/bar_size_default.json
@@ -0,0 +1,19 @@
+{
+ "data": {"url": "data/cars.json"},
+ "mark": "bar",
+ "encoding": {
+ "x": {
+ "field": "Origin",
+ "type": "nominal",
+ "scale": {"bandSize": 25}
+ },
+ "y": {
+ "aggregate": "count",
+ "field": "*",
+ "type": "quantitative"
+ }
+ },
+ "config": {
+ "cell": {"width": 200, "height": 200}
+ }
+}
diff --git a/examples/specs/bar_size_explicit.json b/examples/specs/bar_size_explicit.json
new file mode 100644
index 00000000000..d072269b28d
--- /dev/null
+++ b/examples/specs/bar_size_explicit.json
@@ -0,0 +1,17 @@
+{
+ "width": 120,
+ "height": 120,
+ "data": {"url": "data/cars.json"},
+ "mark": "bar",
+ "encoding": {
+ "x": {
+ "field": "Origin",
+ "type": "nominal"
+ },
+ "y": {
+ "aggregate": "count",
+ "field": "*",
+ "type": "quantitative"
+ }
+ }
+}
diff --git a/examples/specs/bar_size_explicit_bad.json b/examples/specs/bar_size_explicit_bad.json
new file mode 100644
index 00000000000..5226ffafe71
--- /dev/null
+++ b/examples/specs/bar_size_explicit_bad.json
@@ -0,0 +1,18 @@
+{
+ "width": 120,
+ "height": 120,
+ "data": {"url": "data/cars.json"},
+ "mark": "bar",
+ "encoding": {
+ "x": {
+ "field": "Name",
+ "type": "nominal",
+ "scale": {"round": false}
+ },
+ "y": {
+ "aggregate": "count",
+ "field": "*",
+ "type": "quantitative"
+ }
+ }
+}
diff --git a/examples/specs/bar_size_fit.json b/examples/specs/bar_size_fit.json
new file mode 100644
index 00000000000..eaf11127601
--- /dev/null
+++ b/examples/specs/bar_size_fit.json
@@ -0,0 +1,19 @@
+{
+ "data": {"url": "data/cars.json"},
+ "mark": "bar",
+ "encoding": {
+ "x": {
+ "field": "Origin",
+ "type": "nominal",
+ "scale": {"bandSize": "fit"}
+ },
+ "y": {
+ "aggregate": "count",
+ "field": "*",
+ "type": "quantitative"
+ }
+ },
+ "config": {
+ "cell": {"width": 200, "height": 200}
+ }
+}
diff --git a/site/docs/config.md b/site/docs/config.md
index 46ac90877c2..d511d14a049 100644
--- a/site/docs/config.md
+++ b/site/docs/config.md
@@ -63,8 +63,8 @@ Each plot in either a single plot or a trellis plot is called a _cell_. Cell con
| Property | Type | Description |
| :------------ |:-------------:| :------------- |
-| width | Integer | The width of the single plot or each plot in a trellis plot when the visualization has continuous x-scale. (If the plot has ordinal x-scale, the width is determined by the x-scale's [`bandSize`](scale.html#ordinal) and the cardinality of the x-scale. If the plot does not have a field on `x`, the width is derived from [scale config](#scale-config)'s `bandSize` for all marks except `text` and from [scale config](#scale-config)'s `textBandWidth` for `text` mark.) __Default value:__ `200` |
-| height | Integer | The height of the single plot or each plot in a trellis plot when the visualization has continuous y-scale. (If the visualization has ordinal y-scale, the height is determined by the `bandSize` and the cardinality of the y-scale. If the plot does not have a field on `y`, the height is [scale config](#scale-config)'s `bandSize`.) __Default value:__ `200` |
+| width | Integer | The default width of the single plot or each plot in a trellis plot when the visualization has a continuous (non-ordinal) x-scale or ordinal x-scale with `bandSize` = `"fit"`. __Default value:__ `200` |
+| height | Integer | The default height of the single plot or each plot in a trellis plot when the visualization has a continuous (non-ordinal) y-scale with `bandSize` = `"fit"`. __Default value:__ `200` |
**For more information about visualization's size, please see [Customizing Size](size.html) page.**
diff --git a/site/docs/scale.md b/site/docs/scale.md
index d5dd25a3fef..6fce07bc233 100644
--- a/site/docs/scale.md
+++ b/site/docs/scale.md
@@ -218,8 +218,8 @@ For ordinal, quantitative, and time fields, `range` can be a two-element array d
| Property | Type | Description |
| :------------ |:-------------:| :------------- |
-| bandSize | Number | Width for each `x` or `y` ordinal band. __Default value:__ for `x` ordinal scale of a `text` mark, derived from [scale config](config.html#scale-config)'s `textBandWidth`; otherwise, derived from [scale config](config.html#scale-config)'s `bandSize`. |
-| padding | Number | • For `x` and `y` channels, the padding is a multiple of the spacing between points. A reasonable value is 1.0, such that the first and last point will be offset from the minimum and maximum value by half the distance between points. (See D3's [`ordinalRangePoints()`](https://github.com/mbostock/d3/wiki/Ordinal-Scales#ordinal_rangePoints) for illustration.) __Default value:__ derived from [scale config](config.html#scale-config)'s `padding`
• For `row` and `column`, padding is a pixel value for padding between cells in the trellis plots. __Default value:__ derived from [facet scale config](config.html#facet-scale-config)'s `padding`. |
+| bandSize | Integer | String | Width for each `x` or `y` ordinal band. This can be an integer value or a string `"fit"`. For `"fit"`, the band size will be automatically adjusted to fit the scale for the specified width (for x-axis) or height (for y-axis). __Default value:__ for `x` ordinal scale of a `text` mark, derived from [scale config](config.html#scale-config)'s `textBandWidth`; otherwise, derived from [scale config](config.html#scale-config)'s `bandSize`. __Warning__:
1) Numeric `bandSize` will be applied only if the top-level `width` (for x-scale) or `height` (for y-scale) is not specified. If `width` (for x-scale) or `height` (for y-scale) is specified, `bandWidth` will always be `"fit"`.
2) If the cardinality of the scale domain is too high, the bandSize might become less than one pixel and the mark might not appear correctly. |
+| padding | Number | • For `x` and `y` channels, the padding is a multiple of the spacing between points. A reasonable value is 1.0, such that the first and last point will be offset from the minimum and maximum value by half the distance between points. (See D3's [`ordinalRangePoints()`](https://github.com/mbostock/d3/wiki/Ordinal-Scales#ordinal_rangePoints) for illustration.) • __Default value:__ derived from [scale config](config.html#scale-config)'s `padding`
• For `row` and `column`, padding is a pixel value for padding between cells in the trellis plots. •__Default value:__ derived from [facet scale config](config.html#facet-scale-config)'s `padding`. |
{:#ex-bandwidth}
#### Example: Custom Band Width
@@ -230,23 +230,6 @@ Given a bar chart:
We can make the band for each bar smaller by providing `scale`'s `bandSize`.
-