2017-04-03 30 views
1

我在这里有一个AmCharts的例子,我已经做了拖拽功能,但是我需要将图表放入容器中并且适合尺寸。有人知道吗?感谢您的帮助容器的位置图

这里是提琴:

http://jsfiddle.net/ngg2f5gz/1/

拖动ñ下降功能

$(function() { 
    $("#chartdiv").draggable(); 
    $("#container").droppable({ 
     drop: function(event, ui) { 
     $(this) 
      .addClass("ui-state-highlight") 
      .find("p") 
      .html("Dropped!"); 
     } 
    }); 
    }); 

回答

1

方法如下:

$("#container").droppable({ 
    drop: function(event, ui) { 
    # clear the container 
    $(this).html(''); 

    # append chart to container 
    ui.draggable.appendTo($(this)); 

    # modify some css to fit 
    ui.draggable.css({ 
     width: '100%', 
     height: '100%', 
     top: 0, 
     left: 0, 
     position: 'absolute' 
    }); 

    # destroy draggable after chart was dropped 
    ui.draggable.draggable('destroy'); 
    } 
}); 

,并添加position: relative;#container的CSS规则。

+0

感谢您的解决方案,但我仍然不能抓住图表 – Michal

+0

@Michal被放入一个“容器”后?只要删除'ui.draggable.draggable('destroy');' –

+0

不能图表我想到 看这里:http://jsfiddle.net/ngg2f5gz/2/ – Michal