nvd3 Line Chart on Meteor JS 1.1.0.3 - 'addGraph' Error


#1

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 })
		.useInteractiveGuideline(true)
		.transition()
		.duration(350)
		.showLegend(true)
		.showYAxis(true)
		.showXAxis(true);

	earnedChart.xAxis
		.axisLabel('Date')
		.tickFormat(d3.format('d'));

	earnedChart.yAxis
		.axisLabel('Earned')
		.tickFormat(d3.format('d'));

	d3.select('#earned-charts svg').datum(
		[{
			key: 'Earned',
			values: formattedEarnedData
		}]
	).call(earnedChart);

	nv.utils.windowResize(earnedChart.update);

	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) {
	earnedDataArray.push({
		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.