Razor Storm
Razor Storm

Reputation: 12336

r.g is undefined in graphael?

Based on the graphael documentation I am supposed to draw charts like this:

var r =Raphael('blah');
var chart = r.hbarchart(...);

Then I attempted to add a gradient and saw people doing like this:

var r = Raphael('blah');
var chart = r.g.hbarchart(...);

chart.shades[0].attr({...});

I tried:

chart.shades[0].attr({...});

but the browser complained that chart.shades is undefined. So I decided maybe if I change r.hbarchart({...}); into r.g.hbarchart({...}); it will work.

However, now it says r.g is undefined.

Upvotes: 0

Views: 1093

Answers (2)

Ebin John
Ebin John

Reputation: 51

I believe you are using the latest version of g.line.js. They have removed the namespace r.g from .05 version. Going forward namespace g will not be available. But the methods has been integrated with the Raphael object. So if you using the latest versions, instead of using r.g.hbarchart you can just use r.hbarchart. If you do that you will get the chart.shades array and you can use like chart.shades[0].attr...

The version history says " g is no longer a namespace, but instead a prototype object that all charts inherit" .

I have had the same issue when i started working, but after spending some time on firebug i was able to figure out the issue.

Upvotes: 1

Rajat Singhal
Rajat Singhal

Reputation: 11264

Yes the same problem I faces some days ago..and couldn't reach any valid conclusion..

But in order to get it working what you can do is download the repo on github I am giving link and include those libs which are in the repo and follow the examples in the repo..you'll be able to use r.g...

Repo on github with all working deomos..

The reason I could understand is that they have changed r.g to r. for all types of graphs and normal vector images..thats why we can't use r.g....and irony is that we can't use the other advanced features like label, shades with r.

Upvotes: 2

Related Questions