trouble with highchart and .clone()

2019-07-24 21:46发布

I don't understand how I'm supposed to use jQuery .clone() when i'm cloning an highchart. I know that .clone() doesn't link the methods on objects. So the clone of the highchart looked correct, but you couldn't interact with it anymore. SO, I've been trying the following :

function clonage(src){
    var clone = src.clone(false);
    if (clone.hasClass("highchart")){
        clone.highcharts({});
    }
}

By doing this, I've got back the interactions with the chart (the chart is blank), but this is destroying the original of the clone (ie src) which is now only a blank widget. I would like to be able to recreate the exact same chart without embedding all the chart information to recreate it. If anyone has an idea in order to do this?

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-07-24 22:10

Have you tried using jquery .extend ? Seems to work for me.

var clone = $.extend(true, {}, $obj);
查看更多
登录 后发表回答