I have a JSON file (containing an integer array) to which a I send a <iron-ajax>
request and retrieve the response. I want to process the response (an the integer array) and increment all the values in the integer array by one on a button-click.
Every time I click the button, it should increment the value by 1.
My element template:
<iron-ajax
url="/api/time-series/simple-data/4"
last-response="{{_simpleDataValuesA}}"
auto>
</iron-ajax>
<h1> /* Where I would like the entire updated array to be shown when I press the BUTTON to increment */
My Polymer definition:
Polymer({
is: 'new-page',
properties: {
_simpleDataValuesA: {
type: Object
},
_cal: {
type: Array,
computed: 'cal_incr(_simpleDataValuesA)'
}
},
cal_incr:function(_simpleDataValuesA){
var a = this._simpleDataValuesA.data.values[0];
a.forEach(function increment(item,index,a) {
a[index]+=1;
})
console.log('array -- >',a);
console.log('this._simpleDataValuesA.data.values[0] -- >',this._simpleDataValuesA.data.values[0]);
this._simpleDataValuesA.data.values[0]=a;
return this._simpleDataValuesA.data.values;
}
});
My JSON File:
{
"id": 4,
"data": {
"labels": ["acvc","b","a","b","a"],
"values": [[112,57,53,122,128,120,56]]
}
}