Commit ad91f16c by liwk

commit

1 parent 48d39d0d
<template>
<div id="app">
<page2></page2>
<page1></page1>
<!-- <page2></page2> -->
</div>
</template>
<script>
......
......@@ -18,7 +18,8 @@ export default {
labels: [],
values: [],
second: [],
lineData: []
lineData: [],
themeRiverList: []
}
},
props: {
......@@ -71,16 +72,34 @@ export default {
this.canvas = echarts.init(this.$refs.canvas)
let options = null
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 = {
tooltip: {
trigger: 'axis',
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: {
type: 'line',
lineStyle: {
color: 'rgba(0,0,0,0.2)',
width: 1,
color: 'rgba(87,213,255,0.4)',
width: 2,
type: 'solid'
}
}
......@@ -100,11 +119,10 @@ export default {
color: ['#0592b9', '#24bfff', '#0a83f3', '#0a4dc9'],
singleAxis: {
top: '95px',
left: '120px',
left: '80px',
right: '120px',
bottom: '103px',
nameLocation: 'center',
boundaryGap: ['1000px', '1000px'],
type: 'time',
axisPointer: {
label: {
......@@ -132,7 +150,7 @@ export default {
color: '#8e99a6',
fontSize: 18,
formatter: (val, index) => {
let value = this.days[index]
let value = this.labels[index]
return value
}
}
......@@ -140,7 +158,6 @@ export default {
series: [
{
type: 'themeRiver',
label: false,
itemStyle: {
emphasis: {
......@@ -148,7 +165,7 @@ export default {
shadowColor: 'rgba(0, 0, 0, 0.8)'
}
},
data: this.data
data: this.themeRiverList
}
]
}
......@@ -306,26 +323,44 @@ export default {
}
this.canvas.setOption(options)
// if (this.days.length > 6) {
// setInterval(() => {
// this.moveCanvas(options)
// }, this.speed * 1000)
// }
if (this.days.length > 6) {
setInterval(() => {
this.moveCanvas(options)
}, this.speed * 1000)
}
},
moveCanvas (options) {
if (this.index > this.days.length - 1) {
this.index = 0
}
this.labels.shift()
this.values.shift()
this.labels.push(this.days[this.index])
this.values.push(this.data[this.index])
if (this.type != 'bar') {
options.series[1].data = this.values
if (this.type == 'themeRiver') {
if (this.index > this.days.length - 1) {
this.index = 0
}
for (let i = 0; i < 4; i++) {
this.themeRiverList.shift()
}
this.data.forEach(e => {
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.labels.shift()
this.labels.push(this.days[this.index - 1])
this.canvas.setOption(options)
}
},
......
......@@ -5,7 +5,10 @@
ref="map"
>
</div>
<div class="activation">
<div
class="activation"
v-if='!type'
>
<div
class="activation-box"
:style="activationStyle"
......@@ -22,12 +25,14 @@
</div>
<div
class="map-back"
v-show='mapName != "china"'
v-show='mapName != "zhongguo"'
@click='back'
:class="{storeBack:type}"
></div>
<div
class="map-nanhai"
v-show='mapName == "china"'
v-show='mapName == "zhongguo"'
:class="{storeNanhai:type}"
></div>
</div>
</template>
......@@ -46,21 +51,26 @@ Array.prototype.min = function () {
}
export default {
name: 'GlMap',
props: {
type: null
},
data () {
return {
mapName: 'china',
mapName: 'zhongguo',
map: null,
visualMapRange: [],
pid: null,
geoCoordMap: {},
activationStyle: {
top: 0,
left: 0
},
/**数据 */
options: {
visualMap: {
show: false,
inRange: {
color: ['#1DE6EE', '#0B7FE1']
color: ['#59bfff ', '#2896db']
}
},
// tooltip: {
......@@ -136,11 +146,66 @@ export default {
alpha: 40,
beta: 0,
maxAlpha: 35,
distance: 100,
distance: 120,
maxBeta: 360,
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 {
}
},
mounted () {
console.log(china)
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.getData(() => {
this.chinaConfigure(this.mapName, china)
this.map.on('click', even => {
console.log(even)
if (this.mapName == 'china') {
this.pid = map_code[even.name]
this.$emit('mapclick', this.pid)
this.$refs.map.classList.add('change')
this.mapName = even.name
this.axios.get(`/map/province/${even.name}.json`).then(res => {
this.map.clear()
this.mapData = []
this.visualMapRange = []
this.getData(() => {
this.chinaConfigure(even.name, res.data)
if (!this.type) {
this.map.on('click', even => {
if (this.mapName == 'zhongguo') {
this.pid = map_code[even.name]
this.$emit('mapclick', this.pid)
this.$refs.map.classList.add('change')
this.mapName = even.name
this.axios.get(`/map/province/${even.name}.json`).then(res => {
this.map.clear()
this.mapData = []
this.visualMapRange = []
this.getData(() => {
this.chinaConfigure(even.name, res.data)
})
})
})
}
})
}
})
}
})
},
methods: {
......@@ -181,7 +254,7 @@ export default {
}).then(res => {
console.log('获取全国省份数据', res)
let data = res.data.data
if (this.mapName == 'china') {
if (this.mapName == 'zhongguo') {
for (const key in map_code) {
data.forEach(el => {
if (el.prov_code == map_code[key]) {
......@@ -204,11 +277,12 @@ export default {
}
return callBack()
})
callBack()
},
back () {
this.map.clear()
this.$refs.map.classList.add('change')
this.mapName = 'china'
this.mapName = 'zhongguo'
this.pid = null
this.mapData = []
this.visualMapRange = []
......@@ -222,13 +296,24 @@ export default {
this.map.hideLoading()
echarts.registerMap(mapName, data)
window.onresize = this.map.resize
let options = this.options
let options = this.type ? this.options_s : this.options
let max = this.visualMapRange.max()
let min = this.visualMapRange.min()
options.visualMap.min = min
options.visualMap.max = max
options.series[0].data = this.mapData
options.series[0].name = options.series[0].map = mapName
if (!this.type) {
options.visualMap.min = 0
options.visualMap.max = max
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)
setTimeout(() => {
this.$refs.map.classList.remove('change')
......@@ -250,6 +335,18 @@ export default {
// }
// // this.map.setOption(options)
// }, 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 {
background-size: cover;
z-index: 3;
}
.storeNanhai {
bottom: 3px;
right: 25px;
}
.storeBack {
bottom: 0px;
left: 79px;
}
}
.map {
width: 100%;
......@@ -314,4 +419,4 @@ export default {
transform: scale(1);
}
}
</style>
\ No newline at end of file
</style>
\ No newline at end of file
<template>
<div class='header'>
<h1 v-if="$slots.title">
<slot name='title'></slot>
</h1>
<slot name='title'></slot>
<div>
<slot></slot>
</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
......@@ -8,6 +8,8 @@ import GlLineBar from './GlLineBar.vue'
import Count from './Count.vue'
import Order from './Order.vue'
import Radar from './Radar.vue'
import Pie from './Pie.vue'
const components = [
Header,
Box,
......@@ -18,7 +20,8 @@ const components = [
GlLineBar,
Count,
Order,
Radar
Radar,
Pie
]
const GlsxVueComponents = {}
GlsxVueComponents.install = Vue => {
......
......@@ -2,7 +2,7 @@ import Vue from 'vue'
import App from './App.vue'
import components from '@c/index.js'
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.domain = domain
Vue.config.productionTip = false
......
......@@ -74,32 +74,32 @@
<div slot='title'>用户分析</div>
<User :list='userList'></User>
<div class='box-center'></div>
<div class="rose-box">
<div class="rose-item">
<Rose
<div class="pie-box">
<div class="pie-item">
<pie
:list='city'
haveBorder
>
用户城市排行
</Rose>
</pie>
</div>
<div class="rose-item">
<Rose :list='carBrand'>
用户车辆价格分布
</Rose>
<div class="pie-item">
<pie :list='carBrand'>
用户车辆品牌分布
</pie>
</div>
<div class="rose-item">
<Rose
<div class="pie-item">
<pie
:list='dayMileage'
haveBorder
>
用户日均行驶里程分布
</Rose>
</pie>
</div>
<div class="rose-item">
<Rose :list='driving'>
<div class="pie-item">
<pie :list='driving'>
用户月均行驶天数分布
</Rose>
</pie>
</div>
</div>
</Box>
......@@ -438,9 +438,9 @@ export default {
</script>
<style scoped lang='scss'>
.rose-box {
.pie-box {
height: calc(100% - 557px);
.rose-item {
.pie-item {
float: left;
width: 50%;
height: 50%;
......
......@@ -67,7 +67,10 @@
</Box>
</div>
<div class="main-top-center">
<!-- <gl-map @mapclick='mapclick'></gl-map> -->
<gl-map
@mapclick='mapclick'
type
></gl-map>
</div>
<div class='main-top-right'>
<Box>
......@@ -119,7 +122,7 @@
:data='order1'
:days='days'
type='themeRiver'
speed='5'
speed='3'
></gl-line-bar>
</div>
<div class="main-bottom-item">
......@@ -242,24 +245,19 @@ export default {
]
},
user_r: {
first: [7199, 5752, 6017, 6699, 9468, 8133],
second: [7284, 6807, 5434, 6162, 7084, 4131],
line: [1563, 1478, 423, 1006, 1543, 3927]
first: [7199, 5752, 6017, 6699, 9468, 8133, 1009],
second: [7284, 6807, 5434, 6162, 7084, 4131, 8684],
line: [1563, 1478, 423, 1006, 1543, 3927, 2222]
}
}
},
mounted () {
this.days = ['2019-12-01',
'2019-12-02',
'2019-12-03',
'2019-12-04',
'2019-12-05',
'2019-12-06',]
this.days = ['2019-12-01', '2019-12-02', '2019-12-03', '2019-12-04', '2019-12-05', '2019-12-06', '2019-12-07',]
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', 620, '送修'], ['2019-12-02', 600, '送修'], ['2019-12-03', 650, '送修'], ['2019-12-04', 600, '送修'], ['2019-12-05', 800, '送修'], ['2019-12-06', 670, '送修'],
['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', 420, '设备'], ['2019-12-02', 400, '设备'], ['2019-12-03', 450, '设备'], ['2019-12-04', 400, '设备'], ['2019-12-05', 600, '设备'], ['2019-12-06', 470, '设备']
['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-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-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-07', 370, '设备']
]
// this.getUserGenderData()
// this.getUserTotal()
......@@ -557,4 +555,11 @@ export default {
height: 640px;
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>
\ No newline at end of file
......@@ -18,12 +18,6 @@
float: right;
}
.main {
width: 100%;
height: 100%;
box-sizing: border-box;
}
.view-box {
width: 4088px;
height: 1728px;
......@@ -115,6 +109,9 @@
}
.main {
width: 100%;
height: 100%;
box-sizing: border-box;
padding-top: 24px;
&-top {
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!