Reputation: 37
I am using Polymer 1 in my project . I am using array type polymer property in this property i want to hold or store elements in _extractTimeSeriesData callback .below is the piece of code which i am using . this callback is executing whenever i am getting response from Rest API . Here i want to store elements in _series property as (self._series.push({ x: point[0], y0: (1 - (point[1])) * 100 });
but while executing code i am getting error as Uncaught TypeError: self._series.push is not a function
Polymer({
is: 'test-view',
behaviors: [GlobalsBehaviour],
properties: {
timeSeriesData: {
type: Object,
observer: '_extractTimeSeriesData'
},
_series: {
type :Array,
value :[]
},
_extractTimeSeriesData: function (raw) {
if (raw !== null) {
tagsArray = raw.tags;
for (var i = 0; i < tagsArray.length; i++) {
if (this.ltuTag == tagsArray[i].name) {
var datapoints = raw.tags[i].results[0].values;
var self = this;
datapoints.forEach(function (point) {
self._series.push({ x: point[0], y0: (1 - (point[1])) * 100 });
});
console.log("chart data value is", _series);
}
}
}
},
i tried to use first this._series.push({ x: point[0], y0: (1 - (point[1])) * 100 }); but it didnt work then also i tried to refer this using varible as self as above code but this is not working .
Can anyone please tell me how can i store elements in Array Type polymer property.
Upvotes: 1
Views: 87
Reputation: 1259
You have to call self.push('_series', dataStuff)
. Polymer 1 does wrap the default manipulation methods for you. So to change your properties you have to call this.push('propName', value)
or this.set('propName', value)
or this.splice('propName', value)
etc.
Upvotes: 4