Set localization for all reports

Global object

by Flexmonster Pivot Table

HTML

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

<div>
  <h2>How to set localization for all reports</h2>
  <p>
  You can set localization for all reports via the <code>localization</code> property of the <a href="https://www.flexmonster.com/api/global-object/" target="_blank">GlobalObject</a>.
  </p>
  <p>
  In this example, we've applied Spanish localization (lines 5-7 in the JavaScript box). Try setting different reports and notice that component's localization is not changed. 
  </p>
  <p>
  <a href="https://www.flexmonster.com/doc/localizing-component/" target="_blank">Visit our docs to learn more about localizing the component</a>.
  </p>
</div>

<button onclick="setReport(report1)">Set Report 1</button>
<button onclick="setReport(report2)">Set Report 2</button>

<div id="pivot-container">The component will appear here</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,
  global: {
    localization: "loc/es.json"
  }
});

function setReport(report) {
  pivot.setReport(report);
}

let report1 = {
	dataSource: {
  	filename: "data/data-es.csv"
  },
  slice: {
  	rows: [{
    	uniqueName: "Categoría",
      filter: {
      	exclude: [
        	"categoría.[accesorios]",
          "categoría.[bicicletas]"
        ]
      }
    }],
    columns: [
    	{
      	uniqueName: "País"
      },
      {
      	uniqueName: "[Measures]"
      }
    ],
    measures: [{
      uniqueName: "Precio"
    }]
  }
};

let report2 = {
	dataSource: {
    filename: "data/data-es.csv"
  },
  slice: {
    rows: [{
      uniqueName: "Destino"
    }],
    columns: [
     {
        uniqueName: "Tipo de Negocio",
        filter: {
          members: [ "tipo de negocio.[almacén]" ]
        }
      },
      {
        uniqueName: "[Measures]"
      }
    ],
    measures: [{
      uniqueName: "Precio"
    }]
  }
};