Question

I need to smooth my "chart builder" programmically in javascript. Excel variant of doing it is pretty good but I have no suggestion of what algorithm used. I try to get VBA code of doing it by writing macros but all I have got is (expected) ActiveChart.SeriesCollection(1).Smooth = True

Is anybody know what algorithm does Microsoft Excel use to smooth chart or the way of looking its code?

enter image description here

UPD: for those who find this question and have the same problem i can recommend this SVG solution with javascript source code

Was it helpful?

Solution

Splines are used to do this:

http://en.wikipedia.org/wiki/Spline_interpolation

I'm not sure if Excel uses exactly this but cubic splines are often used for this kind of 'join the dots' problem. Essentially you fit a set of cubic polynomials (i.e. a set of cubic equations) through the points. Each cubic is used for one or two regions bounded by two or three points. The cubics are defined by preserving not only the value but the gradient at each point where one cubic finishes and the next one starts. Quite often the second derivative is set to zero which gives you another boundary condition and better smoothness.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top