Custom data source API

Data source

by juvian

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<div id="pivot-container"></div>

JavaScript

let fields = {
    "filters": {
        "advanced": true,
        "string": {
            "members": true
        }
    },
    "aggregations": {
        "number": [
            "sum",
            "avg",
            "min",
            "max"
        ]
    },
    "fields": [
        {
            "uniqueName": "item.title",
            "caption": "Título Publicación",
            "type": "string"
        },
        {
            "uniqueName": "sale.sales_amount",
            "type": "number",
            "caption": "Ventas $",
            "metadata": {
                "select": "sales_amount - COALESCE(LAG(sales_amount) over w, 0)"
            }
        },
        {
            "uniqueName": "sale.sales_amount_usd",
            "type": "number",
            "caption": "Ventas USD",
            "aggregations": [
                "sum"
            ],
            "metadata": {
                "select": "sales_amount_usd - COALESCE(LAG(sales_amount_usd) over w, 0)"
            }
        },
        {
            "uniqueName": "sale.units_sold",
            "type": "number",
            "caption": "Unidades Vendidas",
            "metadata": {
                "select": "units_sold - COALESCE(LAG(units_sold) over w, 0)"
            }
        },
        {
            "uniqueName": "item.price",
            "caption": "Precio actual",
            "type": "number"
        },
        {
            "uniqueName": "item.brand_id",
            "type": "string",
            "caption": "Marca"
        },
        {
            "uniqueName": "item.seller_id",
            "type": "string",
            "caption": "Vendedor"
        },
        {
            "uniqueName": "item.category_id_1",
            "type": "string",
            "caption": "Categoria Nivel 1",
            "filters": {
                "members": true,
                "advanced": true
            },
            "metadata": {
                "tables": [
                    "item_new",
                    "category",
   ...