Temporal binned histogram in Vega lite

Let me go straight to the point, as I am ashame of even asking this but, how do I bin values in vega-lite to make a histogram ?

I did look at the examples flourishing on vega and vega-lite’ pages and at the documentation, using basic tables or the car dataset. I can reproduce those examples. The difference is that in my case I have (to simplify) ids associated with timestamps (unit s). In d3 or python, I can easily do a value_counts() on any round value of the timestamps and display the number of ids in that time interval, but how do I do that in vega lite ?

For example how do I bin the ids per hours to show the total number of ids hour per hour ?

This is a bit hard to answer without seeing the format of your data or knowing what you have tried. Is there a minimal example notebook that you can share? I guess you already know about this page of the vega-lite documentation https://vega.github.io/vega-lite/docs/bin.html

Thank you for your comment bgchen. I agree my question is very malformed. Yes I know about this page you point to, although I need to go slowly and take time to learn another way of doing things…

This crossfilter vega example will help me get personalized timed bins.

1 Like

Vega-Lite author here. I’m happy to help if you can post your question with some code on stack overflow tagged with vega-lite. Thanks!

3 Likes

Thank you Domoritz… I think It will be ok for the binned histogram. the crossfilter vega example is putting me on the good track.

But I have another question… Is there a way to get a d3 export from the vega or vega-lite specifications ? That would be useful to learn more of d3 by reading its code for things we are able to do in vega-lite. For me I would use that to get more insights on d3’s handling of event based on signal specification.

Vega does not generate D3 code so no, it’s not possible. Vega has its own execution engine that is optimized for reactive workloads.

2 Likes

Ok, I understand.

By the way, this is what I was trying to achieve https://beta.observablehq.com/d/08db1104571d415c

1 Like