<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>D3.js サンプル</title> <link rel="stylesheet" href="css/main.css"> <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> </head> <body> <h1>D3.jsサンプル</h1> <div id="result"></div> <script src="js/sample.js"></script> </body> </html>
var list = [10, 20, 30, 40, 50]; var n = d3.mean(list); d3.select("#result").html("平均値は"+n);