2012-10-22 29 views
2

我正在使用jqplotDataHighlight選項在MouseOver上的圖表上顯示工具提示。jqplot觸摸工具提示而不是jqplotDataHighlight或higlightMouseOver或highlightMouseDown

$("#"+sTargetId).bind('jqplotcustomDataHighlight', 
         function (ev, seriesIndex, pointIndex, data) {  
         var chart_left = $("#"+sTargetId).offset().left, 
         chart_right = ($(window).width() - ($("#"+sTargetId).offset().left + $("#"+sTargetId).outerWidth())), 
         chart_top = $("#"+sTargetId).offset().top, 
          x = oPlot.axes.xaxis.u2p(data[0]), // convert x axis units to pixels 
          y = oPlot.axes.yaxis.u2p(data[1]);; 
          var tooltipData = data[1]*scale; 
          $('#tooltip').css({left:chart_left+x, top:chart_top+y, marginRight:chart_right}); 
          $('#tooltip').html('<span style="font-family: Arial;font-size:'+sTooltip+';font:bold;color:#000000;">' +sXDisplay+': '+ tooltipData + '</span>'); 
         $('#tooltip').show(); 
         }); 

      $("#"+sTargetId).bind('jqplotcustomDataUnhighlight', 
        function (ev, seriesIndex, pointIndex, data) { 
         $('#tooltip').empty(); 
         $('#tooltip').hide(); 
        }); 

它工作正常。在iPad上,我希望工具提示可以顯示在某個觸摸事件上。我可以如何實現它?

 // prop: highlightMouseOver 
     // True to highlight slice when moused over. 
     // This must be false to enable highlightMouseDown to highlight when clicking on a slice. 
this.highlightMouseOver = true; 
     // prop: highlightMouseDown 
     // True to highlight when a mouse button is pressed over a slice. 
     // This will be disabled if highlightMouseOver is true. 
this.highlightMouseDown = false; 

我發現只有上述兩個選項可用。我該如何在touchstart上實現它? 在雙擊或任何其他事件顯示工具提示也將是有幫助的

回答

0

也許你已經知道了這一點。這是對我有用的東西。我正在使用jquerymobile,在jquery.jqplot.js version 0.9.7r635行號:2290將mousemove更改爲vmousemove。如果你正在使用cursor: {followMouse: true},那麼事情應該開箱即用,我有一個固定的位置爲我的工具提示,但在mousemove的頂部和左側的值沒有得到應用,所以我硬編碼的頂部和離開的工具提示div .jqplot-cursor-tooltip出現與點擊時位置相同。雖然它不是一個很好的解決方案,但直到現在我還沒有看到奇怪的行爲。希望這可以幫助 !