Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flotchart, disable decimal points on graph scale

in my flotgraphs none of the items in the dataset contain decimal points but in its auto-scaling routine it sometimes decides to show me intermediary decimal points

I don't want it do to that, is there anyway to have it not do that?

The reason this is important is because there are never decimal values in this data set, so it is unnecessary to imply that there would be or to think that it is a helpful addition to the scale

http://jsfiddle.net/gamm/t3Vqh/2/

var dataset = [overdue, open, completed];

var options = {
    series: {
        stack: true,
        bars: {
            show: true
        }
    },
    bars: {
        align: "center",
        horizontal: false,
        barWidth: .8,
        lineWidth: 0
    },
    grid: {
        borderWidth: 0,
        borderColor: null,
        backgroundColor: null,
        labelMargin: 10,
        minBorderMargin: 10
    },
    yaxis: {
        tickColor: "FFFFFF"
    },
    xaxis: {
        tickColor: "FFFFFF",
        ticks: [
            [1, "Public Works"],
            [2, "Sanitation"],
            [3, "Mayor"],
            [4, "L&I"],
            [5, "Police"]
        ]
    },
    legend: {
        position: 'ne',
        show: true
    }
};

$.plot($("#example-section15 #flotcontainer"), dataset, options);
like image 479
CQM Avatar asked Mar 25 '13 18:03

CQM


1 Answers

Use the axis tickDecimals option, like this:

yaxis: {
    tickDecimals: 0
}
like image 132
DNS Avatar answered Oct 13 '22 14:10

DNS