cycle through tabs

cycle through tabs


I am trying to automatically cycle through my tab content for a charts presentation

I have chosen to use something like this:

Although my version of Jquery 3.3.1 and bootstrap 4.1.3 only allows it to auto cycle to just the next tab and then stops

  1.     var tabChange = function(){
  2.         var tabs = $('.nav-tabs > li');
  3.         var active = tabs.filter('.active');
  4.         var next = active.next('li').length? active.next('li').find('a') : tabs.filter(':first-child').find('a');
  5.         // Bootsrap tab show, para ativar a tab
  6.         next.tab('show')
  7.     }
  8.     // Tab Cycle function
  9.     var tabCycle = setInterval(tabChange, 1000)
  10.     // Tab click event handler
  11.     $(function(){
  12.         $('.nav-tabs a').click(function(e) {
  13.             e.preventDefault();
  14.             // Parar o loop
  15.             clearInterval(tabCycle);
  16.             // mosta o tab clicado, default bootstrap
  17.             $(this).tab('show')
  18.             // Inicia o ciclo outra vez
  19.             setTimeout(function(){
  20.                 tabCycle = setInterval(tabChange, 1000)//quando recomeça assume este timing
  21.             }, 1000);
  22.         });
  23.     });

Please help?!
Thanks