2017-04-03 20 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