當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript scale.hasDiscreteDomain函數代碼示例

本文整理匯總了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;
}
開發者ID:herrstucki,項目名稱:compassql,代碼行數:53,代碼來源:stylize.ts

示例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;
}
開發者ID:uwdata,項目名稱:compassql,代碼行數:9,代碼來源:type.ts

示例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;
    }
開發者ID:uwdata,項目名稱:compassql,代碼行數:23,代碼來源:field.ts

示例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;
}
開發者ID:herrstucki,項目名稱:compassql,代碼行數:26,代碼來源:stylize.ts


注:本文中的vega-lite/build/src/scale.hasDiscreteDomain函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。