javascript - Export Data from dc.js dataTable into CSV -


i have data table done dc.js , crossfilter.js, , want export table csv file..

datatable.width(960).height(800) .dimension(by_id) .group(function(d) { return ""  }) .size(data.length)                           .columns([   function(d) { return d.id; },   function(d) { return d.name; },   function(d) { return d.gender; },   function(d) { return parsefloat(d.gpa).tofixed(2); },   function(d) { return parsefloat(d.major_gpa).tofixed(2); },   function(d) { return parsefloat(d.math_gpa).tofixed(2); },   function(d) { return parsefloat(d.english_gpa).tofixed(2); },   function(d) { return parsefloat(d.science_gpa).tofixed(2); },   function(d) { return parsefloat(d.humanities_gpa).tofixed(2); }   ]) .sortby(function(d){ return d.id; }) .order(d3.ascending); 

this common request, i've added example using filesaver.js. (there other ways to download browser, 1 i'm familiar with.)

http://dc-js.github.io/dc.js/examples/download-table.html

the key fetch data table's dimension using dimension.top(infinity). can format using d3.csv.format , download using preferred method. here, filesaver uses blobs mechanism:

    var blob = new blob([d3.csv.format(namedim.top(infinity))],                         {type: "text/csv;charset=utf-8"});     saveas(blob, 'data.csv'); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -