c3js / c3js/c3

Category Axis with a x value of 0 (zero) creates incorrect categories

Open
#1,615 2 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

Using JSON data and axis.x.type: 'category'. I set data.keys.x to 'bin', when a bin is zero, the first category gets goofed up; categories shift over so that the first category gets the label of the second and so on. Finally, the last becomes is given the default category (zero-indexed enumeration).

bad:
![bad](http://i.imgur.com/vzQF1lZ.png)

good:
![good](http://i.imgur.com/m0iiuh1.png)

full code demonstation:

```
var chart = c3.generate({
data: {
type: 'bar',
json: [
{ "count": 1, "bin": 0}, //change this bin to anything but 0 and everything looks great!
{ "count": 10, "bin": 22},
{ "count": 30, "bin": 33},
{ "count": 40, "bin": 3},
],
keys: {
x: 'bin',
value: ['count'],
}
},
axis: {
x: {
type: 'category' // bug only with category axis
}
}
});

```

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.