nvd3 Line Chart on Meteor JS - 'addGraph' Error


Using the official nvd3 package (https://atmospherejs.com/nvd3/nvd3)

I have the following code under the Template.rendered block:

var formattedEarnedData = formatEarnedData(userEarnedDataSet);

nv.addGraph(function() {
	var earnedChart = nv.models.lineChart()
		.margin({ left: 25 })



	d3.select('#earned-charts svg').datum(
			key: 'Earned',
			values: formattedEarnedData


	return earnedChart;

The following lies at the bottom of the js file outside of the rendered block:

var formatEarnedData = function(dataSet) {
    var earnedDataArray = new Array();
    var groupedDates = _.groupBy(_.pluck(dataSet, 'progression'), function(date) {
	return moment(date).format('MMM D');

_.each(_.values(groupedDates), function(dates) {
		date: dates[0],
		total: dates.length

return earnedDataArray;

Even after following the documentation, I am still getting this error:

Cannot read property 'addGraph' of undefined

Can any nvd3 experts shed some light on why this error is happening?

Thanks in advance.