Getting a better performance on repeatedly method on d3 line generator
问题 I've been struggling the past few days to optimize performance on a D3. I'm using a line generator on the SVG and would like to calculate only one time the function used in the x and y . For example: d3.line().curve(d3.curveLinear) .x(function(d){ return Math.sqrt(d) } .y(function(d){ return Math.sqrt(d) + 2) I I would like to save the result of Math.sqrt(d) and compute only one time. Does anyone have any suggestions? 回答1: You could store the result in your first function, and use it in the