c3 icon indicating copy to clipboard operation
c3 copied to clipboard

Load data bug with categorized axis

Open lblb opened this issue 12 years ago • 2 comments

Hi, If you try to add more data to existing chart with categorized X type, it will fail to do that correctly. Only one newly added value is rendered to chart, all the others are invisible (but rects are added to the DOM). It seems that X scale is calculated incorrectly.
Please take a look at the sample below:

  $(function(){
    var chart = c3.generate({
        bindto:"#chart1",
        data: {
            x: "x",
            columns: [
                ["x", "A", "B", "C"],
                ['data1', 130, 120, 150],
                ['data4', 30, 20, 50]
            ],
            type: 'bar'
        },
        axis: {
            x: {
                type: 'categorized'
            }
        },
    });

    setTimeout(function () {
        chart.load({
            columns: [
                ["x", "A", "B", "C", "D", "E", "F", "G", "H"],
                ['data1', 130, 120, 150, 140, 160, 150, 200, 300],
                ['data4', 30, 20, 50, 40, 60, 50, 100, 120]
            ]
        });
    }, 2000);
    });

I tested that loading of data works ok with default 'indexed' X type and timeseries type. In the example of categorized charts there is a loading function placed in timer, but only one more data value is added . Hence this bug is not visible there.

lblb avatar May 20 '14 08:05 lblb

I think I found a way to fix it, created a pull request

lblb avatar May 20 '14 17:05 lblb

Hi, Thank you for working on this. The pull request seems working well and I'll merge soon. Thank you!

masayuki0812 avatar May 21 '14 04:05 masayuki0812