angular-d3 | D3.js directives for AngularJS | Script Programming library
kandi X-RAY | angular-d3 Summary
kandi X-RAY | angular-d3 Summary
angular-d3 provides a number of directives to assist in integrating D3.js into an AngularJS application, providing live scope updates to D3.js automating re- rendering.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of angular-d3
angular-d3 Key Features
angular-d3 Examples and Code Snippets
Community Discussions
Trending Discussions on angular-d3
QUESTION
I have an Angular pie chart component built through VegaEmbed (https://github.com/vega/vega-embed) which uses Vega and D3 as underlying graphics dependencies. It renders from supplying a title and some (key, value) pairs. I isolated that component, and modified main.ts to run Jasmine out of Stackblitz to share with you. In this test, I am checking that the pie chart renders indeed SVG tags for the values "30%" | "70%" and the legend "Combined CEO/Chair" | "Separate CEO/Chair". However, it seems they run too early and VegaEmbed+Vega+D3 are still busy building that SVG. (I inferred what to test by just looking into the DOM through the Chrome dev tools).
https://stackblitz.com/edit/angular-d3-pie-chart-unit-test
I have tried a range of things: async
, FakeAsync
+ tick
, jasmine.clock
, changing the promises logic in my Angular component, etc... fixture.whenStable
gets me a step closer but texts
declared line 50 is still undefined.
I don't know how the internals of Vega, VegaEmbed and D3 are working. If these libraries are not using promises, rather old-fashioned callbacks, then Angular's Zones might fail to wait enough within async
?
What confuses me a little is that console.log(texts);
eventually shows a collection of 4 text SVG element in the console. Yet console.log(texts.length);
displays 0!
- How can that be ?
- How do I get my test code to wait till the moment that D3 has finished drawing the SVG and only run
expect
statements then ?
ANSWER
Answered 2020-Mar-02 at 12:43This is a good question, I have similar issues with Ag-Grid
where I have to wait for the rendering or its callbacks to complete before I do assertions and there is no good way like you mentioned with fakeAsync
, async/done
, etc. At least none that I have found.
A way I have found is to make a utility function like so:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install angular-d3
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page