How to use the vega-lite/src/type.Type.ORDINAL function in vega-lite

To help you get started, we’ve selected a few vega-lite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vega / compass / src / gen / encodings.ts View on Github external
}

    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
github vega / compass / src / gen / encodings.ts View on Github external
// 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;
        }
      }
github vega / compass / src / gen / aggregates.ts View on Github external
checkAndPush();
      return;
    }

    var f = fieldDefs[i];
    // Otherwise, assign i-th field
    switch (f.type) {
      // TODO: "D", "G"
      case Type.QUANTITATIVE:
        assignQ(i, hasAggr, autoMode);
        break;

      case Type.TEMPORAL:
        assignT(i, hasAggr, autoMode);
        break;
      case Type.ORDINAL:
        /* falls through */
      case Type.NOMINAL:
        /* falls through */
      default:
        tf[i] = f;
        assignField(i + 1, hasAggr, autoMode);
        break;
    }
  }
github vega / compass / src / rank / rankEncodings.ts View on Github external
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
github vega / compass / src / gen / aggregates.ts View on Github external
var hasNorO = util.any(fieldDefs, function(f) {
    return f.type === Type.NOMINAL || f.type === Type.ORDINAL;
  });