Default slice

Slice configuration

by Flexmonster Pivot Table

HTML

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

<div>
  <p>This examples demonstrates how the default slice is composed.<br /></p>
  <p>
    If a slice was not defined in the report, Flexmonster will show a default
    slice, where the first non-numeric (string or date) field from the data goes
    to rows and the first numeric field goes to columns.
    <a href="https://www.flexmonster.com/doc/slice/#default-slice" target="_blank"
      >Learn more in our documentation</a
    >.
  </p>
  <p>
    In this example, <code>"Category"</code> is the first string field, so it
    goes to rows. <code>"Price"</code> is the first numeric field, so it goes to
    measures.
  </p>
</div>

<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/",
  height: 300,
  report: {
    dataSource: {
      data: getData()
    }
  }
});

function getData() {
  return [{
      "Category": "Accessories",
      "Country": "Canada",
      "Price": 125,
      "Quantity": 100
    },
    {
      "Category": "Accessories",
      "Country": "France",
      "Price": 74,
      "Quantity": 235
    },
    {
      "Category": "Bikes",
      "Country": "USA",
      "Price": 233,
      "Quantity": 184
    }
  ]
}