Bin dates based on plot width #2057
Unanswered
dmeehan1968
asked this question in
Q&A
Replies: 1 comment
-
You should use the rect mark and the bin transform for quantitative/temporal binning instead of using the cell mark. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have some time series data, which I am binning into date intervals in an SQL query to give date, price and count. I am then plotting using
Plot.cell(data.rows, {x: "date", y: "price", fill: "count" })
.On the plot options, I specify
x : { interval: 'day' }
and this works fine when there are limited number of dates and the width of the plot is wide enough.I have data for 2+ years, but this can lead to cells that are too narrow to render, and so the chart appears blank. What would be acceptable is to bin by week when the number of cells exceeds the displayable width. The individual cell width could be minimum 1px, although I might want to 'inset' the cells so this needs to be taken into account.
I see there are 'thresholds' when binning, but I can't figure out how to use this with the source data, or if I can even achieve the effect I want. The plot is displayed in a React app and therefore I know what the plot width will be, so can bin accordingly, but ideally I'd like the plot to adjust based on width.
Any pointers on how to achieve this?
Beta Was this translation helpful? Give feedback.
All reactions