Hello,
I’m trying out the anychart addon for Meteor. I have a question how do I use it with my current database? In the shown example, the collection has only a string value and an number value. That is all. My collection is more complicated.
Here’s an example of my collection:
addTrip: function(day, month, year, car, a, b, dist, cost, comment){
if(!Meteor.userId()){
throw new Meteor.Error('No access: You are not logged in.');
}
Trips.insert({
userId: Meteor.userId(),
createdAt: new Date(),
day: day,
month: month,
year: year,
car: car,
a: a,
b: b,
dist: dist,
cost: cost,
comment: comment
});
},
Here is what I use to render the anychart example
Template.managerStats.rendered = function(){
if (!DataSource.find({}).fetch().length) {
DataSource.insert({x: 'Department Stores', value: 6371664});
DataSource.insert({x: 'Discount Stores', value: 7216301});
DataSource.insert({x: 'Men\'s/Women\'s Stores', value: 1486621});
DataSource.insert({x: 'Juvenile Specialty Stores', value: 786622});
DataSource.insert({x: 'All other outlets', value: 900000});
}
var container = this.find("#managerChart");
console.log(container);
var data = DataSource.find({}).fetch();
console.log(data);
chart = anychart.pie(data);
chart.title('Statistics');
chart.legend()
.position('bottom')
.itemsLayout('horizontal')
.align('center')
.title('Retail channels');
chart.animation(true);
chart.container(container).draw();
};
How do I do this with Trips.find().fetch()? using the dist, that has to be converted to a number, as it’s currently stored as a string, and as the string value must use the userId and retrieve the email (Meteor.user().emails[0].address)