Trying to Add For Loop Value to an Array
My Current View
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<style>
body {
font-family: Roboto, sans-serif;
}
#chart {
max-width: 650px;
margin: 35px auto;
}
</style>
<div id="chart">
</div>
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
debugger;
var cval = "In-Progress";
$.ajax({
type: "Post",
url: '@Url.Action("GetProjectList", "Dashboard")',
datatype: "Json",
data: { status: cval },
success: function (data) {
debugger;
console.log(data);
var catagorydata = new Array();
var Estimation = new Array();
for (var i = 0; i < data.data.length; i++) {
catagorydata.push[data.data[i].ProjectID];
Estimation.push[data.data[i].EstimatedValue];
}
var options = {
chart: {
type: 'line'
},
series: [{
name: 'sales',
data: Estimation
}],
xaxis: {
categories: catagorydata
}
}
var chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render();
}
})
});
</script>
After receiving 5 values in the data array within the Ajax success function, I am trying to store them in the categorydata and Estimation arrays using a for loop. However, the values are not being stored in the arrays as expected.
catagorydata.push[data.data[i].ProjectID];
Estimation.push[data.data[i].EstimatedValue];
The arrays categorydata and Estimation should store the values from the for loop, but they seem to be empty. Assistance in resolving this issue would be highly appreciated.