大佬教程收集整理的这篇文章主要介绍了Jquery Flot饼图显示数据值而不是百分比,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
读取消息数:50。
未读消息数:150。
创建的饼图显示读取邮件的百分比为25%。在这个地方我想显示实际的50条消息。见下图:
我用来创建饼图的代码:
var data = [ { label: "Read",data: 50,color: '#614E43' },{ label: "Unread",data: 150,color: '#F5912D' } ];
和:
$(function () { $.plot($("#placeholder"),data,{ series: { pie: { show: true,radius: 1,label: { show: true,radius: 2 / 3,formatter: function (label,series) { return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">' + label + '<br/>' + Math.round(series.percent) + '%</div>'; },threshold: 0.1 } } },legend: { show: false } }); });
这可能吗?
有了@Ryley的答案,我来到了一个肮脏的解决方案。当我输出series.data时,返回值“1,150”和“1,50”。我想出了减去返回值的前2个字符并显示减法值的想法。
String(str).subString(2,str.lenght)
这是我用此解决方案创建的饼图:
$(function () { $.plot($("#placeholder"),{ series: { pie: { show: true,label: { show: true,series) { return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">' + label + '<br/>' + series.data[0][1] + '</div>'; },threshold: 0.1 } } },legend: { show: false } }); });
以上是大佬教程为你收集整理的Jquery Flot饼图显示数据值而不是百分比全部内容,希望文章能够帮你解决Jquery Flot饼图显示数据值而不是百分比所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。