Skip to content

Instantly share code, notes, and snippets.

@muddydixon
Created March 14, 2013 11:33
Show Gist options
  • Save muddydixon/5160668 to your computer and use it in GitHub Desktop.
Save muddydixon/5160668 to your computer and use it in GitHub Desktop.
d3を使ったサンプルデータの作り方
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