Hello friends I want to create dynamic array of x-y coordinate with help of JSON array value so below JSON value
"data": [
{
"x_value": 1,
"y_value": 1527116400
},
{
"x_value": 43.45,
"y_value": 1527030000
},
{
"x_value": 43.95,
"y_value": 1526943600
},
{
"x_value": 43.95,
"y_value": 1526857200
},
{
"x_value": 44.05,
"y_value": 1526598000
},
{
"x_value": 44.25,
"y_value": 1526511600
},
{
"price": 44.1,
"y_value": 1526425200
},
{
"x_value": 44.3,
"y_value": 1526338800
},
{
"x_value": 44.25,
"y_value": 1526252400
}
]
My Js code as below
var data = null;
var array_data = response.sData.chart_data;
for (let index = 0; index < chart_data.length; index++) {
data.push({ array_data[index].x_value, y: chart_data[index].y_value });
}
When I run above code I get error message like;
TypeError: null is not an object (evaluating 'data.push')
Any idea how can I solve this? Your all suggestions are appreciable.
var data =[]:|Array.prototype.push()on a boolean variable