Area shape with ordinal x scale ?

6 views
Skip to first unread message

Pierre Massat

unread,
Mar 22, 2017, 9:02:42 AM3/22/17
to d3...@googlegroups.com
Hi,

I'm experimenting with the area shape, and I stumbled upon a behaviour I don't understand.

I specify my shape like so :
var dureeArea = d3.area().x(function(d,i){
                            return xScale(i);
                        })
                        .y0(function(d){return yScale(0);})
                        .y1(function(d){return yScale(d.value);});

I'm trying to plot a pretty large array of items sorted by "value", which is why I'm using their index for the x scale.

What surprizes me is that when I use a linear xScale the path is drawn correctly, but when I use an ordinal scale ( d3.scalePoint()), only the top line of the path is drawn, and the path is closed between the first and the last value of the line (so I don't get the bottom of the area).

Is that a feature ? I don't mind using a linear scale, but it makes more sense to me to use an ordinal scale when using the index of elements to position them on the x axis.

Thanks in advance for your reply,

Pierre.
Reply all
Reply to author
Forward
0 new messages