2014-09-13 74 views
0

我有一個有兩行的jqplot圖表。我正在使用tooltipContentEditor修改工具提示中顯示的文本。在添加第二行之前,工具提示顯示的值很好。現在我添加了另一行,工具提示總是顯示第二行的數據(因此第一行的數據不正確)。我如何顯示正確的值?當圖表有兩行時,Jqplot工具提示值不正確

藍線提示顯示黃線值: JQPLOT

圖初始化(tooltipContentEditor函數內):

$.jqplot('mychart', [coords, paidCoords], { 
     //title:'Sales for ' + name, 
     animate: !$.jqplot.use_excanvas, 
     axesDefaults: { 
      tickRenderer: $.jqplot.CanvasAxisTickRenderer , 
     }, 

     axes:{ 
      xaxis:{ 
       renderer:$.jqplot.DateAxisRenderer, 
       tickInterval: tickInterval, 
       tickOptions: { formatString: formatString, angle: -30 } 
      }, 
      yaxis:{ 
       min:0 
      } 
     }, 

     highlighter: { 
      show: true, 
      sizeAdjust: 7.5, 
      tooltipContentEditor: function(str, pointIndex, index, plot){ 
         console.log('logging in tooltipeditor'); 
         console.log(str); 
         console.log(pointIndex); 
         console.log(index); 
         console.log(plot); 
         var splitted = plot._plotData[1][index]; 
         var x = splitted[0]; 
         var y = splitted[1]; 

         x = new Date(x); 
         x = x.toString(); 
         return x + "<br/>$" + y; 
      } 
     }, 
     cursor:{ 
      show: true, 
      zoom:true, 
      showTooltip:false 
      } 
    }); 

回答

0

沒關係!我想到了!在tooltipContentEditor功能,我需要做到這一點:

var splitted = str.split(","); 

取而代之的是:

var splitted = plot._plotData[1][index]; 
+0

其實,沒有人知道如何讓工具提示顯示原始數據? str正在顯示格式化的日期。 – CaitlinHavener 2014-09-13 00:14:18