流量统计数值保留两位小数

This commit is contained in:
zhanghongqing
2018-12-12 15:33:27 +08:00
parent a3f2943e5c
commit f5b0a0d4d0
4 changed files with 11 additions and 9 deletions

View File

@@ -270,12 +270,12 @@ public class TrafficStatisticsInfoController extends BaseController {
Long totalPackets=0l;
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat df = new DecimalFormat("0.00000000");
DecimalFormat df = new DecimalFormat("0.00");
List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
if(!StringUtil.isEmpty(list)){
for (Object object : list) {
Map m=(Map) object;
Double value1 = Double.parseDouble(m.get("protocolType").toString());
Double value1 = Double.parseDouble(m.get("protoType").toString());
totalGByte+=Double.parseDouble(m.get("GByte").toString());
// String linkNum = df.format(m.get("linkNum"));
m.put("GByte", df.format(m.get("GByte")));
@@ -338,7 +338,7 @@ public class TrafficStatisticsInfoController extends BaseController {
Long totalPackets=0l;
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat df = new DecimalFormat("0.00000000");
DecimalFormat df = new DecimalFormat("0.00");
if(!StringUtil.isEmpty(list)){
for (Object object : list) {
Map m=(Map) object;

View File

@@ -108,6 +108,7 @@ $(document).ready(function(){
});
});
function searchList(){
loading();
var start=$("#searchFoundStartTime").val();
var end=$("#searchFoundEndTime").val();
if(start==''||end==''||end==null||start==null){
@@ -321,7 +322,7 @@ function protocolTypeChart(rs){
softConnector: true, // 是否使用曲线
formatter: function () {
// 通过函数判断是否显示数据标签,为了防止数据标签过于密集
return this.percentage > 1 ? '<b>' + this.point.name + ' :</b> ' +this.percentage.toFixed(1)+' %' : null;
return this.percentage > 1 ? '<b>' + this.point.name + ' :</b> ' +this.percentage.toFixed(2)+' %' : null;
},
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
@@ -353,7 +354,7 @@ function protocolTypeChart(rs){
},
tooltip: {
headerFormat: '{series.name}<br>',
pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
pointFormat: '{point.name}: <b>{point.percentage:.2f}%</b>'
},
series: [{
name: "App",

View File

@@ -98,6 +98,7 @@ $(document).ready(function(){
});
});
function searchList(){
loading();
var start=$("#searchFoundStartTime").val();
var end=$("#searchFoundEndTime").val();
if(start==''||end==''||end==null||start==null){
@@ -310,7 +311,7 @@ function protocolTypeChart(rs){
softConnector: true, // 是否使用曲线
formatter: function () {
// 通过函数判断是否显示数据标签,为了防止数据标签过于密集
return this.percentage > 1 ? '<b>' + this.point.name + ' :</b> ' +this.percentage.toFixed(1)+' %' : null;
return this.percentage > 1 ? '<b>' + this.point.name + ' :</b> ' +this.percentage.toFixed(2)+' %' : null;
},
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
@@ -342,7 +343,7 @@ function protocolTypeChart(rs){
},
tooltip: {
headerFormat: '{series.name}<br>',
pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
pointFormat: '{point.name}: <b>{point.percentage:.2f}%</b>'
},
series: [{
name: "Protocol",

View File

@@ -133,7 +133,7 @@
mouseOver: function(e) { // 鼠标滑过时动态更新标题
// 标题更新函数API 地址https://api.hcharts.cn/highcharts#Chart.setTitle
chart.setTitle({
text:e.target.name.length>10? this.percentage.toFixed(1)+"%<br><span>"+e.target.name.substring(0,10)+"...</span>":this.percentage.toFixed(1)+"%<br><span>"+e.target.name.substring(0,10)+"</span>",
text:e.target.name.length>10? this.percentage.toFixed(2)+"%<br><span>"+e.target.name.substring(0,10)+"...</span>":this.percentage.toFixed(2)+"%<br><span>"+e.target.name.substring(0,10)+"</span>",
floating:true,
y:120,
style: {//设置字体颜色
@@ -375,7 +375,7 @@
// inoctetsNum=inoctetsNumG;
// };
inoctetsNum=inoctetsNumG;
inoctetsNum=inoctetsNum.toFixed(5)
inoctetsNum=inoctetsNum.toFixed(2)
return inoctetsNum;
}
function changeUnit(inoctetsNum){