Flot Plugins – Autoscale

Github Code
Live Example

This is a plugin that implements a different type of autoscaling.

Flot comes with an autoscaler that calculates the maximum y value based on all the the data points.

On graphs that allow multiple series to be shown and hidden, it is useful to autoscale based only on series that are currently visible on the graph.

This plugin simply, loops over all of the datapoints for the series that are visible, finds the maximum value and multiplies it by the autoscale margin.

// limit to visible serie
if (series.lines.show || series.points.show) {
    var max = Number.NEGATIVE_INFINITY;

    for (var i = 0; i < data.length; i++) {
        max = Math.max(max, data[i][1]);

    max += max * options.yaxis.autoscaleMargin * 10;
    return Math.max(_max, max);

Published by


Senior software engineer with extensive experience in enterprise software development targeting wholesale financial organisations and cloud solution providers.

5 thoughts on “Flot Plugins – Autoscale”

  1. Could you please provide an example on how to use this module? I’m new to flot and am having problems figuring this out.

    Thank you!

  2. WOW! Thank you!
    Hello from Russia 🙂
    Thank you. You helped me a lot. I have half a day trying to do it correctly.

Comments are closed.