Browse Source

Fix conflict

pull/1577/merge
Masayuki Tanaka 9 years ago
parent
commit
5b2148f710
  1. 15
      c3.js
  2. 10
      c3.min.js
  3. 1
      src/config.js
  4. 2
      src/core.js
  5. 10
      src/data.convert.js
  6. 2
      src/data.load.js

15
c3.js

@ -86,7 +86,7 @@
$$.initParams(); $$.initParams();
if (config.data_url) { if (config.data_url) {
$$.convertUrlToData(config.data_url, config.data_mimeType, config.data_keys, $$.initWithData); $$.convertUrlToData(config.data_url, config.data_mimeType, config.data_headers, config.data_keys, $$.initWithData);
} }
else if (config.data_json) { else if (config.data_json) {
$$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); $$.initWithData($$.convertJsonToData(config.data_json, config.data_keys));
@ -1123,6 +1123,7 @@
data_onselected: function () {}, data_onselected: function () {},
data_onunselected: function () {}, data_onunselected: function () {},
data_url: undefined, data_url: undefined,
data_headers: undefined,
data_json: undefined, data_json: undefined,
data_rows: undefined, data_rows: undefined,
data_columns: undefined, data_columns: undefined,
@ -2018,9 +2019,15 @@
return current; return current;
}; };
c3_chart_internal_fn.convertUrlToData = function (url, mimeType, keys, done) { c3_chart_internal_fn.convertUrlToData = function (url, mimeType, headers, keys, done) {
var $$ = this, type = mimeType ? mimeType : 'csv'; var $$ = this, type = mimeType ? mimeType : 'csv';
$$.d3.xhr(url, function (error, data) { var req = $$.d3.xhr(url);
if (headers) {
Object.keys(headers).forEach(function (header) {
req.header(header, headers[header]);
});
}
req.get(function (error, data) {
var d; var d;
if (!data) { if (!data) {
throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')'); throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')');
@ -2256,7 +2263,7 @@
$$.load($$.convertDataToTargets(args.data), args); $$.load($$.convertDataToTargets(args.data), args);
} }
else if (args.url) { else if (args.url) {
$$.convertUrlToData(args.url, args.mimeType, args.keys, function (data) { $$.convertUrlToData(args.url, args.mimeType, args.headers, args.keys, function (data) {
$$.load($$.convertDataToTargets(data), args); $$.load($$.convertDataToTargets(data), args);
}); });
} }

10
c3.min.js vendored

File diff suppressed because one or more lines are too long

1
src/config.js

@ -56,6 +56,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
data_onselected: function () {}, data_onselected: function () {},
data_onunselected: function () {}, data_onunselected: function () {},
data_url: undefined, data_url: undefined,
data_headers: undefined,
data_json: undefined, data_json: undefined,
data_rows: undefined, data_rows: undefined,
data_columns: undefined, data_columns: undefined,

2
src/core.js

@ -81,7 +81,7 @@ c3_chart_internal_fn.init = function () {
$$.initParams(); $$.initParams();
if (config.data_url) { if (config.data_url) {
$$.convertUrlToData(config.data_url, config.data_mimeType, config.data_keys, $$.initWithData); $$.convertUrlToData(config.data_url, config.data_mimeType, config.data_headers, config.data_keys, $$.initWithData);
} }
else if (config.data_json) { else if (config.data_json) {
$$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); $$.initWithData($$.convertJsonToData(config.data_json, config.data_keys));

10
src/data.convert.js

@ -1,6 +1,12 @@
c3_chart_internal_fn.convertUrlToData = function (url, mimeType, keys, done) { c3_chart_internal_fn.convertUrlToData = function (url, mimeType, headers, keys, done) {
var $$ = this, type = mimeType ? mimeType : 'csv'; var $$ = this, type = mimeType ? mimeType : 'csv';
$$.d3.xhr(url, function (error, data) { var req = $$.d3.xhr(url);
if (headers) {
Object.keys(headers).forEach(function (header) {
req.header(header, headers[header]);
});
}
req.get(function (error, data) {
var d; var d;
if (!data) { if (!data) {
throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')'); throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')');

2
src/data.load.js

@ -39,7 +39,7 @@ c3_chart_internal_fn.loadFromArgs = function (args) {
$$.load($$.convertDataToTargets(args.data), args); $$.load($$.convertDataToTargets(args.data), args);
} }
else if (args.url) { else if (args.url) {
$$.convertUrlToData(args.url, args.mimeType, args.keys, function (data) { $$.convertUrlToData(args.url, args.mimeType, args.headers, args.keys, function (data) {
$$.load($$.convertDataToTargets(data), args); $$.load($$.convertDataToTargets(data), args);
}); });
} }

Loading…
Cancel
Save