API call updateData for updating the data without cleaning the report
Data source
by jesperra
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<button onclick="updateDataJSON()">Update data from inline JSON</button>
<div id="pivot-container"></div>
JavaScript
var jsonData = [
{
"Color": {
"type": "string",
"caption": "Color"
},
"Country": {
"type": "string",
"caption": "Country"
},
"State": {
"type": "string",
"caption": "State"
},
"City": {
"type": "string",
"caption": "City"
},
"Price": {
"type": "number",
"caption": "Price"
},
"Quantity": {
"type": "number",
"caption": "Quantity"
}
},
{
"Color" : "green",
"Country" : "Canada",
"State" : "Ontario",
"City" : "Toronto",
"Price" : 170454,
"Quantity" : 22
},
{
"Color" : "red",
"Country" : "USA",
"State" : "California",
"City" : "Los Angeles",
"Price" : 166558,
"Quantity" : 19
}
];
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: jsonData
},
slice: {
rows: [
{ uniqueName: "Color" },
{ uniqueName: "[Measures]" }
],
columns: [
{
uniqueName: "Country",
filter: {
exclude: [ "country.[Canada]" ]
}
}
],
measures: [
{
uniqueName: "Price",
aggregation: "sum"
}
]
},
formats: {
name: "",
thousandsSeparator: ".",
decimalSeparator: ",",
decimalPlaces: 2
}
}
});
function updateDataJSON() {
var jsonData = [
{
"Color" : "green",
"Country" : "Canada",
"State" : "Ontario",
"City" : "Toronto",
"Price" : 170454,
"Quantity" : 22
},
{
"Color" : "blue",
"Country" : "Denmark",
"State" : "",
"City" : "Copenhagen",
"Price" : 25602256,
"Quantity" : 13
}];
flexmonster.updateData({ data: jsonData });
}