Here is the JS code that I'm using to render a pieChart on a web page using Meteor. The problem I have is that this code almost works except that the chart when displayed shows on the legends and labels but we cannot see pie(it is just empty). The javaScript code is as
[I'm not able to post the image here]
if (Meteor.isClient) {
Template.pienvd3.rendered = function() {
nv.addGraph(function() {
var pchart = nv.models.pieChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.showLabels(true);
d3.select("#piechart svg")
.datum(pieVar.find().fetch())
.transition().duration(350)
.call(pchart);
return pchart;
});
};}
This is my collection in MongoDB by name "pienvd3"
{
"_id" : ObjectId("54d37d5b30cd72c0dde2611b"),
"label" : "One",
"value" : 29.765957771107
}
{
"_id" : ObjectId("54d37d5b30cd72c0dde2611c"),
"label" : "Two",
"value" : 0
}
--- so on till Eight---
{
"_id" : ObjectId("54d37d5b30cd72c0dde26121"),
"label" : "Seven",
"value" : 13.925743130903
}
{
"_id" : ObjectId("54d37d5b30cd72c0dde26122"),
"label" : "Eight",
"value" : 5.1387322875705
}
I published the collection and also declared it
Meteor.publish(null, function () {
return pieVar.find();
});
pieVar = new Meteor.Collection("pienvd3");
pieVar.allow({
insert: function () {
return true;
},
update: function () {
return true;
},
remove: function () {
return true;
}
});
Now I'm actually not able to understand what exactly is the problem. P.S: I need to make this chart reactive and I've included all the necessary packages for d3. when I refresh the page even this image disappears saying NO DATA FOUND
Thank you