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": {
caption: "Color",
type: "string"
},
"Country": {
caption: "Country",
type: "string"
},
"State": {
caption: "State",
type: "string"
},
"City": {
caption: "City",
type: "string"
},
"Price": {
caption: "Price",
type: "number"
},
"Quantity": {
caption: "Quantity",
type: "number"
}
/*},
{
"Color" : "green",
"Country" : "Canada",
"State" : "Ontario",
"City" : "Toronto",
"Price" : 174,
"Quantity" : 22
},
{
"Color" : "red",
"Country" : "USA",
"State" : "California",
"City" : "Los Angeles",
"Price" : 166,
"Quantity" : 19*/
}];
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: jsonData
},
slice: {
rows: [{
uniqueName: "Color",
filter: {
exclude: ["color.[green]"]
}
},
{
uniqueName: "[Measures]"
}
],
columns: [{
uniqueName: "Country"
}],
measures: [{
uniqueName: "Price",
aggregation: "sum"
}]
}
}
});
function updateDataJSON() {
var jsonData = [{
"Color": {
caption: "Color",
type: "string"
},
"Country": {
caption: "Country",
type: "string"
},
"State": {
caption: "State",
type: "string"
},
"City": {
caption: "City",
type: "string"
},
"Price": {
caption: "Price",
type: "number"
},
"Quantity": {
caption: "Quantity",
type: "number"
}
},
{
"Color": "green",
"Country": "Canada",
"State": "Ontario",
"City": "Toronto",
"Price": 174,
"Quantity": 22
},
{
"Color": "red",
...