需要 jQuery.Flot 图例格式方面的帮助
默认情况下,flot是生成像这样的图例块(表)([#] - 颜色框):
_________________
|_[#]_|_label_1_|
|_[#]_|_label_2_|
|_..._|_......._|
我想要像这样的水平图例:
______________________________.______________________________
|_[#]_|_My_long_label_1_______|_[#]_|_My_another_label_2____|
|_[#]_|_Trololo_label_here____|_[#]_|_hell,_yeah!___________|
.............................................................
我已经尝试使用labelFormatter()但失败了=(
我向每个添加了订单号series 元素并可以在 labelFormatter() 中使用它(例如 ...if(series.num % 2 == 0) { ...next row... }
By default flot was generated legend block (table) like this ([#] - color box):
_________________
|_[#]_|_label_1_|
|_[#]_|_label_2_|
|_..._|_......._|
I wanna have horizontal legend like this:
______________________________.______________________________
|_[#]_|_My_long_label_1_______|_[#]_|_My_another_label_2____|
|_[#]_|_Trololo_label_here____|_[#]_|_hell,_yeah!___________|
.............................................................
I've been tried use labelFormatter() but have failed =(
I was added order number to each series element and can use it in labelFormatter() (like ...if(series.num % 2 == 0) { ...next row... }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下,
Try Following,
不幸的是,它不是这样工作的...
Flot 只能让您管理标签的外观,而不是整个图例本身的结构。请参阅源代码了解其构建方式桌子。
在那里,您会注意到它只是构建了一个 html 表,并将您的标签包含在适当的单元格中。
鉴于该信息,您最好的选择是手动制作自己的信息,并完全抑制默认图例的生成(
show:false
)。您可以很容易地从 flot 源中获取insertLegend
函数,并制作您自己的版本来水平堆叠它们。Unfortunately, it doesn't work that way...
Flot only lets you manage how the labels look, not the structure of the whole legend itself. See the source for how it builds the table.
In there you'll notice that it just builds an html table and includes your labels in the appropriate cell.
Your best bet, given that information is to just make your own by hand, and suppress the generation of the default legend entirely (
show:false
). You could pretty easily take theinsertLegend
function from the flot source and make your own version of it that stacks them horizontally.