TheWitness

Just Updated to 3.15.2 and clone() No Longer Working

Recommended Posts

I've just recently upgrade from 3.11.x to 3.15.2 and it solved a "massive" memory leak, so thanks.  However, when I try to clone() a chart now, either by the charts Id or through it's variable name, it's coming back with no data to display.  Code looks something like this:

<snip>

if (FusionCharts(chartid)) {
    //var newPanel = FusionCharts(chartid).clone();
    var newPanel = charts[panel].clone();
    newPanel.render('fullscreen')
    newPanel.resizeTo(width, height);
}

<snip>

The array charts[panel] holds the chart object, but you can see the line above the clode, which was the way I was cloning it before upgrading.  Tried both way and nada.

Thanks,

TheWitness

Edited by TheWitness

Share this post


Link to post
Share on other sites

That's what I used as the model for the clone() in the first place, and thanks for that.  It was working prior to the update to 3.15.2.  Let me have a look though.  Before I was searching the DOM for the chart object, and I did not assign and "id" in the "new FusionCharts({})" call of the parent object.  So, there were other changes.  But it's presently close to the jsfiddle example.

Share this post


Link to post
Share on other sites

I did multiple things Ayan and nothing worked.

The big change that I did was label the object using the following:

FusionCharts({
  id: 'chart_pane_id',
  ...
});

As soon as I name the ID of the object using that call, the clone basically starts complaining that it can not find data and says no data to display even though when I use the debugger, the parent dom object has the right ID and the FusionCharts(chart_panel_id) returns object as expected.  The clone simply fails, the resize just fails.

Could it be that the use of the JSON tag "id" though it works, is not supported?

By the way, I was able to clone the SVG using jQuery just fine and insert it, but then I lost the ability to resize :( Basically:

var chartObject = $('#chart_panel_id')
$(''#fullscreen').html(chartObject);

Edited by TheWitness

Share this post


Link to post
Share on other sites

Ayan,

Just getting back to this now.  I think I see the problem.  The chart that was properly cloned (I guess), but the "originalDataSource" value is set to undefined.  On the original chart, the originalDataSource was populated via a callback with XML data.  Do I have to grab the data again via a callback, or is there a way to clone that data as well?

Larry

Share this post


Link to post
Share on other sites

Okay, figured it out.  I not only had to clone the chart, but insert the data:

<snip>
var newPanel = charts[panel].clone();
var chart_xml = charts[panel].originalDataSource;
newPanel.setXMLData(chart_xml);
newPanel.render('fullscreen')
newPanel.resizeTo(width, height);
<snip>

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