Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vue.js + D3.jsでグラフを描く
Search
Tatsuya Miyado
May 23, 2018
Technology
1
2.1k
Vue.js + D3.jsでグラフを描く
Vue.js Tokyo v-meetup #7 LTスライド
Tatsuya Miyado
May 23, 2018
Tweet
Share
Other Decks in Technology
See All in Technology
目標設定は好きですか? アジャイルとともに目標と向き合い続ける方法 / Do you like target Management?
kakehashi
10
3k
セキュリティ研修 Day1【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
150
サービス開発を前に進めるために 新米リードエンジニアが 取り組んだこと / Steps Taken by a Novice Lead Engineer to Advance Service Development
nologyance
0
180
テスト・設計研修【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
170
クラウド利用者の「責任」をどう果たす?AWSセキュリティ対策のススメ #AWSSummit
hiashisan
0
270
LLMアプリケーションの評価の実践と課題 ~PharmaXにおける今後の展望~
pharma_x_tech
2
160
AWSサービスメニュー開発をしていてAWSを好きだ!と感じた瞬間
toru_kubota
0
130
Github Actions 로 Android 팀의 효율성 극대화
hadonghyun
0
160
さらに高品質・高速化を目指すAI時代のテスト設計支援と、めざす先 / AI Test Lab vol.1
shift_evolve
0
190
Classmethod流のPlatform Engineering / classmethod-platform-engineering-devio2024
tomoki10
0
470
ABEMAにおけるLLMを用いたコンテンツベース推薦システム導入と効果検証
cyberagentdevelopers
PRO
1
700
テストケースの自動生成に生成AIの導入を試みた話と生成AIによる今後の期待
shift_evolve
0
180
Featured
See All Featured
It's Worth the Effort
3n
181
27k
Leading Effective Engineering Teams 2024
addyosmani
3
300
The Invisible Customer
myddelton
117
13k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
20
7.2k
GraphQLの誤解/rethinking-graphql
sonatard
59
9.6k
Atom: Resistance is Futile
akmur
261
25k
Docker and Python
trallard
37
2.9k
Facilitating Awesome Meetings
lara
46
5.8k
The World Runs on Bad Software
bkeepers
PRO
63
11k
Happy Clients
brianwarren
94
6.5k
The Invisible Side of Design
smashingmag
294
50k
Into the Great Unknown - MozCon
thekraken
20
1.3k
Transcript
7VFKT %KTͰ άϥϑΛඳ͘ 7VFKT5PLZPWNFFUVQ !IPHFTVLF@
!IPHFTVLF@
7VFKTͰάϥϑΛ ඳ͖͍ͨ
%KTΛ͍͍ͨ
7VFKT %KTͬͯ Ͱ͖Δͷʁ
ͬͯΈ·ͨ͠
%&.0 IUUQHSBQIIPHFTVLFOFU
·ͣ7VFΛΘͣʹॻ͍ͯΈΔ const dataset = [ 10, 20, 5, 3, 8,
40, 20, 35]; const w = 200, h = 100, margin = 5; const svg = d3.select(‘.graph').append('svg') .attr('width', w + margin).attr('height', h + margin); const xScale = d3.scaleLinear().domain([0, dataset.length]).range([margin, w - margin]); const yScale = d3.scaleLinear().domain([d3.min(dataset), d3.max(dataset)]).range([h - margin, margin]); const xAxis = d3.axisBottom(xScale); svg.append('g') .attr('transform', `translate(0, ${h})`) .call(xAxis); const yAxis = d3.axisLeft(yScale); svg.append('g') .attr('transform', `translate(${margin}, 0)`) .call(yAxis); const d3line = d3.line() .x((d, i) => xScale(i)) .y(d => yScale(d)) .curve(d3.curveLinear); svg.append('path') .attr(‘d', d3line(dataset)) .style('stroke-width', 2) .style('stroke', 'steelblue') .style('fill', 'none');
͜ΕΛ7VF ίϯϙʔωϯτʹམͱ͠ࠐΉ
const dataset = [ 10, 20, 5, 3, 8, 40,
20, 35]; const w = 200, h = 100, margin = 5; const svg = d3.select(‘.graph').append('svg') .attr('width', w + margin).attr('height', h + margin); const xScale = d3.scaleLinear().domain([0, dataset.length]).range([margin, w - margin]); const yScale = d3.scaleLinear().domain([d3.min(dataset), d3.max(dataset)]).range([h - margin, margin]); const xAxis = d3.axisBottom(xScale); svg.append('g') .attr('transform', `translate(0, ${h})`) .call(xAxis); const yAxis = d3.axisLeft(yScale); svg.append('g') .attr('transform', `translate(${margin}, 0)`) .call(yAxis); const d3line = d3.line() .x((d, i) => xScale(i)) .y(d => yScale(d)) .curve(d3.curveLinear); svg.append('path') .attr(‘d', d3line(dataset)) .style('stroke-width', 2) .style('stroke', 'steelblue') .style('fill', 'none'); 9:࣠ͷඳը QBUIͷඳը 47(ཁૉͷੜ ೖྗσʔλΛඳըྖҬʹ Ϛοϐϯά͢Δؔͷੜ ݩͷίʔυ
:࣠ 9࣠ ύε ίϯϙʔωϯτׂ άϥϑશମ
<template> <path :d="d" /> </template> 5FNQMBUF 1BUI computed: { line
() { return d3.line() .x(d => this.xScale(d.x)) .y(d => this.yScale(d.y)) .curve(d3.curveLinear); }, d () { return this.line(this.data); }, }, 4DSJQU 47(ͷཁૉΛ ςϯϓϨʔτʹॻ͘ ύεͷ࠲ඪͱͳΔ EଐੑͷΛੜ
<template> <path :d="d" /> </template> 5FNQMBUF 1BUI computed: { line
() { return d3.line() .x(d => this.xScale(d.x)) .y(d => this.yScale(d.y)) .curve(d3.curveLinear); }, d () { return this.line(this.data); }, }, 4DSJQU ͱΛͲͷΑ͏ͳۂઢͰ ิؒ͢Δ͔ͷࢦఆ
computed: { xAxis () { return d3.axisBottom(this.xScale) .tickSizeInner(10) // ઢͷ͞ʢଆʣ
.tickSizeOuter(15) // ઢͷ͞ʢ֎ଆʣ .tickPadding(10) // ઢͱςΩετͷؒͷڑ .ticks(4); // ઢͷ }, }, mounted () { d3.select(this.$el).call(this.xAxis); }, 9:࣠ <template> <g :transform="`translate(${position.x}, ${position.y})`" /> </template> 5FNQMBUF 4DSJQU ࣠ΓΛ Hཁૉʹ ඳը͢Δ
computed: { xAxis () { return d3.axisBottom(this.xScale) .tickSizeInner(10) // ઢͷ͞ʢଆʣ
.tickSizeOuter(15) // ઢͷ͞ʢ֎ଆʣ .tickPadding(10) // ઢͱςΩετͷؒͷڑ .ticks(4); // ઢͷ }, }, mounted () { d3.select(this.$el).call(this.xAxis); }, ͜͜ 9:࣠ <template> <g :transform="`translate(${position.x}, ${position.y})`" /> </template> 5FNQMBUF 4DSJQU ࣠ͷΓʹ ؔ͢ΔઃఆΛߦ͏
Ξχϝʔγϣϯ w $44USBOTJUJPOͰQBUIΛΞχϝʔγϣϯͰ͖Δʁ w $ISPNFҎ֎Ͱ Ͱ͖ͳ͍ w ผͷखஈ͕ඞཁ
Ξχϝʔγϣϯ w 5XFFO-JUFKTΛ͏ w ͋ΔΛࢦఆͷඵͰɺࢦఆͷ·ͰঃʑʹมԽͤ͞Δ ػೳΛ࣋ͭ const hoge = {
a: 0 }; TweenLite.to(hoge, 3, { a: 100 }); AIPHFBAͷΛඵ͔͚ͯ·ͰมԽͤ͞Δ
Ξχϝʔγϣϯ w 5XFFO-JUFKTΛQBUIͷEଐੑʹ༻͍Δ͜ͱͰΞχϝʔγϣ ϯՄೳ <path d=“M55,120.20408163265304L66.22448979591837,245.71428571428572L77.44897959183673"></path> <path d="M55,239.59183673469386L66.22448979591837,22.244897959183675L77.44897959183673"></path> ࢀߟঢ়ଶͷτϥϯδγϣϯ7VFKTIUUQTKQWVFKTPSHWHVJEFUSBOTJUJPOJOHTUBUFIUNM
άϥϑͷඳը͕Ͱ͖ͨ
%&.0ͷίʔυ IUUQTHJUIVCDPNIPHFTVLFWVFEEFNP հͰ͖·ͤΜͰ͕ͨ͠ɺ πʔϧνοϓͷ࣮͍ͬͯ·͢
Ҏ্Ͱ͢ ͋Γ͕ͱ͏͍͟͝·ͨ͠