diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue
index 7f0401e06..eaeb17561 100644
--- a/nezha-fronted/src/components/charts/chart-alert-list.vue
+++ b/nezha-fronted/src/components/charts/chart-alert-list.vue
@@ -42,6 +42,7 @@
{dropmenuChange(item.id, show)}"
>
+
+ {dropmenuChange(item.id, show)}"
+ :chart-index="index">
@@ -176,6 +189,7 @@
import chartDataFormat from "./chartDataFormat";
import chartAlertList from './chart-alert-list'
import textChart from './text-chart'
+ import chartPie from './chart-pie'
// import visNetwork from './visNetwork'
export default {
name: 'chartList',
@@ -196,7 +210,8 @@
chartUrl,
chartSingleStat,
draggable,
- textChart
+ textChart,
+ chartPie,
// visNetwork,
},
data() {
@@ -681,7 +696,7 @@
this.$refs['editChart'+chartItem.id][0].setData(chartItem, tableData,
panelId, filter,'',errorMsg);
}
- } else if (chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 4) {
+ } else if (chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 4||chartItem.type ==='pie') {
if (filterType === 'showFullScreen') {//全屏查询
this.$refs['editChart'+chartItem.id][0].setData(chartItem, series,
panelId, filter, legend, filterType,errorMsg);
@@ -817,6 +832,28 @@
threshold: null,
};*/
let errorMsg = "";
+ let pieSeries;
+ if(chartInfo.type ==='pie'){
+ pieSeries={
+ type: 'pie',
+ radius: ['20%', '100%'],
+ center: ['50%', '50%'],
+ roseType: 'radius',
+ minAngle:10,
+ itemStyle: {
+ borderRadius: 5
+ },
+ label: {
+ show: false
+ },
+ emphasis: {
+ label: {
+ show: false
+ }
+ },
+ data:[]
+ }
+ }
res.forEach((response, innerPos) => {
if (response.status === 'success') {
errorMsg = "";
@@ -939,8 +976,12 @@
});
return [dpsItem[0] * 1000, dpsItem[1]];
});
- series.push(seriesItem.theData);
- seriesItem = null;
+ if(chartInfo.type === 'pie'){
+ pieSeries.data.push({value:bus.getSingleStatRlt(chartInfo.param.statistics,seriesItem.theData.data),name:host+"-"+chartItem.elements[innerPos].id+"-" + resIndex})
+ }else{
+ series.push(seriesItem.theData);
+ seriesItem = null;
+ }
} else if (chartItem.elements && chartItem.elements[innerPos]) {
// 无数据提示
/*
@@ -971,6 +1012,9 @@
});
if (this.$refs['editChart' + chartItem.id] && this.$refs['editChart' + chartItem.id].length > 0) {
+ if(chartInfo.type === 'pie'){
+ series.push(pieSeries)
+ }
let chartData = {
chartItem: chartItem,
series: series,
@@ -991,7 +1035,7 @@
this.$refs['editChart' + chartItem.id][0].setData(chartItem, tableData,
this.filter.panelId, this.filter, '', errorMsg);
}
- } else if (chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 4) {
+ } else if (chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 4||chartItem.type == 'pie') {
if (series.length && chartItem.type === 4) {//曲线汇总
//series.push(sumData);//后续需要
}
@@ -1023,7 +1067,7 @@
this.$refs['editChart' + chartItem.id][0].setData(chartItem, [], this.filter.panelId,
this.filter);
}
- } else if (type === 'line' || type === 'bar' || type === 'stackArea' || chartItem.type === 4) {
+ } else if (type === 'line' || type === 'bar' || type === 'stackArea' || chartItem.type === 4||chartItem.type === 'pie') {
if (filterType === 'showFullScreen') {//table的全屏查询
this.$refs['editChart' + chartItem.id][0].setData(chartItem, [], this.filter.panelId,
this.filter, filterType);
diff --git a/nezha-fronted/src/components/charts/chart-pie.vue b/nezha-fronted/src/components/charts/chart-pie.vue
new file mode 100644
index 000000000..adb1a535d
--- /dev/null
+++ b/nezha-fronted/src/components/charts/chart-pie.vue
@@ -0,0 +1,623 @@
+
+
+
+
+
+
+
+
+
+ {{errorContent}}
+
+
+
+
+
+
+
+
+ {{chartData.title}}
+
+
+
+
+
+
+
No Data
+
+
+ {{item.alias?item.alias:item.name}}
+
+
+
+
+
+
+
+
+
+ {{item.alias?item.alias:item.name}}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue
index c7b186993..7312c7333 100644
--- a/nezha-fronted/src/components/charts/chartPreview.vue
+++ b/nezha-fronted/src/components/charts/chartPreview.vue
@@ -3,8 +3,6 @@
}
.nz-preview-picker{
}
- .v-modal{
- }
.hidden{
visibility: hidden;
}
@@ -76,9 +74,9 @@
-
+
-
+
No Data
@@ -267,12 +265,14 @@
this.searchTime = bus.getTimezontDateRange();
this.chart = JSON.parse(JSON.stringify(chartInfo));
+ console.log('chart',this.chart,chartInfo)
+
let chartType= chartInfo.type;
let chartContainerId = 'chartEchartPreview';
if(chartType==='table'){
this.tableShow = false;
chartContainerId = 'chartTablePreview';
- }else if (chartType === 'line' || chartType === 'bar' || chartType === 'stackArea' || chartType === 4) {
+ }else if (chartType === 'line' || chartType === 'bar' || chartType === 'stackArea' || chartType === 4||chartType == 'pie') {
this.isGreyScreen=[];
this.showLegend = false;
chartContainerId = 'chartEchartPreview';
@@ -346,7 +346,7 @@
let chartType= this.chart.type;
if(chartType==='table'){
- }else if (chartType === 'line' || chartType === 'bar' || chartType === 'stackArea' || chartType === 4 || chartType == "endpointInfo") {
+ }else if (chartType === 'line' || chartType === 'bar' || chartType === 'stackArea' || chartType === 4 || chartType == "endpointInfo"||chartType == 'pie') {
if(this.echartModalStore){
this.echartModalStore.clear();
}
@@ -381,7 +381,7 @@
this.$nextTick(() => {
if (chartItem.type === 'table') {//表格
this.setTableData([]);
- } else if (chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 4 || chartItem.type === "endpointInfo") {
+ } else if (chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 4 || chartItem.type === "endpointInfo"||chartItem == 'pie') {
this.setData(chartItem, [], []);
}else if(chartItem.type ==='singleStat'){
this.serieSingleStat = "";
@@ -415,12 +415,28 @@
let singleStatRlt = '';
const legend = [];
const tableData = [];
- const sumData = {
- name: 'sum',
- data: [],
- visible: true,
- threshold: null,
- };
+ let pieSeries;
+ if(chartItem.type ==='pie'){
+ pieSeries={
+ type: 'pie',
+ radius: ['20%', '100%'],
+ center: ['50%', '50%'],
+ roseType: 'radius',
+ minAngle:10,
+ itemStyle: {
+ borderRadius: 5
+ },
+ label: {
+ show: false
+ },
+ emphasis: {
+ label: {
+ show: false
+ }
+ },
+ data:[]
+ }
+ }
res.forEach((response, innerPos) => {
if (response.status === 'success') {
this.isError = false;
@@ -513,8 +529,12 @@
});
return [dpsItem[0] * 1000, dpsItem[1]];
});
- series.push(seriesItem.theData);
-
+ if(chartItem.type === 'pie'){
+ console.log(chartItem.param.statistics,seriesItem.theData.data)
+ pieSeries.data.push({value:bus.getSingleStatRlt(chartItem.param.statistics,seriesItem.theData.data),name:host + resInnerPos})
+ }else{
+ series.push(seriesItem.theData);
+ }
} else if (chartItem.elements && chartItem.elements[innerPos]) {
// 无数据提示
/*
@@ -581,6 +601,14 @@
this.serieSingleStat =singleStatRlt;
}
this.$refs.loadingPreview.endLoading();
+ }else if(chartItem.type == 'pie'){
+ series.push(pieSeries)
+ if(series[0].data.length<1){
+ this.noData=true;
+ }else{
+ this.noData=false;
+ }
+ this.setData(chartItem,series,legend)
}
//}
} else {
@@ -588,7 +616,7 @@
//if(this.$refs.editChart[index]) {
if (type === 'table') {
this.setTableData([]);
- } else if (type === 'line' || type === 'bar' || type === 'stackArea' || type === 4) {
+ } else if (type === 'line' || type === 'bar' || type === 'stackArea' || type === 4||chartItem.type == 'pie') {
this.setData(chartItem, []);
}else if(chartItem.type ==='singleStat'){
this.serieSingleStat = "";
@@ -738,7 +766,7 @@
this.chartType = 'line';
}
this.echartModalStore = echarts.init(ele);
-
+ console.log('height',ele.clientWidth,ele.clientHeight)
var chartWidth = ele.clientWidth;
var title = {
show:false,
@@ -1040,6 +1068,71 @@
}
});
},
+ initPie:function(chartInfo, dataArg, legend){
+ let option={
+ title: {
+ show: false,
+ },
+ legend:{
+ show:false,
+ },
+ grid: {
+ left:'center',
+ top:'middle',
+ },
+ tooltip:{
+ trigger:'item',
+ backgroundColor:'rgba(221,228,237,1)',
+ borderColor :'rgba(255,255,255,0)',
+ textStyle:{
+ color:'#000'
+ },
+ textStyle:{
+ color:'#000'
+ },
+ axisPointer:{
+ snap:false,
+ animation:false,
+ },
+ extraCssText:'z-index:1000;',
+ },
+ series:null,
+ }
+ option.series = dataArg;
+ option.color = this.bgColorList;
+ option.tooltip.formatter=this.pieFormatterFunc;
+ let self=this;
+ let dom = document.getElementById('screenShowArea')
+ this.echartModalStore = echarts.init(dom)
+ console.log('dom',dom.clientWidth,dom.clientHeight)
+ this.showLegend = true;
+ if(legend){
+ this.screenLegendList = [];
+ legend.forEach((item, i) => {
+ let _legend = {
+ name:item.name,
+ alias:item.alias,
+ color:item.color,
+ showText:this.formatLegend(dom.clientWidth,item.alias?item.alias:item.name)
+ };
+ this.screenLegendList.push(_legend);
+ this.isGreyScreen.push(false);
+ });
+ }
+ this.$nextTick(() => {
+ let divHeight = this.$refs.screenLegendArea.offsetHeight;
+ this.echartModalStore.resize({height:(chartInfo.height-this.chartSpaceHeight-divHeight-this.titleHeight)});
+ this.echartModalStore.clear();
+ if(dataArg[0].data.length<1){
+ this.echartModalStore.setOption(chartConfig.getOption('noData'))
+ }else{
+ console.log(option)
+ this.echartModalStore.setOption(option);//创建图表
+ }
+
+ this.$refs.loadingPreview.endLoading();
+ });
+ },
mouseEnterFullChart(){
if (this.echartModalStore) {
this.echartModalStore.setOption({
@@ -1077,6 +1170,10 @@
let sortedOptionKeys=['min','max','avg','last','total']
this.screenLegendOptions=sortedOptionKeys.map(item=>{ return {option:item,sort:'',value:chartItem.param.legendValue[item]}})
}
+ if(chartItem.type == 'pie'){
+ this.initPie(chartItem,seriesItem,legend)
+ return;
+ }
this.initChart(chartItem, seriesItem, this.$refs.screenShowArea,legend);
},
// 设置数据
@@ -1444,6 +1541,23 @@
legend.sort((x,y)=>y[option.option] - x[option.option])
option.sort = 'asc'
}
+ },
+ pieFormatterFunc:function(params, ticket, callback){
+ return `
+
+
+
${this.legend[params.dataIndex].alias}
+
+
value
+
${params.value}
+
+
+
percent
+
${params.percent}%
+
+
+
+ `
}
},
beforeDestroy() {
diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue
index b78dceca7..8402c4454 100644
--- a/nezha-fronted/src/components/charts/line-chart-block.vue
+++ b/nezha-fronted/src/components/charts/line-chart-block.vue
@@ -189,6 +189,7 @@
import timePicker from '../common/timePicker';
import chartConfig from "../page/dashboard/overview/chartConfig";
import {getChart, setChart,lineChartMove,getMousePoint} from "../common/js/common";
+ import {getMetricTypeValue} from "../common/js/tools";
export default {
name: 'lineChartBlock',
@@ -578,20 +579,6 @@
//chartId='screenShowArea';
}
var chartWidth = ele.clientWidth;
- var title = {
- show:false,
- text: chartInfo.title || null,
- textAlign: 'left',
- useHTML: true,
- textStyle: {
- //display: 'inline-block',//无此属性
- width: '60%',
- fontStyle:'normal',
- fontWeight:'bold',
- color: "#333",
-
- }
- };
let stackIconBorderColor = (chartInfo.type==='stackArea'?'#53a3cb':'#7e7e7e');
let stackIconChooseBorderColor = (chartInfo.type==='stackArea'?'#7e7e7e':'#53a3cb');
@@ -1739,94 +1726,17 @@
let options=where =='local'?this.legendOptions:this.screenLegendOptions;
let keys=options.filter(item=>{return item.value == 'on'}).map(item=>{return item.option});
let $self=this;
- keys.forEach(item=>{
- switch (item) {
- case 'min':
- $self.legendMinValue(legend,dataArr);
- break;
- case 'max':
- $self.legendMaxValue(legend,dataArr);
- break;
- case 'avg':
- $self.legendAvgValue(legend,dataArr);
- break;
- case 'last':
- $self.legendLastValue(legend,dataArr);
- break;
- case 'total':
- $self.legendTotalValue(legend,dataArr);
- break;
- }
- })
- },
- legendMinValue:function(legend,dataArr){
- return new Promise(resolve => {
- legend.forEach(item=>{
- let data=dataArr.find(t=>t.name == item.name)
- if(data&&data.data){
- let copy=JSON.parse(JSON.stringify(data.data));
- let min =copy.sort((x,y)=>{return parseFloat(x[1]) - parseFloat(y[1])})[0][1]
- item['min']=parseFloat(min)
- }
+ keys.forEach(key=>{
+ return new Promise(resolve => {
+ legend.forEach(item=>{
+ let data=dataArr.find(t=>t.name == item.name)
+ if(data&&data.data){
+ let value=getMetricTypeValue(data.data,key)
+ item[key] = parseFloat(value)
+ }
+ })
+ resolve();
})
-
- resolve();
- })
- },
- legendMaxValue:function(legend,dataArr){
- return new Promise(resolve => {
- legend.forEach(item=>{
- let data=dataArr.find(t=>t.name == item.name)
- if(data&&data.data){
- let copy=JSON.parse(JSON.stringify(data.data));
- let max =copy.sort((x,y)=>{return parseFloat(y[1]) - parseFloat(x[1])})[0][1]
- item['max']=parseFloat(max)
- }
- })
- resolve();
- })
- },
- legendAvgValue:function(legend,dataArr){
- return new Promise(resolve => {
- legend.forEach(item=>{
- let data=dataArr.find(t=>t.name == item.name)
- if(data&&data.data){
- let copy=JSON.parse(JSON.stringify(data.data));
- copy = copy.map(t=>parseFloat(t[1]))
- let sum = eval(copy.join('+'));
- let avg = sum / copy.length;
-
- item['avg'] = avg;
- }
- })
- resolve();
- })
- },
- legendLastValue:function(legend,dataArr){
- return new Promise(resolve => {
- legend.forEach(item=>{
- let data=dataArr.find(t=>t.name == item.name)
- if(data&&data.data){
- let copy=JSON.parse(JSON.stringify(data.data));
- let last =copy.sort((x,y)=>{return parseFloat(y[0]) - parseFloat(x[0])})[0][1]
- item['last']=parseFloat(last)
- }
- })
- resolve();
- })
- },
- legendTotalValue:function(legend,dataArr){
- return new Promise(resolve => {
- legend.forEach(item=>{
- let data=dataArr.find(t=>t.name == item.name)
- if(data&&data.data){
- let copy=JSON.parse(JSON.stringify(data.data));
- copy = copy.map(t=>parseFloat(t[1]))
- let sum = eval(copy.join('+'));
- item['total'] = sum;
- }
- })
- resolve();
})
},
formatLegendData:function(data){
diff --git a/nezha-fronted/src/components/common/alert/alertMessageTable.vue b/nezha-fronted/src/components/common/alert/alertMessageTable.vue
index 2201293e7..64e1b53bd 100644
--- a/nezha-fronted/src/components/common/alert/alertMessageTable.vue
+++ b/nezha-fronted/src/components/common/alert/alertMessageTable.vue
@@ -6,7 +6,7 @@