Product aggregation

Slice configuration

by Flexmonster Pivot Table

HTML

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

<p>
  In this example, the <code>"product"</code> aggregation is used to calculate a
  product of prices depending on a country and color.
</p>

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

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

JavaScript

const pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  report: {
    dataSource: {
      data: getData()
    },
    slice: {
      rows: [{
        uniqueName: "Country"
      }],
      columns: [{
        uniqueName: "Color"
      }, {
        uniqueName: "[Measures]"
      }],
      measures: [{
        uniqueName: "Price",
        aggregation: "product"
      }]
    }
  }
});

function getData() {
  return [
    {
      "Color" : "green",
      "Country" : "Canada",
      "City" : "Toronto",
      "Price" : 174,
      "Quantity" : 22
    },
    {
      "Color" : "red",
      "Country" : "USA",
      "City" : "Los Angeles",
      "Price" : 166,
      "Quantity" : 19
    },
    {
      "Color" : "blue",
      "Country" : "USA",
      "City" : "Tallahassee",
      "Price" : 215,
      "Quantity" : 25
    },
    {
      "Color" : "black",
      "Country" : "Canada",
      "City" : "Montreal",
      "Price" : 194,
      "Quantity" : 15
    },
    {
      "Color" : "red",
      "Country" : "Canada",
      "City" : "Montreal",
      "Price" : 123,
      "Quantity" : 12
    },
    {
      "Color" : "blue",
      "Country" : "Canada",
      "City" : "Toronto",
      "Price" : 189,
      "Quantity" : 31
    },
    {
      "Color" : "black",
      "Country" : "USA",
      "City" : "New York",
      "Price" : 312,
      "Quantity" : 32
    },
    {
      "Color" : "black",
      "Country" : "USA",
      "City" : "New York",
      "Price" : 246,
      "Quantity" : 21
    },
    {
      "Color" : "black",
      "Country" : "Canada",
      "City" : "Ontario",
      "Price" : 241,
      "Quantity" : 20
    },
    {
      "Color" : "green",
      "Country" : "USA",
      "City" : "Los Angeles",
      "Price" : 243,
      "Quantity" : 23
    },
    {
      "Color" : "blue",
      "Country" : "Canada",
      "City" :...