code: function (){
                              element.find('.title').remove();
                              element.find('.subtitle').remove();
                              element.find('.caption').remove();
                              element.empty();
  
                              // remove tooltip if exists
                              if (scope.chart && scope.chart.tooltip && scope.chart.tooltip.id) {
                                  d3.select('#' + scope.chart.tooltip.id()).remove();
                              }
  
                              // To be compatible with old nvd3 (v1.7.1)
                              if (nv.graphs && scope.chart) {
                                  for (var i = nv.graphs.length - 1; i >= 0; i--) {
                                      if (nv.graphs[i] && (nv.graphs[i].id === scope.chart.id)) {
                                          nv.graphs.splice(i, 1);
                                      }
                                  }
                              }
                              if (nv.tooltip && nv.tooltip.cleanup) {
                                  nv.tooltip.cleanup();
                              }
                              if (scope.chart && scope.chart.resizeHandler) scope.chart.resizeHandler.clear();
                              scope.chart = null;
                          }
docs: Fully clear directive element