Open zufanka opened 5 years ago
In Altair, try adding a clip=True
argument to your barMark method?
I think @zufanka is asking for something different: the ability to constrain the interactivity of the axes to a particular range. So that, e.g. you could zoom freely within the range 0...1000, but the axis extent would be prevented from being larger than [0, 1000].
Thanks @jakevdp, it appears I pattern-matched too quickly! I agree that this would be a great feature to include.
@jakevdp yes indeed! In the case of barcharts it's namely not that intuitive (for me at least) that I will be zooming in where the mouse pointer is. That is why constraining the axis would be a very welcome feature
To add another use case, I'm trying to make a Gantt chart using relative times (i.e. we don't care the time a step happens, only its time relative to the other ones). To make it work, I'm offsetting from 0 Unix time, which works perfectly unless the user scrolls to the left:
I want to limit scroll to only time range of the Gantt chart to prevent confusion with an "overflow".
I agree that this would be very useful. The unbounded interactions can be a bit distracting when you are exploring a dataset with integer quantities but looking between gaps of decimal point axes.
Agreed, this would be very nice to have.
(In fact if you think about it this might have even been a reasonable default option since there's always a limited amount of data and it doesn't make much sense to navigate and scroll beyond it.)
Investigating clipping from vega-lite in an Observable notebook. https://observablehq.com/@pbrockmann/untitled/4
Is there a way to clip when bars are outside the scale domain ?
This is probably the kind of question that is best asked on Slack rather than as a GitHub issue.
But, yes, simply use vl.markBar({"clip":true})
Would be better to make clip
default. Usually what happens is that you set domain and you got empty chart (because overflow area is so huge that the actual chart shrinks to nothing) and have no idea what's going on and why there's absolutely nothing on the screen if there's some bug or something like that.
Originally opened an issue for this on altair, got referred to vega-lite
I am making an interactive barchart with
altair
:Chart.interactive()
. I would like it not to be able to go beyond the 0 and above 1000 on the X axis when zooming in and moving the bars around.I am trying to set boundaries to the X axis with
alt.X(scale = alt.scale(domain=(0,1000)))
but that does not prevent the visualization going into out of these bounds on the X axis.Could there be some way to set the limits to scales on interactive visualizations in vega-lite?