title: How do I delete a google chart and replace it with a new one in a google app?
body: <p>I have searched everywhere I can not come up with a solution to this. I am trying to make this code display a chart every time a user clicks "submit" (that part works). The problem comes in with the user clicks submit more then once. It showing the chart multiple times. How do I make it delete the last chart and update it with the new one?</p>
  
  <pre><code>function doGet() {
    var uiApp = UiApp.createApplication().setTitle("some title");
  
    var grid = uiApp.createGrid(3, 2);
    grid.setWidget(0, 0, uiApp.createLabel('Lablel 1'));
    grid.setWidget(1, 0, uiApp.createLabel('Lablel 2'));
  
    var panel = uiApp.createVerticalPanel();
  
    panel.add(grid);
  
    var button = uiApp.createButton('submit');
    var handler = uiApp.createServerHandler('b');
    handler.addCallbackElement(grid);
    button.addClickHandler(handler);
  
    panel.add(button);
    uiApp.add(panel);
  
    return uiApp;
   }
  
  function b(e) {
    var app = UiApp.getActiveApplication();
  
    //gets all my chart data
    var chart = getchartdata()
  
    //Add chart
    app.add(chart)
  
    var uiApp = UiApp.getActiveApplication();
    uiApp.close();
  
    return uiApp;
  }
  </code></pre>