Git.Storage.Web/Theme/plugins/flot/examples/interacting-axes.html

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Flot Examples</title>
    <link href="layout.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>
 </head>
    <body>
    <h1>Flot Examples</h1>

    <div id="placeholder" style="width:600px;height:300px;"></div>

    <p>With multiple axes, you sometimes need to interact with them. A
    simple way to do this is to draw the plot, deduce the axis
    placements and insert a couple of divs on top to catch events.
    Try clicking an axis.</p>

    <p id="click"></p>

<script type="text/javascript">
$(function () {
    function generate(start, end, fn) {
        var res = [];
        for (var i = 0; i <= 100; ++i) {
            var x = start + i / 100 * (end - start);
            res.push([x, fn(x)]);
        }
        return res;
    }

    var data = [
        { data: generate(0, 10, function (x) { return Math.sqrt(x)}), xaxis: 1, yaxis:1 },
        { data: generate(0, 10, function (x) { return Math.sin(x)}), xaxis: 1, yaxis:2 },
        { data: generate(0, 10, function (x) { return Math.cos(x)}), xaxis: 1, yaxis:3 },
        { data: generate(2, 10, function (x) { return Math.tan(x)}), xaxis: 2, yaxis: 4 }
    ];

    var plot = $.plot($("#placeholder"),
                      data,
                      {
                          xaxes: [
                              { position: 'bottom' },
                              { position: 'top'}
                          ],
                          yaxes: [
                              { position: 'left' },
                              { position: 'left' },
                              { position: 'right' },
                              { position: 'left' }
                          ]
                      });

    // now for each axis, create a div

    function getBoundingBoxForAxis(plot, axis) {
        var left = axis.box.left, top = axis.box.top,
            right = left + axis.box.width, bottom = top + axis.box.height;
后面还有 37 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。