Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel chart smoothing algorithm

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

like image 327
Glen Swift Avatar asked Oct 23 '25 12:10

Glen Swift


1 Answers

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.

like image 117
Bathsheba Avatar answered Oct 25 '25 05:10

Bathsheba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!