<!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 = [1,2,3,4,5,6,7,8,9,10]; var total = d3.sum(list); d3.select("#result").text("合計は"+total);