Stacked Horizontal Bar Chart (Normalized)

275 views
Skip to first unread message

slaven....@gmail.com

unread,
Feb 22, 2017, 4:14:08 PM2/22/17
to d3plus
I'm working with the base sample of

http://d3plus.org/examples/advanced/929be3aef3295d9e0acd/

and was trying to do 2 things.

1. I'm trying to create a horizontal stacked bar chart and would like to have the y axis be % based rather than the amount of items im passin in from my data array. I tried setting "scale":"share on the x axis and y to discrete but that just displays nothing.

2. If you look at the sample I linked above, there is a certain gap between each set of bars, is it possible to remove this gap? or manually set whether it is removed or not ?

Thank You

Oleksandr Zastupailo

unread,
Feb 23, 2017, 4:43:13 AM2/23/17
to d3plus, slaven....@gmail.com
1. I wasn't able to set x axis to % too, but one way of solving this is before passing data to visualization to calculate percentage on your own and then d3plus will just draw them in the way you want.

2. You need to set 'padding' attribute of the .y() method:

.y({"value": "year", 'padding': 1.1})

slaven....@gmail.com

unread,
Feb 23, 2017, 10:09:34 AM2/23/17
to d3plus, slaven....@gmail.com
Hi, Thanks your suggestion for 2. worked.

I was wondering, do you know any way possible to normalize the data on a "horizontal" stacked bar chart? For some reason I can accomplish it on a vertical stacked bar chart but nothing displays when I try to do the same thing on a horizontally stacked bar chart.

Thanks
Reply all
Reply to author
Forward
0 new messages