12. About Me
• sparXys CEO and senior consultant
• Microsoft MVP
• Co-author of Pro Single Page Application
Development (Apress)
• Angular UP conference and GDG Rashlatz Meetup
co-organizer
13. Agenda
• SVG in a Nutshell
• SVG + AngularJS = <3
• Use Case: Biological Modeling
14. SVG in a Nutshell
• Graphics model in the browser
• Create and draw 2D vector graphics using HTML
• Support for:
o Full DOM access
o Document structure, scripting, styling, paths, shapes, colors, transforms,
gradients, patterns, masking, clipping, markers, linking and views
16. What we can do with SVG?
Demo
http://www.themaninblue.com/experiment/Blobular/
http://lavadip.com/experiments/jigsaw/
17. SVG + AngularJS = <3
Combining SVG and AngularJS isn’t hard
SVG elements are part of the DOM!
18. SVG + AngularJS 1 Caveats
• In directives that generate SVG, use
templateNamespace in the DDO:
• Set SVG attributes using ng-attr- prefix:
<circle ng-attr-cx="{{radius}}" ng-attr-cy="{{radius}}" ng-attr-r="{{radius}}"/>
templateNamespace: 'svg'
20. SVG + Angular 2 Caveats
• In components that generate SVG, use svg: prefix
when using SVG elements:
• Set SVG attributes using attr. prefix:
• Remember:
SVG cannot accept elements it doesn't recognize!
o Don’t create your own named components, use named attributes instead
<svg:circle [attr.cx]="radius" [attr.cy]="radius" [attr.r]="radius"/>
<svg:circle cx="10" cy="10" r="30"/>
31. Problems We Faced
• Generating the plasmid dynamically from specific
files
o Solved by dynamically adding AngularPlasmid elements
o Then, we use the $compile service
• Adding selection to the plasmid
o Solved by adding our own implementation
34. Building the Sequence –
The Naïve Way
• Let AngularJS generate the whole sequence
o Use ng-repeat, SVG and browser scrolling
• Add annotation layers with SVG
• The problem is…
38. Can we do better?
Maybe infinite scrolling?
Not good enough!
39. Virtual Scrolling
• Generate only the current viewport
• Good reading reference:
o https://developers.google.com/web/updates/2016/07/infinite-scroller?hl=en
o http://blog.stackfull.com/2013/02/angularjs-virtual-scrolling-part-1/
o http://blog.stackfull.com/2013/03/angularjs-virtual-scrolling-part-2/
42. Summary
• SVG is one of the options to create graphics in
the browser
• SVG and AngularJS can work well together
• You can create sophisticated modeling using
SVG and AngularJS