diff --git a/examples/compiled/concat_marginal_histograms.svg b/examples/compiled/concat_marginal_histograms.svg
index c748e4f8bc2..ed6bcad3c5c 100644
--- a/examples/compiled/concat_marginal_histograms.svg
+++ b/examples/compiled/concat_marginal_histograms.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/concat_marginal_histograms.vg.json b/examples/compiled/concat_marginal_histograms.vg.json
index f5fce8e2619..36f5cba938c 100644
--- a/examples/compiled/concat_marginal_histograms.vg.json
+++ b/examples/compiled/concat_marginal_histograms.vg.json
@@ -263,7 +263,7 @@
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(concat_1_concat_0_width/10)"},
- "zindex": 0
+ "zindex": 1
},
{
"scale": "concat_1_concat_0_y",
@@ -272,7 +272,7 @@
"title": "Rotten_Tomatoes_Rating (binned)",
"labelOverlap": true,
"tickCount": {"signal": "ceil(concat_1_height/10)"},
- "zindex": 0
+ "zindex": 1
}
]
},
diff --git a/examples/compiled/facet_cross_independent_scale.svg b/examples/compiled/facet_cross_independent_scale.svg
index 4ba990ce54e..cf5cd4e8baf 100644
--- a/examples/compiled/facet_cross_independent_scale.svg
+++ b/examples/compiled/facet_cross_independent_scale.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/facet_cross_independent_scale.vg.json b/examples/compiled/facet_cross_independent_scale.vg.json
index 3c09d23cdea..d0e826ae224 100644
--- a/examples/compiled/facet_cross_independent_scale.vg.json
+++ b/examples/compiled/facet_cross_independent_scale.vg.json
@@ -196,14 +196,14 @@
"labelAlign": "right",
"labelAngle": 270,
"labelBaseline": "middle",
- "zindex": 0
+ "zindex": 1
},
{
"scale": "child_y",
"orient": "left",
"grid": false,
"title": "b",
- "zindex": 0
+ "zindex": 1
}
]
}
diff --git a/examples/compiled/interactive_concat_layer.svg b/examples/compiled/interactive_concat_layer.svg
index 1fcaf7e9ed1..258af7ae7a7 100644
--- a/examples/compiled/interactive_concat_layer.svg
+++ b/examples/compiled/interactive_concat_layer.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/interactive_concat_layer.vg.json b/examples/compiled/interactive_concat_layer.vg.json
index fcff77e610a..c75a565cce8 100644
--- a/examples/compiled/interactive_concat_layer.vg.json
+++ b/examples/compiled/interactive_concat_layer.vg.json
@@ -226,7 +226,7 @@
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(concat_0_width/10)"},
- "zindex": 0
+ "zindex": 1
},
{
"scale": "concat_0_y",
@@ -235,7 +235,7 @@
"title": "Rotten_Tomatoes_Rating (binned)",
"labelOverlap": true,
"tickCount": {"signal": "ceil(concat_0_height/10)"},
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/layer_text_heatmap.svg b/examples/compiled/layer_text_heatmap.svg
index 3758409f62f..ba6ace19c79 100644
--- a/examples/compiled/layer_text_heatmap.svg
+++ b/examples/compiled/layer_text_heatmap.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/layer_text_heatmap.vg.json b/examples/compiled/layer_text_heatmap.vg.json
index 7e8f818d3f7..92ecdcac755 100644
--- a/examples/compiled/layer_text_heatmap.vg.json
+++ b/examples/compiled/layer_text_heatmap.vg.json
@@ -118,7 +118,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -126,7 +126,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/rect_binned_heatmap.svg b/examples/compiled/rect_binned_heatmap.svg
index cba5dbb7952..bd795dfa03f 100644
--- a/examples/compiled/rect_binned_heatmap.svg
+++ b/examples/compiled/rect_binned_heatmap.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/rect_binned_heatmap.vg.json b/examples/compiled/rect_binned_heatmap.vg.json
index 9ad0f1c673b..132660a6764 100644
--- a/examples/compiled/rect_binned_heatmap.vg.json
+++ b/examples/compiled/rect_binned_heatmap.vg.json
@@ -146,7 +146,7 @@
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(width/10)"},
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -155,7 +155,7 @@
"title": "Rotten_Tomatoes_Rating (binned)",
"labelOverlap": true,
"tickCount": {"signal": "ceil(height/10)"},
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/rect_heatmap.svg b/examples/compiled/rect_heatmap.svg
index c7126616123..fbbebb25f18 100644
--- a/examples/compiled/rect_heatmap.svg
+++ b/examples/compiled/rect_heatmap.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/rect_heatmap.vg.json b/examples/compiled/rect_heatmap.vg.json
index eafb65ea09d..8a1b4440556 100644
--- a/examples/compiled/rect_heatmap.vg.json
+++ b/examples/compiled/rect_heatmap.vg.json
@@ -78,14 +78,14 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "Origin",
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/rect_heatmap_weather.svg b/examples/compiled/rect_heatmap_weather.svg
index 88a25859e24..dd396808ab1 100644
--- a/examples/compiled/rect_heatmap_weather.svg
+++ b/examples/compiled/rect_heatmap_weather.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/rect_heatmap_weather.vg.json b/examples/compiled/rect_heatmap_weather.vg.json
index 82bcb999ada..05d15da3fbb 100644
--- a/examples/compiled/rect_heatmap_weather.vg.json
+++ b/examples/compiled/rect_heatmap_weather.vg.json
@@ -97,7 +97,7 @@
"labelAlign": "center",
"labelBaseline": "top",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -110,7 +110,7 @@
"update": {"text": {"signal": "timeFormat(datum.value, '%b')"}}
}
},
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/rect_lasagna_future.svg b/examples/compiled/rect_lasagna_future.svg
index 0e52b5c0366..638773f2c2d 100644
--- a/examples/compiled/rect_lasagna_future.svg
+++ b/examples/compiled/rect_lasagna_future.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/rect_lasagna_future.vg.json b/examples/compiled/rect_lasagna_future.vg.json
index fc06fb87951..214e6a45621 100644
--- a/examples/compiled/rect_lasagna_future.vg.json
+++ b/examples/compiled/rect_lasagna_future.vg.json
@@ -109,9 +109,9 @@
},
"labelAlign": "center",
"labelBaseline": "top",
- "zindex": 0
+ "zindex": 1
},
- {"scale": "y", "orient": "left", "grid": false, "zindex": 0}
+ {"scale": "y", "orient": "left", "grid": false, "zindex": 1}
],
"legends": [
{
diff --git a/examples/compiled/selection_composition_and.svg b/examples/compiled/selection_composition_and.svg
index 4bbba0a5a81..1fb01ac63b1 100644
--- a/examples/compiled/selection_composition_and.svg
+++ b/examples/compiled/selection_composition_and.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_composition_and.vg.json b/examples/compiled/selection_composition_and.vg.json
index fc1431d6e71..82706ac523d 100644
--- a/examples/compiled/selection_composition_and.vg.json
+++ b/examples/compiled/selection_composition_and.vg.json
@@ -701,7 +701,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -709,7 +709,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_composition_or.svg b/examples/compiled/selection_composition_or.svg
index 4bbba0a5a81..1fb01ac63b1 100644
--- a/examples/compiled/selection_composition_or.svg
+++ b/examples/compiled/selection_composition_or.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_composition_or.vg.json b/examples/compiled/selection_composition_or.vg.json
index 73b939b3f5b..cfcb38df20a 100644
--- a/examples/compiled/selection_composition_or.vg.json
+++ b/examples/compiled/selection_composition_or.vg.json
@@ -701,7 +701,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -709,7 +709,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_interval_mark_style.svg b/examples/compiled/selection_interval_mark_style.svg
index 4bbba0a5a81..1fb01ac63b1 100644
--- a/examples/compiled/selection_interval_mark_style.svg
+++ b/examples/compiled/selection_interval_mark_style.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_interval_mark_style.vg.json b/examples/compiled/selection_interval_mark_style.vg.json
index 66239b99ced..8b9f1cce890 100644
--- a/examples/compiled/selection_interval_mark_style.vg.json
+++ b/examples/compiled/selection_interval_mark_style.vg.json
@@ -694,7 +694,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -702,7 +702,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_project_interval.svg b/examples/compiled/selection_project_interval.svg
index 49599973196..55fac921a17 100644
--- a/examples/compiled/selection_project_interval.svg
+++ b/examples/compiled/selection_project_interval.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_project_interval.vg.json b/examples/compiled/selection_project_interval.vg.json
index a30ab59980c..e83ab167495 100644
--- a/examples/compiled/selection_project_interval.vg.json
+++ b/examples/compiled/selection_project_interval.vg.json
@@ -384,7 +384,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -392,7 +392,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_project_interval_x.svg b/examples/compiled/selection_project_interval_x.svg
index 49599973196..55fac921a17 100644
--- a/examples/compiled/selection_project_interval_x.svg
+++ b/examples/compiled/selection_project_interval_x.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_project_interval_x.vg.json b/examples/compiled/selection_project_interval_x.vg.json
index 433e8a33307..9fc59870e5f 100644
--- a/examples/compiled/selection_project_interval_x.vg.json
+++ b/examples/compiled/selection_project_interval_x.vg.json
@@ -324,7 +324,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -332,7 +332,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_project_interval_x_y.svg b/examples/compiled/selection_project_interval_x_y.svg
index 49599973196..55fac921a17 100644
--- a/examples/compiled/selection_project_interval_x_y.svg
+++ b/examples/compiled/selection_project_interval_x_y.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_project_interval_x_y.vg.json b/examples/compiled/selection_project_interval_x_y.vg.json
index a30ab59980c..e83ab167495 100644
--- a/examples/compiled/selection_project_interval_x_y.vg.json
+++ b/examples/compiled/selection_project_interval_x_y.vg.json
@@ -384,7 +384,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -392,7 +392,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_project_interval_y.svg b/examples/compiled/selection_project_interval_y.svg
index 49599973196..55fac921a17 100644
--- a/examples/compiled/selection_project_interval_y.svg
+++ b/examples/compiled/selection_project_interval_y.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_project_interval_y.vg.json b/examples/compiled/selection_project_interval_y.vg.json
index ceecb4c5d7f..8245acbd815 100644
--- a/examples/compiled/selection_project_interval_y.vg.json
+++ b/examples/compiled/selection_project_interval_y.vg.json
@@ -324,7 +324,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -332,7 +332,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_type_interval.svg b/examples/compiled/selection_type_interval.svg
index 49599973196..55fac921a17 100644
--- a/examples/compiled/selection_type_interval.svg
+++ b/examples/compiled/selection_type_interval.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_type_interval.vg.json b/examples/compiled/selection_type_interval.vg.json
index a30ab59980c..e83ab167495 100644
--- a/examples/compiled/selection_type_interval.vg.json
+++ b/examples/compiled/selection_type_interval.vg.json
@@ -384,7 +384,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -392,7 +392,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_type_interval_invert.svg b/examples/compiled/selection_type_interval_invert.svg
index 17b0ba3a00b..421e47b089f 100644
--- a/examples/compiled/selection_type_interval_invert.svg
+++ b/examples/compiled/selection_type_interval_invert.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_type_interval_invert.vg.json b/examples/compiled/selection_type_interval_invert.vg.json
index 4880ac51894..8c3e2fc5ce2 100644
--- a/examples/compiled/selection_type_interval_invert.vg.json
+++ b/examples/compiled/selection_type_interval_invert.vg.json
@@ -383,7 +383,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -391,7 +391,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_type_multi.svg b/examples/compiled/selection_type_multi.svg
index 19001d57fe3..44e23cf4bad 100644
--- a/examples/compiled/selection_type_multi.svg
+++ b/examples/compiled/selection_type_multi.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_type_multi.vg.json b/examples/compiled/selection_type_multi.vg.json
index 62eff79cb47..3c12be84dce 100644
--- a/examples/compiled/selection_type_multi.vg.json
+++ b/examples/compiled/selection_type_multi.vg.json
@@ -126,7 +126,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -134,7 +134,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_type_single.svg b/examples/compiled/selection_type_single.svg
index 19001d57fe3..44e23cf4bad 100644
--- a/examples/compiled/selection_type_single.svg
+++ b/examples/compiled/selection_type_single.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_type_single.vg.json b/examples/compiled/selection_type_single.vg.json
index 9d2bd1fbac8..9783fda9109 100644
--- a/examples/compiled/selection_type_single.vg.json
+++ b/examples/compiled/selection_type_single.vg.json
@@ -112,7 +112,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -120,7 +120,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_type_single_dblclick.svg b/examples/compiled/selection_type_single_dblclick.svg
index 19001d57fe3..44e23cf4bad 100644
--- a/examples/compiled/selection_type_single_dblclick.svg
+++ b/examples/compiled/selection_type_single_dblclick.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_type_single_dblclick.vg.json b/examples/compiled/selection_type_single_dblclick.vg.json
index 3929c0f8bd2..aea22281d65 100644
--- a/examples/compiled/selection_type_single_dblclick.vg.json
+++ b/examples/compiled/selection_type_single_dblclick.vg.json
@@ -112,7 +112,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -120,7 +120,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/examples/compiled/selection_type_single_mouseover.svg b/examples/compiled/selection_type_single_mouseover.svg
index 19001d57fe3..44e23cf4bad 100644
--- a/examples/compiled/selection_type_single_mouseover.svg
+++ b/examples/compiled/selection_type_single_mouseover.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/examples/compiled/selection_type_single_mouseover.vg.json b/examples/compiled/selection_type_single_mouseover.vg.json
index ea2e7bed4e9..d5d6913779c 100644
--- a/examples/compiled/selection_type_single_mouseover.vg.json
+++ b/examples/compiled/selection_type_single_mouseover.vg.json
@@ -112,7 +112,7 @@
"labelAngle": 270,
"labelBaseline": "middle",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
},
{
"scale": "y",
@@ -120,7 +120,7 @@
"grid": false,
"title": "Origin",
"labelOverlap": true,
- "zindex": 0
+ "zindex": 1
}
],
"legends": [
diff --git a/src/compile/axis/parse.ts b/src/compile/axis/parse.ts
index 60716f48c74..ac0450acc55 100644
--- a/src/compile/axis/parse.ts
+++ b/src/compile/axis/parse.ts
@@ -1,7 +1,7 @@
import {Axis as VgAxis, AxisEncode as VgAxisEncode, AxisOrient, SignalRef} from 'vega';
import {Axis, AXIS_PARTS, isAxisProperty, VG_AXIS_PROPERTIES} from '../../axis';
import {isBinned} from '../../bin';
-import {POSITION_SCALE_CHANNELS, PositionScaleChannel, X, Y} from '../../channel';
+import {PositionScaleChannel, POSITION_SCALE_CHANNELS, X, Y} from '../../channel';
import {FieldDefBase, isTimeFormatFieldDef, toFieldDefBase} from '../../channeldef';
import {contains, getFirstDefined, keys, normalizeAngle} from '../../util';
import {mergeTitle, mergeTitleComponent, mergeTitleFieldDefs, numberFormat} from '../common';
@@ -292,6 +292,8 @@ function getProperty(
const labelAngle = properties.labelAngle(model, specifiedAxis, channel, fieldDef);
const orient = getFirstDefined(specifiedAxis.orient, properties.orient(channel));
+ const {mark, config} = model;
+
switch (property) {
case 'scale':
return model.scaleName(channel);
@@ -302,7 +304,7 @@ function getProperty(
if (isTimeFormatFieldDef(fieldDef)) {
return undefined;
}
- return numberFormat(fieldDef, specifiedAxis.format, model.config);
+ return numberFormat(fieldDef, specifiedAxis.format, config);
case 'formatType':
// Same as format, We don't include temporal field here as we apply format in encode block
if (isTimeFormatFieldDef(fieldDef)) {
@@ -353,6 +355,8 @@ function getProperty(
}
case 'values':
return properties.values(specifiedAxis, model, fieldDef);
+ case 'zindex':
+ return getFirstDefined(specifiedAxis.zindex, properties.defaultZindex(mark, fieldDef));
}
// Otherwise, return specified property.
return isAxisProperty(property) ? specifiedAxis[property] : undefined;
diff --git a/src/compile/axis/properties.ts b/src/compile/axis/properties.ts
index 34d361e5159..b30031c2cf0 100644
--- a/src/compile/axis/properties.ts
+++ b/src/compile/axis/properties.ts
@@ -2,8 +2,9 @@ import {Align, AxisOrient, SignalRef} from 'vega';
import {Axis} from '../../axis';
import {isBinning} from '../../bin';
import {PositionScaleChannel, X, Y} from '../../channel';
-import {TypedFieldDef, valueArray} from '../../channeldef';
+import {isDiscrete, TypedFieldDef, valueArray} from '../../channeldef';
import * as log from '../../log';
+import {Mark} from '../../mark';
import {hasDiscreteDomain, ScaleType} from '../../scale';
import {NOMINAL, ORDINAL} from '../../type';
import {contains, normalizeAngle} from '../../util';
@@ -168,3 +169,10 @@ export function values(specifiedAxis: Axis, model: UnitModel, fieldDef: TypedFie
return undefined;
}
+
+export function defaultZindex(mark: Mark, fieldDef: TypedFieldDef) {
+ if (mark === 'rect' && isDiscrete(fieldDef)) {
+ return 1;
+ }
+ return 0;
+}
diff --git a/test/compile/axis/properties.test.ts b/test/compile/axis/properties.test.ts
index d7e221ac68e..65a95a701e3 100644
--- a/test/compile/axis/properties.test.ts
+++ b/test/compile/axis/properties.test.ts
@@ -310,4 +310,10 @@ describe('compile/axis', () => {
expect(defaultLabelBaseline(undefined, 'left')).toEqual(undefined);
});
});
+
+ describe('defaultZindex', () => {
+ it('returns 1 for discrete axes of rect marks', () => {
+ expect(properties.defaultZindex('rect', {field: 'a', type: 'nominal'})).toBe(1);
+ });
+ });
});