Home forums Chart Support Uncaught TypeError: Cannot read property 'getTime' of undefined

Viewing 8 posts - 1 through 8 (of 8 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 ????



    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.


    Hi Mudassir
    I am facing same problem,can u tell me how did it worked



    You’ll be able to render the chart by passing valid dataPoints. Seems like you are passing a string to dataPoint array instead of an object. In case you’re fetching the data from JSON data source, parse the received data to the format accepted by CanvasJS.

    In case you’re still facing the issue, can you please create a JSFiddle reproducing the issue so that we can look into it and help you out?

    Shashi Ranjan
    Team CanvasJS


    This error occurs in Chrome Browser when you read a property or call a method on an undefined object . Uncaught TypeError: Cannot read property of undefined error is probably easiest to understand from the perspective of undefined, since undefined is not considered an object type at all (but its own undefined type instead), and properties can only belong to objects within JavaScript. There are a few variations of this error depending on the property you are trying to access. Sometimes instead of undefined it will say null.


    Hello sir,
    Sir, I have also the same output “{‘x’:new Date(2020,02,24),’y’:2},”. As you said then I tried to parse the string after that then this error are come “Uncaught SyntaxError: Unexpected token e in JSON at position 6”.
    I need your help!!



    Can you kindly create a sample project reproducing the issue and share it with us over Google-Drive or Onedrive along with sample JSON data so that we can look into the code, run it locally to understand the scenario better and help you resolve?

    Shashi Ranjan
    Team CanvasJS

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

You must be logged in to reply to this topic.