arrays - Trigger D3 redraw after ng-repeat finishes -


I have an interesting question about applying for the use of EnglishJS and D3 Basically, I have ng-repeat Which repeats on the basis of the content of an array. This array contains objects which have a RECR URL, which they reach periodically and drag data. Once they get this data, a graph is prepared using D3 (a graph for each object in the array).

The problem I am having is to add an object to this object through user input, and the drawing of the job correctly appears that the D3 code jumps to the gun and selects the SVG elements Which have not been sung so far, because Kangaroo is still ending to add stuff to the DOM through NG-repeat.

I have tried to use the $$ timeout and also created a custom directive.

It works well, but only for the first time the event starts to run ng-repeat, when I array to any other object. Any comments on the best way to handle this situation? If I add the previous object every time and then iterate through the array and open the drawing function, then it seems that it will work. Based on the last days, I can fire the incident.

Cheers!

Edit: Currently the D3 code is similar to that which is just a simple donut chart update, with a warning that the redraw has been started by a REST call. There may be more complex graphs in the future, and this is because I was hoping to use D3. Edit 2: I have transmitted all of my D3 code into custom instructions, and after several hours, it seems that working around should not work, apart from the scope, the custom element ng - There is only one scope in the form of repetition and can use the relevant DOM elements along with the object and its properties (I am currently creating an ID which is unique to each object).

The problem now comes when using D3. Selection ... When I try and choose the DIV where I want to keep the drawing, it will not allow me to choose by ID, because it is empty .. The very strange thing about it is that if I ("div"), he can search for that divisor, which I see, but I will not let him choose one.

JsFiddle is showing what I mean ... check the console and test the first test div "obj1", but the second selection returns the null.

If I can do this work and then pull my SVG canvas and within that division, I think it will work!

Contextual Selection:

  var test = d3.selectAll ("div"); Console.log (test); Var chart = D 3.select ("# obj" + obj.id); Console.log (chart);   

HTML should create divs:

  & lt; Div ng-repeat = "object in myData" & gt; & Lt; Div id = "obj {{object.id}}" & gt; Hi & lt; Bar-Chart & gt; & Lt; / Bars-chart & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

No need to use ID for selection Not all You can only select element [0] link function of the Connectional Directive:

  var chart = d3.select (element [ 0]) .andend ('svg')   

For example:

  Angular. Module ('myApp', []). Instructions ('Bar Chatch', Function () {return} Restricted: 'E', Link: Function (Region, Element, ethers) {var chart = D3 selection (element [0]). Attached ('SVG') . ({Height: 20, width: 20}); chart.append ('rect'). Attr ({height: 10, width: 10});}};}); Function Ctrl ($ scope, $ timeout) {$ scope.myData = [{"id": "1"}, {"id": "2"}]; // Just to show that it responds to the change in data and will provide more SVG $ timeout (function () ($ scope.myData.push ({"id": "3"}), 3000) ;}   

See JSFiddle here:



Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -