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.2k
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
Mastraに入門してみた ~AWS CDKを添えて~
tsukuboshi
0
320
Oracle Cloud Infrastructure:2025年4月度サービス・アップデート
oracle4engineer
PRO
0
110
DETR手法の変遷と最新動向(CVPR2025)
tenten0727
2
1.4k
Automatically generating types by running tests
sinsoku
2
3.6k
新卒エンジニアがCICDをモダナイズしてみた話
akashi_sn
2
260
30代からでも遅くない! 内製開発の世界に飛び込み、最前線で戦うLLMアプリ開発エンジニアになろう
minorun365
PRO
13
4.3k
3D生成AIのための画像生成
kosukeito
0
110
【Λ(らむだ)】最近のアプデ情報 / RPALT20250422
lambda
0
120
ブラウザのレガシー・独自機能を愛でる-Firefoxの脆弱性4選- / Browser Crash Club #1
masatokinugawa
1
500
Linuxのパッケージ管理とアップデート基礎知識
go_nishimoto
0
470
バックオフィス向け toB SaaS バクラクにおけるレコメンド技術活用 / recommender-systems-in-layerx-bakuraku
yuya4
6
570
Databricksで完全履修!オールインワンレイクハウスは実在した!
akuwano
0
110
Featured
See All Featured
KATA
mclloyd
29
14k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Optimising Largest Contentful Paint
csswizardry
36
3.2k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Thoughts on Productivity
jonyablonski
69
4.6k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
GraphQLの誤解/rethinking-graphql
sonatard
71
10k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
[RailsConf 2023] Rails as a piece of cake
palkan
54
5.4k
BBQ
matthewcrist
88
9.6k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Making Projects Easy
brettharned
116
6.1k
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 հͰ͖·ͤΜͰ͕ͨ͠ɺ πʔϧνοϓͷ࣮͍ͬͯ·͢
Ҏ্Ͱ͢ ͋Γ͕ͱ͏͍͟͝·ͨ͠