feat:添加chart option选项
This commit is contained in:
@@ -659,23 +659,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.dataList = [...this.dataTotalList];
|
this.dataList = [...this.dataTotalList];
|
||||||
// this.dataList.push({ // 拓扑图
|
|
||||||
// id: -10,
|
|
||||||
// panelId: 0,
|
|
||||||
// title: this.$t("alert.config.chart.alertNumTrend"),
|
|
||||||
// span: 8,
|
|
||||||
// height: 800,
|
|
||||||
// type: "topology",
|
|
||||||
// prev: -11,
|
|
||||||
// next: -1,
|
|
||||||
// unit: 1,
|
|
||||||
// buildIn: 1,
|
|
||||||
// elements: [{
|
|
||||||
// id: '',
|
|
||||||
// expression: `nz_alert_nums{id="${3333}"}`,
|
|
||||||
// type: ''
|
|
||||||
// }]
|
|
||||||
// });
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.dataList.length > 0 ) {
|
if (this.dataList.length > 0 ) {
|
||||||
this.dataList.forEach((item,index) => {
|
this.dataList.forEach((item,index) => {
|
||||||
@@ -854,6 +837,10 @@
|
|||||||
const axiosArr = chartItem.elements.map((ele) => {
|
const axiosArr = chartItem.elements.map((ele) => {
|
||||||
const filterItem = ele;
|
const filterItem = ele;
|
||||||
let query = encodeURIComponent(filterItem.expression);
|
let query = encodeURIComponent(filterItem.expression);
|
||||||
|
if(chartInfo.type==='line'||chartInfo.type==='bar'||chartInfo.type==='stackArea'){//如果是这三个 默认给connected
|
||||||
|
chartInfo.param.nullType=chartInfo.param.nullType||'connected';
|
||||||
|
query+='&nullType='+chartInfo.param.nullType;
|
||||||
|
}
|
||||||
return this.$get('/prom/api/v1/query_range?query=' + query + "&start=" + this.$stringTimeParseToUnix(startTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step);
|
return this.$get('/prom/api/v1/query_range?query=' + query + "&start=" + this.$stringTimeParseToUnix(startTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step);
|
||||||
});
|
});
|
||||||
// 一个图表的所有element单独获取数据
|
// 一个图表的所有element单独获取数据
|
||||||
@@ -1249,6 +1236,10 @@
|
|||||||
let step = bus.getStep(startTime, endTime);
|
let step = bus.getStep(startTime, endTime);
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
let query = chartInfo.elements[0].expression;
|
let query = chartInfo.elements[0].expression;
|
||||||
|
if(chartInfo.type==='line'||chartInfo.type==='bar'||chartInfo.type==='stackArea'){
|
||||||
|
chartInfo.param.nullType=chartInfo.param.nullType||'connected';
|
||||||
|
query+='&nullType='+chartInfo.param.nullType;
|
||||||
|
}
|
||||||
this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step=5m').then(response => {
|
this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step=5m').then(response => {
|
||||||
if (response.status === 'success') {
|
if (response.status === 'success') {
|
||||||
if (response.data.result) {
|
if (response.data.result) {
|
||||||
@@ -1683,6 +1674,7 @@
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.tempDomInit();
|
this.tempDomInit();
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1229,15 +1229,27 @@
|
|||||||
axiosArr = this.data.elements.map((ele) => {
|
axiosArr = this.data.elements.map((ele) => {
|
||||||
const filterItem = ele;
|
const filterItem = ele;
|
||||||
let query = encodeURIComponent(filterItem.expression);
|
let query = encodeURIComponent(filterItem.expression);
|
||||||
|
if(this.chartInfo.type==='line'||this.chartInfo.type==='bar'||this.chartInfo.type==='stackArea'){//如果是这三个 默认给connected
|
||||||
|
this.chartInfo.param.nullType=this.chartInfo.param.nullType||'connected';
|
||||||
|
query+='&nullType='+this.chartInfo.param.nullType;
|
||||||
|
}
|
||||||
return this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step);
|
return this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step);
|
||||||
});
|
});
|
||||||
} else if (type === 'dashboard') { // 概览模式,指标概览中使用
|
} else if (type === 'dashboard') { // 概览模式,指标概览中使用
|
||||||
// 概览模式,需要区分单独一个和多个
|
// 概览模式,需要区分单独一个和多个
|
||||||
if (this.stableFilter.chartCount === 'multiple') {
|
if (this.stableFilter.chartCount === 'multiple') {
|
||||||
let query = encodeURIComponent(this.data.title);
|
let query = encodeURIComponent(this.data.title);
|
||||||
|
if(this.chartInfo.type==='line'||this.chartInfo.type==='bar'||this.chartInfo.type==='stackArea'){//如果是这三个 默认给connected
|
||||||
|
this.chartInfo.param.nullType=this.chartInfo.param.nullType||'connected';
|
||||||
|
query+='&nullType='+this.chartInfo.param.nullType;
|
||||||
|
}
|
||||||
axiosArr = [this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step)];
|
axiosArr = [this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step)];
|
||||||
} else {
|
} else {
|
||||||
let query = encodeURIComponent(this.data.elements[0].expression);
|
let query = encodeURIComponent(this.data.elements[0].expression);
|
||||||
|
if(this.chartInfo.type==='line'||this.chartInfo.type==='bar'||this.chartInfo.type==='stackArea'){//如果是这三个 默认给connected
|
||||||
|
this.chartInfo.param.nullType=this.chartInfo.param.nullType||'connected';
|
||||||
|
query+='&nullType='+this.chartInfo.param.nullType;
|
||||||
|
}
|
||||||
axiosArr = [this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step)];
|
axiosArr = [this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1677,7 +1689,7 @@
|
|||||||
unit,
|
unit,
|
||||||
oldDot
|
oldDot
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.firstLoad = false;
|
this.firstLoad = false;
|
||||||
|
|||||||
@@ -152,7 +152,13 @@
|
|||||||
<el-input size="small" type="textarea" maxlength="1024" show-word-limit v-model="editChart.param.url"></el-input>
|
<el-input size="small" type="textarea" maxlength="1024" show-word-limit v-model="editChart.param.url"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item v-if="editChart.type == 'line' || editChart.type == 'bar' || editChart.type == 'stackArea'" :label='$t("dashboard.panel.chartForm.threshold")' prop="param.threshold" class="half-form-item">
|
<el-form-item v-if="editChart.type == 'line' || editChart.type == 'bar' || editChart.type == 'stackArea'" :label='"Null Type"' prop="nullType" class="half-form-item">
|
||||||
|
<el-select class="right-box-row-with-btn" popper-class="chart-box-dropdown-small" v-model="editChart.param.nullType" placeholder="" size="mini" @change="$forceUpdate()">
|
||||||
|
<el-option v-for="item in nullTypeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item v-if="editChart.type == 'line' || editChart.type == 'bar' || editChart.type == 'stackArea'" :label='$t("dashboard.panel.chartForm.threshold")' prop="param.threshold" class="half-form-item" style="width: 415px">
|
||||||
<el-input size="mini" type="input" v-model="editChart.param.threshold"></el-input>
|
<el-input size="mini" type="input" v-model="editChart.param.threshold"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@@ -374,6 +380,16 @@
|
|||||||
elementTarget: [], // 本地保存数据
|
elementTarget: [], // 本地保存数据
|
||||||
alertParams:{},
|
alertParams:{},
|
||||||
spanList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
spanList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||||
|
nullTypeList:[{
|
||||||
|
label:'connected',
|
||||||
|
value:'connected'
|
||||||
|
},{
|
||||||
|
label:'null',
|
||||||
|
value:'null'
|
||||||
|
},{
|
||||||
|
label:'zero',
|
||||||
|
value:'zero'
|
||||||
|
}],
|
||||||
// 是否为编辑已有信息
|
// 是否为编辑已有信息
|
||||||
isedit: false,
|
isedit: false,
|
||||||
//productId: 0,//不需要这个参数,可以删除
|
//productId: 0,//不需要这个参数,可以删除
|
||||||
@@ -717,6 +733,7 @@
|
|||||||
}
|
}
|
||||||
if(this.editChart.type==='line'||this.editChart.type==='bar'||this.editChart.type==='stackArea'){
|
if(this.editChart.type==='line'||this.editChart.type==='bar'||this.editChart.type==='stackArea'){
|
||||||
params.param.threshold=this.editChart.param.threshold;
|
params.param.threshold=this.editChart.param.threshold;
|
||||||
|
params.param.nullType=this.editChart.param.nullType;
|
||||||
} else {
|
} else {
|
||||||
delete params.param.threshold;
|
delete params.param.threshold;
|
||||||
}
|
}
|
||||||
@@ -993,6 +1010,9 @@
|
|||||||
}else{
|
}else{
|
||||||
this.editChart.param.threshold='';
|
this.editChart.param.threshold='';
|
||||||
}
|
}
|
||||||
|
if((this.editChart.type==='line'||this.editChart.type==='bar'||this.editChart.type==='stackArea')&&data.param){
|
||||||
|
this.editChart.param.nullType=data.param.nullType;
|
||||||
|
}
|
||||||
this.setIsOtherChart();
|
this.setIsOtherChart();
|
||||||
//this.getSuggestMetric();//获得指标列表
|
//this.getSuggestMetric();//获得指标列表
|
||||||
// 指标
|
// 指标
|
||||||
@@ -1029,7 +1049,8 @@
|
|||||||
param.url='';
|
param.url='';
|
||||||
param.threshold='';
|
param.threshold='';
|
||||||
param.valueMapping={type:'text',mapping:[{value:'',text:''}]};
|
param.valueMapping={type:'text',mapping:[{value:'',text:''}]};
|
||||||
param.legendValue={min:'off',max:'off',avg:'off',last:'off',total:'off'}
|
param.legendValue={min:'off',max:'off',avg:'off',last:'off',total:'off'};
|
||||||
|
param.nullType='connected';
|
||||||
this.$set(this.editChart, "param", param);
|
this.$set(this.editChart, "param", param);
|
||||||
this.elements = [1];
|
this.elements = [1];
|
||||||
this.elementTarget = [];
|
this.elementTarget = [];
|
||||||
@@ -1090,7 +1111,7 @@
|
|||||||
}else {
|
}else {
|
||||||
this.setIsOtherChart();
|
this.setIsOtherChart();
|
||||||
if(chartType === 'bar'||chartType === 'line'||chartType === 'stackArea'){
|
if(chartType === 'bar'||chartType === 'line'||chartType === 'stackArea'){
|
||||||
this.editChart.param={threshold:'',legendValue:{min:'off',max:'off',avg:'off',last:'off',total:'off'}}
|
this.editChart.param={nullType:this.editChart.param.nullType,threshold:'',legendValue:{min:'off',max:'off',avg:'off',last:'off',total:'off'}}
|
||||||
}
|
}
|
||||||
/*if(this.$refs.chartTag){
|
/*if(this.$refs.chartTag){
|
||||||
this.$refs.chartTag.forEach((item, index) => {
|
this.$refs.chartTag.forEach((item, index) => {
|
||||||
@@ -1163,9 +1184,11 @@
|
|||||||
}
|
}
|
||||||
if(this.editChart.type==='line'||this.editChart.type==='bar'||this.editChart.type==='stackArea'){
|
if(this.editChart.type==='line'||this.editChart.type==='bar'||this.editChart.type==='stackArea'){
|
||||||
params.param.threshold=this.editChart.param.threshold;
|
params.param.threshold=this.editChart.param.threshold;
|
||||||
|
params.param.nullType=this.editChart.param.nullType;
|
||||||
params.param.legendValue=this.editChart.param.legendValue;
|
params.param.legendValue=this.editChart.param.legendValue;
|
||||||
} else {
|
} else {
|
||||||
delete params.param.threshold;
|
delete params.param.threshold;
|
||||||
|
delete params.param.nullType;
|
||||||
}
|
}
|
||||||
//生成指标数组
|
//生成指标数组
|
||||||
const elements = [];
|
const elements = [];
|
||||||
@@ -1254,6 +1277,9 @@
|
|||||||
immediate: true,
|
immediate: true,
|
||||||
handler(n) {
|
handler(n) {
|
||||||
this.editChart = JSON.parse(JSON.stringify(n));
|
this.editChart = JSON.parse(JSON.stringify(n));
|
||||||
|
if(!n.param.nullType){
|
||||||
|
this.editChart.param.nullType='connected';
|
||||||
|
}
|
||||||
if (n.type === 'url') {
|
if (n.type === 'url') {
|
||||||
this.setIsUrl();
|
this.setIsUrl();
|
||||||
} else if(n.type === 'alertList'){
|
} else if(n.type === 'alertList'){
|
||||||
|
|||||||
Reference in New Issue
Block a user