chart.js - Chartjs Graph is not showing in colorbox -
i trying display doughnut chart in popup(colorbox) dummy values giving error, if call in browser(via url) display graph.
indexsizeerror: index or size negative or greater allowed amount.
var doughnutchart = [{ value: 60, color: "#fcc79e" }, { value: 30, color: "#beefd2" }, { value: 50, color: "#ffddfb" }, { value: 20, color: "#cdecff" }, { value: 90, color: "#fff5bc" }]; var mydoughnutchart = new chart(document.getelementbyid("canvas").getcontext("2d")).doughnut(doughnutchart);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <canvas id="canvas" height="450" width="600"></canvas>
chart.js needs canvas have rendered size before can rendered. need have chart initialization inside cbox_complete
event hook instead of doing first , opening colorbox
something like
$(document).bind('cbox_complete', function () { var doughnutchart = [{ ... ... var mydoughnutchart = new chart(document.getelementbyid("canvas").getcontext("2d")).doughnut(doughnutchart); });
Comments
Post a Comment