Sign in to follow this  
kevincorsigon

Can I get information of a data object from html ( dom )

Recommended Posts

hello, I need to somehow get the information from one point of my chart by javascript, I need the information about the category, series name and value to use in a javascript function. Currently inserted already own a javascript function on my link properties however I could not find it through the DOM.

My goal is to find the object on the screen through the information they already have in my application for example: get the point of my line chart que have the value 7, category '12: 00 ', and series-name' test 'for that in some cases I will be able to add a popover on the circle, rect or other object that has the specific values​​.

 

 

Can anyone help me???

Share this post


Link to post
Share on other sites

Hi,

 

Welcome to FusionCharts Forum.

 

Do you want to obtain the XML data of the chart in HTML DOM and then obtain the series name of the dataset of chart ?  If yes, please check if the below given code suits your requirement:

 
var xmlStr=FusionCharts("myChartId").getXMLData();
var xmlObj=( new window.DOMParser() ).parseFromString(xmlStr, "text/xml");
var y=xmlObj.getElementsByTagName("dataset")[0];
alert(y.getAttribute("seriesName"));

The code snippet given above finds the DOM of the chart, and then uses the DOM parser of window to convert the XML string into an XML object. Then, you may obtain the tag that you are searching for and retrieve its attributes. The above code alerts the series name of the first dataset element in a Multi-series chart.

 

Awaiting your feedback.

Share this post


Link to post
Share on other sites

Thanks Haritha i will try to adapt your code.

I need to get the DOM element that have a especific attribute. I already have in my aplication the information about a chart point and i want to get the <circle> element form example that represents this information. Is that possible?

Share this post


Link to post
Share on other sites

Hi,

 

Are you trying to obtain the attributes of <circle> element from SVG data of chart? If yes, then you may try using the below given code :

var xmlStr=$("#chartContainer").html(); 
var xmlObj=( new window.DOMParser() ).parseFromString(xmlStr, "text/xml");
var y = xmlObj.getElementsByTagName("circle")[0];
alert(y.getAttribute("fill")); // obtain other attributes in the similar way

You may obtain the other attributes of "circle" element like "cx","cy","stroke"  etc in the similar way.

 

Hope this helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this