-
Notifications
You must be signed in to change notification settings - Fork 2k
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
stacked bar chart #22
Comments
Hi @7marjorie , If the data is missing, would you like to treat that as a zero value? If so, probably the best approach would be to detect which pairs are missing, and add "fake data" that fills them in as zero values, before passing the data into d3.nest. I think the problem is that These answers might also be helpful:
Also, this would be a great question for the D3 mailing list, perhaps someone there has a better answer. |
Thank you for the response Curran!!
2017-01-25 14:25 GMT+01:00 Curran Kelleher <[email protected]>:
… Hi @7marjorie <https://github.com/7marjorie> ,
If the data is missing, would you like to treat that as a zero value? If
so, probably the best approach would be to detect which pairs are missing,
and add "fake data" that fills them in as zero values, before passing the
data into d3.nest.
I think the problem is that stack() expects clean data where all possible
pairs are filled in. Probably one way to sol you could do is not use
d3.nest(), but instead roll your own nested loop that iterates over all
combinations (the cartesian product
<https://en.wikipedia.org/wiki/Cartesian_product> of domains for the two
fields), looks them up in the actual data, and generates a zero value for
pairs that are not in the original data.
These answers might also be helpful:
- http://stackoverflow.com/questions/14713503/how-to-
handle-layers-with-missing-data-points-in-d3-layout-stack
<http://stackoverflow.com/questions/14713503/how-to-handle-layers-with-missing-data-points-in-d3-layout-stack>
- http://stackoverflow.com/questions/17415406/filling-
the-gaps-in-d3-array-nesting
- d3.nest() "internal" and "external" keys
<https://groups.google.com/forum/#!topic/d3-js/0zNu-oVVtwk> - This one
has a nice solution.
Also, this would be a great question for the D3 mailing list
<https://groups.google.com/forum/#!forum/d3-js>, perhaps someone there
has a better answer.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVkHM0Ti7WHycjgMhMbsaaKcwdcXujn3ks5rV01JgaJpZM4LsZNK>
.
--
Met vriendelijke groeten,
Marjorie
|
@7marjorie No problem! I feel like it's a common problem, and it would be interesting to have a library that does the filling in of the gaps based on the cartesian product. You might also want to try Datalib https://github.com/vega/datalib/wiki/API-Reference#group-by-aggregation . They have a nice group-by aggregation feature. Although your data is already aggregated, I wonder if you pass it through their group-by processing if it might add in the zeros. |
Hey Curran,
Thanks i will try it out!
Marjorie
2017-01-31 11:56 GMT+01:00 Curran Kelleher <[email protected]>:
… @7marjorie <https://github.com/7marjorie> No problem! I feel like it's a
common problem, and it would be interesting to have a library that does the
filling in of the gaps based on the cartesian product.
You might also want to try Datalib https://github.com/vega/
datalib/wiki/API-Reference#group-by-aggregation . They have a nice
group-by aggregation feature. Although your data is already aggregated, I
wonder if you pass it through their group-by processing if it might add in
the zeros.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVkHM1xfj7pci4S7LDGRU4rQS1w9s1xjks5rXxNsgaJpZM4LsZNK>
.
--
Met vriendelijke groeten,
Marjorie
|
Hey Curran,
Thanks for the sreencasts, I was very helpful.
I made the stacked bar chart and it works ok, if there is no missing data.
In your csv file" religionByCountryTop5.csv" for example Brazil Hindu is marked zero.
In my case the combination of Brazil Hindu would not be in the file.
How can adjust the code to work if data is missing, I plug the chart on oracle BI, so I don't know in advance if data is going to be missing.
Thanks,
The text was updated successfully, but these errors were encountered: