How to use the @finos/perspective/dist/esm/config.get_type_config function in @finos/perspective

To help you get started, we’ve selected a few @finos/perspective 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 finos / perspective / packages / perspective-viewer / src / js / viewer / perspective_element.js View on Github external
if (type_config.type || type) {
            if (col.op === "" || perspective.TYPE_AGGREGATES[type_config.type || type].indexOf(col.op) === -1) {
                col.op = type_config.aggregate;
            }
            aggregates.push(col);
        } else {
            console.warn(`No column "${col.column}" found (specified in aggregates attribute).`);
        }
    }

    // Add columns detected from dataset.
    for (const col of cols) {
        if (!found.has(col)) {
            aggregates.push({
                column: col,
                op: get_type_config(schema[col]).aggregate
            });
        }
    }

    return aggregates;
}
github finos / perspective / packages / perspective-viewer / src / js / viewer / perspective_element.js View on Github external
function get_aggregates_with_defaults(aggregate_attribute, schema, cols) {
    const found = new Set();
    const aggregates = [];
    for (const col of aggregate_attribute) {
        const type = schema[col.column];
        const type_config = get_type_config(type);
        found.add(col.column);
        if (type_config.type || type) {
            if (col.op === "" || perspective.TYPE_AGGREGATES[type_config.type || type].indexOf(col.op) === -1) {
                col.op = type_config.aggregate;
            }
            aggregates.push(col);
        } else {
            console.warn(`No column "${col.column}" found (specified in aggregates attribute).`);
        }
    }

    // Add columns detected from dataset.
    for (const col of cols) {
        if (!found.has(col)) {
            aggregates.push({
                column: col,
github finos / perspective / packages / perspective-viewer / src / js / custom_styles.js View on Github external
function get_type_deps() {
    const types = {"": []};
    for (const type of get_types()) {
        types[type] = [];
        let parent = type;
        while (parent && parent.length) {
            types[type].unshift(parent);
            parent = get_type_config(parent).type;
        }
    }
    return types;
}
github finos / perspective / packages / perspective-viewer / src / js / viewer / dom_element.js View on Github external
_new_row(name, type, aggregate, filter, sort, computed) {
        let row = document.createElement("perspective-row");
        type = type || this._get_type(name);

        if (!aggregate) {
            let aggregates = this.get_aggregate_attribute();
            if (aggregates) {
                aggregate = aggregates.find(x => x.column === name);
                if (aggregate) {
                    aggregate = aggregate.op;
                } else {
                    aggregate = get_type_config(type).aggregate;
                }
            } else {
                aggregate = get_type_config(type).aggregate;
            }
        }

        if (filter) {
            row.setAttribute("filter", filter);

            if (type === "string") {
                const view = this._table.view({row_pivots: [name], aggregates: {}});
                view.to_json().then(json => {
                    row.choices(this._autocomplete_choices(json));
                });
                view.delete();
            }
github finos / perspective / packages / perspective-viewer / src / js / row.js View on Github external
_set_data_transfer(event) {
        if (this.hasAttribute("filter")) {
            const {operator, operand} = JSON.parse(this.getAttribute("filter"));
            event.dataTransfer.setData("text", JSON.stringify([this.getAttribute("name"), operator, operand, this.getAttribute("type"), this.getAttribute("aggregate")]));
        } else {
            event.dataTransfer.setData(
                "text",
                JSON.stringify([this.getAttribute("name"), get_type_config(this.getAttribute("type")).filter_operator, undefined, this.getAttribute("type"), this.getAttribute("aggregate")])
            );
        }
        this.dispatchEvent(new CustomEvent("row-drag"));
    }
github finos / perspective / packages / perspective-viewer / src / js / viewer / dom_element.js View on Github external
_new_row(name, type, aggregate, filter, sort, computed) {
        let row = document.createElement("perspective-row");
        type = type || this._get_type(name);

        if (!aggregate) {
            let aggregates = this.get_aggregate_attribute();
            if (aggregates) {
                aggregate = aggregates.find(x => x.column === name);
                if (aggregate) {
                    aggregate = aggregate.op;
                } else {
                    aggregate = get_type_config(type).aggregate;
                }
            } else {
                aggregate = get_type_config(type).aggregate;
            }
        }

        if (filter) {
            row.setAttribute("filter", filter);

            if (type === "string") {
                const view = this._table.view({row_pivots: [name], aggregates: {}});
                view.to_json().then(json => {
                    row.choices(this._autocomplete_choices(json));
                });
                view.delete();
            }
        }

        if (sort) {
github finos / perspective / packages / perspective-viewer / src / js / row.js View on Github external
set type(t) {
        const elem = this.shadowRoot.querySelector("#name");
        const type = this.getAttribute("type");
        if (!type) return;
        const type_config = get_type_config(type);
        if (type_config.type) {
            elem.classList.add(type_config.type);
        }
        elem.classList.add(type);
        const agg_dropdown = this.shadowRoot.querySelector("#column_aggregate");
        const filter_dropdown = this.shadowRoot.querySelector("#filter_operator");

        render(this._select_template("TYPE_AGGREGATES", type_config.type || type), agg_dropdown);
        render(this._select_template("TYPE_FILTERS", type_config.type || type), filter_dropdown);

        if (!this.hasAttribute("aggregate")) {
            this.aggregate = type_config.aggregate;
        } else {
            this.aggregate = this.getAttribute("aggregate");
        }
        if (this.hasAttribute("filter")) {
github finos / perspective / packages / perspective-viewer / src / js / viewer / perspective_element.js View on Github external
function get_aggregate_defaults(schema, cols) {
    const aggregates = {};
    for (const col of cols) {
        aggregates[col] = get_type_config(schema[col]).aggregate;
    }
    return aggregates;
}