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

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

View File

@@ -108,6 +108,7 @@ $(document).ready(function(){
}); });
}); });
function searchList(){ function searchList(){
loading();
var start=$("#searchFoundStartTime").val(); var start=$("#searchFoundStartTime").val();
var end=$("#searchFoundEndTime").val(); var end=$("#searchFoundEndTime").val();
if(start==''||end==''||end==null||start==null){ if(start==''||end==''||end==null||start==null){
@@ -321,7 +322,7 @@ function protocolTypeChart(rs){
softConnector: true, // 是否使用曲线 softConnector: true, // 是否使用曲线
formatter: function () { 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: { style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
@@ -353,7 +354,7 @@ function protocolTypeChart(rs){
}, },
tooltip: { tooltip: {
headerFormat: '{series.name}<br>', headerFormat: '{series.name}<br>',
pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>' pointFormat: '{point.name}: <b>{point.percentage:.2f}%</b>'
}, },
series: [{ series: [{
name: "App", name: "App",

View File

@@ -98,6 +98,7 @@ $(document).ready(function(){
}); });
}); });
function searchList(){ function searchList(){
loading();
var start=$("#searchFoundStartTime").val(); var start=$("#searchFoundStartTime").val();
var end=$("#searchFoundEndTime").val(); var end=$("#searchFoundEndTime").val();
if(start==''||end==''||end==null||start==null){ if(start==''||end==''||end==null||start==null){
@@ -310,7 +311,7 @@ function protocolTypeChart(rs){
softConnector: true, // 是否使用曲线 softConnector: true, // 是否使用曲线
formatter: function () { 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: { style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
@@ -342,7 +343,7 @@ function protocolTypeChart(rs){
}, },
tooltip: { tooltip: {
headerFormat: '{series.name}<br>', headerFormat: '{series.name}<br>',
pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>' pointFormat: '{point.name}: <b>{point.percentage:.2f}%</b>'
}, },
series: [{ series: [{
name: "Protocol", name: "Protocol",

View File

@@ -133,7 +133,7 @@
mouseOver: function(e) { // 鼠标滑过时动态更新标题 mouseOver: function(e) { // 鼠标滑过时动态更新标题
// 标题更新函数API 地址https://api.hcharts.cn/highcharts#Chart.setTitle // 标题更新函数API 地址https://api.hcharts.cn/highcharts#Chart.setTitle
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, floating:true,
y:120, y:120,
style: {//设置字体颜色 style: {//设置字体颜色
@@ -375,7 +375,7 @@
// inoctetsNum=inoctetsNumG; // inoctetsNum=inoctetsNumG;
// }; // };
inoctetsNum=inoctetsNumG; inoctetsNum=inoctetsNumG;
inoctetsNum=inoctetsNum.toFixed(5) inoctetsNum=inoctetsNum.toFixed(2)
return inoctetsNum; return inoctetsNum;
} }
function changeUnit(inoctetsNum){ function changeUnit(inoctetsNum){