From fcfd95554c3c6d5d563178b6978a189bc9519fab Mon Sep 17 00:00:00 2001 From: Kanit Wongsuphasawat Date: Mon, 4 Jan 2021 21:42:36 +0700 Subject: [PATCH] fix: correct axis schema to clarify which properties support expression (#7148) --- build/vega-lite-schema.json | 132 +++++++++++------------------------- src/axis.ts | 39 ++++++++++- 2 files changed, 75 insertions(+), 96 deletions(-) diff --git a/build/vega-lite-schema.json b/build/vega-lite-schema.json index 6a161a730c..e1c903ea02 100644 --- a/build/vega-lite-schema.json +++ b/build/vega-lite-schema.json @@ -1065,15 +1065,8 @@ ] }, "domain": { - "anyOf": [ - { - "description": "A boolean flag indicating if the domain (the axis baseline) should be included as part of the axis.\n\n__Default value:__ `true`", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "A boolean flag indicating if the domain (the axis baseline) should be included as part of the axis.\n\n__Default value:__ `true`", + "type": "boolean" }, "domainCap": { "anyOf": [ @@ -1506,15 +1499,8 @@ ] }, "labels": { - "anyOf": [ - { - "description": "A boolean flag indicating if labels should be included as part of the axis.\n\n__Default value:__ `true`.", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "A boolean flag indicating if labels should be included as part of the axis.\n\n__Default value:__ `true`.", + "type": "boolean" }, "maxExtent": { "anyOf": [ @@ -1539,8 +1525,15 @@ ] }, "offset": { - "description": "The offset, in pixels, by which to displace the axis from the edge of the enclosing group or data rectangle.\n\n__Default value:__ derived from the [axis config](https://vega.github.io/vega-lite/docs/config.html#facet-scale-config)'s `offset` (`0` by default)", - "type": "number" + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "The offset, in pixels, by which to displace the axis from the edge of the enclosing group or data rectangle.\n\n__Default value:__ derived from the [axis config](https://vega.github.io/vega-lite/docs/config.html#facet-scale-config)'s `offset` (`0` by default)" }, "orient": { "anyOf": [ @@ -1675,15 +1668,8 @@ ] }, "tickExtra": { - "anyOf": [ - { - "description": "Boolean flag indicating if an extra axis tick should be added for the initial position of the axis. This flag is useful for styling axes for `band` scales such that ticks are placed on band boundaries rather in the middle of a band. Use in conjunction with `\"bandPosition\": 1` and an axis `\"padding\"` value of `0`.", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "Boolean flag indicating if an extra axis tick should be added for the initial position of the axis. This flag is useful for styling axes for `band` scales such that ticks are placed on band boundaries rather in the middle of a band. Use in conjunction with `\"bandPosition\": 1` and an axis `\"padding\"` value of `0`.", + "type": "boolean" }, "tickMinStep": { "anyOf": [ @@ -1722,15 +1708,8 @@ ] }, "tickRound": { - "anyOf": [ - { - "description": "Boolean flag indicating if pixel position values should be rounded to the nearest integer.\n\n__Default value:__ `true`", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "Boolean flag indicating if pixel position values should be rounded to the nearest integer.\n\n__Default value:__ `true`", + "type": "boolean" }, "tickSize": { "anyOf": [ @@ -1763,15 +1742,8 @@ ] }, "ticks": { - "anyOf": [ - { - "description": "Boolean value that determines whether the axis should include ticks.\n\n__Default value:__ `true`", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "Boolean value that determines whether the axis should include ticks.\n\n__Default value:__ `true`", + "type": "boolean" }, "title": { "anyOf": [ @@ -2050,15 +2022,8 @@ "type": "boolean" }, "domain": { - "anyOf": [ - { - "description": "A boolean flag indicating if the domain (the axis baseline) should be included as part of the axis.\n\n__Default value:__ `true`", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "A boolean flag indicating if the domain (the axis baseline) should be included as part of the axis.\n\n__Default value:__ `true`", + "type": "boolean" }, "domainCap": { "anyOf": [ @@ -2491,15 +2456,8 @@ ] }, "labels": { - "anyOf": [ - { - "description": "A boolean flag indicating if labels should be included as part of the axis.\n\n__Default value:__ `true`.", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "A boolean flag indicating if labels should be included as part of the axis.\n\n__Default value:__ `true`.", + "type": "boolean" }, "maxExtent": { "anyOf": [ @@ -2524,8 +2482,15 @@ ] }, "offset": { - "description": "The offset, in pixels, by which to displace the axis from the edge of the enclosing group or data rectangle.\n\n__Default value:__ derived from the [axis config](https://vega.github.io/vega-lite/docs/config.html#facet-scale-config)'s `offset` (`0` by default)", - "type": "number" + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "The offset, in pixels, by which to displace the axis from the edge of the enclosing group or data rectangle.\n\n__Default value:__ derived from the [axis config](https://vega.github.io/vega-lite/docs/config.html#facet-scale-config)'s `offset` (`0` by default)" }, "orient": { "anyOf": [ @@ -2660,15 +2625,8 @@ ] }, "tickExtra": { - "anyOf": [ - { - "description": "Boolean flag indicating if an extra axis tick should be added for the initial position of the axis. This flag is useful for styling axes for `band` scales such that ticks are placed on band boundaries rather in the middle of a band. Use in conjunction with `\"bandPosition\": 1` and an axis `\"padding\"` value of `0`.", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "Boolean flag indicating if an extra axis tick should be added for the initial position of the axis. This flag is useful for styling axes for `band` scales such that ticks are placed on band boundaries rather in the middle of a band. Use in conjunction with `\"bandPosition\": 1` and an axis `\"padding\"` value of `0`.", + "type": "boolean" }, "tickMinStep": { "anyOf": [ @@ -2707,15 +2665,8 @@ ] }, "tickRound": { - "anyOf": [ - { - "description": "Boolean flag indicating if pixel position values should be rounded to the nearest integer.\n\n__Default value:__ `true`", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "Boolean flag indicating if pixel position values should be rounded to the nearest integer.\n\n__Default value:__ `true`", + "type": "boolean" }, "tickSize": { "anyOf": [ @@ -2748,15 +2699,8 @@ ] }, "ticks": { - "anyOf": [ - { - "description": "Boolean value that determines whether the axis should include ticks.\n\n__Default value:__ `true`", - "type": "boolean" - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "description": "Boolean value that determines whether the axis should include ticks.\n\n__Default value:__ `true`", + "type": "boolean" }, "title": { "anyOf": [ diff --git a/src/axis.ts b/src/axis.ts index b0cc92c890..31c80e99f6 100644 --- a/src/axis.ts +++ b/src/axis.ts @@ -39,7 +39,14 @@ interface AxisOverrideMixins { */ tickMinStep?: number | ES; - // Override comments to be Vega-Lite specific + // ---------- Properties that do not support signal / expression ---------- + /** + * A boolean flag indicating if the domain (the axis baseline) should be included as part of the axis. + * + * __Default value:__ `true` + */ + domain?: boolean; + /** * A boolean flag indicating if grid lines should be included as part of the axis * @@ -47,6 +54,34 @@ interface AxisOverrideMixins { */ grid?: boolean; + /** + * A boolean flag indicating if labels should be included as part of the axis. + * + * __Default value:__ `true`. + */ + labels?: boolean; + + /** + * Boolean flag indicating if an extra axis tick should be added for the initial position of the axis. This flag is useful for styling axes for `band` scales such that ticks are placed on band boundaries rather in the middle of a band. Use in conjunction with `"bandPosition": 1` and an axis `"padding"` value of `0`. + */ + tickExtra?: boolean; + + /** + * Boolean flag indicating if pixel position values should be rounded to the nearest integer. + * + * __Default value:__ `true` + */ + tickRound?: boolean; + + /** + * Boolean value that determines whether the axis should include ticks. + * + * __Default value:__ `true` + */ + ticks?: boolean; + + // Override comments to be Vega-Lite specific + /** * Indicates if the first and last axis labels should be aligned flush with the scale range. Flush alignment for a horizontal axis will left-align the first label and right-align the last label. For vertical axes, bottom and top text baselines are applied instead. If this property is a number, it also indicates the number of pixels by which to offset the first and last labels; for example, a value of 2 will flush-align the first and last labels and also push them 2 pixels outward from the center of the axis. The additional adjustment can sometimes help the labels better visually group with corresponding axis ticks. * @@ -66,7 +101,7 @@ interface AxisOverrideMixins { * * __Default value:__ derived from the [axis config](https://vega.github.io/vega-lite/docs/config.html#facet-scale-config)'s `offset` (`0` by default) */ - offset?: number; + offset?: number | ES; /** * The orientation of the axis. One of `"top"`, `"bottom"`, `"left"` or `"right"`. The orientation can be used to further specialize the axis type (e.g., a y-axis oriented towards the right edge of the chart).