簡體   English   中英

在Jquery繪圖圖中顯示不同的數據

[英]Show different data in Jquery plot graph tooltip

我正在使用jquery flot圖表。 我想在工具提示中顯示真實數據。 僅顯示Y軸數據。在垂直線上,如果有兩種類型的數據,則每種為50(總計= 100)。

第一部分顯示50,但上部顯示100,也應將50顯示為100-50。

這是我的邏輯代碼。

var options1 = {
series: {stack: stack,
         lines: { show: lines, fill: false, steps: steps },
         bars: { show: bars, barWidth: 0.4 },
         points: { show: true}
         },
         grid: {
  hoverable: true //IMPORTANT! this is needed for tooltip to work
    },
 tooltip: true,
 tooltipOpts: {
 content: "%s : %y", 
 shifts: {
   x: -60,
   y: 25
    }
 },
    legend:{'position':'ne','show':true,'margin':[-3, -20],'backgroundOpacity':0.1, 'noColumns': 4, 'container': null},
        xaxis: {ticks: dest4 ,},

};

我可以用這條線做什么

content: "%s : %y",

http://jsfiddle.net/qbXDw/16/

編輯:我想我誤會了你的問題? 如果這不是您想要的,請忽略它(或評論,我將其刪除)。 我以為您想要工具提示中的類別名稱。


您可以為content屬性提供一個函數,該函數從dest3數組中獲取正確的類別名稱:

content: function(label, xval, yval, flotItem) {
    var category = dest3.filter(function (item) { return item[0] == xval })[0][1];
    return label + ' : ' + category + ' : ' + yval;
},

請參閱更新的小提琴

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM