Graph Raphael.js error

Asked

Viewed 78 times

0

I’m creating a line chart using the library Raphael.js. I used an example, added all the scripts and got an error in my browser:

"Cannot read property 'linechart' of undefined".

The example is very simple:

<head>
    <title>gRaphaël Line Chart - a simple line chart example</title>
   <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/graphael/0.5.1/g.raphael-min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/graphael/0.5.1/g.line-min.js"></script>
    <script type="text/javascript">
        window.onload = function() {
            // Creates canvas 640 × 480 at 10, 50
           var r = Raphael(10, 50, 640, 480);

            // Creates a simple line chart at 10, 10
            // width 300, height 220
            // x-values: [1,2,3,4,5], y-values: [10,20,15,35,30]
            r.g.linechart(10,10,300,220,[1,2,3,4,5],[10,20,15,35,30]);
        }
    </script>
</head>
<body>  
        <div id="holder"></div>
</body>

1 answer

2


The correct is:

r.linechart(10,10,300,220,[1,2,3,4,5],[10,20,15,35,30]);

What the error says is that there is no "g" property in "r" and therefore there is no "linechart" property in it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.