簡體   English   中英

如何使用jQuery Flot將工具提示添加到軸標簽

[英]How to add tooltip to axis label with jQuery Flot

我已經使用jQuery Flot創建了浮動圖表,但現在,我在x軸上有長標簽,並且在字符串末尾被...截斷了。

我需要在x軸標簽上添加工具提示,以查看完整標簽。

我已經附上了屏幕截圖。

在此處輸入圖片說明

還是可以自定義呈現軸標簽(HTML)的方法?

謝謝

已回答的類似問題: 標記問題

這是嘗試使用CSS並進行一些即時調整的嘗試,這樣事情就可以解決了:

// push the labels down half their width
// while we are at it find longest label height
var longest = -1;
$('#flot_chart .xAxis .tickLabel').each(function(){
   var self = $(this);
   var width = self.width();
   self.css('top',parseInt(self.css('top')) + width/2 - 5);
    if (width > longest){
        longest = width;
    }
});

// now adjust the chart height so we don't overflow
$("#flot_chart").height($("#flot_chart").height() + longest - $('#flot_chart .xAxis .tickLabel').height() + 5);

JSFiddle

我已通過在ticks選項中傳遞HTML字符串來解決此問題。

jQuery Flot將HTML字符串注入float-x#-label容器中。

暫無
暫無

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

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