c3js / c3js/c3

Issue in multiline xAxis label positioning when using axis.x.rotate

Open
#2,654 0 comments 0 reactions 0 assignees View on GitHub
C-bug
Dominant language
JavaScript
Stars
9.3k
Forks
1.4k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

When loading new data, the xAxis label is badly positioned when using rotate option.

See http://jsfiddle.net/m9c8qpd2/

The issue is here:

```
AxisInternal.prototype.updateTickTextCharSize = function (tick) {
var internal = this;
if (internal.tickTextCharSize) {
return internal.tickTextCharSize;
}
var size = {
h: 11.5,
w: 5.5
};
tick.select('text').text(function(d) { return internal.textFormatted(d); }).each(function (d) {
var box = this.getBoundingClientRect(),
text = internal.textFormatted(d),
h = box.height,
w = text ? (box.width / text.length) : undefined;
if (h && w) {
size.h = h;
size.w = w;
}
}).text('');
internal.tickTextCharSize = size;
return size;
};
```

We are recomputing the "text char size" using the box's height whereas this is false when the box is rotated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.