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

Loading nested JSON objects #1471

Closed
kelthuzad opened this issue Nov 19, 2015 · 11 comments
Closed

Loading nested JSON objects #1471

kelthuzad opened this issue Nov 19, 2015 · 11 comments
Labels
C-feature-request Category: A feature request or an enhancement resolved maybe

Comments

@kelthuzad
Copy link
Contributor

When I load JSON as chart data, I cannot load any nested objects or array values, but only objects in the first "level" of the JSON object.

This works fine:

c3.generate({
data: [{myVal:1}],
keys: {value: ['myVal']} // load property "myVal" 
});

But this does not work:

c3.generate({
data: [{myVal: {innerVal:1}}],
keys: {value: ['myVal.innerVal']} // cannot access nested data here
});

There would only be a small change needed to implement the access of nested values, and it would make loading of JSON objects much easier in some cases.

@deeg
Copy link

deeg commented Nov 20, 2015

+1

@aendra-rininsland aendra-rininsland added the C-feature-request Category: A feature request or an enhancement label Dec 1, 2015
@ericmillsio
Copy link

+1

@kelthuzad
Copy link
Contributor Author

I just opened a pull request but the CI says my new test cases don't work. However they work fine on my machine. Any suggestions why they don't work here: https://travis-ci.org/masayuki0812/c3/builds/96603362 ?

@tdharris
Copy link

I would like for this to work.

@kelthuzad
Copy link
Contributor Author

Just fixed my pull request, so tests work now!

@z
Copy link

z commented Apr 15, 2016

This looks great. Looking forward to this being merged.

@aendra-rininsland
Copy link
Member

This is a solid idea. Merging PR to dev now.

@kelthuzad
Copy link
Contributor Author

For anyone who is interested, this is a simple jsfiddle that demonstrates the new feature: http://jsfiddle.net/h0wag7ur/

@michaelrodov
Copy link

Great feature!
Will allow us to stop massaging the jsons prior to charts building

@z
Copy link

z commented May 16, 2016

Awesome! So happy to see this merged. Appreciate the demo too.

@akshaysGit
Copy link

Hello,

I am trying to use following JSON data input for stacked bar chart, however its not working for nested input. If I put everything on one level, it works fine. Its just that nested is causing issue. can you pls help?

JSON data -
`[
{
"Month": "Sample 1",
"TotalAmount": "$100",
"StartDate:
"EndDate:
"Detail":
[
{ "Type": "A", "Unit": "50", "Amount": "20"},
{ "Type": "B", "Unit": "20", "Amount": "70"},
{ "Type": "C", "Unit": "2", "Amount": "10"},
]
},
{
"Month": "Sample 2",
"TotalAmount": "$150",
"Detail":
[
{ "Type": "A", "Unit": "50", "Amount": "20"},
{ "Type": "C", "Unit": "2", "Amount": "10"},
]
},

]`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request or an enhancement resolved maybe
Projects
None yet
Development

No branches or pull requests

8 participants