Flot:点击图例&amp ;;切换数据系列curvedLines插件

时间:2014-09-09 15:34:05

标签: javascript jquery flot

我有flot curvedLines插件的问题。我通过点击图例来切换数据系列但是如果curveLines插件处于活动状态我有一些问题。我尝试停用所有工作的插件。我不知道我的代码中是否有错误o是插件问题。你能帮助我吗?这是我的代码:

        $(function() {

        somePlot = null;            
        togglePlot = function(seriesIdx)
        {
          var someData = somePlot.getData();                  
          someData[seriesIdx].lines.show = !someData[seriesIdx].lines.show;               
          somePlot.setData(someData);
          somePlot.draw();
        }
            var d1 = {{ d1|safe }}
            var d2 = {{ d2|safe }}
            var d3 = {{ d3|safe }}      
            var dataset = [{ label: "Data1", 
                            data: d1, 
                            lines : {show : true, lineWidth : 3, fill:true},                                
                            //curvedLines: {apply: true,fit : true},
                            color: "#5482FF",   
                            idx: 0,                                                         
                            },
                            { label: "Data2", 
                            data: d2, 
                            lines : {show : true, lineWidth : 3, fill:true},                                
                            //curvedLines: {apply: true,fit : true},
                            color: "#ed4e2a",
                            idx: 1,
                            },
                { data: d1,
                points : {show : true, radius: 0.5}},
                { data: d2,
                points : {show : true, radius: 0.5}},
                            ];      
            var options = {
                series : {
                    curvedLines : {active : true},
                    stack: true,
                },
                legend: {
                    noColumns: 0,
                    labelBoxBorderColor: "#000000",
                    position: "nw",
                    labelFormatter: function(label, series){
                            return '<input type="checkbox" name="data" checked="checked" id="iddata" onClick="togglePlot('+series.idx+'); return false;">'+label;                               
                            }
                    },
                grid: {hoverable: true,clickable: true,mouseActiveRadius: 30,},
                xaxis:{mode: "time"}, 
            };

            somePlot = $.plot($("#flotFit"),dataset, options);
            $("#flotFit").UseTooltip();
        });
    </script>     

0 个答案:

没有答案