Last active
August 29, 2015 14:10
-
-
Save valbeat/a057d79a81ce62bb813a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# マス目の描画 | |
drawGrid : -> | |
# svgにマス目を内包するグループを作成 | |
@svg.append('g') | |
.attr( | |
class : 'grid' | |
) | |
# マス目グループの中に水平線を追加する | |
@svg.select('g.grid') | |
.selectAll('line.h') | |
.data(d3.range(0, @chartHeight, 10)) | |
.enter() | |
.append('line') | |
.attr( | |
class : 'h' | |
x1 : 0 | |
y1 : (d) -> d | |
x2 : @chartWidth | |
y2 : (d) -> d | |
) | |
# マス目グループの中に垂直線を追加する | |
@svg.select('g.grid') | |
.selectAll('line.v') | |
.data(d3.range(0, @chartWidth, 10)) | |
.enter() | |
.append('line') | |
.attr( | |
class : 'v' | |
x1 : (d) -> d | |
y1 : 0 | |
x2 : (d) -> d | |
y2 : @chartHeight | |
) | |
# マス目のスタイリング | |
@svg.selectAll('line.h,line.v') | |
.attr( | |
stroke : 'black' | |
'stroke-dasharray' : 2 | |
'shape-rendering' : 'crispEdges' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment