Lately, I've delved into utilizing NVD3's impressive angular directives for crafting D3 charts. They certainly have a sleek design. However, I'm encountering numerous challenges with callbacks. While callbacks function smoothly when incorporated using nv.addGraph(), as seen in Alex's answer and on the examples page. I've also had some success with suggestions from other sources like those on Stack Overflow. Yet, to simplify things for junior programmers at my company, I'd prefer to utilize an HTML directive similar to what is showcased on the Github examples.
<nvd3-multi-bar-chart
data="monthData"
id="monthDataChart"
... other properties ...
callback="monthCallback">
<svg></svg>
</nvd3-multi-bar-chart>
The monthCallback function in my scope aims to attach attributes like titles and events such as click to each .nv-bar in the chart. The issue arises when the chart begins rendering before the data is returned from the ajax request, causing the monthCallback to trigger prior to any .nv-bar elements being present on the page. (Note: using or not using parentheses in the callback declaration - i.e. callback="monthCallback" vs. callback="monthCallback()") doesn't seem to make a difference.
I contemplated implementing the workaround by liptga or DavidSouther's solution mentioned on GitHub, but connecting the callback to the transition seemed to be addressing the problem in the wrong manner. Are there any other recommendations for ensuring that the callback fires at the appropriate time when using the HTML directive?