Plot Outliers on Graph

Detects outliers and highlights them on a real-time graph.

Detects outliers so we can highlight them on a graph. This is a common pattern found in analytics services, where one would highlight traffic spikes and even email the user when it happens. This block uses the open source Project EON format and library.


This block assumes messages are being published in the EON format.

    eon: {
        data: Math.floor(Math.random() * 99)

It stores values sent to it into the blocks database. Then, using the historical data it calculates the mean, median, and median absolute deviation using stats.js. Those values are added to the message payload.

// use stats.js to calculate mean, meadian, and mean absolute deviation
request.message.eon.mean = mean(history).toFixed(2) * 1
request.message.eon.median = median(history);
request.message.eon.mad = medianAbsoluteDeviation(history);

Finally, the indexes of historial values that appear to be outliers are added to the payload, along with a handy function that indicates if the last published message that triggered the event script is an outlier.

// use the mean absolute deviation to find index of outliers
request.message.outliers = indexOfOutliers(history);

// if the new value is an outlier, mark it as such
request.message.is_outlier = (Math.max.apply(Math, request.message.outliers) == history.length - 1)

This data can be plugged right into our open source charting library, eon charts.


This block is configured to work with EON charts, so the published data should match best practices. Input Channel: eon-stats-channel



The extra data from stats.js is added as properties to the EON object. Output Channel: eon-stats-channel


Talk to an expert