Skip to content

Commit

Permalink
Make setting axis or legend = null as the default way to disabl…
Browse files Browse the repository at this point in the history
…e them.
  • Loading branch information
kanitw committed Oct 3, 2016
1 parent 902ec5d commit 7e7ad77
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/specs/bar_grouped.vl.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"x": {
"field": "gender", "type": "nominal",
"scale": {"bandSize": 6},
"axis": false
"axis": null
},
"color": {
"field": "gender", "type": "nominal",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/bar_grouped_horizontal.vl.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"y": {
"field": "gender", "type": "nominal",
"scale": {"bandSize": 6},
"axis": false
"axis": null
},
"color": {
"field": "gender", "type": "nominal",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/stacked_area_normalize.vl.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"y": {
"aggregate": "sum", "field": "count","type": "quantitative",
"axis": false
"axis": null
},
"color": {"field":"series", "type":"nominal", "scale":{"range": "category20b"}}
},
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/stacked_area_stream.vl.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"y": {
"aggregate": "sum", "field": "count","type": "quantitative",
"axis": false
"axis": null
},
"color": {"field":"series", "type":"nominal", "scale":{"range": "category20b"}}
},
Expand Down
7 changes: 5 additions & 2 deletions src/compile/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ export class UnitModel extends Model {
(channel === Y && vlEncoding.has(encoding, Y2))) {

const axisSpec = (encoding[channel] || {}).axis;
if (axisSpec !== false) {

// We no longer support false in the schema, but we keep false here for backward compatability.
if (axisSpec !== null && axisSpec !== false) {
_axis[channel] = extend({},
config.axis,
axisSpec === true ? {} : axisSpec || {}
Expand All @@ -196,7 +198,8 @@ export class UnitModel extends Model {
return NONSPATIAL_SCALE_CHANNELS.reduce(function(_legend, channel) {
if (vlEncoding.has(encoding, channel)) {
const legendSpec = encoding[channel].legend;
if (legendSpec !== false) {
// We no longer support false in the schema, but we keep false here for backward compatability.
if (legendSpec !== null && legendSpec !== false) {
_legend[channel] = extend({}, config.legend,
legendSpec === true ? {} : legendSpec || {}
);
Expand Down
2 changes: 1 addition & 1 deletion src/fielddef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface ChannelDefWithScale extends FieldDef {
}

export interface PositionChannelDef extends ChannelDefWithScale {
axis?: boolean | Axis;
axis?: Axis;
}
export interface ChannelDefWithLegend extends ChannelDefWithScale {
legend?: Legend;
Expand Down

0 comments on commit 7e7ad77

Please sign in to comment.