• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fielddef.cardinality函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vega-lite/src/fielddef.cardinality函数的典型用法代码示例。如果您正苦于以下问题:TypeScript cardinality函数的具体用法?TypeScript cardinality怎么用?TypeScript cardinality使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cardinality函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: if

  fieldDefs.forEach(function(fieldDef, index){
    // save indices for stable sort later
    indices[fieldDef.field] = index;

    if (fieldDef.selected) { // selected fields are included in selected
      selected.push(fieldDef);

      if (isDimension(fieldDef) ||
         (fieldDef.type === TEMPORAL /* TODO: add && current constraint make it a dimension */)) {
        // If the field can serve as dimension

        // FIXME vega-lite's isDimension is designed to work with FieldDef, not SchemaField
        // Therefore, we should augment vega-lite's isDimension
        hasSelectedDimension = true;
      } else {
        hasSelectedMeasure = true;
      }
    } else if (fieldDef.selected !== false && !vlFieldDef.isCount(fieldDef)) {
      if (vlFieldDef.isDimension(fieldDef) &&
          !opt.maxCardinalityForAutoAddOrdinal &&
          vlFieldDef.cardinality(fieldDef, stats, 15) > opt.maxCardinalityForAutoAddOrdinal
        ) {
        return;
      }
      fieldsToAdd.push(fieldDef);
    }
  });
开发者ID:sguzwf,项目名称:compass,代码行数:27,代码来源:projections.ts


示例2: color

    export function color(encoding: Encoding, fieldDef: FieldDef, stats, opt: SpecOption) {
      // Don't use color if omitMultipleRetinalEncodings is true and we already have other retinal encoding
      if (!retinalEncRules(encoding, fieldDef, stats, opt)) {
        return false;
      }

      // Color must be either measure or dimension with cardinality lower than the max cardinality
      return isMeasure(fieldDef) ||
        cardinality(fieldDef, stats) <= opt.maxCardinalityForColor;
    }
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:10,代码来源:encodings.ts


示例3: function

export let dimensionScore:any = function(fieldDef, channel, mark, stats, opt){
  var cardinality = vlFieldDef.cardinality(fieldDef, stats);
  switch (channel) {
    case vlChannel.X:
      if (fieldDef.type === Type.NOMINAL || fieldDef.type === Type.ORDINAL)  {
        return D.pos - D.minor;
      }
      return D.pos;

    case vlChannel.Y:
      if (fieldDef.type === Type.NOMINAL || fieldDef.type === Type.ORDINAL) {
        return D.pos - D.minor; // prefer ordinal on y
      }
      if (fieldDef.type === Type.TEMPORAL) {
        return D.Y_T; // time should not be on Y
      }
      return D.pos - D.minor;

    case vlChannel.COLUMN:
      if (mark === 'text') return D.facet_text;
      // prefer column over row due to scrolling issues
      return cardinality <= opt.maxGoodCardinalityForFacets ? D.facet_good :
        cardinality <= opt.maxCardinalityForFacets ? D.facet_ok : D.facet_bad;

    case vlChannel.ROW:
      if (mark === 'text') return D.facet_text;
      return (cardinality <= opt.maxGoodCardinalityForFacets ? D.facet_good :
        cardinality <= opt.maxCardinalityForFacets ? D.facet_ok : D.facet_bad) - D.minor;

    case vlChannel.COLOR:
      var hasOrder = (fieldDef.bin && fieldDef.type=== Type.QUANTITATIVE) || (fieldDef.timeUnit && fieldDef.type=== Type.TEMPORAL);

      // FIXME add stacking option once we have control ..
      var isStacked = mark === Mark.BAR || mark === Mark.AREA;

      // true ordinal on color is currently BAD (until we have good ordinal color scale support)
      if (hasOrder) return D.color_bad;

      // stacking gets lower score
      if (isStacked) return D.color_stack;

      return cardinality <= opt.maxGoodCardinalityForColor ? D.color_good: cardinality <= opt.maxCardinalityForColor ? D.color_ok : D.color_bad;
    case vlChannel.SHAPE:
      return cardinality <= opt.maxCardinalityForShape ? D.shape : TERRIBLE;
    case vlChannel.DETAIL:
      return D.detail;
  }
  return TERRIBLE;
};
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:49,代码来源:rankEncodings.ts


示例4: shape

    export function shape(encoding: Encoding, fieldDef: FieldDef, stats, opt: SpecOption) {
      if (!retinalEncRules(encoding, fieldDef, stats, opt)) {
        return false;
      }

      // TODO: revise if this should mainly be on ranking
      if (opt.omitShapeWithBin && fieldDef.bin && fieldDef.type === Type.QUANTITATIVE) {
        return false;
      }
      if (opt.omitShapeWithTimeDimension && fieldDef.timeUnit && fieldDef.type === Type.TEMPORAL) {
        return false;
      }

      return cardinality(fieldDef, stats) <= opt.maxCardinalityForShape;
    }
开发者ID:sguzwf,项目名称:compass,代码行数:15,代码来源:encodings.ts


示例5: assignQ

  function assignQ(i, hasAggr, autoMode) {
    var f = fieldDefs[i],
      canHaveAggr = hasAggr === true || hasAggr === null;

    tf[i] = {field: f.field, type: f.type};

    if (f.aggregate === AggregateOp.COUNT) { // if count is included in the selected fields
      if (canHaveAggr) {
        tf[i].aggregate = f.aggregate;
        assignField(i + 1, true, autoMode);
      }
    } else if (f._aggregate) {
      // TODO support array of f._aggrs too
      assignAggrQ(i, hasAggr, autoMode, f._aggregate);
    } else if (f._raw) {
      assignAggrQ(i, hasAggr, autoMode, undefined);
    } else if (f._bin) {
      assignBinQ(i, hasAggr, autoMode);
    } else {
      opt.aggrList.forEach(function(a) {
        if (!opt.consistentAutoQ || autoMode === AUTO || autoMode === a) {
          assignAggrQ(i, hasAggr, a /*assign autoMode*/, a);
        }
      });

      if ((!opt.consistentAutoQ || util.isin(autoMode, [AUTO, 'bin', 'cast', 'autocast'])) && !hasNorO) {
        // Constraint: Bin a field only if its cardinality is above certain threshold
        var highCardinality = vlFieldDef.cardinality(f, stats) > opt.minCardinalityForBin;

        var isAuto = opt.genDimQ === QuantitativeDimensionType.AUTO,
          genBin = opt.genDimQ  === QuantitativeDimensionType.BIN || (isAuto && highCardinality),
          genCast = opt.genDimQ === QuantitativeDimensionType.CAST || (isAuto && !highCardinality);

        if (genBin && util.isin(autoMode, [AUTO, 'bin', 'autocast'])) {
          assignBinQ(i, hasAggr, isAuto ? 'autocast' : 'bin');
        }
        if (genCast && util.isin(autoMode, [AUTO, 'cast', 'autocast'])) {
          tf[i].type = Type.ORDINAL;
          assignField(i + 1, hasAggr, isAuto ? 'autocast' : 'cast');
          tf[i].type = Type.QUANTITATIVE;
        }
      }
    }
  }
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:44,代码来源:aggregates.ts


示例6: facetRule

 function facetRule(fieldDef, stats, opt: SpecOption) {
   return cardinality(fieldDef, stats) <= opt.maxCardinalityForFacets;
 }
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:3,代码来源:marks.ts



注:本文中的vega-lite/src/fielddef.cardinality函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fielddef.isCount函数代码示例发布时间:2022-05-25
下一篇:
TypeScript scale.hasDiscreteDomain函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap