Actually i'm parsing some data from MySQL then i serialize them as JSON. The next step is where i retrive the JSON via AJAX and put the data in a Chart.JS.
The issue is that the date values are formatted as
/Date(154564434687)/
Here is the JQuery code where i set the values to the chart from parsed JSON
function GetMOV() {
$.ajax({
type: "post",
url: "index.aspx/GetMOV",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
data = r.d;
data = jQuery.parseJSON(data)
new Chart(document.getElementById("linechart"), {
type: 'line',
data: {
labels: data.map(f => f.text),
datasets: [
{
label: "Venduto",
data: data.map(f => f.value),
fill: false,
borderColor: 'rgba(75,192,192,1)',
lineTension: 0.1,
borderWidth: 3,
pointBackgroundColor: '#fff',
pointBorderWidth: 1,
pointHoverRadius: 5,
borderCapStyle: 'square',
borderJoinStyle: 'square',
pointHitRadius: 20,
pointStyle: 'circle',
}
]
},
options: {
legend: { display: false },
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
min: 0
},
time: {
unit: 'year'
}
}]
}
}
});
},
error: function (error) {
OnFailure(error);
alert('Error');
}
});
}