我这里有一个AmCharts的例子,我已经制作了拖放功能,但我需要将图表放入容器并适合大小。有人知道吗?谢谢你的帮助
这里是小提琴:
http://jsfiddle.net/ngg2f5gz/1/
拖放功能
$( function() {
$( "#chartdiv" ).draggable();
$( "#container" ).droppable({
drop: function( event, ui ) {
$( this )
.addClass( "ui-state-highlight" )
.find( "p" )
.html( "Dropped!" );
}
});
} );
答案 0 :(得分: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规则中。