return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>javascript - What does zoom.scaleExtent() do in d3.js? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What does zoom.scaleExtent() do in d3.js? - Stack Overflow

programmeradmin2浏览0评论

I have created the d3 time axis,

//minDate and maxDates are javascript date object.
var timeScale =d3.scaleTime().domain([minDate,maxDate]).range(
                [0, width]);
var timeAxis = d3.axisBottom(timeScale);

And i have added the zoom interaction to this axis

//gX is group div that has timeAxis.
gX.call(d3.zoom(timeScale).scaleExtent([0,4]).on("zoom",function(d){
    //Do something.
}))

but initially i want to set the zoom level of the axis in day level,default it is showing in hour level,So finally what i am curious is,

  1. How to limit the zooming boundary between years level and min zoom level to day level?
  2. what does numbers [0,4] represent in scaleExtent([0,4]) in zooming?

I have created the d3 time axis,

//minDate and maxDates are javascript date object.
var timeScale =d3.scaleTime().domain([minDate,maxDate]).range(
                [0, width]);
var timeAxis = d3.axisBottom(timeScale);

And i have added the zoom interaction to this axis

//gX is group div that has timeAxis.
gX.call(d3.zoom(timeScale).scaleExtent([0,4]).on("zoom",function(d){
    //Do something.
}))

but initially i want to set the zoom level of the axis in day level,default it is showing in hour level,So finally what i am curious is,

  1. How to limit the zooming boundary between years level and min zoom level to day level?
  2. what does numbers [0,4] represent in scaleExtent([0,4]) in zooming?
Share Improve this question edited Aug 18, 2016 at 9:33 Manjunath M asked Aug 18, 2016 at 8:06 Manjunath MManjunath M 6081 gold badge8 silver badges32 bronze badges 2
  • 4 Good luck! D3 seems to be a mystery to itself. Unfortunately all the documentation out there by Mike Bostock (great programmer as he is, he's absolutely awful at explaining things in a simple, straightforward way), is pretty much useless for anyone who is not prepared to spend at least a month in learning how to create a simple line graph. Powerful library, but most people are simply reduced to copying Mikes code example and tweaking it to do what they want - without fully understanding the code they end up with. Wish there was an alternative with shallower learning curve, would dump D3! – Homunculus Reticulli Commented Sep 8, 2017 at 15:07
  • @HomunculusReticulli you are right, the guy has made no efforts whatsoever to simplify stuff like real time graphs, time series pan zoom etc – PirateApp Commented Aug 17, 2018 at 7:53
Add a ment  | 

2 Answers 2

Reset to default 3

I know this is 4 years old post. Back then were there no documentation? This seems to explain pretty thoroughly.

[k0, k1] where k0 is the minimum allowed scale factor and k1 is the maximum allowed scale factor, and returns this zoom behavior. If extent is not specified, returns the current scale extent, which defaults to [0, ∞]. The scale extent restricts zooming in and out.

From what i understand it's the times factor of the zoom. 4 would be mean: magnified 4 times.

发布评论

评论列表(0)

  1. 暂无评论