~bac/juju-gui/trunkcopy

« back to all changes in this revision

Viewing changes to lib/d3/src/csv/format.js

  • Committer: kapil.foss at gmail
  • Date: 2012-07-13 18:45:59 UTC
  • Revision ID: kapil.foss@gmail.com-20120713184559-2xl7be17egsrz0c9
reshape

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
d3.csv.format = function(rows) {
2
 
  return rows.map(d3_csv_formatRow).join("\n");
3
 
};
4
 
 
5
 
function d3_csv_formatRow(row) {
6
 
  return row.map(d3_csv_formatValue).join(",");
7
 
}
8
 
 
9
 
function d3_csv_formatValue(text) {
10
 
  return /[",\n]/.test(text)
11
 
      ? "\"" + text.replace(/\"/g, "\"\"") + "\""
12
 
      : text;
13
 
}