修改源js文件:jquery.flot.pie.min.js

<script src="/static/assets/js/jquery.flot.pie.min.js"></script>

备注

开发环境是修改:static/assets/js/jquery.flot.pie.min.js

线上环境要修改:static_assets/assets/js/jquery.flot.pie.min.js

修改的地方为下面的红色部分:

/* Flot plugin for rendering pie charts.

Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. The plugin assumes that each series has a single data value, and that each
value is a positive integer or zero. Negative numbers don't make sense for a
pie chart, and have unpredictable results. The values do NOT need to be
passed in as percentages; the plugin will calculate the total and per-slice
percentages internally. * Created by Brian Medendorp * Updated with contributions from btburnett3, Anthony Aragues and Xavi Ivars The plugin supports these options: series: {
pie: {
show: true/false
radius: 0-1 for percentage of fullsize, or a specified pixel length, or 'auto'
innerRadius: 0-1 for percentage of fullsize or a specified pixel length, for creating a donut effect
startAngle: 0-2 factor of PI used for starting angle (in radians) i.e 3/2 starts at the top, 0 and 2 have the same result
tilt: 0-1 for percentage to tilt the pie, where 1 is no tilt, and 0 is completely flat (nothing will show)
offset: {
top: integer value to move the pie up or down
left: integer value to move the pie left or right, or 'auto'
},
stroke: {
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#FFF')
width: integer pixel width of the stroke
},
label: {
show: true/false, or 'auto'
formatter: a user-defined function that modifies the text/style of the label text
radius: 0-1 for percentage of fullsize, or a specified pixel length
background: {
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#000')
opacity: 0-1
},
threshold: 0-1 for the percentage value at which to hide labels (if they're too small)
},
combine: {
threshold: 0-1 for the percentage value at which to combine slices (if they're too small)
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#CCC'), if null, the plugin will automatically use the color of the first slice to be combined
label: any text value of what the combined slice should be labeled
}
highlight: {
opacity: 0-1
}
}
} More detail and specific examples can be found in the included HTML file. */ !
function(a) {
function b(b) {
function e(b, c, d) {
x || (x = !, r = b.getCanvas(), s = a(r).parent(), t = b.getOptions(), b.setData(f(b.getData())))
}
function f(b) {
for (var c = , d = , e = , f = t.series.pie.combine.color, g = [], h = ; h < b.length; ++h) {
var i = b[h].data;
a.isArray(i) && == i.length && (i = i[]), a.isArray(i) ? !isNaN(parseFloat(i[])) && isFinite(i[]) ? i[] = +i[] : i[] = : i = !isNaN(parseFloat(i)) && isFinite(i) ? [, +i] : [, ], b[h].data = [i]
}
for (var h = ; h < b.length; ++h) c += b[h].data[][];
for (var h = ; h < b.length; ++h) {
var i = b[h].data[][];
i / c <= t.series.pie.combine.threshold && (d += i, e++, f || (f = b[h].color))
}
for (var h = ; h < b.length; ++h) {
var i = b[h].data[][];
( > e || i / c > t.series.pie.combine.threshold) && g.push(a.extend(b[h], {
data: [
[, i]
],
color: b[h].color,
label: b[h].label,
angle: i * Math.PI * / c,
//percent: i / (c / 100)
percent: (i / (c / 100)).toFixed(2)
}))
}
return e > && g.push({
data: [
[, d]
],
color: f,
label: t.series.pie.combine.label,
angle: d * Math.PI * / c,
percent: d / (c / )
}), g
}
function g(b, e) {
function f() {
y.clearRect(, , j, k), s.children().filter(".pieLabel, .pieLabelBackground").remove()
}
function g() {
var a = t.series.pie.shadow.left,
b = t.series.pie.shadow.top,
c = ,
d = t.series.pie.shadow.alpha,
e = t.series.pie.radius > ? t.series.pie.radius : u * t.series.pie.radius;
if (!(e >= j / - a || e * t.series.pie.tilt >= k / - b || c >= e)) {
y.save(), y.translate(a, b), y.globalAlpha = d, y.fillStyle = "#000", y.translate(v, w), y.scale(, t.series.pie.tilt);
for (var f = ; c >= f; f++) y.beginPath(), y.arc(, , e, , * Math.PI, !), y.fill(), e -= f;
y.restore()
}
}
function i() {
function b(a, b, c) {
>= a || isNaN(a) || (c ? y.fillStyle = b : (y.strokeStyle = b, y.lineJoin = "round"), y.beginPath(), Math.abs(a - * Math.PI) > 1e- && y.moveTo(, ), y.arc(, , e, f, f + a / , !), y.arc(, , e, f + a / , f + a, !), y.closePath(), f += a, c ? y.fill() : y.stroke())
}
function c() {
function b(b, c, d) {
if ( == b.data[][]) return !;
var f, g = t.legend.labelFormatter,
h = t.series.pie.label.formatter;
f = g ? g(b.label, b) : b.label, h && (f = h(f, b));
var i = (c + b.angle + c) / ,
l = v + Math.round(Math.cos(i) * e),
m = w + Math.round(Math.sin(i) * e) * t.series.pie.tilt,
n = "<span class='pieLabel' id='pieLabel" + d + "' style='position:absolute;top:" + m + "px;left:" + l + "px;'>" + f + "</span>";
s.append(n);
var o = s.children("#pieLabel" + d),
p = m - o.height() / ,
q = l - o.width() / ;
if (o.css("top", p), o.css("left", q), - p > || - q > || k - (p + o.height()) < || j - (q + o.width()) < ) return !;
if ( != t.series.pie.label.background.opacity) {
var r = t.series.pie.label.background.color;
null == r && (r = b.color);
var u = "top:" + p + "px;left:" + q + "px;";
a("<div class='pieLabelBackground' style='position:absolute;width:" + o.width() + "px;height:" + o.height() + "px;" + u + "background-color:" + r + ";'></div>").css("opacity", t.series.pie.label.background.opacity).insertBefore(o)
}
return !
}
for (var c = d, e = t.series.pie.label.radius > ? t.series.pie.label.radius : u * t.series.pie.label.radius, f = ; f < m.length; ++f) {
if (m[f].percent >= * t.series.pie.label.threshold && !b(m[f], c, f)) return !;
c += m[f].angle
}
return !
}
var d = Math.PI * t.series.pie.startAngle,
e = t.series.pie.radius > ? t.series.pie.radius : u * t.series.pie.radius;
y.save(), y.translate(v, w), y.scale(, t.series.pie.tilt), y.save();
for (var f = d, g = ; g < m.length; ++g) m[g].startAngle = f, b(m[g].angle, m[g].color, !);
if (y.restore(), t.series.pie.stroke.width > ) {
y.save(), y.lineWidth = t.series.pie.stroke.width, f = d;
for (var g = ; g < m.length; ++g) b(m[g].angle, t.series.pie.stroke.color, !);
y.restore()
}
return h(y), y.restore(), t.series.pie.label.show ? c() : !
}
if (s) {
var j = b.getPlaceholder().width(),
k = b.getPlaceholder().height(),
l = s.children().filter(".legend").children().width() || ;
y = e, x = !, u = Math.min(j, k / t.series.pie.tilt) / , w = k / + t.series.pie.offset.top, v = j / , "auto" == t.series.pie.offset.left ? (t.legend.position.match("w") ? v += l / : v -= l / , u > v ? v = u : v > j - u && (v = j - u)) : v += t.series.pie.offset.left;
var m = b.getData(),
n = ;
do n > && (u *= d), n += , f(), t.series.pie.tilt <= . && g();
while (!i() && c > n);
n >= c && (f(), s.prepend("<div class='error'>Could not draw pie with labels contained inside canvas</div>")), b.setSeries && b.insertLegend && (b.setSeries(m), b.insertLegend())
}
}
function h(a) {
if (t.series.pie.innerRadius > ) {
a.save();
var b = t.series.pie.innerRadius > ? t.series.pie.innerRadius : u * t.series.pie.innerRadius;
a.globalCompositeOperation = "destination-out", a.beginPath(), a.fillStyle = t.series.pie.stroke.color, a.arc(, , b, , * Math.PI, !), a.fill(), a.closePath(), a.restore(), a.save(), a.beginPath(), a.strokeStyle = t.series.pie.stroke.color, a.arc(, , b, , * Math.PI, !), a.stroke(), a.closePath(), a.restore()
}
}
function i(a, b) {
for (var c = !, d = -, e = a.length, f = e - ; ++d < e; f = d)(a[d][] <= b[] && b[] < a[f][] || a[f][] <= b[] && b[] < a[d][]) && b[] < (a[f][] - a[d][]) * (b[] - a[d][]) / (a[f][] - a[d][]) + a[d][] && (c = !c);
return c
}
function j(a, c) {
for (var d, e, f = b.getData(), g = b.getOptions(), h = g.series.pie.radius > ? g.series.pie.radius : u * g.series.pie.radius, j = ; j < f.length; ++j) {
var k = f[j];
if (k.pie.show) {
if (y.save(), y.beginPath(), y.moveTo(, ), y.arc(, , h, k.startAngle, k.startAngle + k.angle / , !), y.arc(, , h, k.startAngle + k.angle / , k.startAngle + k.angle, !), y.closePath(), d = a - v, e = c - w, y.isPointInPath) {
if (y.isPointInPath(a - v, c - w)) return y.restore(), {
datapoint: [k.percent, k.data],
dataIndex: ,
series: k,
seriesIndex: j
}
} else {
var l = h * Math.cos(k.startAngle),
m = h * Math.sin(k.startAngle),
n = h * Math.cos(k.startAngle + k.angle / ),
o = h * Math.sin(k.startAngle + k.angle / ),
p = h * Math.cos(k.startAngle + k.angle / ),
q = h * Math.sin(k.startAngle + k.angle / ),
r = h * Math.cos(k.startAngle + k.angle / 1.5),
s = h * Math.sin(k.startAngle + k.angle / 1.5),
t = h * Math.cos(k.startAngle + k.angle),
x = h * Math.sin(k.startAngle + k.angle),
z = [
[, ],
[l, m],
[n, o],
[p, q],
[r, s],
[t, x]
],
A = [d, e];
if (i(z, A)) return y.restore(), {
datapoint: [k.percent, k.data],
dataIndex: ,
series: k,
seriesIndex: j
}
}
y.restore()
}
}
return null
}
function k(a) {
m("plothover", a)
}
function l(a) {
m("plotclick", a)
}
function m(a, c) {
var d = b.offset(),
e = parseInt(c.pageX - d.left),
f = parseInt(c.pageY - d.top),
g = j(e, f);
if (t.grid.autoHighlight) for (var h = ; h < z.length; ++h) {
var i = z[h];
i.auto != a || g && i.series == g.series || o(i.series)
}
g && n(g.series, a);
var k = {
pageX: c.pageX,
pageY: c.pageY
};
s.trigger(a, [k, g])
}
function n(a, c) {
var d = p(a); - == d ? (z.push({
series: a,
auto: c
}), b.triggerRedrawOverlay()) : c || (z[d].auto = !)
}
function o(a) {
null == a && (z = [], b.triggerRedrawOverlay());
var c = p(a); - != c && (z.splice(c, ), b.triggerRedrawOverlay())
}
function p(a) {
for (var b = ; b < z.length; ++b) {
var c = z[b];
if (c.series == a) return b
}
return -
}
function q(a, b) {
function c(a) {
a.angle <= || isNaN(a.angle) || (b.fillStyle = "rgba(255, 255, 255, " + d.series.pie.highlight.opacity + ")", b.beginPath(), Math.abs(a.angle - * Math.PI) > 1e- && b.moveTo(, ), b.arc(, , e, a.startAngle, a.startAngle + a.angle / , !), b.arc(, , e, a.startAngle + a.angle / , a.startAngle + a.angle, !), b.closePath(), b.fill())
}
var d = a.getOptions(),
e = d.series.pie.radius > ? d.series.pie.radius : u * d.series.pie.radius;
b.save(), b.translate(v, w), b.scale(, d.series.pie.tilt);
for (var f = ; f < z.length; ++f) c(z[f].series);
h(b), b.restore()
}
var r = null,
s = null,
t = null,
u = null,
v = null,
w = null,
x = !,
y = null,
z = [];
b.hooks.processOptions.push(function(a, b) {
b.series.pie.show && (b.grid.show = !, "auto" == b.series.pie.label.show && (b.legend.show ? b.series.pie.label.show = ! : b.series.pie.label.show = !), "auto" == b.series.pie.radius && (b.series.pie.label.show ? b.series.pie.radius = . : b.series.pie.radius = ), b.series.pie.tilt > ? b.series.pie.tilt = : b.series.pie.tilt < && (b.series.pie.tilt = ))
}), b.hooks.bindEvents.push(function(a, b) {
var c = a.getOptions();
c.series.pie.show && (c.grid.hoverable && b.unbind("mousemove").mousemove(k), c.grid.clickable && b.unbind("click").click(l))
}), b.hooks.processDatapoints.push(function(a, b, c, d) {
var f = a.getOptions();
f.series.pie.show && e(a, b, c, d)
}), b.hooks.drawOverlay.push(function(a, b) {
var c = a.getOptions();
c.series.pie.show && q(a, b)
}), b.hooks.draw.push(function(a, b) {
var c = a.getOptions();
c.series.pie.show && g(a, b)
})
}
var c = ,
d = .,
e = {
series: {
pie: {
show: !,
radius: "auto",
innerRadius: ,
startAngle: 1.5,
tilt: ,
shadow: {
left: ,
top: ,
alpha: .
},
offset: {
top: ,
left: "auto"
},
stroke: {
color: "#fff",
width:
},
label: {
show: "auto",
formatter: function(a, b) {
return "<div style='font-size:x-small;text-align:center;padding:2px;color:" + b.color + ";'>" + a + "<br/>" + Math.round(b.percent) + "%</div>"
},
radius: ,
background: {
color: null,
opacity:
},
threshold:
},
combine: {
threshold: -,
color: null,
label: "Other"
},
highlight: {
opacity: .
}
}
}
};
a.plot.plugins.push({
init: b,
options: e,
name: "pie",
version: "1.1"
})
}(jQuery);

最后用mis.js压缩工具压缩

参考:

用JS jquery取float型小数点后两位

min.js 解压工具 https://tool.lu/js/

ACE的饼图显示保留两位小数的更多相关文章

  1. Java初学者作业——分别计算两个整数加、减、乘、除的结果并显示,要求除法保留两位小数。

    返回本章节 返回作业目录 需求说明: 分别计算两个整数加.减.乘.除的结果并显示,要求除法保留两位小数. 实现思路: 接收用户控制台输入的两个整数. 实现两个整数的加.减.乘.除的运算并输出结果. 除 ...

  2. java使double保留两位小数的多方法 java保留两位小数

    这篇文章主要介绍了java使double类型保留两位小数的方法,大家参考使用吧 复制代码 代码如下: mport java.text.DecimalFormat; DecimalFormat    d ...

  3. java保留两位小数

    java保留两位小数问题: 方式一: 四舍五入  double   f   =   111231.5585;  BigDecimal   b   =   new   BigDecimal(f);  d ...

  4. Java 保留两位小数

    在实际项目开发中,经常会存在浮点数四舍五入保留几位小数的问题,故收集了几种常用方法: 直接上代码(保留两位小数). Format.java: import java.math.BigDecimal; ...

  5. js 保留两位小数 多位小数(javascript)

    <SCRIPT LANGUAGE="JavaScript"><!--function formatFloat(src, pos){    return Math. ...

  6. Oracle中保留两位小数

    在最近的项目开发中,有个业务需求是界面显示的数字需要保留两位小数,目前我想到的解决方法有两种: (1)在写SQL的时候,直接保留两位小数 (2)在java代码里面将查询出来的数进行格式化处理,保留两位 ...

  7. (后台)Java:对double值进行四舍五入,保留两位小数的几种方法

    mport java.text.DecimalFormat; DecimalFormat df = new DecimalFormat("######0.00"); double ...

  8. [Java]求文件大小并保留两位小数(文件大小是一个长整型数单位是Byte)

    前言 为了获得一堆apk的大小,并与人类友好方式显示.本来是打算用以下方法,到时不能具体到保留两位小数. org.apache.commons.io.FileUtils.byteCountToDisp ...

  9. BigDecimal四舍五入保留两位小数

    import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; public c ...

随机推荐

  1. CMDB资产采集方案

    CMDB资产采集方案 CMDB 资产采集的方案总共有四种 Agent SSH类 Saltstack Puttet 方案设计,从性能上考虑 下面前三种是用Python开发的,目标是兼容三种采集方式的软件 ...

  2. 用requests爬取图片

    # coding=utf-8 from bs4 import BeautifulSoup import requests import urllib x = 1 def crawl(url): res ...

  3. Python中文编码问题(字符串前面加'u')

    中文编码问题是用中文的程序员经常头大的问题,在python下也是如此,那么应该怎么理解和解决python的编码问题呢? 我们要知道python内部使用的是unicode编码,而外部却要面对千奇百怪的各 ...

  4. 在Scrollview中使用AutoLayout

    AutoLayout 与 UIScrollView的相遇是一个不可避免的场景,像UITableView.UIWebView这些都是继承于UIScrollView的,关于它们的autolayout布局大 ...

  5. js函数节流和函数防抖

    概念解释 函数节流: 频繁触发,但只在特定的时间内才执行一次代码 函数防抖: 频繁触发,但只在特定的时间内没有触发执行条件才执行一次代码 函数节流 函数节流应用的实际场景,多数在监听页面元素滚动事件的 ...

  6. 洛谷 P1593 因子和

    https://www.luogu.org/problemnew/show/P1593#sub 利用约数和定理:可以去看一下公式第13条 然后这个题目的话,要求$a^b$,那么我们首先可以先将a分解然 ...

  7. 二叉搜索树详解(Java实现)

    1.二叉搜索树定义 二叉搜索树,是指一棵空树或者具有下列性质的二叉树: 若任意节点的左子树不空,则左子树上所有节点的值均小于它的根节点的值: 若任意节点的右子树不空,则右子树上所有节点的值均大于它的根 ...

  8. 【状态压缩dp】1195: [HNOI2006]最短母串

    一个清晰的思路就是状压dp:不过也有AC自动机+BFS的做法 Description 给定n个字符串(S1,S2,„,Sn),要求找到一个最短的字符串T,使得这n个字符串(S1,S2,„,Sn)都是T ...

  9. redis学习笔记(1)

    最近在学习redis,做了比较详细的学习笔记,分享给大家,欢迎一起讨论和学习 第一部分,简单介绍redis 和 redis的基本操作 NoSQL的特点 : 数据库种类繁多,但是一个共同的特点都是去掉关 ...

  10. MySql常用数据操作

    1.数据库操作: MySQL服务管理命令: 1.启动服务:sudo service mysql start 2.停止服务:sudo service mysql stop 3.重新启动服务:sudo s ...