Using the https://canvasjs.com/javascript-charts/json-data-api-ajax-chart/ with data from $.getJSON(“https://covidtracking.com/api/us/daily”, addData);
Data coming in looks like:
{“date”:20200330,”states”:56,”positive”:160530,”negative”:784324,”posNeg”:944854,”pending”:65382,”hospitalized”:22303,”death”:2939,”total”:1010236,”hash”:”5d6b80da84d18b345f21f914f55a72520c680310″,”dateChecked”:”2020-03-30T20:00:00Z”,”totalTestResults”:944854,”deathIncrease”:511,”hospitalizedIncrease”:2573,”negativeIncrease”:92034,”positiveIncrease”:21469,”totalTestResultsIncrease”:113503},
and I’m only pulling date and positive:
function addData(data) {
for (var i = 0; i < data.length; i++) {
dataPoints.push({
x: new Date(data[i].date),
y: data[i].positive
});
}
chart.render();
The xaxis is displaying as ‘326ms’ rather than ’03/26/2020′.
How can I format this date properly?