How to use the vega-lite/src/type.Type.TEMPORAL 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 / rank / rankEncodings.ts View on Github external
}
      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 === 'bar' || 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;
  }
github vega / compass / src / gen / encodings.ts View on Github external
}

    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;
  }
github vega / compass / src / gen / aggregates.ts View on Github external
function assignField(i, hasAggr, autoMode) {
    if (i === fieldDefs.length) { // If all fields are assigned
      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 / gen / marks.ts View on Github external
export function line(encoding: Encoding, stats, opt: SpecOption) {
    if (!facetsRule(encoding, stats, opt)) return false;

    // TODO(kanitw): add omitVerticalLine as config

    // FIXME truly ordinal data is fine here too.
    // Line chart should be only horizontal
    // and use only temporal data
    return encoding.x.type === Type.TEMPORAL && !!encoding.x.timeUnit &&
           encoding.y.type === Type.QUANTITATIVE && !!encoding.y.aggregate;
  }