简体   繁体   中英

%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)

I wanted to show percentage area covered by each stack in stacked graph. I have tried it using %p. But it's not working, it return "%p" in tooltip. 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. 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).

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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