2013-01-22 48 views
3

可能重复:
Dynamic Flot graph - show hide series by clicking on legend text or box on graphJQPlot隐藏线点击

我使用JQPlot,我有一个关于隐藏行,如果他们已经点击了传说中的问题。

这里是我的代码:

var plotCustomerSurveyGraph = $.jqplot('CustomerSurveyLineGraph', [[0,1,3,2,3,0,1,3,1,2,3,1,2], [1,2,3,1,1,2,2,3,3,1,2,1,2], [1,2,3,4,4,3,2,2,1,4,3,2,2], [0,1,3,3,1,2,2,1,1,0,0,1,2],[2,2,3,3,4,4,0,2,0,1,1,3,3], [2,2,3,3,1,1,0,1,0,2,3,3,1], [1,3,1,4,3,3,1,2,3,4,1,2,1], [2,1,3,2,1,2,0,1,2,4,2,1,0]], 
{ 
      axes: 
      { 
       xaxis: 
       { 
         label: "Date (Week)", 
         ticks: ['1','2','3','4','5','6','7','8','9','10','11','12','13'] 
       }, 
       yaxis: 
       { 
        label: 'Rating', 
        labelRenderer: $.jqplot.CanvasAxisLabelRenderer, 
        ticks: ['0','1','2','3'] 
       } 
      }, 
    title:'Customer Survey (Last 3 Months)', 
      width: 480, height: 480, 
      legend:{show:true, location: 'e', placement: 'outsideGrid'}, 
    seriesDefaults: 
    { 
       rendererOptions: {smooth: true} 
    }, 
    series:[ 
       { 
        lineWidth:1, 
        label:'Staff Appearance', 
        markerOptions: { size:7, style:'dimaond' } 
       }, 
       { 
        lineWidth:1, 
        label:'Staff Product Knowledge', 
        markerOptions: { size: 7, style:"dimaond" } 
       }, 
       { 
        lineWidth:1, 
        label:'Staff Friendliness', 
        markerOptions: { size:7, style:"filledSquare" } 
       }, 
       { 
        lineWidth:1, 
        label:'Staff Wait Time Acceptable', 
        markerOptions: { size:7, style:"filledSquare" } 
       }, 
       { 
        lineWidth:1, 
        label:'Food Value For Money', 
        markerOptions: { size:7, style:"filledSquare" } 
       }, 
       { 
        lineWidth:1, 
        label:'Overall Quality of Meal', 
        markerOptions: { size:7, style:"filledSquare" } 
       }, 
       { 
        lineWidth:1, 
        label:'Cleanliness of the Premises', 
        markerOptions: { size:7, style:"filledSquare" } 
       }, 
       { 
        lineWidth:1, 
        label:'Ambience and Atmosphere of the Premises', 
        markerOptions: { size:7, style:"filledSquare" } 
       } 
       ] 
    } 
); 

这里是图的图像:

enter image description here

是否有可能启用的功能隐藏/显示行取决于是否他们已被点击在传说中?如果是这样,我可以请一些帮助来做到这一点?

感谢

+1

看到这个问题:http://stackoverflow.com/questions/14201911/动态图表显示隐藏系列通过点击图例在文本或框上的图形/ 14227287#14227287,在它我放在一起演示哟什么哟你在问。 – Mark

+2

此答案适用于JQ FLOT,不适用于JqPlot。 –

回答

9

试试这个

在你的代码添加renderer: $.jqplot.EnhancedLegendRenderer

legend:{ 
       renderer: $.jqplot.EnhancedLegendRenderer, 
       show:true, 
       location: 'e', 
       showSwatches: true, 
       placement: 'outsideGrid' 
      } 

例子: http://jsfiddle.net/JWhmQ/1379/

+0

是的,它的作品。谢谢! –

+1

在LegendRenderer之后如何重新加载yaxis的最大值? –