Zoom to domain with intervals

7 views
Skip to first unread message

Alex

unread,
Mar 22, 2017, 2:25:46 AM3/22/17
to d3-js

I'm using d3 to build a chart with data I get from a mysql database. I was working with this example:https://bl.ocks.org/mbostock/431a331294d2b5ddd33f947cf4c81319. You can see my code in Plunker: http://plnkr.co/edit/HvypuHsrqPSDIcEOiFS0.

I would like that my chart show me the last 8 hours when the chart is load, and then, be able to make zoom or move the chart. I was working in this piece of code:

var d0 = new Date(2003, 1, 5),
d1
= new Date(2003, 2, 10);


I was working for d1 show the actual date, and d0 8 hours less, with one idea from a question in stackoverflow:

var d = new Date();
var d0 = d3.time.hour.offset(d, -8);
var d1 = new Date();


But the chart keep freezed, without transition or zoom capacity. I think is a problem about time format (I got this data: {"Time":"2017-03-12 22:40:23","Probe1":"20.10"}). I was looking for information about intervals, zoom behaviour or offset features, but I can't find a solution. Any idea?

Thanks!

Alex.

Reply all
Reply to author
Forward
0 new messages