How to use the plywood.AttributeInfo.fromJS function in plywood

To help you get started, we’ve selected a few plywood 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 geo-opensource / pivot / src / common / models / measure / measure.mocha.ts View on Github external
it('works with max', () => {
      var attribute = AttributeInfo.fromJS({
        "name": "price",
        "type": "NUMBER",
        "unsplitable": true,
        "makerAction": {
          "action": "max",
          "expression": {
            "name": "price",
            "op": "ref"
          }
        }
      });

      var measures = Measure.measuresFromAttributeInfo(attribute).map((m => m.toJS()));
      expect(measures).to.deep.equal([
        {
          "name": "price",
github allegro / turnilo / src / common / models / measure / measure.mocha.ts View on Github external
it("works with sum", () => {
      const attribute = AttributeInfo.fromJS({
        name: "price",
        type: "NUMBER",
        unsplitable: true,
        maker: {
          action: "sum",
          expression: {
            name: "price",
            op: "ref"
          }
        }
      });
      const measures = Measure.measuresFromAttributeInfo(attribute).map((m => m.toJS()));
      expect(measures).to.deep.equal([
        {
          name: "price",
          title: "Price",
github allegro / turnilo / src / common / models / data-cube / data-cube.ts View on Github external
public deduceAttributes(): Attributes {
    const { dimensions, measures, timeAttribute, attributeOverrides } = this;
    let attributes: Attributes = [];

    if (timeAttribute) {
      attributes.push(AttributeInfo.fromJS({ name: timeAttribute.name, type: "TIME" }));
    }

    dimensions.forEachDimension(dimension => {
      const expression = dimension.expression;
      if (expression.equals(timeAttribute)) return;
      const references = expression.getFreeReferences();
      for (let reference of references) {
        if (NamedArray.findByName(attributes, reference)) continue;
        attributes.push(AttributeInfo.fromJS({ name: reference, type: "STRING" }));
      }
    });

    measures.forEachMeasure(measure => {
      const references = Measure.getReferences(measure.expression);
      for (let reference of references) {
        if (NamedArray.findByName(attributes, reference)) continue;
github allegro / turnilo / src / common / models / data-cube / data-cube.ts View on Github external
measures.forEachMeasure(measure => {
      const references = Measure.getReferences(measure.expression);
      for (let reference of references) {
        if (NamedArray.findByName(attributes, reference)) continue;
        if (Measure.hasCountDistinctReferences(measure.expression)) continue;
        if (Measure.hasQuantileReferences(measure.expression)) continue;
        attributes.push(AttributeInfo.fromJS({ name: reference, type: "NUMBER" }));
      }
    });