Home forums Using CanvasJS Uncaught TypeError: Cannot read property 'getTime' of undefined

This topic contains 2 replies, has 2 voices, and was last updated by  Mudassir 3 months, 2 weeks ago.

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


    I am facing an issue when updating the datapoints of canvas chart, and the error message says “Uncaught TypeError: Cannot read property ‘getTime’ of undefined”. Below is my html (I am making ajax call to update the datapoints)

    <script type="text/javascript">
        function GetGraph(val) {
                autoOpen: false,
                modal: true,
                title: "Graph"
                type: 'POST',
                url: '/Ranking/ReturnKeywordGraph',
                contentType: "application/json; charset=utf-8",
                dataType: 'html',
                data: '{keywordId: "' + val + '" }'
            }).success(function (response) {
                var chart = new CanvasJS.Chart("chartContainer",
                    title: {
                    animationEnabled: true,
                    axisX: {
                        interval: 3
                    axisY: {
                    legend: {
                        verticalAlign: "bottom",
                        horizontalAlign: "center"
                    data: [{
                        name: "Graph Overview",
                        showInLegend: true,
                        legendMarkerType: "square",
                        type: "area",
                        color: "#0990B0",
                        markerSize: 0,
                        dataPoints: [
            }).error(function (response) {
    <div id="dialogOpen" style="display: block; width:100%;">
                            <div id="chartContainer" style="height: 289px; width: 100%;">

    The output I receive in response is “{x: new Date(2017, 10, 20),y: 10},{x: new Date(2017, 10, 17),y: 15},” which when replaced with “response” renders the chart successfully. But passing response to datapoints gives the error.

    Any help ????


    Suyash Singh


    dataPoints is an array of objects. Seems like you are passing a string
    ("{x: new Date(2017, 10, 20),y: 10},{x: new Date(2017, 10, 17),y: 15}") to it instead of an object. You need to parse your data and convert it to object.

    If this doesn’t suit your requirements, Can you please create a jsfiddle, along with your sample data, reproducing the issue?

    Suyash Singh
    Team CanvasJS



    @Suyash Singh
    Thanks mate, I got it working, thanks for the helping response.

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

You must be logged in to reply to this topic.