Created
March 14, 2013 11:33
-
-
Save muddydixon/5160668 to your computer and use it in GitHub Desktop.
d3を使ったサンプルデータの作り方
This file contains hidden or 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
var amp = 100; | |
var sigma = 10; | |
var data1 = d3.range(0,100).map(function(d){ return 0|Math.random() * amp;}); | |
var data2 = d3.range(0,100).map(function(d){ return {x: 0|Math.random() * amp};}); | |
var data3 = d3.range(0,100).map(function(d, idx){ return {date: new Date(2013, 0, idx), val: 0|Math.random() * amp};}); | |
var norm = d3.random.normal(amp, sigma); | |
var data4 = d3.range(0,100).map(function(d, idx){ return {date: new Date(2013, 0, idx), val: norm()};} ); | |
var freqs = [1, 24, 7 * 24]; | |
var wave = function(d){ return d3.sum(freqs.map(function(freq){ return Math.sin(d * freq); })) }; | |
var data5 = d3.range(0,100).map(function(d, idx){ return {date: new Date(2013, 0, idx), val: wave(d)}; } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment