c3js,X轴被压碎并且形成不良

时间:2016-06-13 15:05:54

标签: javascript d3.js c3.js

目前我正在玩这个例子: http://c3js.org/samples/axes_x_tick_culling.html

但问题是,当你添加3-4倍的Ammount of Data时,X值会被粉碎并严重格式化。我怎么能解决这个问题?

见这里:http://i.imgur.com/F7BWMDk.png

感谢。

2 个答案:

答案 0 :(得分:2)

宽度对我来说很好,看看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 
            }
        }
    }
}

});

答案 1 :(得分:0)

你走了, 你需要添加tick.width参数。 它还没有记录(我们正在研究它)



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>
&#13;
&#13;
&#13;

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