Home Forums Chart Support YYYYDDMM XAxis using JSON


Viewing 2 posts - 1 through 2 (of 2 total)
  • #28816

    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:

    and I’m only pulling date and positive:
    function addData(data) {
    for (var i = 0; i < data.length; i++) {
    x: new Date(data[i].date),
    y: data[i].positive

    The xaxis is displaying as ‘326ms’ rather than ’03/26/2020′.
    How can I format this date properly?



    Passing x-value in one of the valid JavaScript Date-Formats should work fine in this case. Please take a look at this JSFiddle for an example on parsing date to ISO standard [new Date(“2020-03-05”)].

    Vishwas R
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.