|
|
@ -135,10 +135,6 @@ |
|
|
|
return call && (typeof call === "object" || typeof call === "function") ? call : self; |
|
|
|
return call && (typeof call === "object" || typeof call === "function") ? call : self; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var toArray = function (arr) { |
|
|
|
|
|
|
|
return Array.isArray(arr) ? arr : Array.from(arr); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isValue = function isValue(v) { |
|
|
|
var isValue = function isValue(v) { |
|
|
|
return v || v === 0; |
|
|
|
return v || v === 0; |
|
|
|
}; |
|
|
|
}; |
|
|
@ -5384,35 +5380,30 @@ |
|
|
|
|
|
|
|
|
|
|
|
c3_chart_internal_fn.convertUrlToData = function (url, mimeType, headers, keys, done) { |
|
|
|
c3_chart_internal_fn.convertUrlToData = function (url, mimeType, headers, keys, done) { |
|
|
|
var $$ = this, |
|
|
|
var $$ = this, |
|
|
|
type = mimeType ? mimeType : 'csv'; |
|
|
|
type = mimeType ? mimeType : 'csv', |
|
|
|
var req = $$.d3.request(url); |
|
|
|
f, |
|
|
|
if (headers) { |
|
|
|
converter; |
|
|
|
Object.keys(headers).forEach(function (header) { |
|
|
|
|
|
|
|
req.header(header, headers[header]); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
req.get(function (error, data) { |
|
|
|
|
|
|
|
var d; |
|
|
|
|
|
|
|
var dataResponse = data.response || data.responseText; // Fixes IE9 XHR issue; see #1345
|
|
|
|
|
|
|
|
if (!data) { |
|
|
|
|
|
|
|
throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (type === 'json') { |
|
|
|
if (type === 'json') { |
|
|
|
d = $$.convertJsonToData(JSON.parse(dataResponse), keys); |
|
|
|
f = $$.d3.json; |
|
|
|
|
|
|
|
converter = $$.convertJsonToData; |
|
|
|
} else if (type === 'tsv') { |
|
|
|
} else if (type === 'tsv') { |
|
|
|
d = $$.convertTsvToData(dataResponse); |
|
|
|
f = $$.d3.tsv; |
|
|
|
|
|
|
|
converter = $$.convertXsvToData; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
d = $$.convertCsvToData(dataResponse); |
|
|
|
f = $$.d3.csv; |
|
|
|
|
|
|
|
converter = $$.convertXsvToData; |
|
|
|
} |
|
|
|
} |
|
|
|
done.call($$, d); |
|
|
|
|
|
|
|
|
|
|
|
f(url, headers).then(function (data) { |
|
|
|
|
|
|
|
done.call($$, converter.call($$, data, keys)); |
|
|
|
|
|
|
|
}).catch(function (error) { |
|
|
|
|
|
|
|
throw error; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
c3_chart_internal_fn.convertXsvToData = function (xsv, parser) { |
|
|
|
c3_chart_internal_fn.convertXsvToData = function (xsv) { |
|
|
|
var _parser$parseRows = parser.parseRows(xsv), |
|
|
|
var keys = xsv.columns, |
|
|
|
_parser$parseRows2 = toArray(_parser$parseRows), |
|
|
|
rows = xsv; |
|
|
|
keys = _parser$parseRows2[0], |
|
|
|
|
|
|
|
rows = _parser$parseRows2.slice(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rows.length === 0) { |
|
|
|
if (rows.length === 0) { |
|
|
|
return { keys: keys, rows: [keys.reduce(function (row, key) { |
|
|
|
return { keys: keys, rows: [keys.reduce(function (row, key) { |
|
|
|
return Object.assign(row, defineProperty({}, key, null)); |
|
|
|
return Object.assign(row, defineProperty({}, key, null)); |
|
|
@ -5420,15 +5411,9 @@ |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// [].concat() is to convert result into a plain array otherwise
|
|
|
|
// [].concat() is to convert result into a plain array otherwise
|
|
|
|
// test is not happy because rows have properties.
|
|
|
|
// test is not happy because rows have properties.
|
|
|
|
return { keys: keys, rows: [].concat(parser.parse(xsv)) }; |
|
|
|
return { keys: keys, rows: [].concat(xsv) }; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
c3_chart_internal_fn.convertCsvToData = function (csv) { |
|
|
|
|
|
|
|
return this.convertXsvToData(csv, { parse: this.d3.csvParse, parseRows: this.d3.csvParseRows }); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
c3_chart_internal_fn.convertTsvToData = function (tsv) { |
|
|
|
|
|
|
|
return this.convertXsvToData(tsv, { parse: this.d3.tsvParse, parseRows: this.d3.tsvParseRows }); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
c3_chart_internal_fn.convertJsonToData = function (json, keys) { |
|
|
|
c3_chart_internal_fn.convertJsonToData = function (json, keys) { |
|
|
|
var $$ = this, |
|
|
|
var $$ = this, |
|
|
|
new_rows = [], |
|
|
|
new_rows = [], |
|
|
|