admin管理员组文章数量:1425780
I'm fairly sure if I can find an example showing what I'm trying to do, I can reverse engineer/reimplement it. Has anyone seen an example showing a smooth/animated transition between a linear and log scale in D3JS?
I have both scales working independently, but I have to reload the page to change the scale.
My Google skills have failed me!
Thanks so much.
I'm fairly sure if I can find an example showing what I'm trying to do, I can reverse engineer/reimplement it. Has anyone seen an example showing a smooth/animated transition between a linear and log scale in D3JS?
I have both scales working independently, but I have to reload the page to change the scale.
My Google skills have failed me!
Thanks so much.
Share Improve this question asked Apr 14, 2013 at 0:31 user986122user986122 3655 silver badges16 bronze badges 2-
why not applying progressively to you axes values the function
f(x)=t*x^(1/t)
fort
ranging from0(+epsilon)
to1
... that should interpolate between log and linear. A log function is just the function above taken at the limit toward zero. – nbonneel Commented Apr 14, 2013 at 0:42 - I'm not sure how to actually change the scale without refreshing the page. In principle, I suppose I could use that function to define a scale, but how would I then regenerate the scale and transition between them? – user986122 Commented Apr 14, 2013 at 0:56
1 Answer
Reset to default 8Here's a proof of concept jsfiddle. You simply reselect the data points and redraw them with the new scale. For the axis labels, the transition is even simpler -- you just need to call the axis function again. Relevant excerpt below.
// change to log scale...
yScale = d3.scale.log().domain([1, 100]).range([dim-padding,padding]);
svg.selectAll("circle").data(data)
.transition().delay(1000).duration(1000)
.attr("cx", function(d) { return xScale(d); })
.attr("cy", function(d) { return yScale(d); });
svg.selectAll(".y")
.transition().delay(1000).duration(1000)
.call(yAxis.scale(yScale));
You might need to play around with how the labels are generated to make it look "nice", but in principle d3 will take care of the entire transition.
本文标签: javascriptExamples showing animated transitions between linear and log scales in D3JSStack Overflow
版权声明:本文标题:javascript - Examples showing animated transitions between linear and log scales in D3JS? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745422143a2657947.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论