Question

So I've been trying to work with angularjs-nvd3-directives and for the most part it's been great. I've come to my actual use-case though, and it doesn't work as expected. What I'm doing is making a chart editor, so you would change settings in real-time about the chart and see those changes live. Here's an example of changing the x axis in action. Now, you might notice that the data changes repeatedly. I want to change all of these properties without changing the data, but if you comment out the lines that randomize the data, it doesn't work as expected.

I did some digging in the source code, and I found this curious line that seems to me like it only watches the data variable. Is there a way I can force angular to update, even if the data doesn't change? Setting it to itself doesn't seem to work.

Also, in the example it updates every 1500 ms because of a setInterval. Is there a better way to do that? I feel like making it work off of a change event would be better, but I don't know where to start with that.

Was it helpful?

Solution 2

The solution I had to go with was to set an unused property on the object, and increment it any time I needed it to change.

OTHER TIPS

setting it to itself doesn't seem to work.

That didn't work because angular does a === equality check. Simply solution:

data = angular.copy(data)

This will make data distinct from previous value of data but still functionally equivalent.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top