|
|
@ -4,24 +4,32 @@ c3_chart_internal_fn.convertUrlToData = function (url, mimeType, keys, done) { |
|
|
|
var d; |
|
|
|
var d; |
|
|
|
if (type === 'json') { |
|
|
|
if (type === 'json') { |
|
|
|
d = $$.convertJsonToData(JSON.parse(data.response), keys); |
|
|
|
d = $$.convertJsonToData(JSON.parse(data.response), keys); |
|
|
|
|
|
|
|
} else if (type === 'tsv') { |
|
|
|
|
|
|
|
d = $$.convertTsvToData(data.response); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
d = $$.convertCsvToData(data.response); |
|
|
|
d = $$.convertCsvToData(data.response); |
|
|
|
} |
|
|
|
} |
|
|
|
done.call($$, d); |
|
|
|
done.call($$, d); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
c3_chart_internal_fn.convertCsvToData = function (csv) { |
|
|
|
c3_chart_internal_fn.convertXsvToData = function (xsv, parser) { |
|
|
|
var d3 = this.d3, rows = d3.csv.parseRows(csv), d; |
|
|
|
var rows = parser.parseRows(xsv), d; |
|
|
|
if (rows.length === 1) { |
|
|
|
if (rows.length === 1) { |
|
|
|
d = [{}]; |
|
|
|
d = [{}]; |
|
|
|
rows[0].forEach(function (id) { |
|
|
|
rows[0].forEach(function (id) { |
|
|
|
d[0][id] = null; |
|
|
|
d[0][id] = null; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
d = d3.csv.parse(csv); |
|
|
|
d = parser.parse(xsv); |
|
|
|
} |
|
|
|
} |
|
|
|
return d; |
|
|
|
return d; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
c3_chart_internal_fn.convertCsvToData = function (csv) { |
|
|
|
|
|
|
|
return this.convertXsvToData(csv, this.d3.csv); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
c3_chart_internal_fn.convertTsvToData = function (tsv) { |
|
|
|
|
|
|
|
return this.convertXsvToData(tsv, this.d3.tsv); |
|
|
|
|
|
|
|
}; |
|
|
|
c3_chart_internal_fn.convertJsonToData = function (json, keys) { |
|
|
|
c3_chart_internal_fn.convertJsonToData = function (json, keys) { |
|
|
|
var $$ = this, |
|
|
|
var $$ = this, |
|
|
|
new_rows = [], targetKeys, data; |
|
|
|
new_rows = [], targetKeys, data; |
|
|
|