将图表放入容器

Place Chart to container

我这里有一个 AmCharts 示例,我制作了拖放功能,但我需要将图表放入容器中并调整大小。有人知道吗?感谢帮助

这里是 fiddle:

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

拖放功能

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

方法如下:

$( "#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 规则中。