chart.js - Charts.js -> Display / Load chart only when visible on the screen -


this first question, searching answer here , on google no avail.

i preparing website accountancy company, have requested demo created data visualisations. have opted use 'charts.js'.

my problem this, want chart load when visible on screen. @ moment load @ same time therefore miss quite nice animation.

extending on question, text next chart 'ease-in' too, when visible on screen.

would kind enough point me right material on 'net, or maybe show me easy way achieve this?

kindest regards , thank in advance!

as requested, adding simple code displays 2 charts below screen. make work need chart.js here: chart.js website

index.html:

<!doctype html> <html class="no-js">     <head>         <meta charset="utf-8">         <meta http-equiv="x-ua-compatible" content="ie=edge">         <title>graphs</title>         <link rel="stylesheet" href="css/main.css">         <script src="js/chart.js"></script>     </head>     <body>  <div class="graphs">                      <div class="separator1"></div>               <div class="graph1">                      <canvas id="mycanvas" width="475" height="400">graph 1</canvas>                     <script>                     //get context of canvas element want select                     context = document.getelementbyid('mycanvas').getcontext('2d'); var line = {}; var data = {     labels : ["january","february","march","april","may","june","july"],     datasets : [         {             fillcolor : "rgba(151,57,56,0.5)",             strokecolor : "rgba(151,57,56,1)",             pointcolor : "rgba(151,57,56,1)",             pointstrokecolor : "#fff",             data : [65,59,90,81,56,55,40]         },         {             fillcolor : "rgba(59,97,150,0.5)",             strokecolor : "rgba(59,97,150,1)",             pointcolor : "rgba(59,97,150,1)",             pointstrokecolor : "#fff",             data : [28,48,40,19,96,27,100]         }     ] }; var options = { scaleoverlay : false, scaleoverride : false, scalelinewidth : 1,  pointdotradius : 3, pointdotstrokewidth : 1, animationsteps : 150 };  new chart(context).line(data, options);                      </script>                     </div>                     <div class="text1">                         <div class="innertext">                         <h3>praesent viverra</h3>                         <hr/>                         <p>lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>                         </div>                     </div>             <div class="graph2">                      <canvas id="mycanvas2" width="475" height="400">graph 2</canvas>                     <script>                     //get context of canvas element want select                     context = document.getelementbyid('mycanvas2').getcontext('2d'); var pie = {}; var data = [     {         value: 30,         color:"#973938"     },     {         value : 50,         color : "#78963e"     },     {         value : 40,         color : "#3b6196"     },     {         value : 25,         color: "#f49d20"     },     {         value : 35,         color: "#fbdd13"     }            ]; var options = { animationsteps : 150 };  new chart(context).pie(data, options);                      </script>                     </div>                     <div class="text2">                         <div class="innertext">                         <h3>praesent viverra</h3>                         <hr/>                         <p>lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>                         </div>                     </div>       </body> </html> 

main.css:

.graph1 {     margin-left: 15%;     width: 33%;     float: left;     height: 450px;     display: block; }  .graph1 canvas {     padding: 25px 25px 25px 25px; }  .graph2 {     margin-right: 15%;     width: 33%;     float: right;     height: 450px;     display: block; }  .graph2 canvas {     padding: 25px 25px 25px 25px; }   .innertext {     padding-top: 25%;  }  .text1 {     margin-right: 15%;     width: 33%;     float: right;     height: 450px;  }  .text1 p {     text-align: center; }  .text1 hr {     margin: 0 auto;     width: 40%;     text-align: center; }  .text1 h3 {     text-align: center;     color: #636363; }   .text2 {     margin-left: 15%;     width: 33%;     float: left;     height: 450px;  }  .text2 p {     text-align: center; }  .text2 hr {     margin: 0 auto;     width: 40%;     text-align: center; }  .text2 h3 {     text-align: center;     color: #636363; }  .separator1 {     display: block;     margin: 0 auto;     width: 100%;     height: 1000px; } 

thanks again willing help!


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -