Skip to content

Commit 2f3c359

Browse files
yhoonkimGitHub Actions Bot
and
GitHub Actions Bot
authoredAug 16, 2022
feat: Allow config to set default scale.zero per marktype (#8354)
* Add examples * chore: update examples [CI] * Add config.scale.zero * chore: update examples [CI] * update doc * Minor refactor: - Undo encodingHasRangeChannels - Set `true` for continuous size scale regardless to config - Fix doc * Update the doc and fix the typo Co-authored-by: GitHub Actions Bot <[email protected]>
1 parent 1102bf3 commit 2f3c359

17 files changed

+545
-20
lines changed
 

‎build/vega-lite-schema.json

+4
Original file line numberDiff line numberDiff line change
@@ -21608,6 +21608,10 @@
2160821608
}
2160921609
],
2161021610
"description": "Reverse x-scale by default (useful for right-to-left charts)."
21611+
},
21612+
"zero": {
21613+
"description": "Default `scale.zero` for [`continuous`](https://vega.github.io/vega-lite/docs/scale.html#continuous) scales except for (1) x/y-scales of non-ranged bar or area charts and (2) size scales.\n\n__Default value:__ `true`",
21614+
"type": "boolean"
2161121615
}
2161221616
},
2161321617
"type": "object"
4.84 KB
Loading
+1
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
"$schema": "https://vega.github.io/schema/vega/v5.json",
3+
"description": "A simple bar chart with embedded data.",
4+
"background": "white",
5+
"padding": 5,
6+
"height": 200,
7+
"style": "cell",
8+
"data": [
9+
{
10+
"name": "source_0",
11+
"values": [
12+
{"a": "A", "b": 28},
13+
{"a": "B", "b": 55},
14+
{"a": "C", "b": 43},
15+
{"a": "D", "b": 91},
16+
{"a": "E", "b": 81},
17+
{"a": "F", "b": 53},
18+
{"a": "G", "b": 19},
19+
{"a": "H", "b": 87},
20+
{"a": "I", "b": 52}
21+
]
22+
},
23+
{
24+
"name": "data_0",
25+
"source": "source_0",
26+
"transform": [
27+
{
28+
"type": "stack",
29+
"groupby": ["a"],
30+
"field": "b",
31+
"sort": {"field": [], "order": []},
32+
"as": ["b_start", "b_end"],
33+
"offset": "zero"
34+
},
35+
{
36+
"type": "filter",
37+
"expr": "isValid(datum[\"b\"]) && isFinite(+datum[\"b\"])"
38+
}
39+
]
40+
}
41+
],
42+
"signals": [
43+
{"name": "x_step", "value": 20},
44+
{
45+
"name": "width",
46+
"update": "bandspace(domain('x').length, 0.1, 0.05) * x_step"
47+
}
48+
],
49+
"marks": [
50+
{
51+
"name": "marks",
52+
"type": "rect",
53+
"style": ["bar"],
54+
"from": {"data": "data_0"},
55+
"encode": {
56+
"update": {
57+
"fill": {"value": "#4c78a8"},
58+
"ariaRoleDescription": {"value": "bar"},
59+
"description": {
60+
"signal": "\"a: \" + (isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]) + \"; b: \" + (format(datum[\"b\"], \"\"))"
61+
},
62+
"x": {"scale": "x", "field": "a"},
63+
"width": {"signal": "max(0.25, bandwidth('x'))"},
64+
"y": {"scale": "y", "field": "b_end"},
65+
"y2": {"scale": "y", "field": "b_start"}
66+
}
67+
}
68+
}
69+
],
70+
"scales": [
71+
{
72+
"name": "x",
73+
"type": "band",
74+
"domain": {"data": "data_0", "field": "a", "sort": true},
75+
"range": {"step": {"signal": "x_step"}},
76+
"paddingInner": 0.1,
77+
"paddingOuter": 0.05
78+
},
79+
{
80+
"name": "y",
81+
"type": "linear",
82+
"domain": {"data": "data_0", "fields": ["b_start", "b_end"]},
83+
"range": [{"signal": "height"}, 0],
84+
"nice": true,
85+
"zero": true
86+
}
87+
],
88+
"axes": [
89+
{
90+
"scale": "y",
91+
"orient": "left",
92+
"gridScale": "x",
93+
"grid": true,
94+
"tickCount": {"signal": "ceil(height/40)"},
95+
"domain": false,
96+
"labels": false,
97+
"aria": false,
98+
"maxExtent": 0,
99+
"minExtent": 0,
100+
"ticks": false,
101+
"zindex": 0
102+
},
103+
{
104+
"scale": "x",
105+
"orient": "bottom",
106+
"grid": false,
107+
"title": "a",
108+
"labelAngle": 0,
109+
"labelBaseline": "top",
110+
"zindex": 0
111+
},
112+
{
113+
"scale": "y",
114+
"orient": "left",
115+
"grid": false,
116+
"title": "b",
117+
"labelOverlap": true,
118+
"tickCount": {"signal": "ceil(height/40)"},
119+
"zindex": 0
120+
}
121+
]
122+
}
3.9 KB
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"$schema": "https://vega.github.io/schema/vega/v5.json",
3+
"description": "A simple bar chart with ranged data (aka Gantt Chart).",
4+
"background": "white",
5+
"padding": 5,
6+
"width": 200,
7+
"style": "cell",
8+
"data": [
9+
{
10+
"name": "source_0",
11+
"values": [
12+
{"task": "A", "start": 1, "end": 3},
13+
{"task": "B", "start": 3, "end": 8},
14+
{"task": "C", "start": 8, "end": 10}
15+
]
16+
},
17+
{
18+
"name": "data_0",
19+
"source": "source_0",
20+
"transform": [
21+
{
22+
"type": "filter",
23+
"expr": "isValid(datum[\"start\"]) && isFinite(+datum[\"start\"])"
24+
}
25+
]
26+
}
27+
],
28+
"signals": [
29+
{"name": "y_step", "value": 20},
30+
{
31+
"name": "height",
32+
"update": "bandspace(domain('y').length, 0.1, 0.05) * y_step"
33+
}
34+
],
35+
"marks": [
36+
{
37+
"name": "marks",
38+
"type": "rect",
39+
"style": ["bar"],
40+
"from": {"data": "data_0"},
41+
"encode": {
42+
"update": {
43+
"fill": {"value": "#4c78a8"},
44+
"ariaRoleDescription": {"value": "bar"},
45+
"description": {
46+
"signal": "\"start: \" + (format(datum[\"start\"], \"\")) + \"; task: \" + (isValid(datum[\"task\"]) ? datum[\"task\"] : \"\"+datum[\"task\"]) + \"; end: \" + (format(datum[\"end\"], \"\"))"
47+
},
48+
"x": {"scale": "x", "field": "start"},
49+
"x2": {"scale": "x", "field": "end"},
50+
"y": {"scale": "y", "field": "task"},
51+
"height": {"signal": "max(0.25, bandwidth('y'))"}
52+
}
53+
}
54+
}
55+
],
56+
"scales": [
57+
{
58+
"name": "x",
59+
"type": "linear",
60+
"domain": {"data": "data_0", "fields": ["start", "end"]},
61+
"range": [0, {"signal": "width"}],
62+
"nice": true,
63+
"zero": false
64+
},
65+
{
66+
"name": "y",
67+
"type": "band",
68+
"domain": {"data": "data_0", "field": "task", "sort": true},
69+
"range": {"step": {"signal": "y_step"}},
70+
"paddingInner": 0.1,
71+
"paddingOuter": 0.05
72+
}
73+
],
74+
"axes": [
75+
{
76+
"scale": "x",
77+
"orient": "bottom",
78+
"gridScale": "y",
79+
"grid": true,
80+
"tickCount": {"signal": "ceil(width/40)"},
81+
"domain": false,
82+
"labels": false,
83+
"aria": false,
84+
"maxExtent": 0,
85+
"minExtent": 0,
86+
"ticks": false,
87+
"zindex": 0
88+
},
89+
{
90+
"scale": "x",
91+
"orient": "bottom",
92+
"grid": false,
93+
"title": "start, end",
94+
"labelFlush": true,
95+
"labelOverlap": true,
96+
"tickCount": {"signal": "ceil(width/40)"},
97+
"zindex": 0
98+
},
99+
{
100+
"scale": "y",
101+
"orient": "left",
102+
"grid": false,
103+
"title": "task",
104+
"zindex": 0
105+
}
106+
]
107+
}
27.9 KB
Loading

‎examples/compiled/point_2d_config_no_zero.svg

+5
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"$schema": "https://vega.github.io/schema/vega/v5.json",
3+
"description": "A scatterplot showing horsepower and miles per gallons for various cars.",
4+
"background": "white",
5+
"padding": 5,
6+
"width": 200,
7+
"height": 200,
8+
"style": "cell",
9+
"data": [
10+
{
11+
"name": "source_0",
12+
"url": "data/cars.json",
13+
"format": {"type": "json"},
14+
"transform": [
15+
{
16+
"type": "filter",
17+
"expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Miles_per_Gallon\"]) && isFinite(+datum[\"Miles_per_Gallon\"])"
18+
}
19+
]
20+
}
21+
],
22+
"marks": [
23+
{
24+
"name": "marks",
25+
"type": "symbol",
26+
"style": ["point"],
27+
"from": {"data": "source_0"},
28+
"encode": {
29+
"update": {
30+
"opacity": {"value": 0.7},
31+
"fill": {"value": "transparent"},
32+
"stroke": {"value": "#4c78a8"},
33+
"ariaRoleDescription": {"value": "point"},
34+
"description": {
35+
"signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Miles_per_Gallon: \" + (format(datum[\"Miles_per_Gallon\"], \"\"))"
36+
},
37+
"x": {"scale": "x", "field": "Horsepower"},
38+
"y": {"scale": "y", "field": "Miles_per_Gallon"}
39+
}
40+
}
41+
}
42+
],
43+
"scales": [
44+
{
45+
"name": "x",
46+
"type": "linear",
47+
"domain": {"data": "source_0", "field": "Horsepower"},
48+
"range": [0, {"signal": "width"}],
49+
"nice": true,
50+
"zero": false
51+
},
52+
{
53+
"name": "y",
54+
"type": "linear",
55+
"domain": {"data": "source_0", "field": "Miles_per_Gallon"},
56+
"range": [{"signal": "height"}, 0],
57+
"nice": true,
58+
"zero": false
59+
}
60+
],
61+
"axes": [
62+
{
63+
"scale": "x",
64+
"orient": "bottom",
65+
"gridScale": "y",
66+
"grid": true,
67+
"tickCount": {"signal": "ceil(width/40)"},
68+
"domain": false,
69+
"labels": false,
70+
"aria": false,
71+
"maxExtent": 0,
72+
"minExtent": 0,
73+
"ticks": false,
74+
"zindex": 0
75+
},
76+
{
77+
"scale": "y",
78+
"orient": "left",
79+
"gridScale": "x",
80+
"grid": true,
81+
"tickCount": {"signal": "ceil(height/40)"},
82+
"domain": false,
83+
"labels": false,
84+
"aria": false,
85+
"maxExtent": 0,
86+
"minExtent": 0,
87+
"ticks": false,
88+
"zindex": 0
89+
},
90+
{
91+
"scale": "x",
92+
"orient": "bottom",
93+
"grid": false,
94+
"title": "Horsepower",
95+
"labelFlush": true,
96+
"labelOverlap": true,
97+
"tickCount": {"signal": "ceil(width/40)"},
98+
"zindex": 0
99+
},
100+
{
101+
"scale": "y",
102+
"orient": "left",
103+
"grid": false,
104+
"title": "Miles_per_Gallon",
105+
"labelOverlap": true,
106+
"tickCount": {"signal": "ceil(height/40)"},
107+
"zindex": 0
108+
}
109+
]
110+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
3+
"description": "A simple bar chart with embedded data.",
4+
"data": {
5+
"values": [
6+
{"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
7+
{"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
8+
{"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
9+
]
10+
},
11+
"mark": "bar",
12+
"encoding": {
13+
"x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}},
14+
"y": {"field": "b", "type": "quantitative"}
15+
},
16+
"config": { "scale": { "zero": false } }
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
3+
"description": "A simple bar chart with ranged data (aka Gantt Chart).",
4+
"data": {
5+
"values": [
6+
{"task": "A", "start": 1, "end": 3},
7+
{"task": "B", "start": 3, "end": 8},
8+
{"task": "C", "start": 8, "end": 10}
9+
]
10+
},
11+
"mark": "bar",
12+
"encoding": {
13+
"y": {"field": "task", "type": "ordinal"},
14+
"x": {"field": "start", "type": "quantitative"},
15+
"x2": {"field": "end"}
16+
},
17+
"config": { "scale": { "zero": false } }
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
3+
"description": "A scatterplot showing horsepower and miles per gallons for various cars.",
4+
"data": { "url": "data/cars.json" },
5+
"mark": "point",
6+
"encoding": {
7+
"x": { "field": "Horsepower", "type": "quantitative" },
8+
"y": { "field": "Miles_per_Gallon", "type": "quantitative" }
9+
},
10+
"config": { "scale": { "zero": false } }
11+
}

‎site/docs/encoding/scale.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ To provide themes for all scales, the scale config (`config: {scale: {...}}`) ca
452452

453453
#### Other
454454

455-
{% include table.html props="clamp,round,xReverse,useUnaggregatedDomain" source="ScaleConfig" %}
455+
{% include table.html props="clamp,round,xReverse,useUnaggregatedDomain,zero" source="ScaleConfig" %}
456456

457457
{:#range-config}
458458

‎src/compile/scale/properties.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {isBinned, isBinning, isBinParams} from '../../bin';
44
import {
55
COLOR,
66
FILL,
7+
getSecondaryRangeChannel,
78
isXorY,
89
isXorYOffset,
910
POLAR_POSITION_SCALE_CHANNELS,
@@ -120,7 +121,8 @@ function parseUnitScaleProperty(model: UnitModel, property: Exclude<keyof (Scale
120121
domainMax: specifiedScale.domainMax,
121122
markDef,
122123
config,
123-
hasNestedOffsetScale: channelHasNestedOffsetScale(encoding, channel)
124+
hasNestedOffsetScale: channelHasNestedOffsetScale(encoding, channel),
125+
hasSecondaryRangeChannel: !!encoding[getSecondaryRangeChannel(channel)]
124126
})
125127
: config.scale[property];
126128
if (value !== undefined) {
@@ -144,6 +146,7 @@ export interface ScaleRuleParams {
144146
domainMax: Scale['domainMax'];
145147
markDef: MarkDef<Mark, SignalRef>;
146148
config: Config<SignalRef>;
149+
hasSecondaryRangeChannel: boolean;
147150
}
148151

149152
export const scaleRules: {
@@ -169,8 +172,8 @@ export const scaleRules: {
169172
const sort = isFieldDef(fieldOrDatumDef) ? fieldOrDatumDef.sort : undefined;
170173
return reverse(scaleType, sort, channel, config.scale);
171174
},
172-
zero: ({channel, fieldOrDatumDef, domain, markDef, scaleType}) =>
173-
zero(channel, fieldOrDatumDef, domain, markDef, scaleType)
175+
zero: ({channel, fieldOrDatumDef, domain, markDef, scaleType, config, hasSecondaryRangeChannel}) =>
176+
zero(channel, fieldOrDatumDef, domain, markDef, scaleType, config.scale, hasSecondaryRangeChannel)
174177
};
175178

176179
// This method is here rather than in range.ts to avoid circular dependency.
@@ -399,7 +402,9 @@ export function zero(
399402
fieldDef: TypedFieldDef<string> | ScaleDatumDef,
400403
specifiedDomain: Domain,
401404
markDef: MarkDef,
402-
scaleType: ScaleType
405+
scaleType: ScaleType,
406+
scaleConfig: ScaleConfig<SignalRef>,
407+
hasSecondaryRangeChannel: boolean
403408
) {
404409
// If users explicitly provide a domain, we should not augment zero as that will be unexpected.
405410
const hasCustomDomain = !!specifiedDomain && specifiedDomain !== 'unaggregated';
@@ -418,7 +423,7 @@ export function zero(
418423
}
419424
}
420425

421-
// If there is no custom domain, return true only for the following cases:
426+
// If there is no custom domain, return configZero value (=`true` as default) only for the following cases:
422427

423428
// 1) using quantitative field with size
424429
// While this can be either ratio or interval fields, our assumption is that
@@ -430,6 +435,7 @@ export function zero(
430435

431436
// 2) non-binned, quantitative x-scale or y-scale
432437
// (For binning, we should not include zero by default because binning are calculated without zero.)
438+
// (For area/bar charts with ratio scale chart, we should always include zero.)
433439
if (
434440
!(isFieldDef(fieldDef) && fieldDef.bin) &&
435441
util.contains([...POSITION_SCALE_CHANNELS, ...POLAR_POSITION_SCALE_CHANNELS], channel)
@@ -441,7 +447,12 @@ export function zero(
441447
}
442448
}
443449

444-
return true;
450+
if (contains(['bar', 'area'], type) && !hasSecondaryRangeChannel) {
451+
return true;
452+
}
453+
454+
return scaleConfig?.zero;
445455
}
456+
446457
return false;
447458
}

‎src/scale.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,14 @@ export interface ScaleConfig<ES extends ExprRef | SignalRef> {
415415
* Reverse x-scale by default (useful for right-to-left charts).
416416
*/
417417
xReverse?: boolean | ES;
418+
419+
/**
420+
* Default `scale.zero` for [`continuous`](https://vega.github.io/vega-lite/docs/scale.html#continuous) scales except for (1) x/y-scales of non-ranged bar or area charts and (2) size scales.
421+
*
422+
* __Default value:__ `true`
423+
*
424+
*/
425+
zero?: boolean;
418426
}
419427

420428
export const defaultScaleConfig: ScaleConfig<SignalRef> = {
@@ -439,7 +447,9 @@ export const defaultScaleConfig: ScaleConfig<SignalRef> = {
439447
minStrokeWidth: 1,
440448
maxStrokeWidth: 4,
441449
quantileCount: 4,
442-
quantizeCount: 4
450+
quantizeCount: 4,
451+
452+
zero: true
443453
};
444454

445455
export interface SchemeParams {

‎test/compile/scale/properties.test.ts

+116-12
Original file line numberDiff line numberDiff line change
@@ -199,43 +199,79 @@ describe('compile/scale', () => {
199199
});
200200

201201
describe('zero', () => {
202-
it('should return true when mapping a quantitative field to x with scale.domain = "unaggregated"', () => {
202+
it('should return default (undefined) when mapping a quantitative field to x with scale.domain = "unaggregated"', () => {
203203
expect(
204-
rules.zero('x', {field: 'a', type: 'quantitative'}, 'unaggregated', {type: 'point'}, 'linear')
205-
).toBeTruthy();
204+
rules.zero('x', {field: 'a', type: 'quantitative'}, 'unaggregated', {type: 'point'}, 'linear', undefined, false)
205+
).toBeUndefined();
206206
});
207207

208208
it('should return true when mapping a quantitative field to size', () => {
209-
expect(rules.zero('size', {field: 'a', type: 'quantitative'}, undefined, {type: 'point'}, 'linear')).toBeTruthy();
209+
expect(
210+
rules.zero('size', {field: 'a', type: 'quantitative'}, undefined, {type: 'point'}, 'linear', undefined, false)
211+
).toBeTruthy();
210212
});
211213

212214
it('should return false when mapping a ordinal field to size', () => {
213-
expect(!rules.zero('size', {field: 'a', type: 'ordinal'}, undefined, {type: 'point'}, 'linear')).toBeTruthy();
215+
expect(
216+
!rules.zero('size', {field: 'a', type: 'ordinal'}, undefined, {type: 'point'}, 'linear', undefined, false)
217+
).toBeTruthy();
214218
});
215219

216-
it('should return true when mapping a non-binned quantitative field to x/y of point', () => {
220+
it('should return default (undefined) when mapping a non-binned quantitative field to x/y of point', () => {
217221
for (const channel of ['x', 'y'] as const) {
218222
expect(
219-
rules.zero(channel, {field: 'a', type: 'quantitative'}, undefined, {type: 'point'}, 'linear')
220-
).toBeTruthy();
223+
rules.zero(
224+
channel,
225+
{field: 'a', type: 'quantitative'},
226+
undefined,
227+
{type: 'point'},
228+
'linear',
229+
undefined,
230+
false
231+
)
232+
).toBeUndefined();
221233
}
222234
});
223235

224236
it('should return false when mapping a quantitative field to dimension axis of bar, line, and area', () => {
225237
for (const mark of [BAR, AREA, LINE]) {
226238
expect(
227-
rules.zero('x', {field: 'a', type: 'quantitative'}, undefined, {type: mark, orient: 'vertical'}, 'linear')
239+
rules.zero(
240+
'x',
241+
{field: 'a', type: 'quantitative'},
242+
undefined,
243+
{type: mark, orient: 'vertical'},
244+
'linear',
245+
undefined,
246+
false
247+
)
228248
).toBe(false);
229249
expect(
230-
rules.zero('y', {field: 'a', type: 'quantitative'}, undefined, {type: mark, orient: 'horizontal'}, 'linear')
250+
rules.zero(
251+
'y',
252+
{field: 'a', type: 'quantitative'},
253+
undefined,
254+
{type: mark, orient: 'horizontal'},
255+
'linear',
256+
undefined,
257+
false
258+
)
231259
).toBe(false);
232260
}
233261
});
234262

235263
it('should return false when mapping a binned quantitative field to x/y', () => {
236264
for (const channel of ['x', 'y'] as const) {
237265
expect(
238-
!rules.zero(channel, {bin: true, field: 'a', type: 'quantitative'}, undefined, {type: 'point'}, 'linear')
266+
!rules.zero(
267+
channel,
268+
{bin: true, field: 'a', type: 'quantitative'},
269+
undefined,
270+
{type: 'point'},
271+
'linear',
272+
undefined,
273+
false
274+
)
239275
).toBeTruthy();
240276
}
241277
});
@@ -252,10 +288,78 @@ describe('compile/scale', () => {
252288
},
253289
[3, 5],
254290
{type: 'point'},
255-
'linear'
291+
'linear',
292+
undefined,
293+
false
256294
)
257295
).toBeTruthy();
258296
}
259297
});
298+
299+
it(`should return config.scale.zero instead of true if it is specified`, () => {
300+
const configZero = false;
301+
for (const channel of ['x', 'y'] as const) {
302+
expect(
303+
rules.zero(
304+
channel,
305+
{field: 'a', type: 'quantitative'},
306+
undefined,
307+
{type: 'point'},
308+
'linear',
309+
{zero: configZero},
310+
false
311+
)
312+
).toBe(configZero);
313+
}
314+
315+
expect(
316+
rules.zero(
317+
'size',
318+
{field: 'a', type: 'ordinal'},
319+
undefined,
320+
{type: 'point'},
321+
'linear',
322+
{zero: configZero},
323+
false
324+
)
325+
).toBe(configZero);
326+
327+
// ranged bar/area should take default configZero
328+
expect(
329+
rules.zero('x', {field: 'a', type: 'quantitative'}, undefined, {type: BAR}, 'linear', {zero: configZero}, true)
330+
).toBe(configZero);
331+
});
332+
333+
it(`should return true for x/y scales of the non-ranged area/bar charts regardless to config`, () => {
334+
for (const mark of [BAR, AREA]) {
335+
for (const channel of ['x', 'y'] as const) {
336+
expect(
337+
rules.zero(
338+
channel,
339+
{field: 'a', type: 'quantitative'},
340+
undefined,
341+
{type: mark},
342+
'linear',
343+
{zero: false},
344+
false
345+
)
346+
).toBe(true);
347+
}
348+
}
349+
});
350+
351+
it(`should return true for the continuous & quantitative size scale regardless to config`, () => {
352+
expect(
353+
rules.zero(
354+
'size',
355+
{field: 'a', type: 'quantitative'},
356+
undefined,
357+
{type: 'point'},
358+
'linear',
359+
{zero: false},
360+
false
361+
)
362+
).toBe(true);
363+
});
260364
});
261365
});

0 commit comments

Comments
 (0)
Please sign in to comment.