Inheriting default format properties in formats for specific measures

Number formatting

by Flexmonster Pivot Table

HTML

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

<div>
  <h2>Inheriting default format properties in formats for specific measures</h2>
  <p>
    This example shows that number format properties inherit values from the
    default format when they are not defined for specific measure.
  </p>
  <p>
    Notice that the <code>thousandsSeparator</code> is set to
    <code>","</code> in the default format (line 11 in the JavaScript box).
    Since this property is not defined in the <code>"currency"</code> and
    <code>"amount"</code> formats, they inherit the
    <code>thousandsSeparator</code>'s value from the default format.
  </p>
</div>

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

CSS

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

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      filename: "data/data.csv"
    },
    formats: [{
        name: "",
        thousandsSeparator: ","
      },
      {
        name: "currency",
        currencySymbol: "$"
      },
      {
        name: "amount",
        decimalPlaces: 0,
        currencySymbol: " pcs.",
        positiveCurrencyFormat: "1$"
      }
    ],
    slice: {
      rows: [{
        uniqueName: "Category"
      }],
      measures: [{
          uniqueName: "Price",
          aggregation: "sum",
          active: true,
          format: "currency"
        },
        {
          uniqueName: "Discount",
          aggregation: "sum",
          active: false,
          format: "currency"
        },
        {
          uniqueName: "Quantity",
          aggregation: "sum",
          active: true,
          format: "amount"
        }
      ]
    }
  }
});