Browse Source

Fix data label on negative bar chart

pull/1069/merge
Masayuki Tanaka 10 years ago
parent
commit
97cc3eb349
  1. 6
      c3.js
  2. 2
      c3.min.js
  3. 6
      src/text.js

6
c3.js

@ -3346,11 +3346,13 @@
};
c3_chart_internal_fn.getYForText = function (points, d, textElement) {
var $$ = this,
box = textElement.getBoundingClientRect(), yPos;
box = textElement.getBoundingClientRect(),
offset = $$.isBarType(d) ? 0 : 3,
yPos;
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 * 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
if (d.value === null && !$$.config.axis_rotated) {

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

6
src/text.js

@ -92,11 +92,13 @@ c3_chart_internal_fn.getXForText = function (points, d, textElement) {
};
c3_chart_internal_fn.getYForText = function (points, d, textElement) {
var $$ = this,
box = textElement.getBoundingClientRect(), yPos;
box = textElement.getBoundingClientRect(),
offset = $$.isBarType(d) ? 0 : 3,
yPos;
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 * 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
if (d.value === null && !$$.config.axis_rotated) {

Loading…
Cancel
Save