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
Rect = require'./rect.coffee' | |
class Rects | |
el: 'rect' | |
constructor: (selection) -> | |
@dom = selection.selectAll(@el) | |
@position = (d,i) -> 'translate(0,0)' | |
@width = (d) => | |
@height = (d) => | |
@name = (d,i) -> d.name |
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
Visualizer = require './visualizer.coffee' | |
class Rect extends Visualizer | |
el: 'rect' | |
fill: '#000' | |
stroke: '' | |
constructor: -> | |
@setAttr | |
fill: @fill |
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
# 棒のグループ要素 | |
class Bars extends Visualizer | |
type: "g" | |
constructor: -> | |
@el.attr 'class' : 'bars' | |
@rects = new Rects @el | |
render: (data) -> | |
@rects.render data |
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
class BarChart | |
setup: -> | |
@svg = new Svg('') | |
@bars = new Bars(@svg.dom) | |
size: (size) -> | |
@svg.attr( | |
width: size.width | |
height: size.height | |
) |
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
class BarChart | |
setup: -> | |
@svg = new Svg('') | |
@bars = new Bars(@svg.dom) | |
size: (size) -> | |
@svg.attr( | |
width: size.width | |
height: size.height | |
) |
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
# テキストを改行させる | |
textWrapper : (text) -> | |
text.each(()-> | |
text = d3.select(this) | |
rect = text.node().previousElementSibling | |
textArea = | |
width : rect.getAttribute('width') | |
height : rect.getAttribute('height') | |
# テキストを単語で区切った配列に |
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
# x軸を生成 スケールと描画位置を指定する。 | |
@xAxis = d3.svg.axis() | |
.scale(@xScale) | |
.orient('bottom') | |
# .tickFormat(@customFormat) | |
.tickSize(-@chartHeight) | |
.tickPadding(10) | |
.outerTickSize(5) | |
# y軸を生成 スケールと描画位置を指定する。 | |
@yAxis = d3.svg.axis() |
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
# | |
# 凡例 | |
# | |
class Legends | |
RECT_SIZE = 14 | |
TEXT_MARGIN = 20 | |
LEGEND_MARGIN = 2 | |
LEGEND_WIDTH = 150 | |
LEGEND_HEIGHT = 20 |
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
'東京都文京区本郷' | |
.replace(/^(.{2}[都道府県]|.{3}県)(.+)/, "$1 $2") | |
.split(' ') | |
// ['東京都','文京区本郷'] |
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
# 回文チェック | |
def check(word) | |
word = word.to_s | |
word == word.reverse | |
end | |
# 文字列 | |
str = "234567890328927412102352356776" | |
result = "" |