Jed
Jed

Reputation: 10877

How to get Min/Max Dates From Flot Chart

Does Flot offer us a function that will return the minimum and maximum dates of the data that is used in the chart?

To be clear, I'm not looking for a function that returns the min/max dates of the x-axis, but rather the min/max dates that exists within all the dataset that the chart is using. (i.e. I'm aware of the plot.getAxes().xaxis.max/min functions that return the dates that are shown on the xaxis).

I'm guessing that Flot does "know" the min/max dates within a dataset, since it is able to dynamically create the xaxis date range properly. I'm hoping that it makes those dates available to us.

Upvotes: 2

Views: 522

Answers (1)

Raidri
Raidri

Reputation: 17550

Here are all properties from plot.getAxes().yaxis:

yaxis: Object
    box: Object
    c2p: (c) { return m + c / s; }
->  datamax: 116.2
->  datamin: 0
    direction: "y"
    innermost: true
    labelHeight: 11
    labelWidth: 18
    max: 118
    min: 0
    n: 1
    options: Object
    p2c: (p) { return (p - m) * s; }
    position: "left"
    reserveSpace: true
    scale: 6.3559322033898304
    show: true
    tickDecimals: 0
    tickFormatter: (v, axis) {
    tickGenerator: (axis) {
    tickLength: "full"
    tickSize: 10
    ticks: Array[13]
    used: true

What you want are the datamax and datamin properties.

Upvotes: 1

Related Questions