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

TypeScript fielddef.isDimension函数代码示例

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

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



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

示例1: point

  export function point(encoding: Encoding, stats, opt: SpecOption) {
    if(!facetsRule(encoding, stats, opt)) return false;
    if (encoding.x && encoding.y) {
      // have both x & y ==> scatter plot / bubble plot

      var xIsDim = isDimension(encoding.x),
        yIsDim = isDimension(encoding.y);

      // For OxO
      if (xIsDim && yIsDim) {
        // TODO: revise if we need his
        // shape doesn't work with both x, y as ordinal
        if (encoding.shape) {
          return false;
        }

        // TODO(kanitw): check that there is quant at least ...
        if (encoding.color && isDimension(encoding.color)) {
          return false;
        }
      }

    } else { // plot with one axis = dot plot
      if (opt.omitDotPlot) return false;

      // Dot plot should always be horizontal
      if (opt.omitTranspose && encoding.y) return false;

      // dot plot shouldn't have other encoding
      if (opt.omitDotPlotWithExtraEncoding && util.keys(encoding).length > 1) return false;

    }
    return true;
  }
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:34,代码来源:marks.ts


示例2: tick

  export function tick(encoding: Encoding, stats, opt: SpecOption) {
    // jshint unused:false
    if (encoding.x || encoding.y) {
      if(isAggregate(encoding)) return false;

      var xIsDim = isDimension(encoding.x),
        yIsDim = isDimension(encoding.y);

      return (!xIsDim && (!encoding.y || yIsDim)) ||
        (!yIsDim && (!encoding.x || xIsDim));
    }
    return false;
  }
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:13,代码来源:marks.ts


示例3: 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


示例4: assignField

  function assignField(i) {
    // If all fields are assigned, save
    if (i === fieldDefs.length) {
      // at the minimal all chart should have x, y, geo, text or arc
      if (rule.encoding(tmpEncoding, stats, opt)) {
        encodings.push(duplicate(tmpEncoding));
      }
      return;
    }

    // Otherwise, assign i-th field
    var fieldDef = fieldDefs[i];
    for (var j in opt.channelList) {
      var channel = opt.channelList[j],
        isDim = isDimension(fieldDef);

      const supportedRole = getSupportedRole(channel);

      // TODO: support "multiple" assignment
      if (
        // encoding not used
        !(channel in tmpEncoding) &&
        // channel support the assigned role
        ((isDim && supportedRole.dimension) || (!isDim && supportedRole.measure)) &&
        // the field satisfies the channel's rule
        rule.channel[channel](tmpEncoding, fieldDef, stats, opt)
      ) {
        tmpEncoding[channel] = fieldDef;
        assignField(i + 1);
        delete tmpEncoding[channel];
      }
    }
  }
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:33,代码来源:encodings.ts


示例5: xyPlotRules

  function xyPlotRules(encoding: Encoding, stats, opt: SpecOption) {
    if (encoding.row || encoding.column) { // have facet(s)
      if (opt.omitNonTextAggrWithAllDimsOnFacets) {
        // remove all aggregated charts with all dims on facets (row, column)
        if (isAggrWithAllDimOnFacets(encoding)) { return false; }
      }
    }

    var isDimX = isDimension(encoding.x),
      isDimY = isDimension(encoding.y);

    // If both x and y are dimension, and the plot is not aggregated,
    // there might be occlusion.
    if (opt.omitRawWithXYBothDimension && isDimX && isDimY && !isAggregate(encoding)) {
      // FIXME actually check if there would be occlusion #90
      return false;
    }

    if (opt.omitTranspose) {
      if (isDimX !== isDimY) { // dim x mea
        // create horizontal histogram for ordinal
        if ((encoding.y.type === Type.NOMINAL || encoding.y.type === Type.ORDINAL) && isMeasure(encoding.x)) {
          return true;
        }

        // vertical histogram for binned Q and T
        if (!isDimY && isDimX && !(encoding.x.type === Type.NOMINAL || encoding.x.type === Type.ORDINAL)) {
          return true;
        }

        return false;
      } else if (encoding.y.type=== Type.TEMPORAL || encoding.x.type === Type.TEMPORAL) {
        // FIXME revise this
        if (encoding.y.type=== Type.TEMPORAL && encoding.x.type !== Type.TEMPORAL) {
          return false;
        }
      } else {
        // FIXME: test if we can remove this rule
        // show only one OxO, QxQ
        if (encoding.x.field > encoding.y.field) {
          return false;
        }
      }
    }
    return true;
  }
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:46,代码来源:encodings.ts


示例6: roleScore

      scores = mappings.map(function(m) {
        var roleScore = vlFieldDef.isDimension(m.fieldDef) ?
                          dimensionScore : measureScore;

        var score = roleScore(m.fieldDef, m.channel, spec.mark, stats, opt);

        return !selected || selected[m.fieldDef.field] ? score : Math.pow(score, 0.125);
      });
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:8,代码来源:rankEncodings.ts


示例7:

 tf.forEach(function(f) {
   if (vlFieldDef.isDimension(f)) {
     hasDimension = true;
   } else {
     hasMeasure = true;
     if (!f.aggregate) { hasRaw = true; }
   }
 });
开发者ID:sguzwf,项目名称:compass,代码行数:8,代码来源:aggregates.ts


示例8: bar

  export function bar(encoding: Encoding, stats, opt: SpecOption) {
    if(!facetsRule(encoding, stats, opt)) return false;

    // bar requires at least x or y
    if (!encoding.x && !encoding.y) return false;

    if (opt.omitSizeOnBar && encoding.size !== undefined) return false;


    if (opt.omitLengthForLogScale) {
      if (encoding.x && encoding.x.scale && encoding.x.scale.type === ScaleType.LOG ) return false;
      if (encoding.y && encoding.y.scale && encoding.y.scale.type === ScaleType.LOG ) return false;
    }



    // FIXME actually check if there would be occlusion #90
    // need to aggregate on either x or y

    var aggEitherXorY =
      (!encoding.x || encoding.x.aggregate === undefined) !== // xor
      (!encoding.y || encoding.y.aggregate === undefined);


    if (aggEitherXorY) {
      var eitherXorYisDimOrNull =
        (!encoding.x || isDimension(encoding.x)) !== // xor
        (!encoding.y || isDimension(encoding.y));

      if (eitherXorYisDimOrNull) {
        var aggregate = encoding.x.aggregate || encoding.y.aggregate;

        // TODO: revise
        return !(opt.omitStackedAverage && aggregate === AggregateOp.MEAN && encoding.color);
      }
    }

    return false;
  }
开发者ID:mchally,项目名称:ExploringDataViz,代码行数:39,代码来源:marks.ts


示例9: isAggrWithAllDimOnFacets

  function isAggrWithAllDimOnFacets(encoding) {
    var hasAggr = false, hasOtherO = false;
    for (var channel in encoding) {
      var fieldDef = encoding[channel];
      if (fieldDef.aggregate) {
        hasAggr = true;
      }
      if (isDimension(fieldDef) && (channel !== ROW && channel !== COLUMN)) {
        hasOtherO = true;
      }
      if (hasAggr && hasOtherO) { break; }
    }

    return hasAggr && !hasOtherO;
  };
开发者ID:sguzwf,项目名称:compass,代码行数:15,代码来源:encodings.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript fielddef.isMeasure函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fielddef.isCount函数代码示例发布时间: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