load element when it is visible

load element when it is visible

Hello, I'm a newby to Jquery. I like it ;)
Now I want to load an element when it is visible, how can I do it?
I use the plugin from github to check if it is visible:

I want my canvas been drawn when it is visible:
The canvas is a chart that is made with this plugin:

I have tried to use a while statement on rule number 48 but than the page won't load.
Now I use a if - statement. The first time you visit the page, you won't see the chart on the canvas.
But when you reload when the div .graph is visible, then the chart will be shown.

What I want? That the graph is drawn when the div graph is visible (and not after reloading on the div).
If you need the whole project files, they project is attached as a zip.
  1. <div class="graph">
  2.       <canvas id="tableMichiel" width="300" height="300"></canvas>
  3. </div>

  4. <!-- Chart grafiek pas tonen wanneer hij zichtbaar is -->
  5. <script src="js/jquery.isonscreen.js"></script>
  6. <!-- Chart.js -->
  7. <script src="js/Chart.Core.js"></script>
  8. <script src="js/Chart.Doughnut.js"></script>
  9. <script>
  10. $(document).ready(
  11.             function() {
  12. tekenGrafiek()
  13.                 setInterval(function() {
  14. tekenGrafiek()
  15.                 }, 3000);
  16.             });
  17. function tekenGrafiek() {
  18. var doughnutData = [
  19. {
  20. value: 23,
  21. color:"rgba(1,168,184,0.25)",
  22. highlight: "rgba(250,102,89,1)",
  23. label: "Droge huid"
  24. },
  25. {
  26. value: 57,
  27. color:"rgba(1,168,184,0.5)",
  28. highlight: "rgba(250,102,89,1)",
  29. label: "Normale huid"
  30. },
  31. {
  32. value: 16,
  33. color:"rgba(1,168,184,0.75)",
  34. highlight: "rgba(250,102,89,1)",
  35. label: "Vette huid"
  36. },
  37. {
  38. value: 4,
  39. color:"rgba(1,168,184,1)",
  40. highlight: "rgba(250,102,89,1)",
  41. label: "Combi vet en droog"
  42. }
  43. ];
  44. // aanpassingen: tooltip-template aangepast, cutout in het midden verkleint
  45. if($('.graph').isOnScreen()){
  46. window.onload = function(){
  47. var ctx = document.getElementById("tableMichiel").getContext("2d");
  48. window.myDoughnut = new Chart(ctx).Doughnut(doughnutData, {responsive : true});
  49. };
  50. }
  51. </script>