javascript - Can't graphic with Chart.js and JQuery Mobile -


i'm having small problem here, i'm traying make charts can't make work , don't know why. i'm using chart.js charts graphics.

here html5, has "canvas" chart going id=canvasejercicio2.

<div data-theme="a" data-role="header">     <a data-role="button" data-inline="true" data-direction="reverse" data-theme="a" data-transition="slideup"     href="#principal" data-icon="home" data-iconpos="left" class="ui-btn-left">     volver     </a>     <h3 id="nombreaplicacion">         nombre aplicacion     </h3> </div> <div data-role="content">     <h4 id="tituloestadisticas">         estadisticas     </h4>     <canvas id="canvasejercicio2" width="400" height="400"></canvas> </div> 

here jquery code, here not working charts, can't figure out whats crashing here:

/* ******************************************/ /* *****    page refresh estadisticas   *****/ /* ******************************************/ $(document).on('pagebeforeshow', '#estadisticas', function() {      graficar();     mostrardatosejercicios(); });  /* ******************************************/ /* ****  mostrar estadisticas al entrar  ****/ /* ******************************************/ $('#botonestadisticas').click(function() {     graficar();     mostrardatosejercicios(); } );  /* ******************************************/ /* ****   mostrar graficos ejercicio 2   ****/ /* ******************************************/ function graficar() {     //get context of canvas element want select     var contexto = $("#canvasejercicio2").get(0).getcontext("2d");     var datos = [         {             value: 1,             color:"#f38630"         },         {             value : 2,             color : "#e0e4cc"         },         {             value : 3,             color : "#69d2e7"         }                ];     var graficoejercicio2 = new chart(contexto).pie(datos); }; 

i've had same problem when found post although solution not clear. record solution loading chart in pageshow event , not before.

$(document).on("pageshow", "#page-grafica", function(event) {    // create chart here... } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -