简体   繁体   English

带有 jquery.flot.tooltip 的堆叠图中百分比的 %p 不起作用

[英]%p for percent in stacked graph with jquery.flot.tooltip is not working

I am using jquery.flot.js (v 1.1) for graphs and for tooltip jquery.flot.tooltip.js (version: 0.6.7)我将 jquery.flot.js (v 1.1) 用于图形和工具提示 jquery.flot.tooltip.js (version: 0.6.7)

I wanted to show percentage area covered by each stack in stacked graph.我想在堆叠图中显示每个堆栈覆盖的百分比区域。 I have tried it using %p.我已经用 %p 试过了。 But it's not working, it return "%p" in tooltip.但它不起作用,它在工具提示中返回“%p”。 Code snippet:代码片段:

tooltip: true,
tooltipOpts: {
  content: "%s : %y : %p.1%"
}

My graph is-我的图表是-

在此处输入图片说明

Could any one help me please ?任何人都可以帮助我吗?

You can use %p only if you also use pie charts plugin http://www.flotcharts.org/flot/examples/series-pie/index.html , that placeholder was introduced only to support that plugin.仅当您还使用饼图插件http://www.flotcharts.org/flot/examples/series-pie/index.html时才可以使用%p ,该占位符仅用于支持该插件。 I see that is not clear in the documentation.我看到文档中不清楚。

In your case you need to count percentage value by yourself.在您的情况下,您需要自己计算百分比值。 You may use callback function for that.您可以为此使用回调函数。 The format is function(label, xval, yval, flotItem) and must return a string in correct format (needed by tooltip).格式为function(label, xval, yval, flotItem)并且必须以正确的格式返回字符串(工具提示需要)。

Hope it helps!希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM