最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - flotchart, disable decimal points on graph scale - Stack Overflow

programmeradmin4浏览0评论

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

/

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);

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);
Share Improve this question asked Mar 25, 2013 at 18:35 CQMCQM 44.2k77 gold badges229 silver badges370 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 24

Use the axis tickDecimals option, like this:

yaxis: {
    tickDecimals: 0
}
发布评论

评论列表(0)

  1. 暂无评论