Problem fetching HBar or Rose dataset


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by prakash on 2nd October 2016
i am trying to attach an onclick event to my graphs, I have following code working for Bar charts but it does not return dataset with Horizontal Bar chart OR Rose chart

this.graphInstance.onclick = (e, shape)=>{
            
             var obj = e.target.__object__;
             var ca = obj.canvas;
             var idx = shape.index;
             var dataset = shape['dataset'];
            
             console.log("dataset == "+dataset);
             console.log("index = "+idx);
             console.log(" label = " + JSON.stringify(this.graphInstance.get('labels')));
             console.log(" key = " + JSON.stringify(this.graphInstance.get('key')));
             console.log(" data = " + JSON.stringify(this.graphInstance.data));
         };


How can we get the Dataset for Horizontal bar charts
Posted by Richard on 2nd October 2016
Hi there,

Well the Rose chart index in the shape object appears to be broken - so I'll take a look at that.

The HBar doesn't have the dataset property - just the index property - which is a sequential index of the bar.

With that however you can get the "group" index by using this API function:


RGraph.sequentialIndexToGrouped(index, data);


Here's an example of it:

www.rgraph.net/fiddle/view.html/hbar-showing-a-click-handler


Richard
Posted by Richard on 2nd October 2016
Hi there,

As it turns out, the Rose chart isn't broken - here's an example of fetching the index (using the same sequentialIndexToGrouped() function):

www.rgraph.net/tests/rose-click-index.html


Richard
Posted by prakash on 4th October 2016
Thanks a lot for your help :)
sequentialIndexToGrouped() function is of good help.

Add a reply

 




« Back to message list
RGraph on social media