jqplot没有显示光标

时间:2014-04-10 08:16:34

标签: javascript jquery jqplot

这是我的代码。

<!DOCTYPE html>
<html>
<head>
    <title>Hello Flot</title>
    <link class="include" rel="stylesheet" type="text/css" href="/static/jqplot/jquery.jqplot.min.css" />
    <script language="javascript" type="text/javascript" src="/static/jquery.min.js"></script>
    <script language="javascript" type="text/javascript" src="/static/flot/jquery.flot.js"></script>
    <script language="javascript" type="text/javascript" src="/static/flot/jquery.flot.selection.js"></script>
    <script type="text/javascript" src="/static/jqplot/plugins/jqplot.cursor.min.js"></script>
    <script language="javascript" type="text/javascript" src="/static/jqplot/jquery.jqplot.js"></script>


<body>

<div id="output_plot_container" style="float:left; width: 800px; height: 600px"></div>

<button onclick="updateChart()">Try it</button>

<script >
    var plot1 = $.jqplot ('output_plot_container', [[1,2,3,4]], {
        title : 'Demodulated signal',
        cursor:{zoom:true}
    });
    var url = "/sensor/demodulated_debug_data";

    var updateChart = function() {
        $.getJSON(url, function(newdata) {
        console.log(newdata);
            for (var f_id in newdata)
            if (newdata.hasOwnProperty(f_id)) {
                if (f_id == 'demodulated') {
                    plot1.series[0].data = newdata[f_id];
                    plot1.replot({ resetAxes: true } );
                }
            }
        })
    };

    timer = setInterval(function(){updateChart()}, 1000);
    console.log('still running');
</script>
</body>
</html>

我正在阅读文档,但我无法弄清楚它为什么不向我显示光标。

2 个答案:

答案 0 :(得分:0)

试试这个,它对我有用

$(document).ready(function () {
    $('#output_plot_container').on('jqplotDataHighlight', function () {
        $('.jqplot-event-canvas').css('cursor', 'pointer');
    });
    $('#output_plot_container').on('jqplotDataUnhighlight', function () {
        $('.jqplot-event-canvas').css('cursor', 'auto');
    });
});

 .pointerlink
{
cursor: pointer;
}

<div id="output_plot_container" class="pointerLink" ...> 

答案 1 :(得分:0)

原来我应该在这个html中的光标前包含jqplot。