当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fielddef.isDimension函数代码示例

本文整理汇总了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;未经允许,请勿转载。