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

oughton

A software / web applications developer, living in Hamilton and currently studying at Waikato University.

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!

Leave a Reply

Your email address will not be published. Required fields are marked *