Rendered ticks are incorrect. #1213

Closed
chebee7i opened this Issue Dec 24, 2013 · 2 comments

Projects

None yet

2 participants

@chebee7i

In the following example, as of 39bc058, the specified xticks are ignored. Instead we see: 0.0, 1.0, ..., 8.0. If you change the code so that:

            var d2 = [[0, 3], [4, 8], [6, 5], [9, 13]];

then the xticks are correct: 0, 1, ..., 9. This changes the last data point from [8, 13] to [9, 13]. Seems harmless, so its strange that it should affect how the xticks are rendered.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Flot Examples: Basic Usage</title>
    <link href="../examples.css" rel="stylesheet" type="text/css">
    <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../../excanvas.min.js"></script><![endif]-->
    <script language="javascript" type="text/javascript" src="../../jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../../jquery.flot.js"></script>
    <script type="text/javascript">

    $(function() {

        //var d2 = [[0, 3], [4, 8], [6, 5], [9, 13]];
        var d2 = [[0, 3], [4, 8], [6, 5], [8, 13]];

        var d3 = [[0, 12], [3, 12], null, [2, 2.5], [6, 2.4]];

    var options = {
        xaxis: {
            ticks: [
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
                13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
            ]
        }
    };

        $.plot("#placeholder", [ d2, d3 ], options);
    });

    </script>
</head>
<body>
    <div id="content">
        <div class="demo-container">
            <div id="placeholder" class="demo-placeholder"></div>
        </div>
    </div>
</body>
</html>
@dnschnur
Flot member

This is working correctly. You're providing numeric values; how they are formatted is a separate thing. So when you switch that datapoint to 9 the number of ticks reaches 10, and the formatter decides that the decimal is no longer necessary.

You can use the tickDecimals option to control this behavior.

@dnschnur dnschnur closed this Dec 24, 2013
@chebee7i

Aha. Thanks for that. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment