perf:chart组件增加设置随机颜色方法
tip:当线条过多,默认颜色数量不够时须使用此方法
This commit is contained in:
@@ -174,7 +174,7 @@ const en = {
|
|||||||
lastSevenDay:'Last 7 days',
|
lastSevenDay:'Last 7 days',
|
||||||
lastThirtyDay:'Last 30 days',
|
lastThirtyDay:'Last 30 days',
|
||||||
refreshInterval:{
|
refreshInterval:{
|
||||||
never:'OFF', //'从不'
|
never:'Off', //'从不'
|
||||||
oneMinute:'1 minute', // 1 minute
|
oneMinute:'1 minute', // 1 minute
|
||||||
threeMinutes:'3 minutes', //'3分钟'
|
threeMinutes:'3 minutes', //'3分钟'
|
||||||
fiveMinutes:'5 minutes', //'5分钟'
|
fiveMinutes:'5 minutes', //'5分钟'
|
||||||
|
|||||||
@@ -171,7 +171,7 @@
|
|||||||
selectInterval(val) {
|
selectInterval(val) {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
clearInterval(this.intervalTimer);
|
clearInterval(this.intervalTimer);
|
||||||
if (val) {
|
if (val && val.value != -1) {
|
||||||
this.interval = val;
|
this.interval = val;
|
||||||
const start = new Date(this.searchTime[1]);
|
const start = new Date(this.searchTime[1]);
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<template slot="added-text">{{$t('dashboard.metricPreview.runQuery')}}</template>
|
<template slot="added-text">{{$t('dashboard.metricPreview.runQuery')}}</template>
|
||||||
</pick-time>
|
</pick-time>
|
||||||
</div>
|
</div>
|
||||||
<div style="height: 100%;width: 100%;" >
|
<div style="height: calc(100% - 50px);width: 100%;" >
|
||||||
<el-scrollbar style="height: 100%" class="el-scrollbar-large">
|
<el-scrollbar style="height: 100%" class="el-scrollbar-large">
|
||||||
<div class="expression-room right-margin" style="padding-top: 5px">
|
<div class="expression-room right-margin" style="padding-top: 5px">
|
||||||
<!--坑,这个index居然是从1开始-->
|
<!--坑,这个index居然是从1开始-->
|
||||||
@@ -292,6 +292,7 @@ instance_cpu_time_ns{app="fox", proc="widget", rev="4d3a513", env="prod", job="c
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.$refs.exploreChart.setLegend(legend);
|
this.$refs.exploreChart.setLegend(legend);
|
||||||
|
this.$refs.exploreChart.setRandomColors(series.length)
|
||||||
this.$refs.exploreChart.setSeries(series)
|
this.$refs.exploreChart.setSeries(series)
|
||||||
}
|
}
|
||||||
this.defaultChartVisible = true;
|
this.defaultChartVisible = true;
|
||||||
@@ -511,7 +512,7 @@ instance_cpu_time_ns{app="fox", proc="widget", rev="4d3a513", env="prod", job="c
|
|||||||
|
|
||||||
.explore .chart-room {
|
.explore .chart-room {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 500px
|
height: 400px
|
||||||
}
|
}
|
||||||
|
|
||||||
.explore .chart-view, .table-view {
|
.explore .chart-view, .table-view {
|
||||||
|
|||||||
@@ -20,10 +20,10 @@
|
|||||||
import echarts from 'echarts';
|
import echarts from 'echarts';
|
||||||
import chartDataFormat from "../../../charts/chartDataFormat";
|
import chartDataFormat from "../../../charts/chartDataFormat";
|
||||||
import loading from "../../../common/loading";
|
import loading from "../../../common/loading";
|
||||||
import uuidv1 from "uuid/v1";
|
|
||||||
import chartConfig from './chartConfig'
|
import chartConfig from './chartConfig'
|
||||||
import bus from "../../../../libs/bus";
|
import bus from "../../../../libs/bus";
|
||||||
import EleResize from "../../../common/js/divResize";
|
import EleResize from "../../../common/js/divResize";
|
||||||
|
import {randomcolor} from "../../../common/js/radomcolor/randomcolor";
|
||||||
export default {
|
export default {
|
||||||
name: "chart",
|
name: "chart",
|
||||||
components:{
|
components:{
|
||||||
@@ -41,9 +41,10 @@
|
|||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
chart:null,
|
chart:null,
|
||||||
option:{},
|
option:null,
|
||||||
chartId: this.name + new uuidv1()+'-'+new Date().getTime(),
|
chartId: this.name + '-'+this.guid()+'-'+new Date().getTime(),
|
||||||
legend:[],
|
legend:[],
|
||||||
|
colors:chartConfig.getBgColorList(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -86,7 +87,7 @@
|
|||||||
if (this.tooltipFormatter) {
|
if (this.tooltipFormatter) {
|
||||||
this.modifyOption('tooltip', 'formatter', this.tooltipFormatter)
|
this.modifyOption('tooltip', 'formatter', this.tooltipFormatter)
|
||||||
} else {
|
} else {
|
||||||
//this.modifyOption('tooltip', 'formatter', this.defaultTooltipFormatter)
|
this.modifyOption('tooltip', 'formatter', this.defaultTooltipFormatter)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.chartType == 'line'){
|
if(this.chartType == 'line'){
|
||||||
@@ -140,7 +141,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getBgColor:function(index){
|
getBgColor:function(index){
|
||||||
let color=chartConfig.getBgColorList()[index];
|
let color=this.colors[index];
|
||||||
return color;
|
return color;
|
||||||
},
|
},
|
||||||
clickLegend(legendName,index){
|
clickLegend(legendName,index){
|
||||||
@@ -245,12 +246,27 @@
|
|||||||
let unit=chartDataFormat.getUnit(5);
|
let unit=chartDataFormat.getUnit(5);
|
||||||
return unit.compute(value,index);
|
return unit.compute(value,index);
|
||||||
},
|
},
|
||||||
|
setRandomColors:function(num){
|
||||||
|
let colors=[];
|
||||||
|
for(let i=0;i<num;i++){
|
||||||
|
colors.push(randomcolor())
|
||||||
|
}
|
||||||
|
this.colors=Object.assign([],colors)
|
||||||
|
this.option.color=colors;
|
||||||
|
},
|
||||||
startLoading:function(){
|
startLoading:function(){
|
||||||
this.$refs.loading.startLoading();
|
this.$refs.loading.startLoading();
|
||||||
},
|
},
|
||||||
endLoading:function(){
|
endLoading:function(){
|
||||||
this.$refs.loading.endLoading();
|
this.$refs.loading.endLoading();
|
||||||
}
|
},
|
||||||
|
guid() {
|
||||||
|
function S4() {
|
||||||
|
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.chart=echarts.init(document.getElementById(this.chartId));
|
this.chart=echarts.init(document.getElementById(this.chartId));
|
||||||
|
|||||||
Reference in New Issue
Block a user