I am working on a very large scale data modeling project. Just
beginning to familiarize myself with d3. I do enjoy the project, and
appreciate its potential. Thank you.
I understand the convenience of modeling time series over regular
intervals, but in my world, events happen at random, with random UNIX
timestamps, and I am puzzled with how to set up the time scales for x
and y axes in my model. Perhaps by providing an example of what I am
doing, your generosity, and my ongoing tenacity, we'll have this
better understood...
My time series is this, but much larger:
[{ t: 1322523468721, v: 19587 }
{ t: 1322523478911, v: 52425 }
{ t: 1322523795609, v: 14266 }
{ t: 1322523903723, v: 78271 }
{ t: 1322523144777, v: 8372 }
{ t: 1322523226188, v: 93030 }
{ t: 1322523255502, v: 8279 }
{ t: 1322523706449, v: 36722 }
{ t: 1322523966551, v: 13442 }
{ t: 1322523795959, v: 13455 }]
1. I want to create an x time scale from the first date to the last
date, but I don't understand how range factors into the random set of
time values. So, x =
d3.time.scale().domain([min_t,max_t]).range(?)
2. I want to create a y time scale for the v values occurring at time
t. All v are the duration of the event at time t.
3. I want to then draw a vertical rectangle (or line 2px wide) at each
time t along the x time scale.
A. How should I be setting up the time scale functions? for x? for
y?
B. To draw lines, should I create a function of t returning the x-
pixel value between the the pixel values of minimum t and maximum t,
i.e. the chart's full width?
C. Do these timestamps and time deltas need to become Date objects in
order to render properly?
Any foothold is appreciated.
Your y scale is not dates but magnitude of duration so your min is 0
and your max could be the longest one. Your y range is the height of
your chart. When you draw your svg rectangle, you can use the x and y
scales to determine the (x,y) point of the corner of the box.
You would only need to use the Date object to display the x labels if
you care about how they look and you want to report in a human-
friendly way which is likely. The scale function's domain can work on
the unix timestamps themselves.