admin管理员组文章数量:1022720
I made a map using an orthographic projection and I try to improve performance because the rotation is not smooth (around 6-7FPS).
It's a map of the world built with a topojson file (world-100m). I need to interact with country and colorized them so there is as many svg:path as there are countries.
After the loading I have an automatic rotation function launched using d3.timer :
autoRotate = () =>
@start_time = Date.now() # Store the current time (used by automatic rotation)
d3.timer () =>
dt = Date.now() - @start_time
if @stopRotation or dt > @config.autoRotationDuration
true
else
@currentRotation[0] = @currentRotation[0] - @config.autoRotationSpeed
@projection.rotate @currentRotation
redrawPathsOnRotationOrScale(@currentRotation, @projection.scale())
false
redrawPathsOnRotationOrScale = (rotation, scale, duration = 1) =>
@currentRotation = rotation
@projection
.rotate(@currentRotation)
.scale(scale)
@groupPaths.selectAll("path")
.attr("d", path)
To understand why it was so slow, I made a profile record in Chrome and here is the result :
It seems the Animation Frame Fired is the slow part but I don't really know what it is. And when I open it, there is 2 GC Event (garbage collector ?) but nothing around... Do you have an idea what is happening during this 90ms ?
Any tips to improve the performance is more than wele :-)
Thanks by advance !
By the way, it looks like this :
I made a map using an orthographic projection and I try to improve performance because the rotation is not smooth (around 6-7FPS).
It's a map of the world built with a topojson file (world-100m). I need to interact with country and colorized them so there is as many svg:path as there are countries.
After the loading I have an automatic rotation function launched using d3.timer :
autoRotate = () =>
@start_time = Date.now() # Store the current time (used by automatic rotation)
d3.timer () =>
dt = Date.now() - @start_time
if @stopRotation or dt > @config.autoRotationDuration
true
else
@currentRotation[0] = @currentRotation[0] - @config.autoRotationSpeed
@projection.rotate @currentRotation
redrawPathsOnRotationOrScale(@currentRotation, @projection.scale())
false
redrawPathsOnRotationOrScale = (rotation, scale, duration = 1) =>
@currentRotation = rotation
@projection
.rotate(@currentRotation)
.scale(scale)
@groupPaths.selectAll("path")
.attr("d", path)
To understand why it was so slow, I made a profile record in Chrome and here is the result :
It seems the Animation Frame Fired is the slow part but I don't really know what it is. And when I open it, there is 2 GC Event (garbage collector ?) but nothing around... Do you have an idea what is happening during this 90ms ?
Any tips to improve the performance is more than wele :-)
Thanks by advance !
By the way, it looks like this :
Share Improve this question asked Jul 10, 2013 at 7:55 John SmithJohn Smith 4891 gold badge6 silver badges13 bronze badges2 Answers
Reset to default 3Try reducing the plexity of the SVG paths by adjusting the --simplify-proportion, -s or --quantization topojson flags. Browsers still have fairly poor SVG rendering performance, and with maps it really helps to reduce the number and precision of the points.
D3.js uses Request Animation Frames to perform timers.
From D3 documentation:
If your browser supports it, the timer queue will use requestAnimationFrame for fluid and efficient animation.
As I know it's the best approach to perform animations in modern browsers and I don't think you can directly optimize this part. Otherwise it seems that you call stack use selection_each
that could probably be cached into a variable.
I made a map using an orthographic projection and I try to improve performance because the rotation is not smooth (around 6-7FPS).
It's a map of the world built with a topojson file (world-100m). I need to interact with country and colorized them so there is as many svg:path as there are countries.
After the loading I have an automatic rotation function launched using d3.timer :
autoRotate = () =>
@start_time = Date.now() # Store the current time (used by automatic rotation)
d3.timer () =>
dt = Date.now() - @start_time
if @stopRotation or dt > @config.autoRotationDuration
true
else
@currentRotation[0] = @currentRotation[0] - @config.autoRotationSpeed
@projection.rotate @currentRotation
redrawPathsOnRotationOrScale(@currentRotation, @projection.scale())
false
redrawPathsOnRotationOrScale = (rotation, scale, duration = 1) =>
@currentRotation = rotation
@projection
.rotate(@currentRotation)
.scale(scale)
@groupPaths.selectAll("path")
.attr("d", path)
To understand why it was so slow, I made a profile record in Chrome and here is the result :
It seems the Animation Frame Fired is the slow part but I don't really know what it is. And when I open it, there is 2 GC Event (garbage collector ?) but nothing around... Do you have an idea what is happening during this 90ms ?
Any tips to improve the performance is more than wele :-)
Thanks by advance !
By the way, it looks like this :
I made a map using an orthographic projection and I try to improve performance because the rotation is not smooth (around 6-7FPS).
It's a map of the world built with a topojson file (world-100m). I need to interact with country and colorized them so there is as many svg:path as there are countries.
After the loading I have an automatic rotation function launched using d3.timer :
autoRotate = () =>
@start_time = Date.now() # Store the current time (used by automatic rotation)
d3.timer () =>
dt = Date.now() - @start_time
if @stopRotation or dt > @config.autoRotationDuration
true
else
@currentRotation[0] = @currentRotation[0] - @config.autoRotationSpeed
@projection.rotate @currentRotation
redrawPathsOnRotationOrScale(@currentRotation, @projection.scale())
false
redrawPathsOnRotationOrScale = (rotation, scale, duration = 1) =>
@currentRotation = rotation
@projection
.rotate(@currentRotation)
.scale(scale)
@groupPaths.selectAll("path")
.attr("d", path)
To understand why it was so slow, I made a profile record in Chrome and here is the result :
It seems the Animation Frame Fired is the slow part but I don't really know what it is. And when I open it, there is 2 GC Event (garbage collector ?) but nothing around... Do you have an idea what is happening during this 90ms ?
Any tips to improve the performance is more than wele :-)
Thanks by advance !
By the way, it looks like this :
Share Improve this question asked Jul 10, 2013 at 7:55 John SmithJohn Smith 4891 gold badge6 silver badges13 bronze badges2 Answers
Reset to default 3Try reducing the plexity of the SVG paths by adjusting the --simplify-proportion, -s or --quantization topojson flags. Browsers still have fairly poor SVG rendering performance, and with maps it really helps to reduce the number and precision of the points.
D3.js uses Request Animation Frames to perform timers.
From D3 documentation:
If your browser supports it, the timer queue will use requestAnimationFrame for fluid and efficient animation.
As I know it's the best approach to perform animations in modern browsers and I don't think you can directly optimize this part. Otherwise it seems that you call stack use selection_each
that could probably be cached into a variable.
本文标签: javascriptd3jsorthographic rotation optimizationStack Overflow
版权声明:本文标题:javascript - d3.js : orthographic rotation optimization - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745502176a2153442.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论