本文整理汇总了TypeScript中vega-lite/build/src/scale.hasDiscreteDomain函数的典型用法代码示例。如果您正苦于以下问题:TypeScript hasDiscreteDomain函数的具体用法?TypeScript hasDiscreteDomain怎么用?TypeScript hasDiscreteDomain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hasDiscreteDomain函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: smallRangeStepForHighCardinalityOrFacet
export function smallRangeStepForHighCardinalityOrFacet(specM: SpecQueryModel, schema: Schema, encQIndex: Dict<EncodingQuery>, opt: QueryConfig): SpecQueryModel {
[Channel.ROW, Channel.Y, Channel.COLUMN, Channel.X].forEach((channel) => {
encQIndex[channel] = specM.getEncodingQueryByChannel(channel);
});
const yEncQ = encQIndex[Channel.Y];
if (yEncQ !== undefined && isFieldQuery(yEncQ)) {
if (encQIndex[Channel.ROW] ||
schema.cardinality(yEncQ) > opt.smallRangeStepForHighCardinalityOrFacet.maxCardinality) {
// We check for undefined rather than
// yEncQ.scale = yEncQ.scale || {} to cover the case where
// yEncQ.scale has been set to false/null.
// This prevents us from incorrectly overriding scale and
// assigning a rangeStep when scale is set to false.
if (yEncQ.scale === undefined) {
yEncQ.scale = {};
}
// We do not want to assign a rangeStep if scale is set to false
// and we only apply this if the scale is (or can be) an ordinal scale.
const yScaleType = scaleType(yEncQ);
if (yEncQ.scale && (yScaleType === undefined || hasDiscreteDomain(yScaleType))) {
if (!(yEncQ.scale as ScaleQuery).rangeStep) {
(yEncQ.scale as ScaleQuery).rangeStep = 12;
}
}
}
}
const xEncQ = encQIndex[Channel.X];
if (isFieldQuery(xEncQ)) {
if (encQIndex[Channel.COLUMN] ||
schema.cardinality(xEncQ) > opt.smallRangeStepForHighCardinalityOrFacet.maxCardinality) {
// Just like y, we don't want to do this if scale is null/false
if (xEncQ.scale === undefined) {
xEncQ.scale = {};
}
// We do not want to assign a rangeStep if scale is set to false
// and we only apply this if the scale is (or can be) an ordinal scale.
const xScaleType = scaleType(xEncQ);
if (xEncQ.scale && (xScaleType === undefined || hasDiscreteDomain(xScaleType))) {
if (!(xEncQ.scale as ScaleQuery).rangeStep) {
(xEncQ.scale as ScaleQuery).rangeStep = 12;
}
}
}
}
return specM;
}
示例2: getExtendedType
export function getExtendedType(fieldQ: FieldQuery): ExtendedType {
if (fieldQ.bin) {
return ExtendedType.BIN_Q;
} else if (fieldQ.timeUnit) {
const sType = scaleType(fieldQ);
return hasDiscreteDomain(sType) ? ExtendedType.TIMEUNIT_O : ExtendedType.TIMEUNIT_T;
}
return fieldQ.type as ExtendedType;
}
示例3: scaleType
satisfy: (fieldQ: FieldQuery, _: Schema, __: PropIndex<Wildcard<any>>, ___: QueryConfig) => {
if (fieldQ.scale) {
const type = fieldQ.type;
const sType = scaleType(fieldQ);
if (isDiscrete(type)) {
return sType === undefined || hasDiscreteDomain(sType);
} else if (type === Type.TEMPORAL) {
if(!fieldQ.timeUnit) {
return contains([ScaleType.TIME, ScaleType.UTC, undefined], sType);
} else {
return contains([ScaleType.TIME, ScaleType.UTC, undefined], sType) || hasDiscreteDomain(sType);
}
} else if (type === Type.QUANTITATIVE) {
if (fieldQ.bin) {
return contains([ScaleType.LINEAR, undefined], sType);
} else {
return contains([ScaleType.LOG, ScaleType.POW, ScaleType.SQRT, ScaleType.QUANTILE, ScaleType.QUANTIZE, ScaleType.LINEAR, undefined], sType);
}
}
}
return true;
}
示例4: xAxisOnTopForHighYCardinalityWithoutColumn
export function xAxisOnTopForHighYCardinalityWithoutColumn(specM: SpecQueryModel, schema: Schema, encQIndex: Dict<EncodingQuery>, opt: QueryConfig): SpecQueryModel {
[Channel.COLUMN, Channel.X, Channel.Y].forEach((channel) => {
encQIndex[channel] = specM.getEncodingQueryByChannel(channel);
});
if (encQIndex[Channel.COLUMN] === undefined) {
const xEncQ = encQIndex[Channel.X];
const yEncQ = encQIndex[Channel.Y];
if (isFieldQuery(xEncQ) && isFieldQuery(yEncQ) && yEncQ !== undefined && yEncQ.field && hasDiscreteDomain(scaleType(yEncQ))) {
if (xEncQ !== undefined) {
if (schema.cardinality(yEncQ) > opt.xAxisOnTopForHighYCardinalityWithoutColumn.maxCardinality) {
if (xEncQ.axis === undefined) {
xEncQ.axis = {};
}
if (xEncQ.axis && !(xEncQ.axis as AxisQuery).orient) {
(xEncQ.axis as AxisQuery).orient = 'top';
}
}
}
}
}
return specM;
}