c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.33k stars 1.39k forks source link

Bar-chart's columns are overlapping on sparse data #2811

Open strizhechenko opened 3 years ago

strizhechenko commented 3 years ago

JSFeedle: https://jsfiddle.net/tymufe5x/

var chart = c3.generate({
    data: {
        columns: [
            // light sparse is ok:
            // ['value', 1, 2, 4],
            // ['percent', 10, 20, 30]

            // no sparse is ok too
            // ['value', 1, 2, 3, 4, 5],
            // ['percent', 10, 20, 30, 40, 50]

            // but this way columns 1 and 2 are overlapping 
            ['value', 1, 2, 5],
            ['percent', 10, 20, 30]
        ],
        x: 'value',
        type: 'bar'
    },
});

Versions:

Zenthae commented 3 years ago

you can use

bar: {
        width: {
            ratio: 0.5 // this makes bar width 50% of length between ticks
        }
        // or
        //width: 100 // this makes bar width 100px
    }

https://c3js.org/reference.html#bar-width-ratio