Neoon
Neoon

Reputation: 169

c3js, X Axis crushed and badly formated

Currently I am playing arround with this Example: http://c3js.org/samples/axes_x_tick_culling.html

But the issue is, when you add like 3-4x the Ammount of Data, the X values get crushed and badly formated. How can I fix this any idea?

See here: https://i.sstatic.net/gzrTR.png

Thanks.

Upvotes: 0

Views: 65

Answers (2)

Mike Rodov
Mike Rodov

Reputation: 597

Width is working fine for me, take a look X axis with tripple digit numbers

enter link description here

var chart = c3.generate({
data: {
    columns: [
        ['sq', 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250,30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250,30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250,30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250,30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250,30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250,30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250]

]

},
axis: {
    x: {
        type: 'category',
        tick: {
        width: 22,
            culling: {
                max: 7 
            }
        }
    }
}

});

Upvotes: 2

Mike Rodov
Mike Rodov

Reputation: 597

Here you go, you need to add the tick.width parameter. It's not documented yet (we're working on it)

var chart = c3.generate({
    data: {
        columns: [
                        ['sq', 30, 200, 100, 400, 150, 11,11,11,11,111,11,11,11,22,22,22,22,22,223,43,32,14,250, 30,31, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250]]
        
    },
    axis: {
        x: {
            type: 'category',
            tick: {
                culling: true,
                width: 11
            }
        }
    }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<div id="chart">
</div>

var chart = c3.generate({
data: {
    columns: [
                    ['sq', 30, 200, 100, 400, 150, 11,11,11,11,111,11,11,11,22,22,22,22,22,223,43,32,14,250, 30,31, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250, 200, 100, 400, 150, 250]]

},
axis: {
    x: {
        type: 'category',
        tick: {
            culling: true,
            width: 11
        }
    }
}

});

jsfiddle

Upvotes: 0

Related Questions