c3js / c3js/c3

c3.js X-Axis String Value Javascript error

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

Description

I am setting values to a simple c3.js bar chart by javascript. Here is how I am setting the values

```
var values={ x : 'x',
type: "bar",
columns: [['x', data_0x,data_1x,data_2x,data_3x,data_4x] ,
["% of Employees",data_0y,data_1y,data_2y,data_3y,data_4y]]}
```

While generating the chart, the following is my code

```

var chart = new c3.generate({
bindto: '#chartContainer',
data: values,
axis: {x: {type: 'category'}}
});
```

When data_0x, data_1x etc are numerical values, the chart comes out perfect.

However when these are string values like 'a', 'b' etc, I am getting the following javascript errors

> d3.v3.min.js:670 Error: attribute transform: Expected number, "translate(NaN, 0)".attrFunction @ d3.v3.min.js:670
> d3.v3.min.js:670 Error: attribute x: Expected length, "NaN".attrFunction @ d3.v3.min.js:670
> d3.v3.min.js:670 Error: attribute width: Expected length, "NaN".

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.