c3js / c3js/c3

Wrapping RTL text in X-Axis does not work correctly

Open
#1,768 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
1.4k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

(P.S. Sorry for my English)

When a RTL label is splited on X-Axis, the calculation of its placement are wrong:

current status:
![bad](https://cloud.githubusercontent.com/assets/5174413/16895386/405887c0-4b7d-11e6-9891-b050e705580d.png)

needs to be:
![good](https://cloud.githubusercontent.com/assets/5174413/16895387/44112232-4b7d-11e6-843a-663cfbbc77d9.png)

When looking on the SVG code that C3 generate, I found that chaning:

```

תנועת חיפוש
אורגאנית

```

to the following code solves the problem (I changed y instead of dy and put it in seperate text element):

```
תנועת חיפוש
אורגאנית
```

Relevant method in c3: function axis(g)

sample c3 chart with the problem (make the window small to see the word wrap:

```
var chart = c3.generate({
data: {
columns:[
["x","\u05ea\u05e0\u05d5\u05e2\u05ea \u05d7\u05d9\u05e4\u05d5\u05e9 \u05de\u05de\u05d5\u05de\u05e0\u05ea","\u05ea\u05e0\u05d5\u05e2\u05d4 \u05d9\u05e9\u05d9\u05e8\u05d4","\u05ea\u05e0\u05d5\u05e2\u05ea \u05d7\u05d9\u05e4\u05d5\u05e9 \u05d0\u05d5\u05e8\u05d2\u05d0\u05e0\u05d9\u05ea","\u05ea\u05e0\u05d5\u05e2\u05ea \u05d4\u05e4\u05e0\u05d9\u05d4"],
["cpc",39150,null,null,null],["(none)",null,6300,null,null],["organic",null,null,12000,null],["referral",null,null,null,3000]],
names:{organic:"\u05ea\u05e0\u05d5\u05e2\u05ea \u05d7\u05d9\u05e4\u05d5\u05e9 \u05d0\u05d5\u05e8\u05d2\u05d0\u05e0\u05d9\u05ea","(none)":"\u05ea\u05e0\u05d5\u05e2\u05d4 \u05d9\u05e9\u05d9\u05e8\u05d4",referral:"\u05ea\u05e0\u05d5\u05e2\u05ea \u05d4\u05e4\u05e0\u05d9\u05d4",cpc:"\u05ea\u05e0\u05d5\u05e2\u05ea \u05d7\u05d9\u05e4\u05d5\u05e9 \u05de\u05de\u05d5\u05de\u05e0\u05ea"},
type: 'bar',
groups:[["organic","(none)","referral","cpc"]],

},
axis:
{x: {show:true,type:'category',
categories:["\u05ea\u05e0\u05d5\u05e2\u05ea \u05d7\u05d9\u05e4\u05d5\u05e9 \u05de\u05de\u05d5\u05de\u05e0\u05ea",
"\u05ea\u05e0\u05d5\u05e2\u05d4 \u05d9\u05e9\u05d9\u05e8\u05d4",
"\u05ea\u05e0\u05d5\u05e2\u05ea \u05d7\u05d9\u05e4\u05d5\u05e9 \u05d0\u05d5\u05e8\u05d2\u05d0\u05e0\u05d9\u05ea",
"\u05ea\u05e0\u05d5\u05e2\u05ea \u05d4\u05e4\u05e0\u05d9\u05d4"]}},

});

```

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.