This document discusses using SVG and AngularJS for biological modeling. It begins with an introduction to SVG and how it can be used to create 2D vector graphics in the browser. It then explains how SVG can be combined with AngularJS using directives and manipulating SVG elements in the DOM. As a use case, it presents using SVG and AngularJS to build components for visualizing DNA plasmids and sequences, including challenges faced and solutions developed like lazy loading data. A demo is shown of an AngularJS-based genome viewer for synchronized plasmid and sequence views.
14. About Me
• sparXys CEO and Senior consultant
• ASP.NET/IIS Microsoft MVP
• Co-author of Pro Single Page Application
Development (Apress)
• ng-conf Israel co-organizer and GDG Rashlatz
Meetup co-organizer
15. Agenda
• SVG in a Nutshell
• SVG + AngularJS = <3
• Use Case: Biological Modelling
16. 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
19. SVG + AngularJS = <3
Combining SVG and AngularJS isn’t hard
SVG elements are part of the DOM!
20. SVG + AngularJS Caveats
• In directives that generate SVG, use
templateNamespace in the DDO:
• Set SVG attributes by using ng-attr- prefix:
<circle ng-attr-cx="{{radius}}" ng-attr-cy="{{radius}}" ng-attr-r="{{radius}}"/>
templateNamespace: 'svg'
30. 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
33. 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…
37. Can we do better?
Maybe infinite scrolling?
Not good enough!
38. Virtual Scrolling
• Generate only the current viewport
• Good reading reference:
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 modelling using
SVG and AngularJS