Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong stack order when names a mix of text only and numbers only #1534

Closed
raphaelgera opened this issue Jan 11, 2016 · 4 comments · Fixed by #2314
Closed

Wrong stack order when names a mix of text only and numbers only #1534

raphaelgera opened this issue Jan 11, 2016 · 4 comments · Fixed by #2314

Comments

@raphaelgera
Copy link

raphaelgera commented Jan 11, 2016

The below code breaks the order and puts the number only name first

    data: {
        columns: [
            ['data1', 130, 200, 320, 400, 530, 750],
            ['2', 130, 10, 130, 200, 150, 250],
            ['data3', 130, 50, 10, 200, 250, 150]
        ],
        type: 'bar',
        groups: [
            ['data1', '2', 'data3']
        ] 
   }

image
This code works as expected

    data: {
        columns: [
            ['data1', 130, 200, 320, 400, 530, 750],
            ['2data', 130, 10, 130, 200, 150, 250],
            ['data3', 130, 50, 10, 200, 250, 150]
        ],
        type: 'bar',
        groups: [
            ['data1', '2data', 'data3']
        ] 
   }

image

@Misophistful
Copy link

Probably related to the same issue:

When the column title is a number (or a string that just contains a number), then the given order of the columns is ignored, and they're rendered in ascending numerical order of the column title.

This renders the columns in order they're listed (i.e. 'data5', 'data1', 'data2', 'data4', 'data3')

var chart = c3.generate({
    data: {
        columns: [
            ['data5', 30],
            ['data1', 130],
            ['data2', 35],
            ['data4', 60],
            ['data3', 100]
        ],
        type: 'bar'
    }
});

This renders the columns in ascending order of their titles (i.e. 1, 2, 3, 4, 5):

var chart = c3.generate({
    data: {
        columns: [
            [5, 30],
            [1, 130],
            [2, 35],
            [4, 60],
            [3, 100]
        ],
        type: 'bar'
    }
});

@chrisjensen
Copy link

chrisjensen commented Dec 8, 2016

For those stumbling on this looking for a quick fix, I append a space to my column headers.
eg

columns: [
['data1', 130, 200, 320, 400, 530, 750],
['2 ', 130, 10, 130, 200, 150, 250],
['data3', 130, 50, 10, 200, 250, 150]
],

Here's an example:
http://jsfiddle.net/gur3q5nt/1/

@panthony
Copy link
Contributor

The cause of this issue it the pivot format used between the input data and the generation of the targets.

It uses the names as object keys.

It "works" when the names are alphanumerical but not at all of the names is numeric.

@kt3k
Copy link
Member

kt3k commented Apr 13, 2018

Thanks for the issue. This has been fixed at v0.5.3 by #2314 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants