Home Forums Chart Support CanvasJS.formatDate() only sees one valid date for X axis labels

CanvasJS.formatDate() only sees one valid date for X axis labels

Viewing 3 posts - 1 through 3 (of 3 total)
  • #15387

    I have just started working with CanvasJS today.

    My datasource is an external API from which I receive JSON.

    I build the datapoints array and feed it date objects and integers using

    dataPoints.push({label: new Date(json.dataset.data[key][0]), y: json.dataset.data[key][1]});

    I set the X axis labels with the following

    axisX:{
        labelFormatter: function (e) {
        return CanvasJS.formatDate( e.value, "MMM YYYY");
        }
    }

    The line graph is perfect and hovering shows dates formatted “Wed Aug 17 2016 19:00:00 GMT-0500 (Central Daylight Time)”.

    The X axis shows a first label of Jun 2017 which should be the last entry. The others all show Dec 1968 indicating that the date was not parsable.

    But the dates are correctly displayed in the line itself so one assumes they were successfully converted to Date objects and used there.

    How do I correct this?

    http://jsfiddle.net/wevy4c92/1/

    #15389

    @jerrygarciuh,

    You should use x instead of using labels while pushing into dataSeries. Please, check the updated jsFiddle.

    —-
    Bivek Singh,
    Team CanvasJS

    #15401

    Thank you so much… What a newbie error. Y’all rock!

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

You must be logged in to reply to this topic.