Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
SVG Performance with Angular
Search
Yosuke Kurami
April 20, 2016
4.5k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SVG Performance with Angular
Yosuke Kurami
April 20, 2016
More Decks by Yosuke Kurami
See All by Yosuke Kurami
TypeScript LSP の今までとこれから
quramy
1
2.2k
フロントエンドテストの育て方
quramy
12
3.9k
App Router 悲喜交々
quramy
8
770
上手に付き合うコンポーネントテスト
quramy
6
2.4k
Patched fetch did not work
quramy
6
810
GraphQL あるいは React における自律的なデータ取得について
quramy
18
6k
Next.js App Router
quramy
15
4k
Fragment Composition of GraphQL
quramy
17
4.9k
reg-viz VRT tools
quramy
4
1.8k
Featured
See All Featured
The Limits of Empathy - UXLibs8
cassininazir
1
700
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
Accessibility Awareness
sabderemane
1
230
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
260
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
300
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
510
Transcript
SVG Performance with Angular @Quramy 2016.04.20 #ng_sake
About me • Yosuke KURAMI (@Quramy) • Frontend Web Developer
at WACUL INC. • ʑͷࣄAngularJS(1.x)ͰSPA։ൃ • झຯͰTypeScript༻ͷVimϓϥΪϯ։ൃͯ͠·͢ • http://vimawesome.com/plugin/tsuquyomi
Angular2ຊʹ͍ͷ͔ʁ
ࢼͯ͠Έͨ
͓: D3.js • Force Layout in D3.js (http://bl.ocks.org/mbostock/4062045) • Node,
LinkͷؔΛݩʹॏྗܭࢉΛߦͬͯNode ͷஔΛܾఆ͢ΔΞϧΰϦζϜ • D3.layoutͷؔͳͷͰɺComponentʹbind ͢ΕD3.jsҎ֎ͷFrameworkʹΈࠐΊΔ
Force Layout const size = 600; const force = d3.layout.force()
.nodes(this.UserLink.nodes()) .links(this.UserLink.links()) .size([size, size]) .gravity(1.1) .friction(0.98) .charge(-30) .linkDistance(size / 18.0) .alpha(.9) ; const nodes = <UserNode[]>force.nodes(); // nodeͷ࠲ඪใͷऔಘ const links = <Link[]>force.links(); // linkͷ࠲ඪใͷऔಘ force.on('tick', () => { // ߋ৽ຖͷϋϯυϥΛ͜͜ʹॻ͘ }); force.start();
With AngularJS 1.5 <svg> <g ng-if="ctrl.nodes.length && ctrl.links.length"> <line ng-repeat="link
in ctrl.links" ng-attr-x1="{{link.source.x}}" ng-attr-y1="{{link.source.y}}" ng-attr-x2="{{link.target.x}}" ng-attr-y2="{{link.target.y}}" ></line> <circle ng-repeat="node in ctrl.nodes" r="5" title="node.id" ng-attr-cx="{{node.x}}" ng-attr-cy="{{node.y}}" ng-attr-fill="{{ctrl.hsl(node)}}" ng-click="ctrl.onClick(node)" ng-class="{selected: node.id===ctrl.selectedNode.id}" ></circle> </g> </svg> force.on('tick', () => { this.$scope.$digest(); // ࣗͰDigestϧʔϓճ͢ඞཁ͋Γ });
With Angular 2 <svg> <g *ngIf="nodes?.length && links?.length"> <line *ngFor="#link
of links" [attr.x1]="link.source.x" [attr.y1]="link.source.y" [attr.x2]="link.target.x" [attr.y2]="link.target.y" ></line> <circle *ngFor="#node of nodes" r="5" [attr.title]="node?.id" [attr.cx]="node.x" [attr.cy]="node.y" [attr.fill]="hsl(node)" (click)="onClick(node)" [class.selected]="node?.id===selectedNode?.id" ></circle> </g> </svg> force.on('tick', () => { // উखʹzone.js͕ಈ͘ͷͰԿ͢Δඞཁͳ͠ });
Demonstration http://quramy.github.io/ng-svg-perf/ng1/ http://quramy.github.io/ng-svg-perf/ng2/
Results 7PMVNF$POEJUJPO "OHVMBS+4 "OHVMBS CFUB d/PEFT d-JOLT '14 '14 d/PEFT
d-JOLT '14 '14 d/PEFT d -JOLT '14 '14 d /PEFT d -JOLT '14 '14
Angular2ຊʹ͔ͬͨ(͜ͳΈ)
ࢀߟ • Angular2ͰͱΓ͋͑ͣSVGΛඳ͍ͯΈΔ (http://qiita.com/_likr/items/b2cbaa0e5e3e21a92e57) • D3.js on AngularJSͷ࣮ύλʔϯൺֱ (http://qiita.com/Quramy/items/4ed72ae91899b47fb167) •
Replacing (most of) d3.js with pure SVG + AngularJS (http://alexandros.resin.io/angular-d3-svg/)