javascript - chart.js in meteor not drawing -
in meteor project, have copied demo code chart.js client folder follows:
function drawchart(){ var data = { labels : ["january","february","march","april","may","june","july"], datasets : [ { fillcolor : "rgba(220,220,220,0.5)", strokecolor : "rgba(220,220,220,1)", pointcolor : "rgba(220,220,220,1)", pointstrokecolor : "#fff", data : [65,59,90,81,56,55,40] }, { fillcolor : "rgba(151,187,205,0.5)", strokecolor : "rgba(151,187,205,1)", pointcolor : "rgba(151,187,205,1)", pointstrokecolor : "#fff", data : [28,48,40,19,96,27,100] } ] } //get context jquery - using jquery's .get() method. var ctx = $("#mychart").get(0).getcontext("2d"); //this first returned node in jquery collection. var mynewchart = new chart(ctx); new chart(ctx).line(data); } meteor.startup(function() { drawchart(); });
in html have:
<canvas id="mychart" width="400" height="400"></canvas>
nothing drawn, nor errors thrown. same code run in console produces chart. missing?
i using meteor-chartjs library.
add canvas template
<template name="chart"> <canvas id="mychart" width="400" height="400"></canvas> </template>
use template rendered callback call drawchart function
template.chart.rendered = function(){ drawchart(); }
Comments
Post a Comment