Merge branch 'dev' of https://git.mesalab.cn/cyber-narrator/cn-ui into dev
This commit is contained in:
@@ -5,7 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
import { format } from 'echarts'
|
import { format } from 'echarts'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
export const chartColor = ['#73A0FA', '#73DEB3', '#F7C739', '#EB7E65', '#FFAB67', '#A285D2', '#FFA8CB']
|
||||||
|
export function getChartColor (index) {
|
||||||
|
return chartColor[index % chartColor.length]
|
||||||
|
}
|
||||||
const line = {
|
const line = {
|
||||||
tooltip: {
|
tooltip: {
|
||||||
appendToBody: true,
|
appendToBody: true,
|
||||||
@@ -30,6 +33,7 @@ const line = {
|
|||||||
bottom: 45,
|
bottom: 45,
|
||||||
top: 30
|
top: 30
|
||||||
},
|
},
|
||||||
|
color: chartColor,
|
||||||
legend: {
|
legend: {
|
||||||
show: true,
|
show: true,
|
||||||
right: 30,
|
right: 30,
|
||||||
@@ -76,6 +80,7 @@ const lineWithStatistics = {
|
|||||||
yAxis: {
|
yAxis: {
|
||||||
type: 'value'
|
type: 'value'
|
||||||
},
|
},
|
||||||
|
color: chartColor,
|
||||||
grid: {
|
grid: {
|
||||||
left: 55,
|
left: 55,
|
||||||
bottom: 45,
|
bottom: 45,
|
||||||
@@ -112,6 +117,7 @@ const lineStack = {
|
|||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'time'
|
type: 'time'
|
||||||
},
|
},
|
||||||
|
color: chartColor,
|
||||||
yAxis: {
|
yAxis: {
|
||||||
type: 'value'
|
type: 'value'
|
||||||
},
|
},
|
||||||
@@ -154,6 +160,7 @@ const pieWithTable = {
|
|||||||
appendToBody: true,
|
appendToBody: true,
|
||||||
trigger: 'item'
|
trigger: 'item'
|
||||||
},
|
},
|
||||||
|
color: chartColor,
|
||||||
animation: false,
|
animation: false,
|
||||||
legend: {
|
legend: {
|
||||||
orient: 'vertical',
|
orient: 'vertical',
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ import {
|
|||||||
isEchartsWithTable,
|
isEchartsWithTable,
|
||||||
isEchartsWithStatistics,
|
isEchartsWithStatistics,
|
||||||
isMapLine,
|
isMapLine,
|
||||||
isTabs
|
isTabs,
|
||||||
|
getChartColor
|
||||||
} from '@/components/charts/chart-options'
|
} from '@/components/charts/chart-options'
|
||||||
import EchartsFrame from '@/components/charts/EchartsFrame'
|
import EchartsFrame from '@/components/charts/EchartsFrame'
|
||||||
import SingleValue from '@/components/charts/ChartSingleValue'
|
import SingleValue from '@/components/charts/ChartSingleValue'
|
||||||
@@ -338,6 +339,28 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else if (this.isEchartsWithStatistics) {
|
} else if (this.isEchartsWithStatistics) {
|
||||||
|
const queryParams = { startTime: parseInt(this.startTime / 1000), endTime: parseInt(this.endTime / 1000) }
|
||||||
|
get(replaceUrlPlaceholder(chartParams.url, queryParams)).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.statisticsData = response.data.result
|
||||||
|
const seriesTemplate = this.chartOption.series[0]
|
||||||
|
this.chartOption.series = response.data.result.map((r, i) => {
|
||||||
|
return {
|
||||||
|
...seriesTemplate,
|
||||||
|
name: r.legend,
|
||||||
|
data: r.values.map(v => [Number(v[0]) * 1000, Number(v[1])]),
|
||||||
|
lineStyle: {
|
||||||
|
color: getChartColor[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.myChart.setOption(this.chartOption)
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.myChart.resize()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
const queryParams = { startTime: parseInt(this.startTime / 1000), endTime: parseInt(this.endTime / 1000) }
|
const queryParams = { startTime: parseInt(this.startTime / 1000), endTime: parseInt(this.endTime / 1000) }
|
||||||
get(replaceUrlPlaceholder(chartParams.url, queryParams)).then(response => {
|
get(replaceUrlPlaceholder(chartParams.url, queryParams)).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
|
|||||||
Reference in New Issue
Block a user