|
|
|
@ -86,7 +86,7 @@
|
|
|
|
|
$$.initParams(); |
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
|
$$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); |
|
|
|
@ -1123,6 +1123,7 @@
|
|
|
|
|
data_onselected: function () {}, |
|
|
|
|
data_onunselected: function () {}, |
|
|
|
|
data_url: undefined, |
|
|
|
|
data_headers: undefined, |
|
|
|
|
data_json: undefined, |
|
|
|
|
data_rows: undefined, |
|
|
|
|
data_columns: undefined, |
|
|
|
@ -1187,6 +1188,7 @@
|
|
|
|
|
axis_y_tick_format: undefined, |
|
|
|
|
axis_y_tick_outer: true, |
|
|
|
|
axis_y_tick_values: null,
|
|
|
|
|
axis_y_tick_rotate: 0, |
|
|
|
|
axis_y_tick_count: undefined, |
|
|
|
|
axis_y_tick_time_value: undefined, |
|
|
|
|
axis_y_tick_time_interval: undefined, |
|
|
|
@ -2020,9 +2022,15 @@
|
|
|
|
|
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'; |
|
|
|
|
$$.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; |
|
|
|
|
if (!data) { |
|
|
|
|
throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')'); |
|
|
|
@ -2258,7 +2266,7 @@
|
|
|
|
|
$$.load($$.convertDataToTargets(args.data), args); |
|
|
|
|
} |
|
|
|
|
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); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -2747,12 +2755,18 @@
|
|
|
|
|
var $$ = this, config = $$.config, h = 30; |
|
|
|
|
if (axisId === 'x' && !config.axis_x_show) { return 8; } |
|
|
|
|
if (axisId === 'x' && config.axis_x_height) { return config.axis_x_height; } |
|
|
|
|
if (axisId === 'y' && !config.axis_y_show) { return config.legend_show && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1; } |
|
|
|
|
if (axisId === 'y' && !config.axis_y_show) {
|
|
|
|
|
return config.legend_show && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1;
|
|
|
|
|
} |
|
|
|
|
if (axisId === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; } |
|
|
|
|
// Calculate x axis height when tick rotated
|
|
|
|
|
if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) { |
|
|
|
|
h = 30 + $$.axis.getMaxTickWidth(axisId) * Math.cos(Math.PI * (90 - config.axis_x_tick_rotate) / 180); |
|
|
|
|
} |
|
|
|
|
// Calculate y axis height when tick rotated
|
|
|
|
|
if (axisId === 'y' && config.axis_rotated && config.axis_y_tick_rotate) { |
|
|
|
|
h = 30 + $$.axis.getMaxTickWidth(axisId) * Math.cos(Math.PI * (90 - config.axis_y_tick_rotate) / 180); |
|
|
|
|
} |
|
|
|
|
return h + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + (axisId === 'y2' ? -10 : 0); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -4396,17 +4410,16 @@
|
|
|
|
|
} |
|
|
|
|
return tickValues; |
|
|
|
|
}; |
|
|
|
|
Axis.prototype.getYAxis = function getYAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition) { |
|
|
|
|
var axisParams = { |
|
|
|
|
withOuterTick: withOuterTick, |
|
|
|
|
withoutTransition: withoutTransition, |
|
|
|
|
}, |
|
|
|
|
$$ = this.owner, |
|
|
|
|
d3 = $$.d3, |
|
|
|
|
config = $$.config, |
|
|
|
|
axis = c3_axis(d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat); |
|
|
|
|
Axis.prototype.getYAxis = function getYAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { |
|
|
|
|
var $$ = this.owner, config = $$.config, |
|
|
|
|
axisParams = { |
|
|
|
|
withOuterTick: withOuterTick, |
|
|
|
|
withoutTransition: withoutTransition, |
|
|
|
|
tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate |
|
|
|
|
}, |
|
|
|
|
axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat); |
|
|
|
|
if ($$.isTimeSeriesY()) { |
|
|
|
|
axis.ticks(d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval); |
|
|
|
|
axis.ticks($$.d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval); |
|
|
|
|
} else { |
|
|
|
|
axis.tickValues(tickValues); |
|
|
|
|
} |
|
|
|
@ -4596,10 +4609,10 @@
|
|
|
|
|
targetsToShow = $$.filterTargetsToShow($$.data.targets); |
|
|
|
|
if (id === 'y') { |
|
|
|
|
scale = $$.y.copy().domain($$.getYDomain(targetsToShow, 'y')); |
|
|
|
|
axis = this.getYAxis(scale, $$.yOrient, config.axis_y_tick_format, $$.yAxisTickValues, false, true); |
|
|
|
|
axis = this.getYAxis(scale, $$.yOrient, config.axis_y_tick_format, $$.yAxisTickValues, false, true, true); |
|
|
|
|
} else if (id === 'y2') { |
|
|
|
|
scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); |
|
|
|
|
axis = this.getYAxis(scale, $$.y2Orient, config.axis_y2_tick_format, $$.y2AxisTickValues, false, true); |
|
|
|
|
axis = this.getYAxis(scale, $$.y2Orient, config.axis_y2_tick_format, $$.y2AxisTickValues, false, true, true); |
|
|
|
|
} else { |
|
|
|
|
scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); |
|
|
|
|
axis = this.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues, false, true, true); |
|
|
|
@ -6220,6 +6233,10 @@
|
|
|
|
|
if (args.xs) { |
|
|
|
|
$$.addXs(args.xs); |
|
|
|
|
} |
|
|
|
|
// update names if exists
|
|
|
|
|
if ('names' in args) { |
|
|
|
|
c3_chart_fn.data.names.bind(this)(args.names); |
|
|
|
|
} |
|
|
|
|
// update classes if exists
|
|
|
|
|
if ('classes' in args) { |
|
|
|
|
Object.keys(args.classes).forEach(function (id) { |
|
|
|
|