Browse Source

Fix conflict

pull/1207/head
Masayuki Tanaka 10 years ago
parent
commit
cdecc19fdf
  1. 27
      c3.js
  2. 8
      c3.min.js
  3. 25
      src/data.convert.js
  4. 2
      src/text.js

27
c3.js

@ -2066,8 +2066,12 @@
var $$ = this, config = $$.config,
ids = $$.d3.keys(data[0]).filter($$.isNotX, $$),
xs = $$.d3.keys(data[0]).filter($$.isX, $$),
zeroUnderYAxis = true,
allZero = true,
targets;
$$.allDataIsNegative = true;
// save x for update data by load when custom x and c3.x API
ids.forEach(function (id) {
var xKey = $$.getXKey(id);
@ -2110,7 +2114,9 @@
id: convertedId,
id_org: id,
values: data.map(function (d, i) {
var xKey = $$.getXKey(id), rawX = d[xKey], x = $$.generateTargetX(rawX, id, i);
var xKey = $$.getXKey(id), rawX = d[xKey],
x = $$.generateTargetX(rawX, id, i),
value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null;
// use x as categories if custom x and categorized
if ($$.isCustomX() && $$.isCategorized() && index === 0 && rawX) {
if (i === 0) { config.axis_x_categories = []; }
@ -2120,7 +2126,16 @@
if (isUndefined(d[id]) || $$.data.xs[id].length <= i) {
x = undefined;
}
return {x: x, value: d[id] !== null && !isNaN(d[id]) ? +d[id] : null, id: convertedId};
if(value !== null && value !== 0) {
allZero = false;
}
if(value > 0) {
zeroUnderYAxis = false;
}
return {x: x, value: value, id: convertedId};
}).filter(function (v) { return isDefined(v.x); })
};
});
@ -2147,6 +2162,12 @@
});
});
if(allZero) {
zeroUnderYAxis = false;
}
$$.zeroUnderYAxis = zeroUnderYAxis;
// set target types
if (config.data_type) {
$$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config.data_types); }), config.data_type);
@ -3387,7 +3408,7 @@
yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2;
} else {
yPos = points[2][1];
if (d.value < 0) {
if (d.value < 0 || (d.value === 0 && $$.zeroUnderYAxis)) {
yPos += box.height;
if ($$.isBarType(d) && $$.isSafari()) {
yPos -= 3;

8
c3.min.js vendored

File diff suppressed because one or more lines are too long

25
src/data.convert.js

@ -96,8 +96,12 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
var $$ = this, config = $$.config,
ids = $$.d3.keys(data[0]).filter($$.isNotX, $$),
xs = $$.d3.keys(data[0]).filter($$.isX, $$),
zeroUnderYAxis = true,
allZero = true,
targets;
$$.allDataIsNegative = true;
// save x for update data by load when custom x and c3.x API
ids.forEach(function (id) {
var xKey = $$.getXKey(id);
@ -140,7 +144,9 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
id: convertedId,
id_org: id,
values: data.map(function (d, i) {
var xKey = $$.getXKey(id), rawX = d[xKey], x = $$.generateTargetX(rawX, id, i);
var xKey = $$.getXKey(id), rawX = d[xKey],
x = $$.generateTargetX(rawX, id, i),
value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null;
// use x as categories if custom x and categorized
if ($$.isCustomX() && $$.isCategorized() && index === 0 && rawX) {
if (i === 0) { config.axis_x_categories = []; }
@ -150,7 +156,16 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
if (isUndefined(d[id]) || $$.data.xs[id].length <= i) {
x = undefined;
}
return {x: x, value: d[id] !== null && !isNaN(d[id]) ? +d[id] : null, id: convertedId};
if(value !== null && value !== 0) {
allZero = false;
}
if(value > 0) {
zeroUnderYAxis = false;
}
return {x: x, value: value, id: convertedId};
}).filter(function (v) { return isDefined(v.x); })
};
});
@ -177,6 +192,12 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
});
});
if(allZero) {
zeroUnderYAxis = false;
}
$$.zeroUnderYAxis = zeroUnderYAxis;
// set target types
if (config.data_type) {
$$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config.data_types); }), config.data_type);

2
src/text.js

@ -98,7 +98,7 @@ c3_chart_internal_fn.getYForText = function (points, d, textElement) {
yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2;
} else {
yPos = points[2][1];
if (d.value < 0) {
if (d.value < 0 || (d.value === 0 && $$.zeroUnderYAxis)) {
yPos += box.height;
if ($$.isBarType(d) && $$.isSafari()) {
yPos -= 3;

Loading…
Cancel
Save