Vladimirs
Vladimirs

Reputation: 8619

How to set minimum step on a time axis

I am using code below to display some daily statistics:

    var data2 = [[[1401897069000, 10], [1401983469000, 20], [1402069869000, 15]]];

    $.plot('#pieChart2', data2, {
        series: {
            bars: {
                show: true
            },
        },
        xaxis: {
            mode: "time",
            timeformat: "%Y/%m/%d"
        }
    });

Is there any way of setting time axis step because otherwise there are duplicated labels on time axis and bars looks like just lines.

See jsfiddle (Firefox only)

Upvotes: 0

Views: 58

Answers (1)

mechenbier
mechenbier

Reputation: 3067

The section "Time Series Data" section of Flot's API.md documents the minTickSize option.

From the documentation:

"...you can specify that you just don't want ticks at a size less than a specific tick size with "minTickSize". Note that for time series, the format is an array like [2, "month"], see the next section."

You can set the minTickSize option as specified in the documentation like so:

$.plot('#pieChart2', data2, {
    series: {
        bars: {
            show: true
        },
    },
    xaxis: {
        mode: "time",
        timeformat: "%Y/%m/%d",
        minTickSize: [1, "day"]
    }
}

I've updated your JSFiddle with an example: http://jsfiddle.net/cH29a/3/

Upvotes: 3

Related Questions