|
8 | 8 | ScaleType, |
9 | 9 | scaleTypeSupportProperty |
10 | 10 | } from 'vega-lite/build/src/scale'; |
| 11 | +import {isLocalSingleTimeUnit, isUtcSingleTimeUnit} from 'vega-lite/build/src/timeunit'; |
11 | 12 | import * as TYPE from 'vega-lite/build/src/type'; |
12 | 13 | import {QueryConfig} from '../config'; |
13 | 14 | import {getEncodingNestedProp, Property, SCALE_PROPS} from '../property'; |
@@ -89,7 +90,19 @@ export const FIELD_CONSTRAINTS: EncodingConstraintModel<FieldQuery>[] = [ |
89 | 90 | ...toFieldDef(fieldQ, {schema, props: ['bin', 'timeUnit', 'type']}) |
90 | 91 | }; |
91 | 92 |
|
92 | | - return channelCompatibility(fieldDef, fieldQ.channel as Channel).compatible; |
| 93 | + const {compatible} = channelCompatibility(fieldDef, fieldQ.channel as Channel); |
| 94 | + |
| 95 | + if (compatible) { |
| 96 | + return true; |
| 97 | + } else { |
| 98 | + // In VL, facet's field def must be discrete (O/N), but in CompassQL we can relax this a bit. |
| 99 | + const isFacet = fieldQ.channel === 'row' || fieldQ.channel === 'column'; |
| 100 | + |
| 101 | + if (isFacet && (isLocalSingleTimeUnit(fieldDef.timeUnit) || isUtcSingleTimeUnit(fieldDef.timeUnit))) { |
| 102 | + return true; |
| 103 | + } |
| 104 | + return false; |
| 105 | + } |
93 | 106 | } |
94 | 107 | }, |
95 | 108 | { |
@@ -242,7 +255,7 @@ export const FIELD_CONSTRAINTS: EncodingConstraintModel<FieldQuery>[] = [ |
242 | 255 | }, |
243 | 256 | { |
244 | 257 | name: 'typeMatchesPrimitiveType', |
245 | | - description: 'Data type should be supported by field\'s primitive type.', |
| 258 | + description: "Data type should be supported by field's primitive type.", |
246 | 259 | properties: [Property.FIELD, Property.TYPE], |
247 | 260 | allowWildcardForProperties: false, |
248 | 261 | strict: true, |
@@ -278,7 +291,7 @@ export const FIELD_CONSTRAINTS: EncodingConstraintModel<FieldQuery>[] = [ |
278 | 291 | }, |
279 | 292 | { |
280 | 293 | name: 'typeMatchesSchemaType', |
281 | | - description: 'Enumerated data type of a field should match the field\'s type in the schema.', |
| 294 | + description: "Enumerated data type of a field should match the field's type in the schema.", |
282 | 295 | properties: [Property.FIELD, Property.TYPE], |
283 | 296 | allowWildcardForProperties: false, |
284 | 297 | strict: false, |
|
0 commit comments