@@ -0,0 +1 @@ | |||||
<div :id="id" class="chart"></div> |
@@ -0,0 +1,229 @@ | |||||
import * as echarts from 'echarts'; | |||||
import elementResizeDetectorMaker from 'element-resize-detector'; | |||||
export default { | |||||
props: { | |||||
id: { | |||||
type: String, | |||||
default: 'bar' | |||||
}, | |||||
data: { | |||||
type: Array, | |||||
default: function () { | |||||
return [ | |||||
{ | |||||
name: '1月', | |||||
value: '10' | |||||
}, | |||||
{ | |||||
name: '2月', | |||||
value: '19' | |||||
} | |||||
]; | |||||
} | |||||
}, | |||||
unit: { | |||||
type: String, | |||||
default: '单位:万元' | |||||
}, | |||||
color: { | |||||
type: Array, | |||||
default: function () { | |||||
return ['rgba(15, 252, 252, 1)', 'rgba(53, 197, 124, 1)'] | |||||
} | |||||
} | |||||
}, | |||||
data () { | |||||
return { | |||||
chart: null | |||||
}; | |||||
}, | |||||
mounted () { | |||||
this.initChart(); | |||||
}, | |||||
computed: { | |||||
}, | |||||
methods: { | |||||
// 设置监听器 页面尺寸变化重新绘制图表 | |||||
initResizeCallBack () { | |||||
const erd = elementResizeDetectorMaker(); | |||||
erd.listenTo(document.getElementById(this.id), () => { | |||||
this.$nextTick(() => { | |||||
this.chart.resize(); | |||||
}); | |||||
}); | |||||
}, | |||||
initChart () { | |||||
this.chart = echarts.init(document.getElementById(this.id)); | |||||
this.chartSetOption(); | |||||
}, | |||||
chartSetOption () { | |||||
let xAxisData = []; | |||||
let data = []; | |||||
this.data.forEach(item => { | |||||
xAxisData.push(item.name) | |||||
data.push(item.value) | |||||
}); | |||||
const option = { | |||||
color: ["#3398DB"], | |||||
tooltip: { | |||||
trigger: "axis", | |||||
axisPointer: { | |||||
type: "line", | |||||
lineStyle: { | |||||
opacity: 0, | |||||
}, | |||||
} | |||||
}, | |||||
legend: { | |||||
data: ["直接访问", "背景"], | |||||
show: false, | |||||
}, | |||||
grid: { | |||||
left: "0%", | |||||
right: "0%", | |||||
bottom: "5%", | |||||
top: "15%", | |||||
containLabel: true, | |||||
z: 22, | |||||
}, | |||||
xAxis: [ | |||||
{ | |||||
splitArea: { | |||||
show: false, | |||||
areaStyle: { | |||||
color: ['RGBA(13, 31, 64, 1)'] | |||||
} | |||||
}, | |||||
splitLine: { | |||||
show: false, | |||||
lineStyle: { | |||||
color: ['rgba(18, 40, 83, 1)'], | |||||
width: 100 | |||||
} | |||||
}, | |||||
type: "category", | |||||
gridIndex: 0, | |||||
data: xAxisData, | |||||
axisTick: { | |||||
alignWithLabel: true, | |||||
}, | |||||
axisLine: { | |||||
lineStyle: { | |||||
color: "#0c3b71", | |||||
}, | |||||
}, | |||||
axisLabel: { | |||||
show: true, | |||||
color: 'rgba(185, 211, 235, 1)' | |||||
}, | |||||
}, | |||||
], | |||||
yAxis: [ | |||||
{ | |||||
type: "value", | |||||
name: this.unit, | |||||
nameTextStyle: { | |||||
color: 'rgba(185, 211, 235, 1)' | |||||
}, | |||||
axisLabel: { | |||||
formatter: "{value}", | |||||
textStyle: { | |||||
color: "rgba(185, 211, 235, 1)", | |||||
}, | |||||
}, | |||||
axisLine: { | |||||
lineStyle: { | |||||
color: "#27b4c2", | |||||
}, | |||||
}, | |||||
axisTick: { | |||||
show: false, | |||||
}, | |||||
splitLine: { | |||||
show: true, | |||||
lineStyle: { | |||||
color: "#11366e", | |||||
}, | |||||
}, | |||||
}, | |||||
{ | |||||
type: "value", | |||||
gridIndex: 0, | |||||
max: 100, | |||||
splitNumber: 12, | |||||
splitLine: { | |||||
show: false, | |||||
}, | |||||
axisLine: { | |||||
show: false, | |||||
}, | |||||
axisTick: { | |||||
show: false, | |||||
}, | |||||
axisLabel: { | |||||
show: false, | |||||
} | |||||
}, | |||||
], | |||||
series: [ | |||||
{ | |||||
name: "合格率", | |||||
type: "bar", | |||||
barWidth: 15, | |||||
xAxisIndex: 0, | |||||
yAxisIndex: 0, | |||||
showBackground: false, | |||||
backgroundStyle: { | |||||
shadowBlur: 10, | |||||
color: 'rgba(18, 40, 83, 1)' | |||||
}, | |||||
itemStyle: { | |||||
normal: { | |||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ | |||||
{ | |||||
offset: 0, | |||||
color: this.color[0], | |||||
}, | |||||
{ | |||||
offset: 1, | |||||
color: this.color[1], | |||||
}, | |||||
]), | |||||
}, | |||||
}, | |||||
data: data, | |||||
zlevel: 11, | |||||
}, | |||||
{ | |||||
type: 'custom', | |||||
itemStyle: { | |||||
color: 'rgba(18, 40, 83, 0.4)' | |||||
}, | |||||
renderItem: function (params, api) { | |||||
//获取对应类目的axisTick中心点坐标 | |||||
var start = api.coord([api.value(0)]); | |||||
//通过坐标系的宽度和类目数,计算单个类目的背景 | |||||
var width = (params.coordSys.width / 7) * 0.6; | |||||
return { | |||||
type: 'rect', | |||||
shape: { | |||||
// 相对左上角坐标 | |||||
x: start[0] - width / 2, | |||||
y: params.coordSys.y, | |||||
width: width, | |||||
height: params.coordSys.height, | |||||
}, | |||||
style: api.style() | |||||
}; | |||||
}, | |||||
data: [100, 100, 100, 100, 100, 100, 100] | |||||
}, | |||||
], | |||||
};; | |||||
this.chart.setOption(option); | |||||
this.initResizeCallBack(); | |||||
} | |||||
} | |||||
}; |
@@ -0,0 +1,6 @@ | |||||
.chart { | |||||
overflow: visible; | |||||
width: 100%; | |||||
height: 100%; | |||||
z-index: 2; | |||||
} |
@@ -0,0 +1,3 @@ | |||||
<template src='./index.html'/> | |||||
<script lang='js' src='./index.js'></script> | |||||
<style lang='scss' src='./index.scss' scoped></style> |
@@ -1,4 +1,12 @@ | |||||
<Pannel> | |||||
<Pannel title="资金往来敏感词预警分析" height="305"> | |||||
<div class="full"> | |||||
<div class="top"> | |||||
<PannelTabs @change="tabChange"></PannelTabs> | |||||
</div> | |||||
<div class="buttom"> | |||||
<Bar id="bar2" :color="['rgba(134, 91, 252, 1)', 'rgba(49, 129, 246, 1)']"></Bar> | |||||
</div> | |||||
</div> | |||||
</Pannel> | </Pannel> |
@@ -1,7 +1,10 @@ | |||||
import Pannel from '@/components/pannel/index.vue'; | import Pannel from '@/components/pannel/index.vue'; | ||||
import Bar from '@/components/charts/bar/index.vue'; | |||||
import PannelTabs from '@/components/pannel-tabs/index.vue'; | |||||
export default { | export default { | ||||
components: { | components: { | ||||
PannelTabs, | |||||
Bar, | |||||
Pannel | Pannel | ||||
}, | }, | ||||
data () { | data () { | ||||
@@ -13,5 +16,8 @@ export default { | |||||
mounted () { | mounted () { | ||||
}, | }, | ||||
methods: { | methods: { | ||||
tabChange () { | |||||
} | |||||
} | } | ||||
}; | }; |
@@ -0,0 +1,17 @@ | |||||
.full { | |||||
display: flex; | |||||
flex-direction: column; | |||||
.top { | |||||
height: 50px !important; | |||||
width: 100%; | |||||
display: flex !important; | |||||
align-items: center !important; | |||||
justify-content: flex-end; | |||||
} | |||||
.buttom { | |||||
flex: 1; | |||||
width: 100%; | |||||
} | |||||
} |
@@ -1,4 +1,4 @@ | |||||
<Pannel> | |||||
<Pannel title="资金支出大额预警分析" height="305"> | |||||
<Bar></Bar> | |||||
</Pannel> | </Pannel> |
@@ -1,7 +1,9 @@ | |||||
import Pannel from '@/components/pannel/index.vue'; | import Pannel from '@/components/pannel/index.vue'; | ||||
import Bar from '@/components/charts/bar/index.vue'; | |||||
export default { | export default { | ||||
components: { | components: { | ||||
Bar, | |||||
Pannel | Pannel | ||||
}, | }, | ||||
data () { | data () { | ||||
@@ -13,8 +13,8 @@ export const comps = { | |||||
}, | }, | ||||
'2': { | '2': { | ||||
'left': [ | 'left': [ | ||||
'', | |||||
'', | |||||
'Left12', | |||||
'Left22', | |||||
'' | '' | ||||
], | ], | ||||
'right': [ | 'right': [ | ||||
@@ -8,6 +8,8 @@ import Right11 from './comps/right/top/1/index.vue'; | |||||
import Right21 from './comps/right/middle/1/index.vue'; | import Right21 from './comps/right/middle/1/index.vue'; | ||||
import Right31 from './comps/right/bottom/1/index.vue'; | import Right31 from './comps/right/bottom/1/index.vue'; | ||||
import Left12 from './comps/left/top/2/index.vue'; | |||||
import Left22 from './comps/left/middle/2/index.vue'; | |||||
import Right12 from './comps/right/top/2/index.vue'; | import Right12 from './comps/right/top/2/index.vue'; | ||||
import Right22 from './comps/right/middle/2/index.vue'; | import Right22 from './comps/right/middle/2/index.vue'; | ||||
import Right32 from './comps/right/bottom/2/index.vue'; | import Right32 from './comps/right/bottom/2/index.vue'; | ||||
@@ -29,6 +31,8 @@ export default { | |||||
Right11, | Right11, | ||||
Right21, | Right21, | ||||
Right31, | Right31, | ||||
Left12, | |||||
Left22, | |||||
Right12, | Right12, | ||||
Right22, | Right22, | ||||
Right32 | Right32 | ||||