Commit 97cc3eb3 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix data label on negative bar chart

parent 0f55800e
...@@ -3346,11 +3346,13 @@ ...@@ -3346,11 +3346,13 @@
}; };
c3_chart_internal_fn.getYForText = function (points, d, textElement) { c3_chart_internal_fn.getYForText = function (points, d, textElement) {
var $$ = this, var $$ = this,
box = textElement.getBoundingClientRect(), yPos; box = textElement.getBoundingClientRect(),
offset = $$.isBarType(d) ? 0 : 3,
yPos;
if ($$.config.axis_rotated) { if ($$.config.axis_rotated) {
yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2; yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2;
} else { } else {
yPos = points[2][1] + (d.value < 0 ? box.height * 1.3 : $$.isBarType(d) ? -3 : -6); yPos = points[2][1] + (d.value < 0 ? box.height + offset : (-3 - offset));
} }
// show labels regardless of the domain if value is null // show labels regardless of the domain if value is null
if (d.value === null && !$$.config.axis_rotated) { if (d.value === null && !$$.config.axis_rotated) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -92,11 +92,13 @@ c3_chart_internal_fn.getXForText = function (points, d, textElement) { ...@@ -92,11 +92,13 @@ c3_chart_internal_fn.getXForText = function (points, d, textElement) {
}; };
c3_chart_internal_fn.getYForText = function (points, d, textElement) { c3_chart_internal_fn.getYForText = function (points, d, textElement) {
var $$ = this, var $$ = this,
box = textElement.getBoundingClientRect(), yPos; box = textElement.getBoundingClientRect(),
offset = $$.isBarType(d) ? 0 : 3,
yPos;
if ($$.config.axis_rotated) { if ($$.config.axis_rotated) {
yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2; yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2;
} else { } else {
yPos = points[2][1] + (d.value < 0 ? box.height * 1.3 : $$.isBarType(d) ? -3 : -6); yPos = points[2][1] + (d.value < 0 ? box.height + offset : (-3 - offset));
} }
// show labels regardless of the domain if value is null // show labels regardless of the domain if value is null
if (d.value === null && !$$.config.axis_rotated) { if (d.value === null && !$$.config.axis_rotated) {
......
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