12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073 |
- <template>
- <div class="detail_box">
- <div v-if="AnalystData.grpc" style="border-bottom:1px dashed #eee;padding-bottom:20px">
- <div class='titlesty'>grpc信息</div>
- <div style='text-indent: 18px'>
- <div id='main1' class="echartsbox" v-loading="loading" style="width:100%;height:300px;"></div>
- </div>
- </div>
- <div v-if="AnalystData.http" style="border-bottom:1px dashed #eee;padding-bottom:20px">
- <div class='titlesty'>https信息</div>
- <div style='text-indent: 18px'>
- <div id='main2' class="echartsbox" style='width:100%;height:300px'></div>
- </div>
- </div>
- <div v-if="AnalystData.kafka" style="border-bottom:1px dashed #eee;padding-bottom:20px">
- <div class='titlesty'>kafka信息</div>
- <div style='text-indent: 18px'>
- <div id='main3' class="echartsbox" style='width:100%;height:300px'></div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import resize from './mixins/resize'
- import moment from 'moment'
- export default {
- mixins: [resize],
- data(){
- return{
- queryParams:{
- start_time:1699941690,
- end_time:1699945290,
- // app_alias:'UNSET',
- // service_name:'frontend',
- app_alias:'',
- service_name:'',
- percentile:0.95
- },
- AnalystData:{},
- // topoUrl:'http://observe-front.cestong.com.cn',
- topoUrl:'',
- httpChart:null,
- grpcChart:null,
- kafkaChart:null,
- app_alias:'',
- }
- },
- watch:{
- // option:{
- // handler(newVal,oldVal){
- // if (this.chart) {
- // if (newVal) {
- // this.chart.setOption(newVal);
- // } else {
- // this.chart.setOption(oldVal);
- // }
- // }
- // },
- // deep: true
- // },
- },
- created(){
- this.queryParams.start_time = this.GetRequest().start_time; //点击应用拓扑节点获取到id
- this.queryParams.end_time = this.GetRequest().end_time; //点击应用拓扑节点获取到id
- this.queryParams.app_alias = this.GetRequest().app_alias; //点击应用拓扑节点获取到id
- this.app_alias = this.GetRequest().app_alias;
- this.queryParams.service_name = this.GetRequest().service_name; //点击应用拓扑节点获取到id
- this.queryParams.percentile = this.GetRequest().percentile; //点击应用拓扑节点获取到id
- },
- mounted(){
- if (this.queryParams.app_alias != undefined) {
- this.getList();
- }
- setTimeout(()=>{
- if(this.AnalystData.grpc != undefined){
- this.grpcInitChart(this.AnalystData.grpc)
- }
- if(this.AnalystData.http != undefined){
- this.httpInitChart(this.AnalystData.http)
- }
- if(this.AnalystData.kafka != undefined){
- this.kafkaInitChart(this.AnalystData.kafka)
- }
- // var iframeH = document.getElementById("detail_box").scrollHeight;
- // console.log(iframeH,'iframeH')
- // this.h=iframeH;
- // window.parent.postMessage({ data: iframeH }, "*");
- // var screenH = document.documentElement.clientHeight;
- // this.h = screenH;
- },2000)
- },
- methods:{
- getList() {
- this.loading = true
- // this.topoUrl = window.location.host;
- this.$http({
- // url: `${this.topoUrl}/re/api/v1/service/side`,
- url: '/re/api/v1/service/side',
- method: "get",
- params: this.queryParams
- }).then(res => {
- console.log(res,'res====')
- if(res.data.code == 200){
- console.log(res,'节点详情')
- console.log(res.data.data,'front 获取节点的信息')
- this.loading = false;
- this.AnalystData= res.data.data;
- }
- });
- },
- GetRequest() {
- var url = window.location.href; //获取url中"?"符后的字串
- // var url = `http://123.56.75.55:8208/#/iframe/nodeDetail?endpoint_id=1&id=81&ip=5.3.4.5&cmdb_tag=1`;
- var theRequest = new Object();
- if (url.indexOf("?") != -1) {
- // var str = url.substring(1);
- var str = url.substring(url.indexOf('?')+1,url.length);
- var strs = str.split("&");
- for (var i = 0; i < strs.length; i++) {
- theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
- }
- }
- return theRequest;
- },
- grpcInitChart(tmpData) {
- console.log('grpc是否有渲染')
- let _this = this;
- this.grpcChart = this.$echarts5.init(document.getElementById('main1'))
- console.log(this.grpcChart ,'echarts=====================')
- this.grpcChart.clear();
- let option = {
- title: {
- text: 'Latency',
- subtext: 'ms',
- textStyle:{
- fontSize:14
- },
- },
- grid: {
- left: '5%',
- right: '7%',
- bottom: '7%',
- containLabel: true
- },
- tooltip: {
- showDelay: 0,
- formatter: function (params) {
- let newParams = moment(params.data[0]).format('YYYY-MM-DD HH:mm:ss');
- let time = newParams+"<br/>"+ params.data[1]+"ms"
- return time;
- },
- axisPointer: {
- show: true,
- type: 'cross',
- lineStyle: {
- type: 'dashed',
- width: 1
- }
- }
- },
- toolbox: {
- show:true,
- showTitle: true,
- feature: {
- rect: {
- show: true,
- title: 'Trace选择'
- },
- },
- left:"57%", //组件离容器左侧的距离,'left', 'center', 'right','20%'
- top:"3%", //组件离容器上侧的距离,'top', 'middle', 'bottom','20%'
- right:"auto", //组件离容器右侧的距离,'20%'
- bottom:"auto",
- },
- brush: {
- toolbox: ['rect'],
- xAxisIndex: 0,
- throttleType:'debounce',
- throttleDelay:600
- },
- legend: {
- data: ['Success', 'Failed'],
- left: 'center',
- bottom: -2,
- itemGap: 100,
- textStyle: {//文字颜色
- fontSize: 12,
- padding:[0,3],//文字与图形之间的左右间距
- rich:{
- labelName:{
- fontSize:14,
- color:'#333',
- fontWeight:500
- }
- }
- },
- formatter: function (params) {
- // 获取legend显示内容
- let data = tmpData;
- let sl,fl;
- if(data.success!=null){
- sl = tmpData.success.length;
- }else{
- sl = 0
- }
- if( data.failed!=null){
- fl = tmpData.failed.length;
- }else{
- fl = 0
- }
- var target;
- if(params == 'Success'){
- target = sl;
- }else if(params == 'Failed'){
- target = fl;
- }
- return target != undefined?params +' '+`{labelName|${target}}`:params
- },
- },
- xAxis: [
- {
- // type: 'category',
- type:'time',
- scale: true,
- gridIndex:0,
- axisLabel: {
- textStyle: {
- fontSize: 12,
- textAlign:'center'
- },
- formatter: function(params) {
- let newParams = moment(params).format('YYYY-MM-DD HH:mm:ss');
- let newArr = newParams.split(' ')
- let time = newArr[0] + "\n" + newArr[1]
- return time;
- }
- },
- splitLine: {
- show: true
- },
- }
- ],
- yAxis: [
- {
- type: 'value',
- scale: true,
- gridIndex:0,
- axisLabel: {
- formatter: '{value}'
- },
- axisLine:{
- show:true
- },
- axisTick:{
- show:true
- },
- splitLine: {
- show: true
- },
- data:[0,2500,5000,7500,10000],
- }
- ],
- series: [
- {
- name: 'Success',
- type: 'scatter',
- emphasis: {
- focus: 'series'
- },
- //设置散点图样式
- itemStyle:{
- color:'#13ce66'
- },
- symbolSize:10,//设置散点的大小
- data:tmpData.success,
- markArea: {
- silent: true,
- itemStyle: {
- color: 'transparent',
- borderWidth: 0,
- borderType: 'dashed'
- },
- },
- },
- {
- name: 'Failed',
- type: 'scatter',
- emphasis: {
- focus: 'series'
- },
- itemStyle:{
- color:'#ff4949'
- },
- // prettier-ignore
- data:tmpData.failed,
- // data:[],
- markArea: {
- silent: true,
- itemStyle: {
- color: 'transparent',
- borderWidth: 0,
- borderType: 'dashed'
- },
- },
- }
- ]
- }
- this.grpcChart.setOption(option,true)
- this.grpcChart.off("brushSelected");
- //框选选择数据
- this.grpcChart.on('brushSelected', (params) => {
- console.log(params,'框选事件')
- var brushComponent = params.batch[0];
- let successIndexList=[];
- let failIndexList =[];
- let successList=[];
- let failList=[];
- if(brushComponent.selected.length>1){
- successIndexList = brushComponent.selected[0].dataIndex
- failIndexList = brushComponent.selected[1].dataIndex
- }else{
- if(brushComponent.selected[0].seriesName !=undefined){
- if(brushComponent.selected[0].seriesName =="Failed"){
- failIndexList = brushComponent.selected[0].dataIndex
- }else{
- successIndexList = brushComponent.selected[0].dataIndex
- }
- }
- }
- if(successIndexList.length>0){
- for(let i = 0;i<tmpData.success.length;i++){
- for(let j=0;j<successIndexList.length;j++){
- if(successIndexList[j] == i){
- successList.push(tmpData.success[i])
- }
- }
- }
- }
- if(failIndexList.length>0){
- for(let k=0;k<tmpData.failed.length;k++){
- for(let l=0;l<failIndexList.length;l++){
- if(failIndexList[l] == k){
- failList.push(tmpData.failed[k])
- }
- }
- }
- }
- let arr =successList.concat(failList);
- let dataRange={};
- if(arr.length>0){
- let timeArr =[];
- let valueArr=[];
- for(let m=0;m<arr.length;m++){
- timeArr.push(Math.round(Date.parse(arr[m][0])/1000));
- valueArr.push(arr[m][1]);
- }
- let minTime = Math.min(...timeArr);
- let maxTime = Math.max(...timeArr);
- let minValue = Math.min(...valueArr);
- let maxValue = Math.max(...valueArr)
- if(minTime == maxTime){
- minTime = minTime-1;
- maxTime = maxTime+1;
- }
- if(minValue == maxValue){
- minValue = minValue-1;
- maxValue = maxValue+1;
- }
- //看是否有成功节点
- if(successIndexList.length>0){
- dataRange = {
- start_time:minTime,
- end_time:maxTime,
- min_duration:minValue,
- max_duration:maxValue,
- app_alias:this.app_alias
- }
- }else{
- dataRange = {
- start_time:minTime,
- end_time:maxTime,
- min_duration:minValue,
- max_duration:maxValue,
- failed:true,
- app_alias:this.app_alias
- }
- }
-
- let timeAndDuration = JSON.stringify(dataRange);
- // this.$router.push({
- // path:'/latency/index',
- // query:{
- // data:timeAndDuration
- // }
- // })
- let href = this.$router.resolve({
- path:'/latency/index',
- query:{
- data:timeAndDuration
- }
- })
- console.log(href)
- window.open(window.location.origin+"/"+href.href,"_blank")
- this.grpcChart.dispatchAction({
- type: 'brush',//选择action行为
- areas:[]//areas表示选框的集合,此时为空即可。
- });
- }
-
- });
- // this.chart.on("legendinverseselect", (params) => {
- // console.log(params)
- // })
- },
- httpInitChart(tmpData) {
- let _this = this;
- this.httpChart = this.$echarts5.init(document.getElementById('main2'))
- console.log(this.httpChart ,'echarts=====================')
- // var myEchart = this.$el.getElementsByClassName('echartsbox');
- // for(var i = 0; i < myEchart.length; i++){
- // var myChart = this.$echarts5.init(myEchart[i]);
- // }
- this.httpChart.clear();
- let option = {
- title: {
- text: 'Latency',
- subtext: 'ms',
- textStyle:{
- fontSize:14
- },
- },
- grid: {
- left: '3%',
- right: '7%',
- bottom: '7%',
- containLabel: true
- },
- tooltip: {
- showDelay: 0,
- formatter: function (params) {
- let newParams = moment(params.data[0]).format('YYYY-MM-DD HH:mm:ss');
- let time = newParams+"<br/>"+ params.data[1]+"ms"
- return time;
- },
- axisPointer: {
- show: true,
- type: 'cross',
- lineStyle: {
- type: 'dashed',
- width: 1
- }
- }
- },
- toolbox: {
- show:true,
- showTitle: true,
- feature: {
- rect: {
- show: true,
- title: 'Trace选择'
- },
- },
- left:"57%", //组件离容器左侧的距离,'left', 'center', 'right','20%'
- top:"3%", //组件离容器上侧的距离,'top', 'middle', 'bottom','20%'
- right:"auto", //组件离容器右侧的距离,'20%'
- bottom:"auto",
- },
- brush: {
- toolbox: ['rect'],
- xAxisIndex: 0,
- throttleType:'debounce',
- throttleDelay:600
- },
- legend: {
- data: ['Success', 'Failed'],
- left: 'center',
- bottom: -2,
- itemGap: 100,
- textStyle: {//文字颜色
- fontSize: 12,
- padding:[0,3],//文字与图形之间的左右间距
- rich:{
- labelName:{
- fontSize:14,
- color:'#333',
- fontWeight:500
- }
- }
- },
- formatter: function (params) {
- // 获取legend显示内容
- let data = tmpData;
- let sl,fl;
- if(data.success!=null){
- sl = tmpData.success.length;
- }else{
- sl = 0
- }
- if( data.failed!=null){
- fl = tmpData.failed.length;
- }else{
- fl = 0
- }
- var target;
- if(params == 'Success'){
- target = sl;
- }else if(params == 'Failed'){
- target = fl;
- }
- return target != undefined?params +' '+`{labelName|${target}}`:params
- },
- },
- xAxis: [
- {
- // type: 'category',
- type:'time',
- scale: true,
- gridIndex:0,
- axisLabel: {
- textStyle: {
- fontSize: 12,
- textAlign:'center'
- },
- formatter: function(params) {
- let newParams = moment(params).format('YYYY-MM-DD HH:mm:ss');
- let newArr = newParams.split(' ')
- let time = newArr[0] + "\n" + newArr[1]
- return time;
- }
- },
- splitLine: {
- show: true
- },
- }
- ],
- yAxis: [
- {
- type: 'value',
- scale: true,
- gridIndex:0,
- axisLabel: {
- formatter: '{value}'
- },
- axisLine:{
- show:true
- },
- axisTick:{
- show:true
- },
- splitLine: {
- show: true
- },
- data:[0,2500,5000,7500,10000],
- }
- ],
- series: [
- {
- name: 'Success',
- type: 'scatter',
- emphasis: {
- focus: 'series'
- },
- //设置散点图样式
- itemStyle:{
- color:'#13ce66'
- },
- symbolSize:10,//设置散点的大小
- data:tmpData.success,
- markArea: {
- silent: true,
- itemStyle: {
- color: 'transparent',
- borderWidth: 0,
- borderType: 'dashed'
- },
- },
- },
- {
- name: 'Failed',
- type: 'scatter',
- emphasis: {
- focus: 'series'
- },
- itemStyle:{
- color:'#ff4949'
- },
- // prettier-ignore
- data:tmpData.failed,
- // data:[],
- markArea: {
- silent: true,
- itemStyle: {
- color: 'transparent',
- borderWidth: 0,
- borderType: 'dashed'
- },
- },
- }
- ]
- }
- this.httpChart.setOption(option,true)
- this.httpChart.off("brushSelected");
- //框选选择数据
- this.httpChart.on('brushSelected', (params) => {
- console.log(params,'框选事件')
- var brushComponent = params.batch[0];
- let successIndexList=[];
- let failIndexList =[];
- let successList=[];
- let failList=[];
- if(brushComponent.selected.length>1){
- successIndexList = brushComponent.selected[0].dataIndex
- failIndexList = brushComponent.selected[1].dataIndex
- }else{
- if(brushComponent.selected[0].seriesName !=undefined){
- if(brushComponent.selected[0].seriesName =="Failed"){
- failIndexList = brushComponent.selected[0].dataIndex
- }else{
- successIndexList = brushComponent.selected[0].dataIndex
- }
- }
- }
- if(successIndexList.length>0){
- for(let i = 0;i<tmpData.success.length;i++){
- for(let j=0;j<successIndexList.length;j++){
- if(successIndexList[j] == i){
- successList.push(tmpData.success[i])
- }
- }
- }
- }
- if(failIndexList.length>0){
- for(let k=0;k<tmpData.failed.length;k++){
- for(let l=0;l<failIndexList.length;l++){
- if(failIndexList[l] == k){
- failList.push(tmpData.failed[k])
- }
- }
- }
- }
- let arr =successList.concat(failList);
- let dataRange={};
- if(arr.length>0){
- let timeArr =[];
- let valueArr=[];
- for(let m=0;m<arr.length;m++){
- timeArr.push(Math.round(Date.parse(arr[m][0])/1000));
- valueArr.push(arr[m][1]);
- }
- let minTime = Math.min(...timeArr);
- let maxTime = Math.max(...timeArr);
- let minValue = Math.min(...valueArr);
- let maxValue = Math.max(...valueArr)
- if(minTime == maxTime){
- minTime = minTime-1;
- maxTime = maxTime+1;
- }
- if(minValue == maxValue){
- minValue = minValue-1;
- maxValue = maxValue+1;
- }
- //看是否有成功节点
- if(successIndexList.length>0){
- dataRange = {
- start_time:minTime,
- end_time:maxTime,
- min_duration:minValue,
- max_duration:maxValue,
- app_alias:this.app_alias
- }
- }else{
- dataRange = {
- start_time:minTime,
- end_time:maxTime,
- min_duration:minValue,
- max_duration:maxValue,
- failed:true,
- app_alias:this.app_alias
- }
- }
-
- let timeAndDuration = JSON.stringify(dataRange);
- // this.$router.push({
- // path:'/latency/index',
- // query:{
- // data:timeAndDuration
- // }
- // })
- let href = this.$router.resolve({
- path:'/latency/index',
- query:{
- data:timeAndDuration
- }
- })
- console.log(href)
- window.open(window.location.origin+"/"+href.href,"_blank")
- this.httpChart.dispatchAction({
- type: 'brush',//选择action行为
- areas:[]//areas表示选框的集合,此时为空即可。
- });
- }
-
- });
- // this.chart.on("legendinverseselect", (params) => {
- // console.log(params)
- // })
- },
- kafkaInitChart(tmpData) {
- let _this = this;
- this.kafkaChart = this.$echarts5.init(document.getElementById('main3'))
- console.log(this.kafkaChart ,'echarts=====================')
- // var myEchart = this.$el.getElementsByClassName('echartsbox');
- // for(var i = 0; i < myEchart.length; i++){
- // var myChart = this.$echarts5.init(myEchart[i]);
- // }
- this.kafkaChart.clear();
- let option = {
- title: {
- text: 'Latency',
- subtext: 'ms',
- textStyle:{
- fontSize:14
- },
- },
- grid: {
- left: '3%',
- right: '7%',
- bottom: '7%',
- containLabel: true
- },
- tooltip: {
- showDelay: 0,
- formatter: function (params) {
- let newParams = moment(params.data[0]).format('YYYY-MM-DD HH:mm:ss');
- let time = newParams+"<br/>"+ params.data[1]+"ms"
- return time;
- },
- axisPointer: {
- show: true,
- type: 'cross',
- lineStyle: {
- type: 'dashed',
- width: 1
- }
- }
- },
- toolbox: {
- show:true,
- showTitle: true,
- feature: {
- rect: {
- show: true,
- title: 'Trace选择'
- },
- },
- left:"57%", //组件离容器左侧的距离,'left', 'center', 'right','20%'
- top:"3%", //组件离容器上侧的距离,'top', 'middle', 'bottom','20%'
- right:"auto", //组件离容器右侧的距离,'20%'
- bottom:"auto",
- },
- brush: {
- toolbox: ['rect'],
- xAxisIndex: 0,
- throttleType:'debounce',
- throttleDelay:600
- },
- legend: {
- data: ['Success', 'Failed'],
- left: 'center',
- bottom: -2,
- itemGap: 100,
- textStyle: {//文字颜色
- fontSize: 12,
- padding:[0,3],//文字与图形之间的左右间距
- rich:{
- labelName:{
- fontSize:14,
- color:'#333',
- fontWeight:500
- }
- }
- },
- formatter: function (params) {
- // 获取legend显示内容
- let data = tmpData;
- let sl,fl;
- if(data.success!=null){
- sl = tmpData.success.length;
- }else{
- sl = 0
- }
- if( data.failed!=null){
- fl = tmpData.failed.length;
- }else{
- fl = 0
- }
- var target;
- if(params == 'Success'){
- target = sl;
- }else if(params == 'Failed'){
- target = fl;
- }
- return target != undefined?params +' '+`{labelName|${target}}`:params
- },
- },
- xAxis: [
- {
- // type: 'category',
- type:'time',
- scale: true,
- gridIndex:0,
- axisLabel: {
- textStyle: {
- fontSize: 12,
- textAlign:'center'
- },
- formatter: function(params) {
- let newParams = moment(params).format('YYYY-MM-DD HH:mm:ss');
- let newArr = newParams.split(' ')
- let time = newArr[0] + "\n" + newArr[1]
- return time;
- }
- },
- splitLine: {
- show: true
- },
- }
- ],
- yAxis: [
- {
- type: 'value',
- scale: true,
- gridIndex:0,
- axisLabel: {
- formatter: '{value}'
- },
- axisLine:{
- show:true
- },
- axisTick:{
- show:true
- },
- splitLine: {
- show: true
- },
- data:[0,2500,5000,7500,10000],
- }
- ],
- series: [
- {
- name: 'Success',
- type: 'scatter',
- emphasis: {
- focus: 'series'
- },
- //设置散点图样式
- itemStyle:{
- color:'#13ce66'
- },
- symbolSize:10,//设置散点的大小
- data:tmpData.success,
- markArea: {
- silent: true,
- itemStyle: {
- color: 'transparent',
- borderWidth: 0,
- borderType: 'dashed'
- },
- },
- },
- {
- name: 'Failed',
- type: 'scatter',
- emphasis: {
- focus: 'series'
- },
- itemStyle:{
- color:'#ff4949'
- },
- // prettier-ignore
- data:tmpData.failed,
- // data:[],
- markArea: {
- silent: true,
- itemStyle: {
- color: 'transparent',
- borderWidth: 0,
- borderType: 'dashed'
- },
- },
- }
- ]
- }
- this.kafkaChart.setOption(option,true)
- this.kafkaChart.off("brushSelected");
- //框选选择数据
- this.kafkaChart.on('brushSelected', (params) => {
- console.log(params,'框选事件')
- var brushComponent = params.batch[0];
- let successIndexList=[];
- let failIndexList =[];
- let successList=[];
- let failList=[];
- if(brushComponent.selected.length>1){
- successIndexList = brushComponent.selected[0].dataIndex
- failIndexList = brushComponent.selected[1].dataIndex
- }else{
- if(brushComponent.selected[0].seriesName !=undefined){
- if(brushComponent.selected[0].seriesName =="Failed"){
- failIndexList = brushComponent.selected[0].dataIndex
- }else{
- successIndexList = brushComponent.selected[0].dataIndex
- }
- }
- }
- if(successIndexList.length>0){
- for(let i = 0;i<tmpData.success.length;i++){
- for(let j=0;j<successIndexList.length;j++){
- if(successIndexList[j] == i){
- successList.push(tmpData.success[i])
- }
- }
- }
- }
- if(failIndexList.length>0){
- for(let k=0;k<tmpData.failed.length;k++){
- for(let l=0;l<failIndexList.length;l++){
- if(failIndexList[l] == k){
- failList.push(tmpData.failed[k])
- }
- }
- }
- }
- let arr =successList.concat(failList);
- let dataRange={};
- if(arr.length>0){
- let timeArr =[];
- let valueArr=[];
- for(let m=0;m<arr.length;m++){
- timeArr.push(Math.round(Date.parse(arr[m][0])/1000));
- valueArr.push(arr[m][1]);
- }
- let minTime = Math.min(...timeArr);
- let maxTime = Math.max(...timeArr);
- let minValue = Math.min(...valueArr);
- let maxValue = Math.max(...valueArr)
- if(minTime == maxTime){
- minTime = minTime-1;
- maxTime = maxTime+1;
- }
- if(minValue == maxValue){
- minValue = minValue-1;
- maxValue = maxValue+1;
- }
- //看是否有成功节点
- if(successIndexList.length>0){
- dataRange = {
- start_time:minTime,
- end_time:maxTime,
- min_duration:minValue,
- max_duration:maxValue,
- app_alias:this.app_alias
- }
- }else{
- dataRange = {
- start_time:minTime,
- end_time:maxTime,
- min_duration:minValue,
- max_duration:maxValue,
- failed:true,
- app_alias:this.app_alias
- }
- }
-
- let timeAndDuration = JSON.stringify(dataRange);
- // this.$router.push({
- // path:'/latency/index',
- // query:{
- // data:timeAndDuration
- // }
- // })
- let href = this.$router.resolve({
- path:'/latency/index',
- query:{
- data:timeAndDuration
- }
- })
- console.log(href)
- window.open(window.location.origin+"/"+href.href,"_blank")
- this.kafkaChart.dispatchAction({
- type: 'brush',//选择action行为
- areas:[]//areas表示选框的集合,此时为空即可。
- });
- }
-
- });
- // this.chart.on("legendinverseselect", (params) => {
- // console.log(params)
- // })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .detail_box{
- background:#fff;
- margin-top: -20px;
- .titlesty{
- font-size: 14px;
- font-weight: bold;
- height: 32px;
- line-height: 32px;
- background: rgb(238, 238, 238);
- color: rgb(51, 51, 51);
- padding-left: 20px;
- margin: 20px auto;
- padding-left: 20px;
- padding-right: 15px;
- background: #eee;
- color:#333;
- }
- }
- </style>>
|