DEV Community

Discussion on: Use Laravel charts in Laravel.

Collapse
 
neeraj1005 profile image
Neeraj Singh • Edited

Charts is wroking fine but when i jumped to other url, THis shows me error:
Undefined variable: chart (View: C:\wamp64\www\AdBlog\resources\views\admin\layouts\footer.blade.php)
I faced this issued when i jumped to other page.

And i have add this code end of the footer. this show an error
 <footer class="main-footer">
    <div class="pull-right hidden-xs">
      <b>Version</b> 2.3.8
  </div>
  <strong>Copyright &copy; 2019-{{ Carbon\carbon::now()->year }} <a href="http://facebook.com">NS Tech</a>.</strong> All rights
  reserved.
  <script src="{{ asset('admin/plugins/jQuery/jquery-2.2.3.min.js') }}"></script>
  <!-- jQuery UI 1.11.4 -->
  <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
  <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  <script>
      $.widget.bridge('uibutton', $.ui.button);
  </script>
  <!-- Bootstrap 3.3.6 -->
  <script src="{{ asset('admin/bootstrap/js/bootstrap.min.js') }}"></script>
  <!-- Morris.js charts -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
  <script src="{{ asset('admin/plugins/morris/morris.min.js') }}"></script>
  <!-- Sparkline -->
  <script src="{{ asset('admin/plugins/sparkline/jquery.sparkline.min.js') }}"></script>
  <!-- jvectormap -->
  <script src="{{ asset('admin/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js') }}"></script>
  <script src="{{ asset('admin/plugins/jvectormap/jquery-jvectormap-world-mill-en.js') }}"></script>
  <!-- jQuery Knob Chart -->
  <script src="{{ asset('admin/plugins/knob/jquery.knob.js') }}"></script>
  <!-- daterangepicker -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
  <script src="{{ asset('admin/plugins/daterangepicker/daterangepicker.js') }}"></script>
  <!-- datepicker -->
  <script src="{{ asset('admin/plugins/datepicker/bootstrap-datepicker.js') }}"></script>
  <!-- Bootstrap WYSIHTML5 -->
  <script src="{{ asset('admin/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js') }}"></script>
  <!-- Slimscroll -->
  <script src="{{ asset('admin/plugins/slimScroll/jquery.slimscroll.min.js') }}"></script>
  <!-- FastClick -->
  <script src="{{ asset('admin/plugins/fastclick/fastclick.js') }}"></script>
  <!-- AdminLTE App -->
  <script src="{{ asset('admin/dist/js/app.min.js') }}"></script>
  <!-- AdminLTE dashboard demo (This is only for demo purposes) -->

  <script src="{{ asset('admin/dist/js/pages/dashboard.js') }}"></script> 
  <!-- AdminLTE for demo purposes -->
  <script src="{{ asset('admin/dist/js/demo.js') }}"></script>



   @if($chart)
     {!! $chart->script() !!}
     @endif




  @section('footerSection')
  @show
</footer>
Collapse
 
arielmejiadev profile image
Ariel Mejia

you need to add your chart helper

{!! $chart->script() !!}

in the blade file of the view, this error is because it is added to the master blade layout, and if you extends other views from this layout you need to pass the chart variable to any file to extend from this layout, but the correct way is to pass the helper ONLY to your dashboard view not in the layout so it only be required there, I hope it works, happy coding!