question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

C3 bar chart - JSON input

See original GitHub issue

Does the C3 bar chart support JSON data? I am trying to get a simple example working but could not find any documentation or examples on how to achieve something like this:

var chart = c3.generate({
    data: {
        type: 'bar',
        json: [
            { 'indicator': 'X', 'total': 100 },
            { 'indicator': 'Y', 'total': 200 },
            { 'indicator': 'Z', 'total': 300 }
        ],
        keys: {
            x: 'indicator',
            value: ['total']
        }
    },
    bar: {
        width: {
            ratio: 0.5
        }
    }
});

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
xrCKN8km6scommented, Nov 3, 2014

It seems that you are missing ‘axis’ section. Try this:

var chart = c3.generate({
    data: {
        type: 'bar',
        json: [
            { 'indicator': 'X', 'total': 100 },
            { 'indicator': 'Y', 'total': 200 },
            { 'indicator': 'Z', 'total': 300 }
        ],
        keys: {
            x: 'indicator',
            value: ['total']
        }
    },
    axis: {
            x: {
                type: 'category'
            }
    },
    bar: {
        width: {
            ratio: 0.5
        }
    }
});
0reactions
armandinocommented, Nov 3, 2014

Thanks for the pointer! That was the problem.

Here’s a working fiddle if anyone else runs into this: http://jsfiddle.net/z2erLqgx/2/

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - C3 bar chart - JSON input - Stack Overflow
Problem was the missing axis value. Here is a working JS fiddle. var chart = c3.generate({ data: { type: 'bar', json: [ {...
Read more >
JSON Data - C3.js | D3-based reusable chart library
D3 based reusable chart library.
Read more >
c3.js stacked bar chart json - CodePen
1. var chart = c3.generate({ ; 2. data: { ; 3. groups: [['upload', 'download']], ; 4. type: "bar", ; 5. json: [.
Read more >
[Solved]-C3 - Timeseries chart with JSON and categories-d3.js
forEach (function (value) { obj[value.city] = value.event; cities.add(value.city); }) obj.date = entry.key; return obj; }); var chart = c3.generate({ data: ...
Read more >
Line Chart - Google Developers
The series option specifies which axis to use for each ( 'Temps' and 'Daylight' ; they needn't have any relation to the column...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found