Commit a3a16800 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix literal for config

parent b8ac6975
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -13,11 +13,11 @@ c3_chart_fn.axis.max = function (max) {
var $$ = this.internal, config = $$.config;
if (arguments.length) {
if (typeof max === 'object') {
if (isValue(max.x)) { config[__axis_x_max] = max.x; }
if (isValue(max.y)) { config[__axis_y_max] = max.y; }
if (isValue(max.y2)) { config[__axis_y2_max] = max.y2; }
if (isValue(max.x)) { config.axis_x_max = max.x; }
if (isValue(max.y)) { config.axis_y_max = max.y; }
if (isValue(max.y2)) { config.axis_y2_max = max.y2; }
} else {
config[__axis_y_max] = config[__axis_y2_max] = max;
config.axis_y_max = config.axis_y2_max = max;
}
$$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true});
}
......@@ -26,11 +26,11 @@ c3_chart_fn.axis.min = function (min) {
var $$ = this.internal, config = $$.config;
if (arguments.length) {
if (typeof min === 'object') {
if (isValue(min.x)) { config[__axis_x_min] = min.x; }
if (isValue(min.y)) { config[__axis_y_min] = min.y; }
if (isValue(min.y2)) { config[__axis_y2_min] = min.y2; }
if (isValue(min.x)) { config.axis_x_min = min.x; }
if (isValue(min.y)) { config.axis_y_min = min.y; }
if (isValue(min.y2)) { config.axis_y2_min = min.y2; }
} else {
config[__axis_y_min] = config[__axis_y2_min] = min;
config.axis_y_min = config.axis_y2_min = min;
}
$$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true});
}
......
c3_chart_fn.category = function (i, category) {
var $$ = this.internal, config = $$.config;
if (arguments.length > 1) {
config[__axis_x_categories][i] = category;
config.axis_x_categories[i] = category;
$$.redraw();
}
return config[__axis_x_categories][i];
return config.axis_x_categories[i];
};
c3_chart_fn.categories = function (categories) {
var $$ = this.internal, config = $$.config;
if (!arguments.length) { return config[__axis_x_categories]; }
config[__axis_x_categories] = categories;
if (!arguments.length) { return config.axis_x_categories; }
config.axis_x_categories = categories;
$$.redraw();
return config[__axis_x_categories];
return config.axis_x_categories;
};
c3_chart_fn.resize = function (size) {
var $$ = this.internal, config = $$.config;
config[__size_width] = size ? size.width : null;
config[__size_height] = size ? size.height : null;
config.size_width = size ? size.width : null;
config.size_height = size ? size.height : null;
this.flush();
};
......
......@@ -9,19 +9,19 @@ c3_chart_fn.data.getAsTarget = function (targetId) {
};
c3_chart_fn.data.names = function (names) {
var $$ = this.internal, config = $$.config;
if (!arguments.length) { return config[__data_names]; }
if (!arguments.length) { return config.data_names; }
Object.keys(names).forEach(function (id) {
config[__data_names][id] = names[id];
config.data_names[id] = names[id];
});
$$.redraw({withLegend: true});
return config[__data_names];
return config.data_names;
};
c3_chart_fn.data.colors = function (colors) {
var $$ = this.internal, config = $$.config;
if (!arguments.length) { return config[__data_colors]; }
if (!arguments.length) { return config.data_colors; }
Object.keys(colors).forEach(function (id) {
config[__data_colors][id] = colors[id];
config.data_colors[id] = colors[id];
});
$$.redraw({withLegend: true});
return config[__data_colors];
return config.data_colors;
};
......@@ -130,7 +130,7 @@ c3_chart_fn.flow = function (args) {
flow: {
index: baseValue.index,
length: length,
duration: isValue(args.duration) ? args.duration : $$.config[__transition_duration],
duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
done: args.done,
orgDataCount: orgDataCount,
},
......@@ -243,10 +243,10 @@ c3_chart_internal_fn.generateFlow = function (args) {
xgridLines
.attr('transform', null);
xgridLines.select('line')
.attr("x1", config[__axis_rotated] ? 0 : xv)
.attr("x2", config[__axis_rotated] ? $$.width : xv);
.attr("x1", config.axis_rotated ? 0 : xv)
.attr("x2", config.axis_rotated ? $$.width : xv);
xgridLines.select('text')
.attr("x", config[__axis_rotated] ? $$.width : 0)
.attr("x", config.axis_rotated ? $$.width : 0)
.attr("y", xv);
mainBar
.attr('transform', null)
......
c3_chart_fn.xgrids = function (grids) {
var $$ = this.internal, config = $$.config;
if (! grids) { return config[__grid_x_lines]; }
config[__grid_x_lines] = grids;
if (! grids) { return config.grid_x_lines; }
config.grid_x_lines = grids;
$$.redraw();
return config[__grid_x_lines];
return config.grid_x_lines;
};
c3_chart_fn.xgrids.add = function (grids) {
var $$ = this.internal;
return this.xgrids($$.config[__grid_x_lines].concat(grids ? grids : []));
return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : []));
};
c3_chart_fn.xgrids.remove = function (params) { // TODO: multiple
var $$ = this.internal;
......@@ -16,14 +16,14 @@ c3_chart_fn.xgrids.remove = function (params) { // TODO: multiple
c3_chart_fn.ygrids = function (grids) {
var $$ = this.internal, config = $$.config;
if (! grids) { return config[__grid_y_lines]; }
config[__grid_y_lines] = grids;
if (! grids) { return config.grid_y_lines; }
config.grid_y_lines = grids;
$$.redraw();
return config[__grid_y_lines];
return config.grid_y_lines;
};
c3_chart_fn.ygrids.add = function (grids) {
var $$ = this.internal;
return this.ygrids($$.config[__grid_y_lines].concat(grids ? grids : []));
return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : []));
};
c3_chart_fn.ygrids.remove = function (params) { // TODO: multiple
var $$ = this.internal;
......
c3_chart_fn.groups = function (groups) {
var $$ = this.internal, config = $$.config;
if (isUndefined(groups)) { return config[__data_groups]; }
config[__data_groups] = groups;
if (isUndefined(groups)) { return config.data_groups; }
config.data_groups = groups;
$$.redraw();
return config[__data_groups];
return config.data_groups;
};
......@@ -7,12 +7,12 @@ c3_chart_fn.load = function (args) {
// update classes if exists
if ('classes' in args) {
Object.keys(args.classes).forEach(function (id) {
config[__data_classes][id] = args.classes[id];
config.data_classes[id] = args.classes[id];
});
}
// update categories if exists
if ('categories' in args && $$.isCategorized()) {
config[__axis_x_categories] = args.categories;
config.axis_x_categories = args.categories;
}
// use cache if exists
if ('cacheIds' in args && $$.hasCaches(args.cacheIds)) {
......
c3_chart_fn.regions = function (regions) {
var $$ = this.internal, config = $$.config;
if (!regions) { return config[__regions]; }
config[__regions] = regions;
if (!regions) { return config.regions; }
config.regions = regions;
$$.redraw();
return config[__regions];
return config.regions;
};
c3_chart_fn.regions.add = function (regions) {
var $$ = this.internal, config = $$.config;
if (!regions) { return config[__regions]; }
config[__regions] = config[__regions].concat(regions);
if (!regions) { return config.regions; }
config.regions = config.regions.concat(regions);
$$.redraw();
return config[__regions];
return config.regions;
};
c3_chart_fn.regions.remove = function (options) {
var $$ = this.internal, config = $$.config,
duration, classes, regions;
options = options || {};
duration = $$.getOption(options, "duration", config[__transition_duration]);
duration = $$.getOption(options, "duration", config.transition_duration);
classes = $$.getOption(options, "classes", [CLASS[_region]]);
regions = $$.main.select('.' + CLASS[_regions]).selectAll(classes.map(function (c) { return '.' + c; }));
......@@ -25,7 +25,7 @@ c3_chart_fn.regions.remove = function (options) {
.style('opacity', 0)
.remove();
config[__regions] = config[__regions].filter(function (region) {
config.regions = config.regions.filter(function (region) {
var found = false;
if (!region.class) {
return true;
......@@ -36,5 +36,5 @@ c3_chart_fn.regions.remove = function (options) {
return !found;
});
return config[__regions];
return config.regions;
};
......@@ -8,10 +8,10 @@ c3_chart_fn.selected = function (targetId) {
};
c3_chart_fn.select = function (ids, indices, resetOther) {
var $$ = this.internal, d3 = $$.d3, config = $$.config;
if (! config[__data_selection_enabled]) { return; }
if (! config.data_selection_enabled) { return; }
$$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) {
var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this),
isTargetId = config[__data_selection_grouped] || !ids || ids.indexOf(id) >= 0,
isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
isTargetIndex = !indices || indices.indexOf(i) >= 0,
isSelected = shape.classed(CLASS[_SELECTED]);
// line/area selection not supported yet
......@@ -19,7 +19,7 @@ c3_chart_fn.select = function (ids, indices, resetOther) {
return;
}
if (isTargetId && isTargetIndex) {
if (config[__data_selection_isselectable](d) && !isSelected) {
if (config.data_selection_isselectable(d) && !isSelected) {
toggle(true, shape.classed(CLASS[_SELECTED], true), d, i);
}
} else if (isDefined(resetOther) && resetOther) {
......@@ -31,10 +31,10 @@ c3_chart_fn.select = function (ids, indices, resetOther) {
};
c3_chart_fn.unselect = function (ids, indices) {
var $$ = this.internal, d3 = $$.d3, config = $$.config;
if (! config[__data_selection_enabled]) { return; }
if (! config.data_selection_enabled) { return; }
$$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) {
var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this),
isTargetId = config[__data_selection_grouped] || !ids || ids.indexOf(id) >= 0,
isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
isTargetIndex = !indices || indices.indexOf(i) >= 0,
isSelected = shape.classed(CLASS[_SELECTED]);
// line/area selection not supported yet
......@@ -42,7 +42,7 @@ c3_chart_fn.unselect = function (ids, indices) {
return;
}
if (isTargetId && isTargetIndex) {
if (config[__data_selection_isselectable](d)) {
if (config.data_selection_isselectable(d)) {
if (isSelected) {
toggle(false, shape.classed(CLASS[_SELECTED], false), d, i);
}
......
......@@ -2,7 +2,7 @@ c3_chart_fn.zoom = function () {
};
c3_chart_fn.zoom.enable = function (enabled) {
var $$ = this.internal;
$$.config[__zoom_enabled] = enabled;
$$.config.zoom_enabled = enabled;
$$.updateAndRedraw();
};
c3_chart_fn.unzoom = function () {
......
......@@ -3,14 +3,14 @@ c3_chart_internal_fn.initPie = function () {
$$.pie = d3.layout.pie().value(function (d) {
return d.values.reduce(function (a, b) { return a + b.value; }, 0);
});
if (!config[__data_order] || !config[__pie_sort] || !config[__donut_sort]) {
if (!config.data_order || !config.pie_sort || !config.donut_sort) {
$$.pie.sort(null);
}
};
c3_chart_internal_fn.updateRadius = function () {
var $$ = this, config = $$.config,
w = config[__gauge_width] || config[__donut_width];
w = config.gauge_width || config.donut_width;
$$.radiusExpanded = Math.min($$.arcWidth, $$.arcHeight) / 2;
$$.radius = $$.radiusExpanded * 0.95;
$$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6;
......@@ -39,7 +39,7 @@ c3_chart_internal_fn.updateAngle = function (d) {
d.endAngle = d.startAngle;
}
if ($$.isGaugeType(d.data)) {
var gMin = config[__gauge_min], gMax = config[__gauge_max],
var gMin = config.gauge_min, gMax = config.gauge_max,
gF = Math.abs(gMin) + gMax,
aTic = (Math.PI) / gF;
d.startAngle = (-1 * (Math.PI / 2)) + (aTic * Math.abs(gMin));
......@@ -152,15 +152,15 @@ c3_chart_internal_fn.unexpandArc = function (id) {
c3_chart_internal_fn.shouldExpand = function (id) {
var $$ = this, config = $$.config;
return ($$.isDonutType(id) && config[__donut_expand]) || ($$.isGaugeType(id) && config[__gauge_expand]) || ($$.isPieType(id) && config[__pie_expand]);
return ($$.isDonutType(id) && config.donut_expand) || ($$.isGaugeType(id) && config.gauge_expand) || ($$.isPieType(id) && config.pie_expand);
};
c3_chart_internal_fn.shouldShowArcLabel = function () {
var $$ = this, config = $$.config, shouldShow = true;
if ($$.hasType('donut')) {
shouldShow = config[__donut_label_show];
shouldShow = config.donut_label_show;
} else if ($$.hasType('pie')) {
shouldShow = config[__pie_label_show];
shouldShow = config.pie_label_show;
}
// when gauge, always true
return shouldShow;
......@@ -168,24 +168,24 @@ c3_chart_internal_fn.shouldShowArcLabel = function () {
c3_chart_internal_fn.meetsArcLabelThreshold = function (ratio) {
var $$ = this, config = $$.config,
threshold = $$.hasType('donut') ? config[__donut_label_threshold] : config[__pie_label_threshold];
threshold = $$.hasType('donut') ? config.donut_label_threshold : config.pie_label_threshold;
return ratio >= threshold;
};
c3_chart_internal_fn.getArcLabelFormat = function () {
var $$ = this, config = $$.config,
format = config[__pie_label_format];
format = config.pie_label_format;
if ($$.hasType('gauge')) {
format = config[__gauge_label_format];
format = config.gauge_label_format;
} else if ($$.hasType('donut')) {
format = config[__donut_label_format];
format = config.donut_label_format;
}
return format;
};
c3_chart_internal_fn.getArcTitle = function () {
var $$ = this;
return $$.hasType('donut') ? $$.config[__donut_title] : "";
return $$.hasType('donut') ? $$.config.donut_title : "";
};
c3_chart_internal_fn.descByStartAngle = function (a, b) {
......@@ -232,7 +232,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf
mainArc.enter().append('path')
.attr("class", $$.classArc.bind($$))
.style("fill", function (d) { return $$.color(d.data); })
.style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; })
.style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; })
.style("opacity", 0)
.each(function (d) {
if ($$.isGaugeType(d.data)) {
......@@ -250,7 +250,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf
// transitions
$$.expandArc(updated.data.id);
$$.toggleFocusLegend(updated.data.id, true);
$$.config[__data_onmouseover](arcData, this);
$$.config.data_onmouseover(arcData, this);
})
.on('mousemove', function (d) {
var updated = $$.updateAngle(d),
......@@ -269,7 +269,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf
$$.unexpandArc(updated.data.id);
$$.revertLegend();
$$.hideTooltip();
$$.config[__data_onmouseout](arcData, this);
$$.config.data_onmouseout(arcData, this);
})
.on('click', function (d, i) {
var updated, arcData;
......@@ -332,7 +332,7 @@ c3_chart_internal_fn.initGauge = function () {
.attr("class", CLASS[_chartArcsBackground])
.attr("d", function () {
var d = {
data: [{value: config[__gauge_max]}],
data: [{value: config.gauge_max}],
startAngle: -1 * (Math.PI / 2),
endAngle: Math.PI / 2
};
......@@ -343,20 +343,20 @@ c3_chart_internal_fn.initGauge = function () {
.attr("class", CLASS[_chartArcsGaugeUnit])
.style("text-anchor", "middle")
.style("pointer-events", "none")
.text(config[__gauge_label_show] ? config[__gauge_units] : '');
.text(config.gauge_label_show ? config.gauge_units : '');
arcs.append("text")
.attr("dx", -1 * ($$.innerRadius + (($$.radius - $$.innerRadius) / 2)) + "px")
.attr("dy", "1.2em")
.attr("class", CLASS[_chartArcsGaugeMin])
.style("text-anchor", "middle")
.style("pointer-events", "none")
.text(config[__gauge_label_show] ? config[__gauge_min] : '');
.text(config.gauge_label_show ? config.gauge_min : '');
arcs.append("text")
.attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / 2) + "px")
.attr("dy", "1.2em")
.attr("class", CLASS[_chartArcsGaugeMax])
.style("text-anchor", "middle")
.style("pointer-events", "none")
.text(config[__gauge_label_show] ? config[__gauge_max] : '');
.text(config.gauge_label_show ? config.gauge_max : '');
}
};
c3_chart_internal_fn.categoryName = function (i) {
var config = this.config;
return i < config[__axis_x_categories].length ? config[__axis_x_categories][i] : i;
return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i;
};
......@@ -196,7 +196,7 @@ c3_chart_internal_fn.classEvent = function (d) {
};
c3_chart_internal_fn.classTarget = function (id) {
var $$ = this;
var additionalClassSuffix = $$.config[__data_classes][id], additionalClass = '';
var additionalClassSuffix = $$.config.data_classes[id], additionalClass = '';
if (additionalClassSuffix) {
additionalClass = ' ' + CLASS[_target] + '-' + additionalClassSuffix;
}
......
......@@ -11,19 +11,19 @@ c3_chart_internal_fn.getAxisClipY = function (forHorizontal) {
};
c3_chart_internal_fn.getXAxisClipX = function () {
var $$ = this;
return $$.getAxisClipX(!$$.config[__axis_rotated]);
return $$.getAxisClipX(!$$.config.axis_rotated);
};
c3_chart_internal_fn.getXAxisClipY = function () {
var $$ = this;
return $$.getAxisClipY(!$$.config[__axis_rotated]);
return $$.getAxisClipY(!$$.config.axis_rotated);
};
c3_chart_internal_fn.getYAxisClipX = function () {
var $$ = this;
return $$.getAxisClipX($$.config[__axis_rotated]);
return $$.getAxisClipX($$.config.axis_rotated);
};
c3_chart_internal_fn.getYAxisClipY = function () {
var $$ = this;
return $$.getAxisClipY($$.config[__axis_rotated]);
return $$.getAxisClipY($$.config.axis_rotated);
};
c3_chart_internal_fn.getAxisClipWidth = function (forHorizontal) {
var $$ = this;
......@@ -32,21 +32,21 @@ c3_chart_internal_fn.getAxisClipWidth = function (forHorizontal) {
};
c3_chart_internal_fn.getAxisClipHeight = function (forHorizontal) {
var $$ = this, config = $$.config;
return forHorizontal ? (config[__axis_x_height] ? config[__axis_x_height] : 0) + 80 : $$.height + 8;
return forHorizontal ? (config.axis_x_height ? config.axis_x_height : 0) + 80 : $$.height + 8;
};
c3_chart_internal_fn.getXAxisClipWidth = function () {
var $$ = this;
return $$.getAxisClipWidth(!$$.config[__axis_rotated]);
return $$.getAxisClipWidth(!$$.config.axis_rotated);
};
c3_chart_internal_fn.getXAxisClipHeight = function () {
var $$ = this;
return $$.getAxisClipHeight(!$$.config[__axis_rotated]);
return $$.getAxisClipHeight(!$$.config.axis_rotated);
};
c3_chart_internal_fn.getYAxisClipWidth = function () {
var $$ = this;
return $$.getAxisClipWidth($$.config[__axis_rotated]);
return $$.getAxisClipWidth($$.config.axis_rotated);
};
c3_chart_internal_fn.getYAxisClipHeight = function () {
var $$ = this;
return $$.getAxisClipHeight($$.config[__axis_rotated]);
return $$.getAxisClipHeight($$.config.axis_rotated);
};
c3_chart_internal_fn.generateColor = function () {
var $$ = this, config = $$.config, d3 = $$.d3,
colors = config[__data_colors],
pattern = notEmpty(config[__color_pattern]) ? config[__color_pattern] : d3.scale.category10().range(),
callback = config[__data_color],
colors = config.data_colors,
pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.scale.category10().range(),
callback = config.data_color,
ids = [];
return function (d) {
......@@ -27,12 +27,12 @@ c3_chart_internal_fn.generateColor = function () {
};
c3_chart_internal_fn.generateLevelColor = function () {
var $$ = this, config = $$.config,
colors = config[__color_pattern],
threshold = config[__color_threshold],
colors = config.color_pattern,
threshold = config.color_threshold,
asValue = threshold.unit === 'value',
values = threshold.values && threshold.values.length ? threshold.values : [],
max = threshold.max || 100;
return notEmpty(config[__color_threshold]) ? function (value) {
return notEmpty(config.color_threshold) ? function (value) {
var i, v, color = colors[colors.length - 1];
for (i = 0; i < values.length; i++) {
v = asValue ? value : (value * 100 / max);
......
......@@ -29,7 +29,7 @@ c3_chart_internal_fn.convertJsonToData = function (json, keys) {
targetKeys = keys.value;
if (keys.x) {
targetKeys.push(keys.x);
$$.config[__data_x] = keys.x;
$$.config.data_x = keys.x;
}
new_rows.push(targetKeys);
json.forEach(function (o) {
......@@ -100,11 +100,11 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
);
}
// if not included in input data, find from preloaded data of other id's x
else if (config[__data_x]) {
else if (config.data_x) {
$$.data.xs[id] = $$.getOtherTargetXs();
}
// if not included in input data, find from preloaded data
else if (notEmpty(config[__data_xs])) {
else if (notEmpty(config.data_xs)) {
$$.data.xs[id] = $$.getXValuesOfXKey(xKey, $$.data.targets);
}
// MEMO: if no x included, use same x of current will be used
......@@ -123,7 +123,7 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
// convert to target
targets = ids.map(function (id, index) {
var convertedId = config[__data_idConverter](id);
var convertedId = config.data_idConverter(id);
return {
id: convertedId,
id_org: id,
......@@ -131,8 +131,8 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
var xKey = $$.getXKey(id), rawX = d[xKey], x = $$.generateTargetX(rawX, id, i);
// use x as categories if custom x and categorized
if ($$.isCustomX() && $$.isCategorized() && index === 0 && rawX) {
if (i === 0) { config[__axis_x_categories] = []; }
config[__axis_x_categories].push(rawX);
if (i === 0) { config.axis_x_categories = []; }
config.axis_x_categories.push(rawX);
}
// mark as x = undefined if value is undefined and filter to remove after mapped
if (isUndefined(d[id]) || $$.data.xs[id].length <= i) {
......@@ -164,8 +164,8 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
});
// set target types
if (config[__data_type]) {
$$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config[__data_types]); }), config[__data_type]);
if (config.data_type) {
$$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config.data_types); }), config.data_type);
}
// cache as original id keyed
......
c3_chart_internal_fn.isX = function (key) {
var $$ = this, config = $$.config;
return (config[__data_x] && key === config[__data_x]) || (notEmpty(config[__data_xs]) && hasValue(config[__data_xs], key));
return (config.data_x && key === config.data_x) || (notEmpty(config.data_xs) && hasValue(config.data_xs, key));
};
c3_chart_internal_fn.isNotX = function (key) {
return !this.isX(key);
};
c3_chart_internal_fn.getXKey = function (id) {
var $$ = this, config = $$.config;
return config[__data_x] ? config[__data_x] : notEmpty(config[__data_xs]) ? config[__data_xs][id] : null;
return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null;
};
c3_chart_internal_fn.getXValuesOfXKey = function (key, targets) {
var $$ = this,
......@@ -35,7 +35,7 @@ c3_chart_internal_fn.getOtherTargetX = function (index) {
c3_chart_internal_fn.addXs = function (xs) {
var $$ = this;
Object.keys(xs).forEach(function (id) {
$$.config[__data_xs][id] = xs[id];
$$.config.data_xs[id] = xs[id];
});
};
c3_chart_internal_fn.hasMultipleX = function (xs) {
......@@ -43,12 +43,12 @@ c3_chart_internal_fn.hasMultipleX = function (xs) {
};
c3_chart_internal_fn.isMultipleX = function () {
var $$ = this, config = $$.config;
return notEmpty(config[__data_xs]) && $$.hasMultipleX(config[__data_xs]);
return notEmpty(config.data_xs) && $$.hasMultipleX(config.data_xs);
};
c3_chart_internal_fn.addName = function (data) {
var $$ = this, name;
if (data) {
name = $$.config[__data_names][data.id];
name = $$.config.data_names[data.id];
data.name = name ? name : data.id;
}
return data;
......@@ -203,11 +203,11 @@ c3_chart_internal_fn.hasPositiveValueInTargets = function (targets) {
};
c3_chart_internal_fn.isOrderDesc = function () {
var config = this.config;
return config[__data_order] && config[__data_order].toLowerCase() === 'desc';
return config.data_order && config.data_order.toLowerCase() === 'desc';
};
c3_chart_internal_fn.isOrderAsc = function () {
var config = this.config;
return config[__data_order] && config[__data_order].toLowerCase() === 'asc';
return config.data_order && config.data_order.toLowerCase() === 'asc';
};
c3_chart_internal_fn.orderTargets = function (targets) {
var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc();
......@@ -218,8 +218,8 @@ c3_chart_internal_fn.orderTargets = function (targets) {
t2Sum = t2.values.reduce(reducer, 0);
return orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum;
});
} else if (isFunction(config[__data_order])) {
targets.sort(config[__data_order]);
} else if (isFunction(config.data_order)) {
targets.sort(config.data_order);
} // TODO: accept name array for order
return targets;
};
......@@ -231,9 +231,9 @@ c3_chart_internal_fn.filterRemoveNull = function (data) {
};
c3_chart_internal_fn.hasDataLabel = function () {
var config = this.config;
if (typeof config[__data_labels] === 'boolean' && config[__data_labels]) {
if (typeof config.data_labels === 'boolean' && config.data_labels) {
return true;
} else if (typeof config[__data_labels] === 'object' && notEmpty(config[__data_labels])) {
} else if (typeof config.data_labels === 'object' && notEmpty(config.data_labels)) {
return true;
}
return false;
......@@ -276,7 +276,7 @@ c3_chart_internal_fn.findClosestOfValues = function (values, pos, _min, _max) {
max = _max ? _max : values.length - 1,
med = Math.floor((max - min) / 2) + min,
value = values[med],
diff = $$.x(value.x) - pos[$$.config[__axis_rotated] ? 1 : 0],
diff = $$.x(value.x) - pos[$$.config.axis_rotated ? 1 : 0],
candidates;
// Update range for search
......@@ -325,7 +325,7 @@ c3_chart_internal_fn.findClosest = function (values, pos) {
c3_chart_internal_fn.dist = function (data, pos) {
var $$ = this, config = $$.config,
yScale = $$.getAxisId(data.id) === 'y' ? $$.y : $$.y2,
xIndex = config[__axis_rotated] ? 1 : 0,
yIndex = config[__axis_rotated] ? 0 : 1;
xIndex = config.axis_rotated ? 1 : 0,
yIndex = config.axis_rotated ? 0 : 1;
return Math.pow($$.x(data.x) - pos[xIndex], 2) + Math.pow(yScale(data.value) - pos[yIndex], 2);
};
......@@ -2,11 +2,11 @@ c3_chart_internal_fn.getYDomainMin = function (targets) {
var $$ = this, config = $$.config,
ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets),
j, k, baseId, idsInGroup, id, hasNegativeValue;
if (config[__data_groups].length > 0) {
if (config.data_groups.length > 0) {
hasNegativeValue = $$.hasNegativeValueInTargets(targets);
for (j = 0; j < config[__data_groups].length; j++) {
for (j = 0; j < config.data_groups.length; j++) {
// Determine baseId
idsInGroup = config[__data_groups][j].filter(function (id) { return ids.indexOf(id) >= 0; });
idsInGroup = config.data_groups[j].filter(function (id) { return ids.indexOf(id) >= 0; });
if (idsInGroup.length === 0) { continue; }
baseId = idsInGroup[0];
// Consider negative values
......@@ -33,11 +33,11 @@ c3_chart_internal_fn.getYDomainMax = function (targets) {
var $$ = this, config = $$.config,
ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets),
j, k, baseId, idsInGroup, id, hasPositiveValue;
if (config[__data_groups].length > 0) {
if (config.data_groups.length > 0) {
hasPositiveValue = $$.hasPositiveValueInTargets(targets);
for (j = 0; j < config[__data_groups].length; j++) {
for (j = 0; j < config.data_groups.length; j++) {
// Determine baseId
idsInGroup = config[__data_groups][j].filter(function (id) { return ids.indexOf(id) >= 0; });
idsInGroup = config.data_groups[j].filter(function (id) { return ids.indexOf(id) >= 0; });
if (idsInGroup.length === 0) { continue; }
baseId = idsInGroup[0];
// Consider positive values
......@@ -63,16 +63,16 @@ c3_chart_internal_fn.getYDomainMax = function (targets) {
c3_chart_internal_fn.getYDomain = function (targets, axisId) {
var $$ = this, config = $$.config,
yTargets = targets.filter(function (d) { return $$.getAxisId(d.id) === axisId; }),
yMin = axisId === 'y2' ? config[__axis_y2_min] : config[__axis_y_min],
yMax = axisId === 'y2' ? config[__axis_y2_max] : config[__axis_y_max],
yMin = axisId === 'y2' ? config.axis_y2_min : config.axis_y_min,
yMax = axisId === 'y2' ? config.axis_y2_max : config.axis_y_max,
yDomainMin = isValue(yMin) ? yMin : $$.getYDomainMin(yTargets),
yDomainMax = isValue(yMax) ? yMax : $$.getYDomainMax(yTargets),
domainLength, padding, padding_top, padding_bottom,
center = axisId === 'y2' ? config[__axis_y2_center] : config[__axis_y_center],
center = axisId === 'y2' ? config.axis_y2_center : config.axis_y_center,
yDomainAbs, lengths, diff, ratio, isAllPositive, isAllNegative,
isZeroBased = ($$.hasType('bar', yTargets) && config[__bar_zerobased]) || ($$.hasType('area', yTargets) && config[__area_zerobased]),
showHorizontalDataLabel = $$.hasDataLabel() && config[__axis_rotated],
showVerticalDataLabel = $$.hasDataLabel() && !config[__axis_rotated];
isZeroBased = ($$.hasType('bar', yTargets) && config.bar_zerobased) || ($$.hasType('area', yTargets) && config.area_zerobased),
showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated,
showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated;
if (yTargets.length === 0) { // use current domain if target of axisId is none
return axisId === 'y2' ? $$.y2.domain() : $$.y.domain();
}
......@@ -108,13 +108,13 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId) {
padding_top += lengths[1];
padding_bottom += lengths[0];
}
if (axisId === 'y' && config[__axis_y_padding]) {
padding_top = $$.getAxisPadding(config[__axis_y_padding], 'top', padding, domainLength);
padding_bottom = $$.getAxisPadding(config[__axis_y_padding], 'bottom', padding, domainLength);
if (axisId === 'y' && config.axis_y_padding) {
padding_top = $$.getAxisPadding(config.axis_y_padding, 'top', padding, domainLength);
padding_bottom = $$.getAxisPadding(config.axis_y_padding, 'bottom', padding, domainLength);
}
if (axisId === 'y2' && config[__axis_y2_padding]) {
padding_top = $$.getAxisPadding(config[__axis_y2_padding], 'top', padding, domainLength);
padding_bottom = $$.getAxisPadding(config[__axis_y2_padding], 'bottom', padding, domainLength);
if (axisId === 'y2' && config.axis_y2_padding) {
padding_top = $$.getAxisPadding(config.axis_y2_padding, 'top', padding, domainLength);
padding_bottom = $$.getAxisPadding(config.axis_y2_padding, 'bottom', padding, domainLength);
}
// Bar/Area chart should be 0-based if all positive|negative
if (isZeroBased) {
......@@ -125,14 +125,14 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId) {
};
c3_chart_internal_fn.getXDomainMin = function (targets) {
var $$ = this, config = $$.config;
return config[__axis_x_min] ?
($$.isTimeSeries() ? this.parseDate(config[__axis_x_min]) : config[__axis_x_min]) :
return config.axis_x_min ?
($$.isTimeSeries() ? this.parseDate(config.axis_x_min) : config.axis_x_min) :
$$.d3.min(targets, function (t) { return $$.d3.min(t.values, function (v) { return v.x; }); });
};
c3_chart_internal_fn.getXDomainMax = function (targets) {
var $$ = this, config = $$.config;
return config[__axis_x_max] ?
($$.isTimeSeries() ? this.parseDate(config[__axis_x_max]) : config[__axis_x_max]) :
return config.axis_x_max ?
($$.isTimeSeries() ? this.parseDate(config.axis_x_max) : config.axis_x_max) :
$$.d3.max(targets, function (t) { return $$.d3.max(t.values, function (v) { return v.x; }); });
};
c3_chart_internal_fn.getXDomainPadding = function (targets) {
......@@ -147,11 +147,11 @@ c3_chart_internal_fn.getXDomainPadding = function (targets) {
} else {
padding = diff * 0.01;
}
if (typeof config[__axis_x_padding] === 'object' && notEmpty(config[__axis_x_padding])) {
paddingLeft = isValue(config[__axis_x_padding].left) ? config[__axis_x_padding].left : padding;
paddingRight = isValue(config[__axis_x_padding].right) ? config[__axis_x_padding].right : padding;
} else if (typeof config[__axis_x_padding] === 'number') {
paddingLeft = paddingRight = config[__axis_x_padding];
if (typeof config.axis_x_padding === 'object' && notEmpty(config.axis_x_padding)) {
paddingLeft = isValue(config.axis_x_padding.left) ? config.axis_x_padding.left : padding;
paddingRight = isValue(config.axis_x_padding.right) ? config.axis_x_padding.right : padding;
} else if (typeof config.axis_x_padding === 'number') {
paddingLeft = paddingRight = config.axis_x_padding;
} else {
paddingLeft = paddingRight = padding;
}
......@@ -181,13 +181,13 @@ c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withU
if (withUpdateOrgXDomain) {
$$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets)));
$$.orgXDomain = $$.x.domain();
if (config[__zoom_enabled]) { $$.zoom.scale($$.x).updateScaleExtent(); }
if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); }
$$.subX.domain($$.x.domain());
if ($$.brush) { $$.brush.scale($$.subX); }
}
if (withUpdateXDomain) {
$$.x.domain(domain ? domain : (!$$.brush || $$.brush.empty()) ? $$.orgXDomain : $$.brush.extent());
if (config[__zoom_enabled]) { $$.zoom.scale($$.x).updateScaleExtent(); }
if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); }
}
return $$.x.domain();
};
......@@ -3,9 +3,9 @@ c3_chart_internal_fn.drag = function (mouse) {
var sx, sy, mx, my, minX, maxX, minY, maxY;
if ($$.hasArcType()) { return; }
if (! config[__data_selection_enabled]) { return; } // do nothing if not selectable
if (config[__zoom_enabled] && ! $$.zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior
if (!config[__data_selection_multiple]) { return; } // skip when single selection because drag is used for multiple selection
if (! config.data_selection_enabled) { return; } // do nothing if not selectable
if (config.zoom_enabled && ! $$.zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior
if (!config.data_selection_multiple) { return; } // skip when single selection because drag is used for multiple selection
sx = $$.dragStart[0];
sy = $$.dragStart[1];
......@@ -13,8 +13,8 @@ c3_chart_internal_fn.drag = function (mouse) {
my = mouse[1];
minX = Math.min(sx, mx);
maxX = Math.max(sx, mx);
minY = (config[__data_selection_grouped]) ? $$.margin.top : Math.min(sy, my);
maxY = (config[__data_selection_grouped]) ? $$.height : Math.max(sy, my);
minY = (config.data_selection_grouped) ? $$.margin.top : Math.min(sy, my);
maxY = (config.data_selection_grouped) ? $$.height : Math.max(sy, my);
main.select('.' + CLASS[_dragarea])
.attr('x', minX)
......@@ -23,7 +23,7 @@ c3_chart_internal_fn.drag = function (mouse) {
.attr('height', maxY - minY);
// TODO: binary search when multiple xs
main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape])
.filter(function (d) { return config[__data_selection_isselectable](d); })
.filter(function (d) { return config.data_selection_isselectable(d); })
.each(function (d, i) {
var shape = d3.select(this),
isSelected = shape.classed(CLASS[_SELECTED]),
......@@ -59,19 +59,19 @@ c3_chart_internal_fn.drag = function (mouse) {
c3_chart_internal_fn.dragstart = function (mouse) {
var $$ = this, config = $$.config;
if ($$.hasArcType()) { return; }
if (! config[__data_selection_enabled]) { return; } // do nothing if not selectable
if (! config.data_selection_enabled) { return; } // do nothing if not selectable
$$.dragStart = mouse;
$$.main.select('.' + CLASS[_chart]).append('rect')
.attr('class', CLASS[_dragarea])
.style('opacity', 0.1);
$$.dragging = true;
$$.config[__data_ondragstart]();
$$.config.data_ondragstart();
};
c3_chart_internal_fn.dragend = function () {
var $$ = this, config = $$.config;
if ($$.hasArcType()) { return; }
if (! config[__data_selection_enabled]) { return; } // do nothing if not selectable
if (! config.data_selection_enabled) { return; } // do nothing if not selectable
$$.main.select('.' + CLASS[_dragarea])
.transition().duration(100)
.style('opacity', 0)
......@@ -79,6 +79,6 @@ c3_chart_internal_fn.dragend = function () {
$$.main.selectAll('.' + CLASS[_shape])
.classed(CLASS[_INCLUDED], false);
$$.dragging = false;
$$.config[__data_ondragend]();
$$.config.data_ondragend();
};
......@@ -9,12 +9,12 @@ c3_chart_internal_fn.getYFormat = function (forArc) {
};
c3_chart_internal_fn.yFormat = function (v) {
var $$ = this, config = $$.config,
format = config[__axis_y_tick_format] ? config[__axis_y_tick_format] : $$.defaultValueFormat;
format = config.axis_y_tick_format ? config.axis_y_tick_format : $$.defaultValueFormat;
return format(v);
};
c3_chart_internal_fn.y2Format = function (v) {
var $$ = this, config = $$.config,
format = config[__axis_y2_tick_format] ? config[__axis_y2_tick_format] : $$.defaultValueFormat;
format = config.axis_y2_tick_format ? config.axis_y2_tick_format : $$.defaultValueFormat;
return format(v);
};
c3_chart_internal_fn.defaultValueFormat = function (v) {
......@@ -24,7 +24,7 @@ c3_chart_internal_fn.defaultArcValueFormat = function (v, ratio) {
return (ratio * 100).toFixed(1) + '%';
};
c3_chart_internal_fn.formatByAxisId = function (axisId) {
var $$ = this, data_labels = $$.config[__data_labels],
var $$ = this, data_labels = $$.config.data_labels,
format = function (v) { return isValue(v) ? +v : ""; };
// find format according to axis id
if (data_labels.format) {
......
......@@ -3,15 +3,15 @@ c3_chart_internal_fn.initGrid = function () {
$$.grid = $$.main.append('g')
.attr("clip-path", $$.clipPath)
.attr('class', CLASS[_grid]);
if (config[__grid_x_show]) {
if (config.grid_x_show) {
$$.grid.append("g").attr("class", CLASS[_xgrids]);
}
if (config[__grid_y_show]) {
if (config.grid_y_show) {
$$.grid.append('g').attr('class', CLASS[_ygrids]);
}
$$.grid.append('g').attr("class", CLASS[_xgridLines]);
$$.grid.append('g').attr('class', CLASS[_ygridLines]);
if (config[__grid_focus_show]) {
if (config.grid_focus_show) {
$$.grid.append('g')
.attr("class", CLASS[_xgridFocus])
.append('line')
......@@ -23,10 +23,10 @@ c3_chart_internal_fn.initGrid = function () {
c3_chart_internal_fn.updateXGrid = function (withoutUpdate) {
var $$ = this, config = $$.config, CLASS = $$.CLASS, d3 = $$.d3,
xgridData = $$.generateGridData(config[__grid_x_type], $$.x),
xgridData = $$.generateGridData(config.grid_x_type, $$.x),
tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0;
$$.xgridAttr = config[__axis_rotated] ? {
$$.xgridAttr = config.axis_rotated ? {
'x1': 0,
'x2': $$.width,
'y1': function (d) { return $$.x(d) - tickOffset; },
......@@ -43,7 +43,7 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) {
$$.xgrid.enter().append('line').attr("class", CLASS[_xgrid]);
if (!withoutUpdate) {
$$.xgrid.attr($$.xgridAttr)
.style("opacity", function () { return +d3.select(this).attr(config[__axis_rotated] ? 'y1' : 'x1') === (config[__axis_rotated] ? $$.height : 0) ? 0 : 1; });
.style("opacity", function () { return +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1') === (config.axis_rotated ? $$.height : 0) ? 0 : 1; });
}
$$.xgrid.exit().remove();
};
......@@ -51,13 +51,13 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) {
c3_chart_internal_fn.updateYGrid = function () {
var $$ = this, config = $$.config, CLASS = $$.CLASS;
$$.ygrid = $$.main.select('.' + CLASS[_ygrids]).selectAll('.' + CLASS[_ygrid])
.data($$.y.ticks(config[__grid_y_ticks]));
.data($$.y.ticks(config.grid_y_ticks));
$$.ygrid.enter().append('line')
.attr('class', CLASS[_ygrid]);
$$.ygrid.attr("x1", config[__axis_rotated] ? $$.y : 0)
.attr("x2", config[__axis_rotated] ? $$.y : $$.width)
.attr("y1", config[__axis_rotated] ? 0 : $$.y)
.attr("y2", config[__axis_rotated] ? $$.height : $$.y);
$$.ygrid.attr("x1", config.axis_rotated ? $$.y : 0)
.attr("x2", config.axis_rotated ? $$.y : $$.width)
.attr("y1", config.axis_rotated ? 0 : $$.y)
.attr("y2", config.axis_rotated ? $$.height : $$.y);
$$.ygrid.exit().remove();
$$.smoothLines($$.ygrid, 'grid');
};
......@@ -67,11 +67,11 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) {
var $$ = this, main = $$.main, config = $$.config, CLASS = $$.CLASS,
xgridLine, ygridLine, yv;
main.select('line.' + CLASS[_xgridFocus]).style("visibility", "hidden");
if (config[__grid_x_show]) {
if (config.grid_x_show) {
$$.updateXGrid();
}
$$.xgridLines = main.select('.' + CLASS[_xgridLines]).selectAll('.' + CLASS[_xgridLine])
.data(config[__grid_x_lines]);
.data(config.grid_x_lines);
// enter
xgridLine = $$.xgridLines.enter().append('g')
.attr("class", function (d) { return CLASS[_xgridLine] + (d.class ? ' ' + d.class : ''); });
......@@ -79,8 +79,8 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) {
.style("opacity", 0);
xgridLine.append('text')
.attr("text-anchor", "end")
.attr("transform", config[__axis_rotated] ? "" : "rotate(-90)")
.attr('dx', config[__axis_rotated] ? 0 : -$$.margin.top)
.attr("transform", config.axis_rotated ? "" : "rotate(-90)")
.attr('dx', config.axis_rotated ? 0 : -$$.margin.top)
.attr('dy', -5)
.style("opacity", 0);
// udpate
......@@ -91,12 +91,12 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) {
.remove();
// Y-Grid
if (withY && config[__grid_y_show]) {
if (withY && config.grid_y_show) {
$$.updateYGrid();
}
if (withY) {
$$.ygridLines = main.select('.' + CLASS[_ygridLines]).selectAll('.' + CLASS[_ygridLine])
.data(config[__grid_y_lines]);
.data(config.grid_y_lines);
// enter
ygridLine = $$.ygridLines.enter().append('g')
.attr("class", function (d) { return CLASS[_ygridLine] + (d.class ? ' ' + d.class : ''); });
......@@ -104,22 +104,22 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) {
.style("opacity", 0);
ygridLine.append('text')
.attr("text-anchor", "end")
.attr("transform", config[__axis_rotated] ? "rotate(-90)" : "")
.attr('dx', config[__axis_rotated] ? 0 : -$$.margin.top)
.attr("transform", config.axis_rotated ? "rotate(-90)" : "")
.attr('dx', config.axis_rotated ? 0 : -$$.margin.top)
.attr('dy', -5)
.style("opacity", 0);
// update
yv = $$.yv.bind($$);
$$.ygridLines.select('line')
.transition().duration(duration)
.attr("x1", config[__axis_rotated] ? yv : 0)
.attr("x2", config[__axis_rotated] ? yv : $$.width)
.attr("y1", config[__axis_rotated] ? 0 : yv)
.attr("y2", config[__axis_rotated] ? $$.height : yv)
.attr("x1", config.axis_rotated ? yv : 0)
.attr("x2", config.axis_rotated ? yv : $$.width)
.attr("y1", config.axis_rotated ? 0 : yv)
.attr("y2", config.axis_rotated ? $$.height : yv)
.style("opacity", 1);
$$.ygridLines.select('text')
.transition().duration(duration)
.attr("x", config[__axis_rotated] ? 0 : $$.width)
.attr("x", config.axis_rotated ? 0 : $$.width)
.attr("y", yv)
.text(function (d) { return d.text; })
.style("opacity", 1);
......@@ -132,13 +132,13 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) {
c3_chart_internal_fn.addTransitionForGrid = function (transitions) {
var $$ = this, config = $$.config, xv = $$.xv.bind($$);
transitions.push($$.xgridLines.select('line').transition()
.attr("x1", config[__axis_rotated] ? 0 : xv)
.attr("x2", config[__axis_rotated] ? $$.width : xv)
.attr("y1", config[__axis_rotated] ? xv : $$.margin.top)
.attr("y2", config[__axis_rotated] ? xv : $$.height)
.attr("x1", config.axis_rotated ? 0 : xv)
.attr("x2", config.axis_rotated ? $$.width : xv)
.attr("y1", config.axis_rotated ? xv : $$.margin.top)
.attr("y2", config.axis_rotated ? xv : $$.height)
.style("opacity", 1));
transitions.push($$.xgridLines.select('text').transition()
.attr("x", config[__axis_rotated] ? $$.width : 0)
.attr("x", config.axis_rotated ? $$.width : 0)
.attr("y", xv)
.text(function (d) { return d.text; })
.style("opacity", 1));
......@@ -148,14 +148,14 @@ c3_chart_internal_fn.showXGridFocus = function (selectedData) {
dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); }),
focusEl = $$.main.selectAll('line.' + CLASS[_xgridFocus]),
xx = $$.xx.bind($$);
if (! config[__tooltip_show]) { return; }
if (! config.tooltip_show) { return; }
// Hide when scatter plot exists
if ($$.hasType('scatter') || $$.hasArcType()) { return; }
focusEl
.style("visibility", "visible")
.data([dataToShow[0]])
.attr(config[__axis_rotated] ? 'y1' : 'x1', xx)
.attr(config[__axis_rotated] ? 'y2' : 'x2', xx);
.attr(config.axis_rotated ? 'y1' : 'x1', xx)
.attr(config.axis_rotated ? 'y2' : 'x2', xx);
$$.smoothLines(focusEl, 'grid');
};
c3_chart_internal_fn.hideXGridFocus = function () {
......@@ -164,10 +164,10 @@ c3_chart_internal_fn.hideXGridFocus = function () {
c3_chart_internal_fn.updateXgridFocus = function () {
var $$ = this, config = $$.config;
$$.main.select('line.' + CLASS[_xgridFocus])
.attr("x1", config[__axis_rotated] ? 0 : -10)
.attr("x2", config[__axis_rotated] ? $$.width : -10)
.attr("y1", config[__axis_rotated] ? -10 : 0)
.attr("y2", config[__axis_rotated] ? -10 : $$.height);
.attr("x1", config.axis_rotated ? 0 : -10)
.attr("x2", config.axis_rotated ? $$.width : -10)
.attr("y1", config.axis_rotated ? -10 : 0)
.attr("y2", config.axis_rotated ? -10 : $$.height);
};
c3_chart_internal_fn.generateGridData = function (type, scale) {
var $$ = this,
......@@ -206,11 +206,11 @@ c3_chart_internal_fn.removeGridLines = function (params, forX) {
classLines = forX ? CLASS[_xgridLines] : CLASS[_ygridLines],
classLine = forX ? CLASS[_xgridLine] : CLASS.ygridLine;
$$.main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove)
.transition().duration(config[__transition_duration])
.transition().duration(config.transition_duration)
.style('opacity', 0).remove();
if (forX) {
config[__grid_x_lines] = config[__grid_x_lines].filter(toShow);
config.grid_x_lines = config.grid_x_lines.filter(toShow);
} else {
config[__grid_y_lines] = config[__grid_y_lines].filter(toShow);
config.grid_y_lines = config.grid_y_lines.filter(toShow);
}
};
......@@ -11,7 +11,7 @@ c3_chart_internal_fn.redrawEventRect = function () {
// rects for mouseover
var eventRects = $$.main.select('.' + CLASS[_eventRects])
.style('cursor', config[__zoom_enabled] ? config[__axis_rotated] ? 'ns-resize' : 'ew-resize' : null)
.style('cursor', config.zoom_enabled ? config.axis_rotated ? 'ns-resize' : 'ew-resize' : null)
.classed(CLASS[_eventRectsMultiple], isMultipleX)
.classed(CLASS[_eventRectsSingle], !isMultipleX);
......@@ -74,10 +74,10 @@ c3_chart_internal_fn.updateEventRect = function (eventRectUpdate) {
return $$.x(d.x) - (rectW / 2);
};
}
x = config[__axis_rotated] ? 0 : rectX;
y = config[__axis_rotated] ? rectX : 0;
w = config[__axis_rotated] ? $$.width : rectW;
h = config[__axis_rotated] ? rectW : $$.height;
x = config.axis_rotated ? 0 : rectX;
y = config.axis_rotated ? rectX : 0;
w = config.axis_rotated ? $$.width : rectW;
h = config.axis_rotated ? rectW : $$.height;
}
eventRectUpdate
......@@ -91,7 +91,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
var $$ = this, d3 = $$.d3, config = $$.config;
eventRectEnter.append("rect")
.attr("class", $$.classEvent.bind($$))
.style("cursor", config[__data_selection_enabled] && config[__data_selection_grouped] ? "pointer" : null)
.style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null)
.on('mouseover', function (d) {
var index = d.index, selectedData, newData;
......@@ -104,7 +104,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
// Sort selectedData as names order
newData = [];
Object.keys(config[__data_names]).forEach(function (id) {
Object.keys(config.data_names).forEach(function (id) {
for (var j = 0; j < selectedData.length; j++) {
if (selectedData[j] && selectedData[j].id === id) {
newData.push(selectedData[j]);
......@@ -116,12 +116,12 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
selectedData = newData.concat(selectedData); // Add remained
// Expand shapes for selection
if (config[__point_focus_expand_enabled]) { $$.expandCircles(index); }
if (config.point_focus_expand_enabled) { $$.expandCircles(index); }
$$.expandBars(index);
// Call event handler
$$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) {
config[__data_onmouseover].call(c3, d);
config.data_onmouseover.call($$, d);
});
})
.on('mouseout', function (d) {
......@@ -134,7 +134,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
$$.unexpandBars();
// Call event handler
$$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) {
config[__data_onmouseout].call($$, d);
config.data_onmouseout.call($$, d);
});
})
.on('mousemove', function (d) {
......@@ -149,25 +149,25 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
return $$.addName($$.getValueOnIndex(t.values, index));
});
if (config[__tooltip_grouped]) {
if (config.tooltip_grouped) {
$$.showTooltip(selectedData, d3.mouse(this));
$$.showXGridFocus(selectedData);
}
if (config[__tooltip_grouped] && (!config[__data_selection_enabled] || config[__data_selection_grouped])) {
if (config.tooltip_grouped && (!config.data_selection_enabled || config.data_selection_grouped)) {
return;
}
$$.main.selectAll('.' + CLASS[_shape] + '-' + index)
.each(function () {
d3.select(this).classed(CLASS[_EXPANDED], true);
if (config[__data_selection_enabled]) {
eventRect.style('cursor', config[__data_selection_grouped] ? 'pointer' : null);
if (config.data_selection_enabled) {
eventRect.style('cursor', config.data_selection_grouped ? 'pointer' : null);
}
if (!config[__tooltip_grouped]) {
if (!config.tooltip_grouped) {
$$.hideXGridFocus();
$$.hideTooltip();
if (!config[__data_selection_grouped]) {
if (!config.data_selection_grouped) {
$$.unexpandCircles(index);
$$.unexpandBars();
}
......@@ -182,13 +182,13 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
}
})
.each(function (d) {
if (config[__data_selection_enabled] && (config[__data_selection_grouped] || config[__data_selection_isselectable](d))) {
if (config.data_selection_enabled && (config.data_selection_grouped || config.data_selection_isselectable(d))) {
eventRect.style('cursor', 'pointer');
}
if (!config[__tooltip_grouped]) {
if (!config.tooltip_grouped) {
$$.showTooltip([d], d3.mouse(this));
$$.showXGridFocus([d]);
if (config[__point_focus_expand_enabled]) { $$.expandCircles(index, d.id); }
if (config.point_focus_expand_enabled) { $$.expandCircles(index, d.id); }
$$.expandBars(index, d.id);
}
});
......@@ -252,7 +252,7 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter)
$$.showTooltip(selectedData, mouse);
// expand points
if (config[__point_focus_expand_enabled]) {
if (config.point_focus_expand_enabled) {
$$.unexpandCircles();
$$.expandCircles(closest.index, closest.id);
}
......@@ -264,12 +264,12 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter)
if ($$.dist(closest, mouse) < 100) {
$$.svg.select('.' + CLASS[_eventRect]).style('cursor', 'pointer');
if (!$$.mouseover) {
config[__data_onmouseover].call($$, closest);
config.data_onmouseover.call($$, closest);
$$.mouseover = true;
}
} else if ($$.mouseover) {
$$.svg.select('.' + CLASS[_eventRect]).style('cursor', null);
config[__data_onmouseout].call($$, closest);
config.data_onmouseout.call($$, closest);
$$.mouseover = false;
}
})
......
c3_chart_internal_fn.initLegend = function () {
var $$ = this;
$$.legend = $$.svg.append("g").attr("transform", $$.getTranslate('legend'));
if (!$$.config[__legend_show]) {
if (!$$.config.legend_show) {
$$.legend.style('visibility', 'hidden');
$$.hiddenLegendIds = $$.mapToIds($$.data.targets);
}
......@@ -11,8 +11,8 @@ c3_chart_internal_fn.initLegend = function () {
};
c3_chart_internal_fn.updateSizeForLegend = function (legendHeight, legendWidth) {
var $$ = this, config = $$.config, insetLegendPosition = {
top: $$.isLegendTop ? $$.getCurrentPaddingTop() + config[__legend_inset_y] + 5.5 : $$.currentHeight - legendHeight - $$.getCurrentPaddingBottom() - config[__legend_inset_y],
left: $$.isLegendLeft ? $$.getCurrentPaddingLeft() + config[__legend_inset_x] + 0.5 : $$.currentWidth - legendWidth - $$.getCurrentPaddingRight() - config[__legend_inset_x] + 0.5
top: $$.isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : $$.currentHeight - legendHeight - $$.getCurrentPaddingBottom() - config.legend_inset_y,
left: $$.isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + 0.5 : $$.currentWidth - legendWidth - $$.getCurrentPaddingRight() - config.legend_inset_x + 0.5
};
$$.margin3 = {
top: $$.isLegendRight ? 0 : $$.isLegendInset ? insetLegendPosition.top : $$.currentHeight - legendHeight,
......@@ -36,15 +36,15 @@ c3_chart_internal_fn.updateLegendItemHeight = function (h) {
};
c3_chart_internal_fn.getLegendWidth = function () {
var $$ = this;
return $$.config[__legend_show] ? $$.isLegendRight || $$.isLegendInset ? $$.legendItemWidth * ($$.legendStep + 1) : $$.currentWidth : 0;
return $$.config.legend_show ? $$.isLegendRight || $$.isLegendInset ? $$.legendItemWidth * ($$.legendStep + 1) : $$.currentWidth : 0;
};
c3_chart_internal_fn.getLegendHeight = function () {
var $$ = this, config = $$.config, h = 0;
if (config[__legend_show]) {
if (config.legend_show) {
if ($$.isLegendRight) {
h = $$.currentHeight;
} else if ($$.isLegendInset) {
h = config[__legend_inset_step] ? Math.max(20, $$.legendItemHeight) * (config[__legend_inset_step] + 1) : $$.height;
h = config.legend_inset_step ? Math.max(20, $$.legendItemHeight) * (config.legend_inset_step + 1) : $$.height;
} else {
h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1);
}
......@@ -80,8 +80,8 @@ c3_chart_internal_fn.revertLegend = function () {
};
c3_chart_internal_fn.showLegend = function (targetIds) {
var $$ = this, config = $$.config;
if (!config[__legend_show]) {
config[__legend_show] = true;
if (!config.legend_show) {
config.legend_show = true;
$$.legend.style('visibility', 'visible');
}
$$.removeHiddenLegendIds(targetIds);
......@@ -92,8 +92,8 @@ c3_chart_internal_fn.showLegend = function (targetIds) {
};
c3_chart_internal_fn.hideLegend = function (targetIds) {
var $$ = this, config = $$.config;
if (config[__legend_show] && isEmpty(targetIds)) {
config[__legend_show] = false;
if (config.legend_show && isEmpty(targetIds)) {
config.legend_show = false;
$$.legend.style('visibility', 'hidden');
}
$$.addHiddenLegendIds(targetIds);
......@@ -145,7 +145,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
maxHeight = 0;
}
if (config[__legend_show] && !$$.isLegendToShow(id)) {
if (config.legend_show && !$$.isLegendToShow(id)) {
widths[id] = heights[id] = steps[id] = offsets[id] = 0;
return;
}
......@@ -157,7 +157,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
if (!maxHeight || itemHeight >= maxHeight) { maxHeight = itemHeight; }
maxLength = $$.isLegendRight || $$.isLegendInset ? maxHeight : maxWidth;
if (config[__legend_equally]) {
if (config.legend_equally) {
Object.keys(widths).forEach(function (id) { widths[id] = maxWidth; });
Object.keys(heights).forEach(function (id) { heights[id] = maxHeight; });
margin = (areaLength - maxLength * targetIds.length) / 2;
......@@ -197,15 +197,15 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
.style('visibility', function (id) { return $$.isLegendToShow(id) ? 'visible' : 'hidden'; })
.style('cursor', 'pointer')
.on('click', function (id) {
config[__legend_item_onclick] ? config[__legend_item_onclick].call($$, id) : $$.api.toggle(id);
config.legend_item_onclick ? config.legend_item_onclick.call($$, id) : $$.api.toggle(id);
})
.on('mouseover', function (id) {
$$.d3.select(this).classed(CLASS[_legendItemFocused], true);
if (!$$.transiting) {
$$.api.focus(id);
}
if (config[__legend_item_onmouseover]) {
config[__legend_item_onmouseover].call($$, id);
if (config.legend_item_onmouseover) {
config.legend_item_onmouseover.call($$, id);
}
})
.on('mouseout', function (id) {
......@@ -213,12 +213,12 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
if (!$$.transiting) {
$$.api.revert();
}
if (config[__legend_item_onmouseout]) {
config[__legend_item_onmouseout].call($$, id);
if (config.legend_item_onmouseout) {
config.legend_item_onmouseout.call($$, id);
}
});
l.append('text')
.text(function (id) { return isDefined(config[__data_names][id]) ? config[__data_names][id] : id; })
.text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; })
.each(function (id, i) { updatePositions(this, id, i === 0); })
.style("pointer-events", "none")
.attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200)
......@@ -247,7 +247,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
texts = $$.legend.selectAll('text')
.data(targetIds)
.text(function (id) { return isDefined(config[__data_names][id]) ? config[__data_names][id] : id; }) // MEMO: needed for update
.text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; }) // MEMO: needed for update
.each(function (id, i) { updatePositions(this, id, i === 0); });
(withTransition ? texts.transition() : texts)
.attr('x', xForLegendText)
......
......@@ -7,7 +7,7 @@ c3_chart_internal_fn.initRegion = function () {
c3_chart_internal_fn.redrawRegion = function (duration) {
var $$ = this, config = $$.config, CLASS = $$.CLASS;
$$.mainRegion = $$.main.select('.' + CLASS[_regions]).selectAll('.' + CLASS[_region])
.data(config[__regions]);
.data(config.regions);
$$.mainRegion.enter().append('g')
.attr('class', $$.classRegion.bind($$))
.append('rect')
......@@ -33,9 +33,9 @@ c3_chart_internal_fn.regionX = function (d) {
var $$ = this, config = $$.config,
xPos, yScale = d.axis === 'y' ? $$.y : $$.y2;
if (d.axis === 'y' || d.axis === 'y2') {
xPos = config[__axis_rotated] ? ('start' in d ? yScale(d.start) : 0) : 0;
xPos = config.axis_rotated ? ('start' in d ? yScale(d.start) : 0) : 0;
} else {
xPos = config[__axis_rotated] ? 0 : ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0);
xPos = config.axis_rotated ? 0 : ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0);
}
return xPos;
};
......@@ -43,9 +43,9 @@ c3_chart_internal_fn.regionY = function (d) {
var $$ = this, config = $$.config,
yPos, yScale = d.axis === 'y' ? $$.y : $$.y2;
if (d.axis === 'y' || d.axis === 'y2') {
yPos = config[__axis_rotated] ? 0 : ('end' in d ? yScale(d.end) : 0);
yPos = config.axis_rotated ? 0 : ('end' in d ? yScale(d.end) : 0);
} else {
yPos = config[__axis_rotated] ? ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0) : 0;
yPos = config.axis_rotated ? ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0) : 0;
}
return yPos;
};
......@@ -53,9 +53,9 @@ c3_chart_internal_fn.regionWidth = function (d) {
var $$ = this, config = $$.config,
start = $$.regionX(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2;
if (d.axis === 'y' || d.axis === 'y2') {
end = config[__axis_rotated] ? ('end' in d ? yScale(d.end) : $$.width) : $$.width;
end = config.axis_rotated ? ('end' in d ? yScale(d.end) : $$.width) : $$.width;
} else {
end = config[__axis_rotated] ? $$.width : ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.width);
end = config.axis_rotated ? $$.width : ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.width);
}
return end < start ? 0 : end - start;
};
......@@ -63,9 +63,9 @@ c3_chart_internal_fn.regionHeight = function (d) {
var $$ = this, config = $$.config,
start = this.regionY(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2;
if (d.axis === 'y' || d.axis === 'y2') {
end = config[__axis_rotated] ? $$.height : ('start' in d ? yScale(d.start) : $$.height);
end = config.axis_rotated ? $$.height : ('start' in d ? yScale(d.start) : $$.height);
} else {
end = config[__axis_rotated] ? ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.height) : $$.height;
end = config.axis_rotated ? ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.height) : $$.height;
}
return end < start ? 0 : end - start;
};
......
......@@ -53,14 +53,14 @@ c3_chart_internal_fn.updateScales = function () {
var $$ = this, config = $$.config,
forInit = !$$.x;
// update edges
$$.xMin = config[__axis_rotated] ? 1 : 0;
$$.xMax = config[__axis_rotated] ? $$.height : $$.width;
$$.yMin = config[__axis_rotated] ? 0 : $$.height;
$$.yMax = config[__axis_rotated] ? $$.width : 1;
$$.xMin = config.axis_rotated ? 1 : 0;
$$.xMax = config.axis_rotated ? $$.height : $$.width;
$$.yMin = config.axis_rotated ? 0 : $$.height;
$$.yMax = config.axis_rotated ? $$.width : 1;
$$.subXMin = $$.xMin;
$$.subXMax = $$.xMax;
$$.subYMin = config[__axis_rotated] ? 0 : $$.height2;
$$.subYMax = config[__axis_rotated] ? $$.width2 : 1;
$$.subYMin = config.axis_rotated ? 0 : $$.height2;
$$.subYMax = config.axis_rotated ? $$.width2 : 1;
// update scales
$$.x = $$.getX($$.xMin, $$.xMax, forInit ? undefined : $$.x.orgDomain(), function () { return $$.xAxis.tickOffset(); });
$$.y = $$.getY($$.yMin, $$.yMax, forInit ? undefined : $$.y.domain());
......@@ -70,15 +70,15 @@ c3_chart_internal_fn.updateScales = function () {
$$.subY2 = $$.getY($$.subYMin, $$.subYMax, forInit ? undefined : $$.subY2.domain());
// update axes
$$.xAxisTickFormat = $$.getXAxisTickFormat();
$$.xAxisTickValues = config[__axis_x_tick_values] ? config[__axis_x_tick_values] : (forInit ? undefined : $$.xAxis.tickValues());
$$.xAxisTickValues = config.axis_x_tick_values ? config.axis_x_tick_values : (forInit ? undefined : $$.xAxis.tickValues());
$$.xAxis = $$.getXAxis($$.x, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues);
$$.subXAxis = $$.getXAxis($$.subX, $$.subXOrient, $$.xAxisTickFormat, $$.xAxisTickValues);
$$.yAxis = $$.getYAxis($$.y, $$.yOrient, config[__axis_y_tick_format], config[__axis_y_ticks]);
$$.y2Axis = $$.getYAxis($$.y2, $$.y2Orient, config[__axis_y2_tick_format], config[__axis_y2_ticks]);
$$.yAxis = $$.getYAxis($$.y, $$.yOrient, config.axis_y_tick_format, config.axis_y_ticks);
$$.y2Axis = $$.getYAxis($$.y2, $$.y2Orient, config.axis_y2_tick_format, config.axis_y2_ticks);
// Set initialized scales to brush and zoom
if (!forInit) {
if ($$.brush) { $$.brush.scale($$.subX); }
if (config[__zoom_enabled]) { $$.zoom.scale($$.x); }
if (config.zoom_enabled) { $$.zoom.scale($$.x); }
}
// update for arc
if ($$.updateArc) { $$.updateArc(); }
......
c3_chart_internal_fn.selectPoint = function (target, d, i) {
var $$ = this, config = $$.config,
cx = (config[__axis_rotated] ? $$.circleY : $$.circleX).bind($$),
cy = (config[__axis_rotated] ? $$.circleX : $$.circleY).bind($$),
cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$),
cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$),
r = $$.pointSelectR.bind($$);
config[__data_onselected].call($$.api, d, target.node());
config.data_onselected.call($$.api, d, target.node());
// add selected-circle on low layer g
$$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i)
.data([d])
......@@ -18,7 +18,7 @@ c3_chart_internal_fn.selectPoint = function (target, d, i) {
};
c3_chart_internal_fn.unselectPoint = function (target, d, i) {
var $$ = this;
$$.config[__data_onunselected](d, target.node());
$$.config.data_onunselected(d, target.node());
// remove selected-circle from low layer g
$$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i)
.transition().duration(100).attr('r', 0)
......@@ -29,13 +29,13 @@ c3_chart_internal_fn.togglePoint = function (selected, target, d, i) {
};
c3_chart_internal_fn.selectBar = function (target, d) {
var $$ = this;
$$.config[__data_onselected].call($$, d, target.node());
$$.config.data_onselected.call($$, d, target.node());
target.transition().duration(100)
.style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); });
};
c3_chart_internal_fn.unselectBar = function (target, d) {
var $$ = this;
$$.config[__data_onunselected].call($$, d, target.node());
$$.config.data_onunselected.call($$, d, target.node());
target.transition().duration(100)
.style("fill", function () { return $$.color(d); });
};
......@@ -66,10 +66,10 @@ c3_chart_internal_fn.toggleShape = function (that, d, i) {
toggle = $$.toggleArc;
}
}
if (config[__data_selection_grouped] || isWithin) {
if (config[__data_selection_enabled] && config[__data_selection_isselectable](d)) {
if (!config[__data_selection_multiple]) {
$$.main.selectAll('.' + CLASS[_shapes] + (config[__data_selection_grouped] ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS[_shape]).each(function (d, i) {
if (config.data_selection_grouped || isWithin) {
if (config.data_selection_enabled && config.data_selection_isselectable(d)) {
if (!config.data_selection_multiple) {
$$.main.selectAll('.' + CLASS[_shapes] + (config.data_selection_grouped ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS[_shape]).each(function (d, i) {
var shape = d3.select(this);
if (shape.classed(CLASS[_SELECTED])) { toggle.call($$, false, shape.classed(CLASS[_SELECTED], false), d, i); }
});
......@@ -77,6 +77,6 @@ c3_chart_internal_fn.toggleShape = function (that, d, i) {
shape.classed(CLASS[_SELECTED], !isSelected);
toggle.call($$, !isSelected, shape, d, i);
}
$$.config[__data_onclick].call($$.api, d, that);
$$.config.data_onclick.call($$.api, d, that);
}
};
......@@ -18,7 +18,7 @@ c3_chart_internal_fn.updateTargetsForBar = function (targets) {
// Bars for each data
mainBarEnter.append('g')
.attr("class", classBars)
.style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; });
.style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; });
};
c3_chart_internal_fn.redrawBar = function (durationForExit) {
......@@ -48,8 +48,8 @@ c3_chart_internal_fn.addTransitionForBar = function (transitions, drawBar) {
};
c3_chart_internal_fn.getBarW = function (axis, barTargetsNum) {
var $$ = this, config = $$.config,
w = typeof config[__bar_width] === 'number' ? config[__bar_width] : barTargetsNum ? (axis.tickOffset() * 2 * config[__bar_width_ratio]) / barTargetsNum : 0;
return config[__bar_width_max] && w > config[__bar_width_max] ? config[__bar_width_max] : w;
w = typeof config.bar_width === 'number' ? config.bar_width : barTargetsNum ? (axis.tickOffset() * 2 * config.bar_width_ratio) / barTargetsNum : 0;
return config.bar_width_max && w > config.bar_width_max ? config.bar_width_max : w;
};
c3_chart_internal_fn.getBars = function (i) {
var $$ = this;
......@@ -71,8 +71,8 @@ c3_chart_internal_fn.generateDrawBar = function (barIndices, isSub) {
var points = getPoints(d, i);
// switch points if axis is rotated, not applicable for sub chart
var indexX = config[__axis_rotated] ? 1 : 0;
var indexY = config[__axis_rotated] ? 0 : 1;
var indexX = config.axis_rotated ? 1 : 0;
var indexY = config.axis_rotated ? 0 : 1;
var path = 'M ' + points[0][indexX] + ',' + points[0][indexY] + ' ' +
'L' + points[1][indexX] + ',' + points[1][indexY] + ' ' +
......@@ -96,7 +96,7 @@ c3_chart_internal_fn.generateGetBarPoints = function (barIndices, isSub) {
offset = barOffset(d, i) || y0, // offset is for stacked bar chart
posX = barX(d), posY = barY(d);
// fix posY not to overflow opposite quadrant
if ($$.config[__axis_rotated]) {
if ($$.config.axis_rotated) {
if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; }
}
// 4 points that make a bar
......
......@@ -2,11 +2,11 @@ c3_chart_internal_fn.getShapeIndices = function (typeFilter) {
var $$ = this, config = $$.config,
indices = {}, i = 0, j, k;
$$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) {
for (j = 0; j < config[__data_groups].length; j++) {
if (config[__data_groups][j].indexOf(d.id) < 0) { continue; }
for (k = 0; k < config[__data_groups][j].length; k++) {
if (config[__data_groups][j][k] in indices) {
indices[d.id] = indices[config[__data_groups][j][k]];
for (j = 0; j < config.data_groups.length; j++) {
if (config.data_groups[j].indexOf(d.id) < 0) { continue; }
for (k = 0; k < config.data_groups[j].length; k++) {
if (config.data_groups[j][k] in indices) {
indices[d.id] = indices[config.data_groups[j][k]];
break;
}
}
......
......@@ -28,7 +28,7 @@ c3_chart_internal_fn.updateTargetsForLine = function (targets) {
.attr("class", function (d) { return $$.generateClass(CLASS[_selectedCircles], d.id); });
mainLineEnter.append('g')
.attr("class", classCircles)
.style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; });
.style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; });
// Update date for selected circles
targets.forEach(function (t) {
$$.main.selectAll('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS[_selectedCircle]).each(function (d) {
......@@ -66,17 +66,17 @@ c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) {
yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale,
xValue = function (d) { return (isSub ? $$.subxx : $$.xx).call($$, d); },
yValue = function (d, i) {
return config[__data_groups].length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(d.value);
return config.data_groups.length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(d.value);
};
line = config[__axis_rotated] ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
if (!config[__line_connect_null]) { line = line.defined(function (d) { return d.value != null; }); }
line = config.axis_rotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
if (!config.line_connect_null) { line = line.defined(function (d) { return d.value != null; }); }
return function (d) {
var data = config[__line_connect_null] ? $$.filterRemoveNull(d.values) : d.values,
var data = config.line_connect_null ? $$.filterRemoveNull(d.values) : d.values,
x = isSub ? $$.x : $$.subX, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path;
if ($$.isLineType(d)) {
if (config[__data_regions][d.id]) {
path = $$.lineWithRegions(data, x, y, config[__data_regions][d.id]);
if (config.data_regions[d.id]) {
path = $$.lineWithRegions(data, x, y, config.data_regions[d.id]);
} else {
path = line.interpolate($$.getInterpolate(d))(data);
}
......@@ -85,7 +85,7 @@ c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) {
x0 = x(data[0].x);
y0 = y(data[0].value);
}
path = config[__axis_rotated] ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
path = config.axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
}
return path ? path : "M 0 0";
};
......@@ -102,7 +102,7 @@ c3_chart_internal_fn.generateGetLinePoint = function (lineIndices, isSub) { // p
offset = lineOffset(d, i) || y0, // offset is for stacked area chart
posX = x(d), posY = y(d);
// fix posY not to overflow opposite quadrant
if (config[__axis_rotated]) {
if (config.axis_rotated) {
if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; }
}
// 1 point that marks the line position
......@@ -147,8 +147,8 @@ c3_chart_internal_fn.lineWithRegions = function (d, x, y, _regions) {
}
// Set scales
xValue = config[__axis_rotated] ? function (d) { return y(d.value); } : function (d) { return x(d.x); };
yValue = config[__axis_rotated] ? function (d) { return x(d.x); } : function (d) { return y(d.value); };
xValue = config.axis_rotated ? function (d) { return y(d.value); } : function (d) { return x(d.x); };
yValue = config.axis_rotated ? function (d) { return x(d.x); } : function (d) { return y(d.value); };
// Define svg generator function for region
if ($$.isTimeSeries()) {
......@@ -220,19 +220,19 @@ c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) {
yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale,
xValue = function (d) { return (isSub ? $$.subxx : $$.xx).call($$, d); },
value0 = function (d, i) {
return config[__data_groups].length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(0);
return config.data_groups.length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(0);
},
value1 = function (d, i) {
return config[__data_groups].length > 0 ? getPoint(d, i)[1][1] : yScaleGetter.call($$, d.id)(d.value);
return config.data_groups.length > 0 ? getPoint(d, i)[1][1] : yScaleGetter.call($$, d.id)(d.value);
};
area = config[__axis_rotated] ? area.x0(value0).x1(value1).y(xValue) : area.x(xValue).y0(value0).y1(value1);
if (!config[__line_connect_null]) {
area = config.axis_rotated ? area.x0(value0).x1(value1).y(xValue) : area.x(xValue).y0(value0).y1(value1);
if (!config.line_connect_null) {
area = area.defined(function (d) { return d.value !== null; });
}
return function (d) {
var data = config[__line_connect_null] ? $$.filterRemoveNull(d.values) : d.values, x0 = 0, y0 = 0, path;
var data = config.line_connect_null ? $$.filterRemoveNull(d.values) : d.values, x0 = 0, y0 = 0, path;
if ($$.isAreaType(d)) {
path = area.interpolate($$.getInterpolate(d))(data);
} else {
......@@ -240,7 +240,7 @@ c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) {
x0 = $$.x(data[0].x);
y0 = $$.getYScale(d.id)(data[0].value);
}
path = config[__axis_rotated] ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
path = config.axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
}
return path ? path : "M 0 0";
};
......@@ -258,7 +258,7 @@ c3_chart_internal_fn.generateGetAreaPoint = function (areaIndices, isSub) { // p
offset = areaOffset(d, i) || y0, // offset is for stacked area chart
posX = x(d), posY = y(d);
// fix posY not to overflow opposite quadrant
if (config[__axis_rotated]) {
if (config.axis_rotated) {
if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; }
}
// 1 point that marks the area position
......@@ -299,7 +299,7 @@ c3_chart_internal_fn.circleX = function (d) {
c3_chart_internal_fn.circleY = function (d, i) {
var $$ = this,
lineIndices = $$.getShapeIndices($$.isLineType), getPoint = $$.generateGetLinePoint(lineIndices);
return $$.config[__data_groups].length > 0 ? getPoint(d, i)[0][1] : $$.getYScale(d.id)(d.value);
return $$.config.data_groups.length > 0 ? getPoint(d, i)[0][1] : $$.getYScale(d.id)(d.value);
};
c3_chart_internal_fn.getCircles = function (i, id) {
var $$ = this;
......@@ -322,15 +322,15 @@ c3_chart_internal_fn.unexpandCircles = function (i) {
};
c3_chart_internal_fn.pointR = function (d) {
var $$ = this, config = $$.config;
return config[__point_show] && !$$.isStepType(d) ? (isFunction(config[__point_r]) ? config[__point_r](d) : config[__point_r]) : 0;
return config.point_show && !$$.isStepType(d) ? (isFunction(config.point_r) ? config.point_r(d) : config.point_r) : 0;
};
c3_chart_internal_fn.pointExpandedR = function (d) {
var $$ = this, config = $$.config;
return config[__point_focus_expand_enabled] ? (config[__point_focus_expand_r] ? config[__point_focus_expand_r] : $$.pointR(d) * 1.75) : $$.pointR(d);
return config.point_focus_expand_enabled ? (config.point_focus_expand_r ? config.point_focus_expand_r : $$.pointR(d) * 1.75) : $$.pointR(d);
};
c3_chart_internal_fn.pointSelectR = function (d) {
var $$ = this, config = $$.config;
return config[__point_select_r] ? config[__point_select_r] : $$.pointR(d) * 4;
return config.point_select_r ? config.point_select_r : $$.pointR(d) * 4;
};
c3_chart_internal_fn.isWithinCircle = function (_this, _r) {
var d3 = this.d3,
......
c3_chart_internal_fn.getCurrentWidth = function () {
var $$ = this, config = $$.config;
return config[__size_width] ? config[__size_width] : $$.getParentWidth();
return config.size_width ? config.size_width : $$.getParentWidth();
};
c3_chart_internal_fn.getCurrentHeight = function () {
var $$ = this, config = $$.config,
h = config[__size_height] ? config[__size_height] : $$.getParentHeight();
h = config.size_height ? config.size_height : $$.getParentHeight();
return h > 0 ? h : 320;
};
c3_chart_internal_fn.getCurrentPaddingTop = function () {
var config = this.config;
return isValue(config[__padding_top]) ? config[__padding_top] : 0;
return isValue(config.padding_top) ? config.padding_top : 0;
};
c3_chart_internal_fn.getCurrentPaddingBottom = function () {
var config = this.config;
return isValue(config[__padding_bottom]) ? config[__padding_bottom] : 0;
return isValue(config.padding_bottom) ? config.padding_bottom : 0;
};
c3_chart_internal_fn.getCurrentPaddingLeft = function () {
var $$ = this, config = $$.config;
if (isValue(config[__padding_left])) {
return config[__padding_left];
} else if (config[__axis_rotated]) {
return !config[__axis_x_show] ? 1 : Math.max(ceil10($$.getAxisWidthByAxisId('x')), 40);
if (isValue(config.padding_left)) {
return config.padding_left;
} else if (config.axis_rotated) {
return !config.axis_x_show ? 1 : Math.max(ceil10($$.getAxisWidthByAxisId('x')), 40);
} else {
return !config[__axis_y_show] ? 1 : ceil10($$.getAxisWidthByAxisId('y'));
return !config.axis_y_show ? 1 : ceil10($$.getAxisWidthByAxisId('y'));
}
};
c3_chart_internal_fn.getCurrentPaddingRight = function () {
var $$ = this, config = $$.config,
defaultPadding = 10, legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0;
if (isValue(config[__padding_right])) {
return config[__padding_right] + 1; // 1 is needed not to hide tick line
} else if (config[__axis_rotated]) {
if (isValue(config.padding_right)) {
return config.padding_right + 1; // 1 is needed not to hide tick line
} else if (config.axis_rotated) {
return defaultPadding + legendWidthOnRight;
} else {
return (!config[__axis_y2_show] ? defaultPadding : ceil10($$.getAxisWidthByAxisId('y2'))) + legendWidthOnRight;
return (!config.axis_y2_show ? defaultPadding : ceil10($$.getAxisWidthByAxisId('y2'))) + legendWidthOnRight;
}
};
......@@ -59,7 +59,7 @@ c3_chart_internal_fn.getParentHeight = function () {
c3_chart_internal_fn.getSvgLeft = function () {
var $$ = this, config = $$.config,
leftAxisClass = config[__axis_rotated] ? CLASS[_axisX] : CLASS[_axisY],
leftAxisClass = config.axis_rotated ? CLASS[_axisX] : CLASS[_axisY],
leftAxis = $$.main.select('.' + leftAxisClass).node(),
svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0},
chartRect = $$.selectChart.node().getBoundingClientRect(),
......@@ -75,10 +75,10 @@ c3_chart_internal_fn.getAxisWidthByAxisId = function (id) {
};
c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) {
var $$ = this, config = $$.config;
if (axisId === 'x' && !config[__axis_x_show]) { return 0; }
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 === 'y2' && !config[__axis_y2_show]) { return $$.rotated_padding_top; }
if (axisId === 'x' && !config.axis_x_show) { return 0; }
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 === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; }
return ($$.getAxisLabelPositionById(axisId).isInner ? 30 : 40) + (axisId === 'y2' ? -10 : 0);
};
......@@ -92,7 +92,7 @@ c3_chart_internal_fn.getEventRectWidth = function () {
firstData = target.values[0], lastData = target.values[target.values.length - 1];
base = $$.x(lastData.x) - $$.x(firstData.x);
if (base === 0) {
return $$.config[__axis_rotated] ? $$.height : $$.width;
return $$.config.axis_rotated ? $$.height : $$.width;
}
maxDataCount = $$.getMaxDataCount();
ratio = ($$.hasType('bar') ? (maxDataCount - ($$.isCategorized() ? 0.25 : 1)) / maxDataCount : 1);
......
......@@ -6,14 +6,14 @@ c3_chart_internal_fn.initBrush = function () {
return this;
};
$$.brush.scale = function (scale) {
return $$.config[__axis_rotated] ? this.y(scale) : this.x(scale);
return $$.config.axis_rotated ? this.y(scale) : this.x(scale);
};
};
c3_chart_internal_fn.initSubchart = function () {
var $$ = this, config = $$.config,
context = $$.context = $$.svg.append("g").attr("transform", $$.getTranslate('context'));
if (!config[__subchart_show]) {
if (!config.subchart_show) {
context.style('visibility', 'hidden');
}
......@@ -36,14 +36,14 @@ c3_chart_internal_fn.initSubchart = function () {
.attr("class", CLASS[_brush])
.call($$.brush)
.selectAll("rect")
.attr(config[__axis_rotated] ? "width" : "height", config[__axis_rotated] ? $$.width2 : $$.height2);
.attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? $$.width2 : $$.height2);
// ATTENTION: This must be called AFTER chart added
// Add Axis
$$.axes.subx = context.append("g")
.attr("class", CLASS[_axisX])
.attr("transform", $$.getTranslate('subx'))
.attr("clip-path", config[__axis_rotated] ? "" : $$.clipPathForXAxis);
.attr("clip-path", config.axis_rotated ? "" : $$.clipPathForXAxis);
};
c3_chart_internal_fn.updateTargetsForSubchart = function (targets) {
var $$ = this, context = $$.context, config = $$.config,
......@@ -54,7 +54,7 @@ c3_chart_internal_fn.updateTargetsForSubchart = function (targets) {
classLines = $$.classLines.bind($$),
classAreas = $$.classAreas.bind($$);
if (config[__subchart_show]) {
if (config.subchart_show) {
contextBarUpdate = context.select('.' + CLASS[_chartBars]).selectAll('.' + CLASS[_chartBar])
.data(targets)
.attr('class', classChartBar);
......@@ -91,7 +91,7 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat
initialOpacity = $$.initialOpacity.bind($$);
// subchart
if (config[__subchart_show]) {
if (config.subchart_show) {
// reflect main chart to extent on subchart if zoomed
if (d3.event && d3.event.type === 'zoom') {
$$.brush.extent($$.x.orgDomain()).update();
......@@ -100,8 +100,8 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat
if (withSubchart) {
// rotate tick text if needed
if (!config[__axis_rotated] && config[__axis_x_tick_rotate]) {
$$.rotateTickText($$.axes.subx, transitions.axisSubX, config[__axis_x_tick_rotate]);
if (!config.axis_rotated && config.axis_x_tick_rotate) {
$$.rotateTickText($$.axes.subx, transitions.axisSubX, config.axis_x_tick_rotate);
}
// extent rect
......@@ -168,7 +168,7 @@ c3_chart_internal_fn.redrawForBrush = function () {
withSubchart: false,
withUpdateXDomain: true
});
$$.config[__subchart_onbrush].call($$.api, x.orgDomain());
$$.config.subchart_onbrush.call($$.api, x.orgDomain());
};
c3_chart_internal_fn.transformContext = function (withTransition, transitions) {
var $$ = this, subXAxis;
......
......@@ -26,7 +26,7 @@ c3_chart_internal_fn.redrawText = function (durationForExit) {
.data(barOrLineData);
$$.mainText.enter().append('text')
.attr("class", classText)
.attr('text-anchor', function (d) { return config[__axis_rotated] ? (d.value < 0 ? 'end' : 'start') : 'middle'; })
.attr('text-anchor', function (d) { return config.axis_rotated ? (d.value < 0 ? 'end' : 'start') : 'middle'; })
.style("stroke", 'none')
.style("fill", function (d) { return $$.color(d); })
.style("fill-opacity", 0);
......@@ -68,7 +68,7 @@ c3_chart_internal_fn.generateXYForText = function (barIndices, forX) {
c3_chart_internal_fn.getXForText = function (points, d, textElement) {
var $$ = this,
box = textElement.getBoundingClientRect(), xPos, padding;
if ($$.config[__axis_rotated]) {
if ($$.config.axis_rotated) {
padding = $$.isBarType(d) ? 4 : 6;
xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1);
} else {
......@@ -79,7 +79,7 @@ c3_chart_internal_fn.getXForText = function (points, d, textElement) {
c3_chart_internal_fn.getYForText = function (points, d, textElement) {
var $$ = this,
box = textElement.getBoundingClientRect(), yPos;
if ($$.config[__axis_rotated]) {
if ($$.config.axis_rotated) {
yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2;
} else {
yPos = points[2][1] + (d.value < 0 ? box.height : $$.isBarType(d) ? -3 : -6);
......
......@@ -8,27 +8,27 @@ c3_chart_internal_fn.initTooltip = function () {
.style("z-index", "10")
.style("display", "none");
// Show tooltip if needed
if (config[__tooltip_init_show]) {
if ($$.isTimeSeries() && isString(config[__tooltip_init_x])) {
config[__tooltip_init_x] = $$.parseDate(config[__tooltip_init_x]);
if (config.tooltip_init_show) {
if ($$.isTimeSeries() && isString(config.tooltip_init_x)) {
config.tooltip_init_x = $$.parseDate(config.tooltip_init_x);
for (i = 0; i < $$.data.targets[0].values.length; i++) {
if (($$.data.targets[0].values[i].x - config[__tooltip_init_x]) === 0) { break; }
if (($$.data.targets[0].values[i].x - config.tooltip_init_x) === 0) { break; }
}
config[__tooltip_init_x] = i;
config.tooltip_init_x = i;
}
$$.tooltip.html(config[__tooltip_contents].call($$, $$.data.targets.map(function (d) {
return $$.addName(d.values[config[__tooltip_init_x]]);
$$.tooltip.html(config.tooltip_contents.call($$, $$.data.targets.map(function (d) {
return $$.addName(d.values[config.tooltip_init_x]);
}), $$.getXAxisTickFormat(), $$.getYFormat($$.hasArcType()), $$.color));
$$.tooltip.style("top", config[__tooltip_init_position].top)
.style("left", config[__tooltip_init_position].left)
$$.tooltip.style("top", config.tooltip_init_position.top)
.style("left", config.tooltip_init_position.left)
.style("display", "block");
}
};
c3_chart_internal_fn.getTooltipContent = function (d, defaultTitleFormat, defaultValueFormat, color) {
var $$ = this, config = $$.config,
titleFormat = config[__tooltip_format_title] || defaultTitleFormat,
nameFormat = config[__tooltip_format_name] || function (name) { return name; },
valueFormat = config[__tooltip_format_value] || defaultValueFormat,
titleFormat = config.tooltip_format_title || defaultTitleFormat,
nameFormat = config.tooltip_format_name || function (name) { return name; },
valueFormat = config.tooltip_format_value || defaultValueFormat,
text, i, title, value, name, bgcolor;
for (i = 0; i < d.length; i++) {
if (! (d[i] && (d[i].value || d[i].value === 0))) { continue; }
......@@ -54,10 +54,10 @@ c3_chart_internal_fn.showTooltip = function (selectedData, mouse) {
var tWidth, tHeight, svgLeft, tooltipLeft, tooltipRight, tooltipTop, chartRight;
var forArc = $$.hasArcType(),
dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); });
if (dataToShow.length === 0 || !config[__tooltip_show]) {
if (dataToShow.length === 0 || !config.tooltip_show) {
return;
}
$$.tooltip.html(config[__tooltip_contents].call($$, selectedData, $$.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)).style("display", "block");
$$.tooltip.html(config.tooltip_contents.call($$, selectedData, $$.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)).style("display", "block");
// Get tooltip dimensions
tWidth = $$.tooltip.property('offsetWidth');
......@@ -67,7 +67,7 @@ c3_chart_internal_fn.showTooltip = function (selectedData, mouse) {
tooltipLeft = ($$.width / 2) + mouse[0];
tooltipTop = ($$.height / 2) + mouse[1] + 20;
} else {
if (config[__axis_rotated]) {
if (config.axis_rotated) {
svgLeft = $$.getSvgLeft();
tooltipLeft = svgLeft + mouse[0] + 100;
tooltipRight = tooltipLeft + tWidth;
......
c3_chart_internal_fn.setTargetType = function (targetIds, type) {
var $$ = this, config = $$.config;
$$.mapToTargetIds(targetIds).forEach(function (id) {
$$.withoutFadeIn[id] = (type === config[__data_types][id]);
config[__data_types][id] = type;
$$.withoutFadeIn[id] = (type === config.data_types[id]);
config.data_types[id] = type;
});
if (!targetIds) {
config[__data_type] = type;
config.data_type = type;
}
};
c3_chart_internal_fn.hasType = function (type, targets) {
var $$ = this, types = $$.config[__data_types], has = false;
var $$ = this, types = $$.config.data_types, has = false;
(targets || $$.data.targets).forEach(function (t) {
if ((types[t.id] && types[t.id].indexOf(type) >= 0) || (!(t.id in types) && type === 'line')) {
has = true;
......@@ -22,39 +22,39 @@ c3_chart_internal_fn.hasArcType = function (targets) {
};
c3_chart_internal_fn.isLineType = function (d) {
var config = this.config, id = isString(d) ? d : d.id;
return !config[__data_types][id] || ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf(config[__data_types][id]) >= 0;
return !config.data_types[id] || ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf(config.data_types[id]) >= 0;
};
c3_chart_internal_fn.isStepType = function (d) {
var id = isString(d) ? d : d.id;
return ['step', 'area-step'].indexOf(this.config[__data_types][id]) >= 0;
return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0;
};
c3_chart_internal_fn.isSplineType = function (d) {
var id = isString(d) ? d : d.id;
return ['spline', 'area-spline'].indexOf(this.config[__data_types][id]) >= 0;
return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0;
};
c3_chart_internal_fn.isAreaType = function (d) {
var id = isString(d) ? d : d.id;
return ['area', 'area-spline', 'area-step'].indexOf(this.config[__data_types][id]) >= 0;
return ['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= 0;
};
c3_chart_internal_fn.isBarType = function (d) {
var id = isString(d) ? d : d.id;
return this.config[__data_types][id] === 'bar';
return this.config.data_types[id] === 'bar';
};
c3_chart_internal_fn.isScatterType = function (d) {
var id = isString(d) ? d : d.id;
return this.config[__data_types][id] === 'scatter';
return this.config.data_types[id] === 'scatter';
};
c3_chart_internal_fn.isPieType = function (d) {
var id = isString(d) ? d : d.id;
return this.config[__data_types][id] === 'pie';
return this.config.data_types[id] === 'pie';
};
c3_chart_internal_fn.isGaugeType = function (d) {
var id = isString(d) ? d : d.id;
return this.config[__data_types][id] === 'gauge';
return this.config.data_types[id] === 'gauge';
};
c3_chart_internal_fn.isDonutType = function (d) {
var id = isString(d) ? d : d.id;
return this.config[__data_types][id] === 'donut';
return this.config.data_types[id] === 'donut';
};
c3_chart_internal_fn.isArcType = function (d) {
return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d);
......
......@@ -6,10 +6,10 @@ c3_chart_internal_fn.initZoom = function () {
})
.on("zoom", function () { $$.redrawForZoom.call($$); });
$$.zoom.scale = function (scale) {
return config[__axis_rotated] ? this.y(scale) : this.x(scale);
return config.axis_rotated ? this.y(scale) : this.x(scale);
};
$$.zoom.orgScaleExtent = function () {
var extent = config[__zoom_extent] ? config[__zoom_extent] : [1, 10];
var extent = config.zoom_extent ? config.zoom_extent : [1, 10];
return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])];
};
$$.zoom.updateScaleExtent = function () {
......@@ -20,13 +20,13 @@ c3_chart_internal_fn.initZoom = function () {
};
};
c3_chart_internal_fn.updateZoom = function () {
var $$ = this, z = $$.config[__zoom_enabled] ? $$.zoom : function () {};
var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {};
$$.main.select('.' + $$.CLASS[_zoomRect]).call(z);
$$.main.selectAll('.' + $$.CLASS[_eventRect]).call(z);
};
c3_chart_internal_fn.redrawForZoom = function () {
var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x, orgXDomain = $$.orgXDomain;
if (!config[__zoom_enabled]) {
if (!config.zoom_enabled) {
return;
}
if ($$.filterTargetsToShow($$.data.targets).length === 0) {
......@@ -48,5 +48,5 @@ c3_chart_internal_fn.redrawForZoom = function () {
if (d3.event.sourceEvent.type === 'mousemove') {
$$.cancelClick = true;
}
config[__zoom_onzoom].call($$.api, x.orgDomain());
config.zoom_onzoom.call($$.api, x.orgDomain());
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment