Chart.js & BPopUp - Make a Chart in a PopUP -


i'm working in little application school, need give chart inside popup.

the problem in middle of testing, when put

<canvas id="mychart" width="500" height="400"></canvas> inside element_to_pop_up id not work.

i made fiddle make easier understand.

https://jsfiddle.net/enanotg/od90stph/

please help!

there seems issue bpopup refrence. i've worked around in fiddle including bpopup code @ top of javascript section. scroll down bottom of section actual application code.

you can draw chart once canvas element visible. move charting code window.onload after bpopup triggered

(function ($) {     // dom ready     $(function () {         // binding click event         // jquery v.1.7.0 use .on() instead of .bind()         $('#my-button').bind('click', function (e) {              // prevents default action triggered.              e.preventdefault();              // triggering bpopup when click event fired             $('#element_to_pop_up').bpopup();              var ctx = document.getelementbyid("mychart").getcontext("2d");             var step = 1;             var max = 24;             var start = 8;             window.myline = new chart(ctx).linealt(linechartdata, {                 responsive: false,                 scaleoverride: true,                 scalesteps: math.ceil((max - start) / step),                 scalestepwidth: step,                 scalestartvalue: start,                 pointdot: false,                 datasetfill: false,                 showtooltips: false,             });         });     }); })(jquery); 

fiddle - https://jsfiddle.net/o8twjcrl/


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -