1

Am quite new to Flot, and am wondering if there is a way to change the x axis title as I pan.

Each point on the x axis represents a date, but I only want to show the day number, and have the x axis title display the month - so as the user pans through the days from 1 to 31 it would show January, then as they pan into days 1 - 28, it would show February - and so on.

First, is it possible, and if so, how?

Thanks.

ojsglobal
  • 525
  • 1
  • 6
  • 31

1 Answers1

1

Yes, you can do that using the plotpan event. Do something like this:

    $('#placeholder').bind("plotpan", function (event, plot) {
        var xAxis = plot.getAxes().xaxis;

        // build this function depending on the format of your a values (timestamp ...)
        var monthName = getMonthNameFromMaxValue(xAxis.max);

        // this depends on the plugin you use for your axis labels (see the link below)
        setAxisLabel(monthName);
    });

Axis label in Flot

Community
  • 1
  • 1
Raidri
  • 17,258
  • 9
  • 62
  • 65