Flot Charts - 获取工具提示插件显示的问题

时间:2015-10-03 18:37:10

标签: javascript charts flot

我正在使用Flot Charts(http://www.flotcharts.org)并且在使用某些插件时遇到问题。下面是我的折线图,我无法显示工具提示插件(https://github.com/krzysu/flot.tooltip)。我也无法获得轴标签插件。但是,resize插件运行良好。我的代码怎么了?我感谢任何帮助。

<head>

    <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/FitText.js/1.2.0/jquery.fittext.min.js"></script>
    <script language="javascript" type="text/javascript" src="js/flot/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="js/flot/jquery.flot.js"></script>
    <script language="javascript" type="text/javascript" src="js/flot/jquery.flot.tooltip.js"></script>
    <script language="javascript" type="text/javascript" src="js/flot/jquery.flot.resize.js"></script>
    <!--<script language="javascript" type="text/javascript" src="js/flot/jquery.flot.time.js"></script>-->
    <script language="javascript" type="text/javascript"> 
    $(document).ready(function(){

    $.ajax({
            //usually, we'll just call the same URL, a script
            //connected to a database, but in this case we only
            //have static example files so we need to modify the
            //URL
        url: "views/sales_year_line_data.php",
        method: 'GET',
        dataType: 'json',
        success: onOutboundReceived
    });


        function onOutboundReceived(series) {
            var length = series.length;
            var finalData = series;
            var options = {
            lines: { show: true, fill: true},
            points: { show: true, hoverable:true },
            grid: { show: true, aboveData: false, color: "rgba(255, 255, 255, 1.0)", borderWidth: 0, hoverable: true, clickable: true },
            legend: {position: "sw", backgroundOpacity: 0},
            xaxis: { ticks: [[1,'Jan'],[2,'Feb'],[3,'Mar'],[4,'Apr'],[5,'May'],[6,'Jun'],[7,'Jul'],[8,'Aug'],[9,'Sep'],[10,'Oct'],[11,'Nov'],[12,'Dec']] },
            yaxis: { show: false },
            tooltip: { show: true, content: "%s | x: %x; y: %y"}

            };

    $.plot($("#test-flot"), finalData, options);
        }
    });     
    </script>

</head>

1 个答案:

答案 0 :(得分:0)

我使用了cloudflare.com cdn中的jquery.flot.tooltip.js,现在工具提示工作了。

<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/flot.tooltip/0.8.5/jquery.flot.tooltip.js"></script>