Commit ad91f16c by liwk

commit

1 parent 48d39d0d
<template> <template>
<div id="app"> <div id="app">
<page2></page2> <page1></page1>
<!-- <page2></page2> -->
</div> </div>
</template> </template>
<script> <script>
......
...@@ -18,7 +18,8 @@ export default { ...@@ -18,7 +18,8 @@ export default {
labels: [], labels: [],
values: [], values: [],
second: [], second: [],
lineData: [] lineData: [],
themeRiverList: []
} }
}, },
props: { props: {
...@@ -71,16 +72,34 @@ export default { ...@@ -71,16 +72,34 @@ export default {
this.canvas = echarts.init(this.$refs.canvas) this.canvas = echarts.init(this.$refs.canvas)
let options = null let options = null
if (this.type == 'themeRiver') { if (this.type == 'themeRiver') {
let data = this.data
for (let i = 0; i < this.index; i++) {
this.data.forEach(e => {
if (e[0] == this.days[i]) {
this.themeRiverList.push(e)
}
})
}
options = { options = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
padding: [8, 9, 8, 9], padding: [8, 9, 8, 9],
formatter: value => {
let val = ''
value.forEach((e, ind) => {
if (ind == 0) {
val += `${e.data[0]}<br>${e.name}\t${e.data[1]}`
} else {
val += `<br>${e.name}\t${e.data[1]}`
}
})
return val
},
axisPointer: { axisPointer: {
type: 'line', type: 'line',
lineStyle: { lineStyle: {
color: 'rgba(0,0,0,0.2)', color: 'rgba(87,213,255,0.4)',
width: 1, width: 2,
type: 'solid' type: 'solid'
} }
} }
...@@ -100,11 +119,10 @@ export default { ...@@ -100,11 +119,10 @@ export default {
color: ['#0592b9', '#24bfff', '#0a83f3', '#0a4dc9'], color: ['#0592b9', '#24bfff', '#0a83f3', '#0a4dc9'],
singleAxis: { singleAxis: {
top: '95px', top: '95px',
left: '120px', left: '80px',
right: '120px', right: '120px',
bottom: '103px', bottom: '103px',
nameLocation: 'center', nameLocation: 'center',
boundaryGap: ['1000px', '1000px'],
type: 'time', type: 'time',
axisPointer: { axisPointer: {
label: { label: {
...@@ -132,7 +150,7 @@ export default { ...@@ -132,7 +150,7 @@ export default {
color: '#8e99a6', color: '#8e99a6',
fontSize: 18, fontSize: 18,
formatter: (val, index) => { formatter: (val, index) => {
let value = this.days[index] let value = this.labels[index]
return value return value
} }
} }
...@@ -140,7 +158,6 @@ export default { ...@@ -140,7 +158,6 @@ export default {
series: [ series: [
{ {
type: 'themeRiver', type: 'themeRiver',
label: false, label: false,
itemStyle: { itemStyle: {
emphasis: { emphasis: {
...@@ -148,7 +165,7 @@ export default { ...@@ -148,7 +165,7 @@ export default {
shadowColor: 'rgba(0, 0, 0, 0.8)' shadowColor: 'rgba(0, 0, 0, 0.8)'
} }
}, },
data: this.data data: this.themeRiverList
} }
] ]
} }
...@@ -306,26 +323,44 @@ export default { ...@@ -306,26 +323,44 @@ export default {
} }
this.canvas.setOption(options) this.canvas.setOption(options)
// if (this.days.length > 6) { if (this.days.length > 6) {
// setInterval(() => { setInterval(() => {
// this.moveCanvas(options) this.moveCanvas(options)
// }, this.speed * 1000) }, this.speed * 1000)
// } }
}, },
moveCanvas (options) { moveCanvas (options) {
if (this.index > this.days.length - 1) { if (this.type == 'themeRiver') {
this.index = 0 if (this.index > this.days.length - 1) {
} this.index = 0
this.labels.shift() }
this.values.shift() for (let i = 0; i < 4; i++) {
this.labels.push(this.days[this.index]) this.themeRiverList.shift()
this.values.push(this.data[this.index]) }
if (this.type != 'bar') { this.data.forEach(e => {
options.series[1].data = this.values if (e[0] == this.days[this.index]) {
this.themeRiverList.push(e)
}
})
} else {
if (this.index > this.days.length - 1) {
this.index = 0
}
if (this.haveLine) {
this.values.shift()
this.lineData.shift()
this.second.shift()
this.values.push(this.data.first[this.index])
this.lineData.push(this.data.line[this.index])
this.second.push(this.data.second[this.index])
} else {
this.values.shift()
this.values.push(this.data[this.index])
}
} }
options.xAxis.data = this.labels
options.series[0].data = this.values
this.index++ this.index++
this.labels.shift()
this.labels.push(this.days[this.index - 1])
this.canvas.setOption(options) this.canvas.setOption(options)
} }
}, },
......
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
ref="map" ref="map"
> >
</div> </div>
<div class="activation"> <div
class="activation"
v-if='!type'
>
<div <div
class="activation-box" class="activation-box"
:style="activationStyle" :style="activationStyle"
...@@ -22,12 +25,14 @@ ...@@ -22,12 +25,14 @@
</div> </div>
<div <div
class="map-back" class="map-back"
v-show='mapName != "china"' v-show='mapName != "zhongguo"'
@click='back' @click='back'
:class="{storeBack:type}"
></div> ></div>
<div <div
class="map-nanhai" class="map-nanhai"
v-show='mapName == "china"' v-show='mapName == "zhongguo"'
:class="{storeNanhai:type}"
></div> ></div>
</div> </div>
</template> </template>
...@@ -46,21 +51,26 @@ Array.prototype.min = function () { ...@@ -46,21 +51,26 @@ Array.prototype.min = function () {
} }
export default { export default {
name: 'GlMap', name: 'GlMap',
props: {
type: null
},
data () { data () {
return { return {
mapName: 'china', mapName: 'zhongguo',
map: null, map: null,
visualMapRange: [], visualMapRange: [],
pid: null, pid: null,
geoCoordMap: {},
activationStyle: { activationStyle: {
top: 0, top: 0,
left: 0 left: 0
}, },
/**数据 */
options: { options: {
visualMap: { visualMap: {
show: false, show: false,
inRange: { inRange: {
color: ['#1DE6EE', '#0B7FE1'] color: ['#59bfff ', '#2896db']
} }
}, },
// tooltip: { // tooltip: {
...@@ -136,11 +146,66 @@ export default { ...@@ -136,11 +146,66 @@ export default {
alpha: 40, alpha: 40,
beta: 0, beta: 0,
maxAlpha: 35, maxAlpha: 35,
distance: 100, distance: 120,
maxBeta: 360, maxBeta: 360,
animationDurationUpdate: 3000 animationDurationUpdate: 3000
}, },
}
]
},
/**商户 */
options_s: {
geo: {
roam: true,
zoom: 1,
label: {
normal: {
show: true,
textStyle: {
color: '#a9b9c0',
fontSize: 16
}
},
emphasis: {
textStyle: {
color: '#fff'
}
}
},
itemStyle: {
normal: {
borderColor: '#64d5ff',
borderWidth: 1,
areaColor: 'rgba(0,0,0,0)',
shadowColor: '#64d5ff',
shadowOffsetX: 2,
shadowOffsetY: 2,
shadowBlur: 20,
},
emphasis: {
areaColor: '#ffd823',
borderWidth: 0
}
},
},
series: [
{
type: 'effectScatter',
coordinateSystem: 'geo',
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke',
color: 'rgba(255,157,29,0.3)'
},
symbolSize: 16,
hoverAnimation: true,
label: false,
itemStyle: {
normal: {
color: '#ffe404',
}
},
zlevel: 1
} }
] ]
}, },
...@@ -148,27 +213,35 @@ export default { ...@@ -148,27 +213,35 @@ export default {
} }
}, },
mounted () { mounted () {
console.log(china)
this.map = echarts.init(this.$refs.map) this.map = echarts.init(this.$refs.map)
let mapFeatures = china.features
mapFeatures.forEach(e => {
let name = e.properties.name
this.geoCoordMap[name] = e.properties.cp
})
this.map.showLoading() this.map.showLoading()
this.getData(() => { this.getData(() => {
this.chinaConfigure(this.mapName, china) this.chinaConfigure(this.mapName, china)
this.map.on('click', even => { if (!this.type) {
console.log(even) this.map.on('click', even => {
if (this.mapName == 'china') { if (this.mapName == 'zhongguo') {
this.pid = map_code[even.name] this.pid = map_code[even.name]
this.$emit('mapclick', this.pid) this.$emit('mapclick', this.pid)
this.$refs.map.classList.add('change') this.$refs.map.classList.add('change')
this.mapName = even.name this.mapName = even.name
this.axios.get(`/map/province/${even.name}.json`).then(res => { this.axios.get(`/map/province/${even.name}.json`).then(res => {
this.map.clear() this.map.clear()
this.mapData = [] this.mapData = []
this.visualMapRange = [] this.visualMapRange = []
this.getData(() => { this.getData(() => {
this.chinaConfigure(even.name, res.data) this.chinaConfigure(even.name, res.data)
})
}) })
}) }
} })
}) }
}) })
}, },
methods: { methods: {
...@@ -181,7 +254,7 @@ export default { ...@@ -181,7 +254,7 @@ export default {
}).then(res => { }).then(res => {
console.log('获取全国省份数据', res) console.log('获取全国省份数据', res)
let data = res.data.data let data = res.data.data
if (this.mapName == 'china') { if (this.mapName == 'zhongguo') {
for (const key in map_code) { for (const key in map_code) {
data.forEach(el => { data.forEach(el => {
if (el.prov_code == map_code[key]) { if (el.prov_code == map_code[key]) {
...@@ -204,11 +277,12 @@ export default { ...@@ -204,11 +277,12 @@ export default {
} }
return callBack() return callBack()
}) })
callBack()
}, },
back () { back () {
this.map.clear() this.map.clear()
this.$refs.map.classList.add('change') this.$refs.map.classList.add('change')
this.mapName = 'china' this.mapName = 'zhongguo'
this.pid = null this.pid = null
this.mapData = [] this.mapData = []
this.visualMapRange = [] this.visualMapRange = []
...@@ -222,13 +296,24 @@ export default { ...@@ -222,13 +296,24 @@ export default {
this.map.hideLoading() this.map.hideLoading()
echarts.registerMap(mapName, data) echarts.registerMap(mapName, data)
window.onresize = this.map.resize window.onresize = this.map.resize
let options = this.options let options = this.type ? this.options_s : this.options
let max = this.visualMapRange.max() let max = this.visualMapRange.max()
let min = this.visualMapRange.min() let min = this.visualMapRange.min()
options.visualMap.min = min if (!this.type) {
options.visualMap.max = max options.visualMap.min = 0
options.series[0].data = this.mapData options.visualMap.max = max
options.series[0].name = options.series[0].map = mapName this.mapData.push({
name: '台湾',
value: 0
})
options.series[0].data = this.mapData
options.series[0].name = options.series[0].map = mapName
} else {
options.geo.data = this.mapData
options.geo.name = options.geo.map = mapName
options.series[0].data = this.convertData(this.mapData)
}
console.log(options)
this.map.setOption(options) this.map.setOption(options)
setTimeout(() => { setTimeout(() => {
this.$refs.map.classList.remove('change') this.$refs.map.classList.remove('change')
...@@ -250,6 +335,18 @@ export default { ...@@ -250,6 +335,18 @@ export default {
// } // }
// // this.map.setOption(options) // // this.map.setOption(options)
// }, 5000) // }, 5000)
},
convertData (data, res = []) {
for (let i = 0; i < data.length; i++) {
let geoCoord = this.geoCoordMap[data[i].name]
if (geoCoord) {
res.push({
name: data[i].name,
value: geoCoord.concat(data[i].value)
})
}
}
return res
} }
} }
} }
...@@ -283,6 +380,14 @@ export default { ...@@ -283,6 +380,14 @@ export default {
background-size: cover; background-size: cover;
z-index: 3; z-index: 3;
} }
.storeNanhai {
bottom: 3px;
right: 25px;
}
.storeBack {
bottom: 0px;
left: 79px;
}
} }
.map { .map {
width: 100%; width: 100%;
...@@ -314,4 +419,4 @@ export default { ...@@ -314,4 +419,4 @@ export default {
transform: scale(1); transform: scale(1);
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<div class='header'> <div class='header'>
<h1 v-if="$slots.title"> <slot name='title'></slot>
<slot name='title'></slot>
</h1>
<div> <div>
<slot></slot> <slot></slot>
</div> </div>
......
<template>
<div class='pie'>
<div
class="pie-canvas"
ref='data'
></div>
<div class='pie-title'>
<slot></slot>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'Pie',
props: {
list: {
type: Array,
default: []
}
},
data () {
return {
roseColors: ['#773ae6', '#372ef0', '#5242f3', '#0060ff', '#0096ff', '#00e5dd', '#36a8ff', '#0078f4'],
canvas: null
}
},
watch: {
'list' (n, o) {
if (n.length > 0) {
console.log(n)
this.createdCanvas()
}
}
},
methods: {
createdCanvas () {
if (this.canvas) this.canvas.clear()
let roseColors = []
let data = this.list
let sum = data.reduce((pre, next) => pre + Number(next.value), 0)
data.forEach((e, i) => {
roseColors.push(this.roseColors[8 - data.length + i])
})
this.canvas = echarts.init(this.$refs.data)
let options = {
series: [{
type: 'pie',
radius: '65%',
center: ['50%', 120],
color: roseColors,
data: data,
label: {
normal: {
show: false,
formatter: ['{b|{b}}', '{d|{d}%}'].join('\n'),
rich: {
d: {
color: '#fff',
fontSize: 16,
},
b: {
color: '#fff',
fontSize: 16,
lineHeight: 20
},
},
}
},
labelLine: {
normal: {
lineStyle: {
color: '#fff',
},
smooth: 0.1,
length: 1,
length2: 14,
}
},
itemStyle: {
normal: {
shadowColor: 'rgba(0,0,0,0.5)',
shadowBlur: 50,
}
}
}]
}
let option = options.series[0]
this.canvas.on('mouseover', params => {
option.data[params.dataIndex].labelLine = option.data[params.dataIndex].label = {
normal: {
show: true
}
}
this.canvas.setOption(options)
})
this.canvas.on('mouseout', params => {
option.data[params.dataIndex].label = option.data[params.dataIndex].labelLine = {
normal: {
show: false
}
}
})
this.canvas.setOption(options)
}
}
}
</script>
<style scoped lang='scss'>
.pie {
width: 100%;
height: 100%;
position: relative;
&-canvas {
width: 100%;
height: 100%;
}
&-title {
position: absolute;
left: 0;
bottom: 38px;
width: 100%;
text-align: center;
font-size: 24px;
color: #8e99a6;
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -8,6 +8,8 @@ import GlLineBar from './GlLineBar.vue' ...@@ -8,6 +8,8 @@ import GlLineBar from './GlLineBar.vue'
import Count from './Count.vue' import Count from './Count.vue'
import Order from './Order.vue' import Order from './Order.vue'
import Radar from './Radar.vue' import Radar from './Radar.vue'
import Pie from './Pie.vue'
const components = [ const components = [
Header, Header,
Box, Box,
...@@ -18,7 +20,8 @@ const components = [ ...@@ -18,7 +20,8 @@ const components = [
GlLineBar, GlLineBar,
Count, Count,
Order, Order,
Radar Radar,
Pie
] ]
const GlsxVueComponents = {} const GlsxVueComponents = {}
GlsxVueComponents.install = Vue => { GlsxVueComponents.install = Vue => {
......
...@@ -2,7 +2,7 @@ import Vue from 'vue' ...@@ -2,7 +2,7 @@ import Vue from 'vue'
import App from './App.vue' import App from './App.vue'
import components from '@c/index.js' import components from '@c/index.js'
import axios from 'axios' import axios from 'axios'
const domain = 'http://192.168.2.222:7001' const domain = 'http://192.168.0.21:7001'
Vue.prototype.axios = axios Vue.prototype.axios = axios
Vue.prototype.domain = domain Vue.prototype.domain = domain
Vue.config.productionTip = false Vue.config.productionTip = false
......
...@@ -74,32 +74,32 @@ ...@@ -74,32 +74,32 @@
<div slot='title'>用户分析</div> <div slot='title'>用户分析</div>
<User :list='userList'></User> <User :list='userList'></User>
<div class='box-center'></div> <div class='box-center'></div>
<div class="rose-box"> <div class="pie-box">
<div class="rose-item"> <div class="pie-item">
<Rose <pie
:list='city' :list='city'
haveBorder haveBorder
> >
用户城市排行 用户城市排行
</Rose> </pie>
</div> </div>
<div class="rose-item"> <div class="pie-item">
<Rose :list='carBrand'> <pie :list='carBrand'>
用户车辆价格分布 用户车辆品牌分布
</Rose> </pie>
</div> </div>
<div class="rose-item"> <div class="pie-item">
<Rose <pie
:list='dayMileage' :list='dayMileage'
haveBorder haveBorder
> >
用户日均行驶里程分布 用户日均行驶里程分布
</Rose> </pie>
</div> </div>
<div class="rose-item"> <div class="pie-item">
<Rose :list='driving'> <pie :list='driving'>
用户月均行驶天数分布 用户月均行驶天数分布
</Rose> </pie>
</div> </div>
</div> </div>
</Box> </Box>
...@@ -438,9 +438,9 @@ export default { ...@@ -438,9 +438,9 @@ export default {
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.rose-box { .pie-box {
height: calc(100% - 557px); height: calc(100% - 557px);
.rose-item { .pie-item {
float: left; float: left;
width: 50%; width: 50%;
height: 50%; height: 50%;
......
...@@ -67,7 +67,10 @@ ...@@ -67,7 +67,10 @@
</Box> </Box>
</div> </div>
<div class="main-top-center"> <div class="main-top-center">
<!-- <gl-map @mapclick='mapclick'></gl-map> --> <gl-map
@mapclick='mapclick'
type
></gl-map>
</div> </div>
<div class='main-top-right'> <div class='main-top-right'>
<Box> <Box>
...@@ -119,7 +122,7 @@ ...@@ -119,7 +122,7 @@
:data='order1' :data='order1'
:days='days' :days='days'
type='themeRiver' type='themeRiver'
speed='5' speed='3'
></gl-line-bar> ></gl-line-bar>
</div> </div>
<div class="main-bottom-item"> <div class="main-bottom-item">
...@@ -242,24 +245,19 @@ export default { ...@@ -242,24 +245,19 @@ export default {
] ]
}, },
user_r: { user_r: {
first: [7199, 5752, 6017, 6699, 9468, 8133], first: [7199, 5752, 6017, 6699, 9468, 8133, 1009],
second: [7284, 6807, 5434, 6162, 7084, 4131], second: [7284, 6807, 5434, 6162, 7084, 4131, 8684],
line: [1563, 1478, 423, 1006, 1543, 3927] line: [1563, 1478, 423, 1006, 1543, 3927, 2222]
} }
} }
}, },
mounted () { mounted () {
this.days = ['2019-12-01', this.days = ['2019-12-01', '2019-12-02', '2019-12-03', '2019-12-04', '2019-12-05', '2019-12-06', '2019-12-07',]
'2019-12-02',
'2019-12-03',
'2019-12-04',
'2019-12-05',
'2019-12-06',]
this.order1 = [ this.order1 = [
['2019-12-01', 720, '保养'], ['2019-12-02', 700, '保养'], ['2019-12-03', 750, '保养'], ['2019-12-04', 800, '保养'], ['2019-12-05', 900, '保养'], ['2019-12-06', 770, '保养'], ['2019-12-01', 720, '保养'], ['2019-12-02', 700, '保养'], ['2019-12-03', 750, '保养'], ['2019-12-04', 800, '保养'], ['2019-12-05', 900, '保养'], ['2019-12-06', 770, '保养'], ['2019-12-07', 440, '保养'],
['2019-12-01', 620, '送修'], ['2019-12-02', 600, '送修'], ['2019-12-03', 650, '送修'], ['2019-12-04', 600, '送修'], ['2019-12-05', 800, '送修'], ['2019-12-06', 670, '送修'], ['2019-12-01', 620, '送修'], ['2019-12-02', 600, '送修'], ['2019-12-03', 650, '送修'], ['2019-12-04', 600, '送修'], ['2019-12-05', 800, '送修'], ['2019-12-06', 670, '送修'], ['2019-12-07', 570, '送修'],
['2019-12-01', 520, '车险'], ['2019-12-02', 500, '车险'], ['2019-12-03', 550, '车险'], ['2019-12-04', 500, '车险'], ['2019-12-05', 700, '车险'], ['2019-12-06', 570, '车险'], ['2019-12-01', 520, '车险'], ['2019-12-02', 500, '车险'], ['2019-12-03', 550, '车险'], ['2019-12-04', 500, '车险'], ['2019-12-05', 700, '车险'], ['2019-12-06', 570, '车险'], ['2019-12-07', 470, '车险'],
['2019-12-01', 420, '设备'], ['2019-12-02', 400, '设备'], ['2019-12-03', 450, '设备'], ['2019-12-04', 400, '设备'], ['2019-12-05', 600, '设备'], ['2019-12-06', 470, '设备'] ['2019-12-01', 420, '设备'], ['2019-12-02', 400, '设备'], ['2019-12-03', 450, '设备'], ['2019-12-04', 400, '设备'], ['2019-12-05', 600, '设备'], ['2019-12-06', 470, '设备'], ['2019-12-07', 370, '设备']
] ]
// this.getUserGenderData() // this.getUserGenderData()
// this.getUserTotal() // this.getUserTotal()
...@@ -557,4 +555,11 @@ export default { ...@@ -557,4 +555,11 @@ export default {
height: 640px; height: 640px;
background: rgba(41, 135, 184, 0.3); background: rgba(41, 135, 184, 0.3);
} }
// .main-top-center {
// height: calc(100% - 697px);
// width: calc(100% - 2048px);
// top: 180px;
// left: 50%;
// transform: translateX(-50%);
// }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -18,12 +18,6 @@ ...@@ -18,12 +18,6 @@
float: right; float: right;
} }
.main {
width: 100%;
height: 100%;
box-sizing: border-box;
}
.view-box { .view-box {
width: 4088px; width: 4088px;
height: 1728px; height: 1728px;
...@@ -115,6 +109,9 @@ ...@@ -115,6 +109,9 @@
} }
.main { .main {
width: 100%;
height: 100%;
box-sizing: border-box;
padding-top: 24px; padding-top: 24px;
&-top { &-top {
height: calc(100% - 519px); height: calc(100% - 519px);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!