Finding trends in noisy analytics data
Vercel Analytics charts recently received an update that makes trends easier to read. The change came out of a side project during Vercel's Design Your Friday program, where engineers work on something of their choosing on the first Friday of each month. The underlying goal was straightforward: improve how time-series data is visualized in Analytics.
The previous approach connected every data point with a straight line. For high-traffic periods with many fluctuations, that produced a very noisy chart where the overall direction was hard to discern. The delta displayed alongside the chart was also misleading—it simply subtracted the last sampled value from the first, ignoring everything in between. A chart could show a -0.15 decrease while the broader trend was actually improving, simply because the most recent data point happened to be favorable. Two users at either end of the dataset with very different network conditions could skew the narrative entirely.
Curve fitting as a solution
Curve fitting addresses both problems. Rather than plotting every point, a fitted curve represents the underlying trend while suppressing noise. This is a well-established technique with many available algorithms. Linear regression, which finds the straight line that best describes the data, is the simplest case—it's technically a polynomial regression where the order is 1.
Higher polynomial orders introduce more turning points. An order-N polynomial has N-1 turning points, so order 2 yields a parabola, order 3 an S-curve, and so on. The Mean Squared Error (MSE), calculated as Σ(value - predictedValue)^2 / dataNum, measures how well the curve fits: lower error means a better description of the data.
The naive approach is to hardcode a polynomial order, which works in many cases. But when you don't know whether the data is monotonically increasing, periodic, or something else entirely, picking the right order in advance is guesswork. A higher order will always produce a lower error on the existing data—it can bend and turn to follow every fluctuation—but that's overfitting. Such a curve describes the current dataset well but generalizes poorly to new data.
Selecting the right order adaptively
To choose an appropriate polynomial order without knowing the data's behavior in advance, the standard machine-learning technique of splitting data into training and test sets applies. Real production data doesn't have a separate test set, but you can split existing data deterministically—for instance, by odd and even indexes.
The training set is used to compute the regression curve, while the test set evaluates how well that curve generalizes. Visualizing the error on both sets as the order increases reveals the typical pattern: error decreases initially (underfitting), reaches a minimum at the appropriate order, then rises again (overfitting).
Defining overall fit quality as error = max(MSE(training set), MSE(test set)) provides a simple heuristic. The optimal order is the one that minimizes this combined error. This adaptive selection avoids manual tuning and works well across different data shapes.
Try it
The improved charts are available now in Vercel Analytics. You can try it by enabling Analytics in your project dashboard.



