Browse Source

Fix error parsing csv from xhr request callback object

pull/1345/head
Jason Frazier 10 years ago
parent
commit
8a68d33501
  1. 10
      c3.js
  2. 2
      c3.min.js
  3. 10
      src/data.convert.js

10
c3.js

@ -2017,18 +2017,16 @@
var $$ = this, type = mimeType ? mimeType : 'csv'; var $$ = this, type = mimeType ? mimeType : 'csv';
$$.d3.xhr(url, function (error, data) { $$.d3.xhr(url, function (error, data) {
var d; var d;
var dataResponse = data.response || data.responseText;
if (!data) { if (!data) {
throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')'); throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')');
} }
if (!data.resonse) {
data.response = data.responseText;
}
if (type === 'json') { if (type === 'json') {
d = $$.convertJsonToData(JSON.parse(data.response), keys); d = $$.convertJsonToData(JSON.parse(dataResponse), keys);
} else if (type === 'tsv') { } else if (type === 'tsv') {
d = $$.convertTsvToData(data.response); d = $$.convertTsvToData(dataResponse);
} else { } else {
d = $$.convertCsvToData(data.response); d = $$.convertCsvToData(dataResponse);
} }
done.call($$, d); done.call($$, d);
}); });

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

10
src/data.convert.js

@ -2,18 +2,16 @@ c3_chart_internal_fn.convertUrlToData = function (url, mimeType, keys, done) {
var $$ = this, type = mimeType ? mimeType : 'csv'; var $$ = this, type = mimeType ? mimeType : 'csv';
$$.d3.xhr(url, function (error, data) { $$.d3.xhr(url, function (error, data) {
var d; var d;
var dataResponse = data.response || data.responseText;
if (!data) { if (!data) {
throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')'); throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')');
} }
if (!data.resonse) {
data.response = data.responseText;
}
if (type === 'json') { if (type === 'json') {
d = $$.convertJsonToData(JSON.parse(data.response), keys); d = $$.convertJsonToData(JSON.parse(dataResponse), keys);
} else if (type === 'tsv') { } else if (type === 'tsv') {
d = $$.convertTsvToData(data.response); d = $$.convertTsvToData(dataResponse);
} else { } else {
d = $$.convertCsvToData(data.response); d = $$.convertCsvToData(dataResponse);
} }
done.call($$, d); done.call($$, d);
}); });

Loading…
Cancel
Save