Commit 72e0c4af by liwk

commit

1 parent 29f3ad62
const Map = {
'北京': 11,
'天津': 12,
'河北': 13,
'山西': 14,
'内蒙古': 15,
'辽宁': 21,
'吉林': 22,
'黑龙江': 23,
'上海': 31,
'江苏': 32,
'浙江': 33,
'安徽': 34,
'福建': 35,
'江西': 36,
'山东': 37,
'河南': 41,
'湖北': 42,
'湖南': 43,
'广东': 44,
'广西': 45,
'海南': 46,
'重庆': 50,
'四川': 51,
'贵州': 52,
'云南': 53,
'西藏': 54,
'陕西': 61,
'甘肃': 62,
'青海': 63,
'宁夏': 64,
'新疆': 65,
'台湾': 71,
'香港': 81,
'澳门': 82
}
export default Map
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
......@@ -15,12 +15,12 @@ export default {
return {
canvas: null,
index: 6,
labels:[],
values:[]
labels: [],
values: []
}
},
props: {
data: null,
data: Array,
days: Array,
type: {
type: String,
......@@ -37,7 +37,7 @@ export default {
},
watch: {
'days' (newVal, oldVal) {
if (newVal) {
if (newVal.length > 0) {
this.createdCanvas()
}
}
......@@ -47,13 +47,17 @@ export default {
},
methods: {
createdCanvas () {
// let days = []
// let data = []
if (this.canvas) {
this.labels = []
this.values = []
this.canvas.clear()
}
this.index = this.days.length < this.index ? this.days.length : this.index
for (let i = 0; i < this.index; i++) {
this.labels.push(this.days[i])
this.values.push(this.data[i])
}
let canvas = echarts.init(this.$refs.canvas)
this.canvas = echarts.init(this.$refs.canvas)
let options = {
xAxis: {
type: 'category',
......@@ -101,7 +105,6 @@ export default {
series: [
{
data: this.values,
name: '出行次数',
type: this.type,
barWidth: '60px',
smooth: true,
......@@ -167,15 +170,17 @@ export default {
data: this.values
})
}
canvas.setOption(options)
setInterval(() => {
this.moveCanvas(options, canvas)
}, 5 * 1000)
this.canvas.setOption(options)
if (this.days.length > 6) {
setInterval(() => {
this.moveCanvas(options)
}, this.speed * 1000)
}
},
moveCanvas (options, canvas) {
if (this.index > this.days.length-1) {
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])
......@@ -183,10 +188,10 @@ export default {
if (this.type != 'bar') {
options.series[1].data = this.values
}
options.xAxis.data = this.labels
options.xAxis.data = this.labels
options.series[0].data = this.values
this.index++
canvas.setOption(options)
this.canvas.setOption(options)
}
},
}
......
......@@ -19,16 +19,30 @@
<script type='text/ecmascript-6'>
import china from '@p/map/china.json'
import axios from 'axios'
import "echarts-gl"
import { request } from 'https'
import map_code from '@p/map/mapId.js'
Array.prototype.max = function () {
return Math.max.apply({}, this)
}
Array.prototype.min = function () {
return Math.min.apply({}, this)
}
export default {
name: 'GlMap',
data () {
return {
mapName: 'china',
map: null,
visualMapRange: [],
pid: null,
options: {
visualMap: {
show: false,
inRange: {
color: ['#1DE6EE', '#0B7FE1']
}
},
tooltip: {
position: 'top',
},
......@@ -38,10 +52,10 @@ export default {
name: 'china',
selectedMode: "single",//地图高亮单选
boxDepth: 90,//地图倾斜度
regionHeight: 8,//地图高度
regionHeight: 2,//地图高度
map: 'china',
itemStyle: {
color: "#40a7ee",
// color: "#40a7ee",
borderWidth: 1,//分界线wdith
borderColor: "#6ce3ec",//分界线颜色
},
......@@ -84,39 +98,91 @@ export default {
}
}
]
}
},
mapData: []
}
},
mounted () {
this.map = echarts.init(this.$refs.map)
this.map.showLoading()
this.chinaConfigure(this.mapName, china)
this.map.on('click', even => {
if (this.mapName == 'china') {
this.$refs.map.classList.add('change')
this.mapName = even.name
axios.get(`/map/province/${even.name}.json`).then(res => {
this.map.clear()
this.chinaConfigure(even.name, res.data)
})
}
})
this.map.on('mouseover', even => {
console.log(even)
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)
})
})
}
})
})
},
methods: {
/**获取全国 省份数据 */
getData (callBack) {
this.axios.get(`${this.domain}/screen/user/total_group_by_province`, {
params: {
pid: this.pid
}
}).then(res => {
console.log('获取全国省份数据', res)
let data = res.data.data
if (this.mapName == 'china') {
for (const key in map_code) {
data.forEach(el => {
if (el.prov_code == map_code[key]) {
this.mapData.push({
name: key,
value: el.total_user
})
this.visualMapRange.push(el.total_user)
}
})
}
} else {
data.forEach(el => {
this.mapData.push({
name: el.city_name,
value: el.total_user
})
this.visualMapRange.push(el.total_user)
})
}
return callBack()
})
},
back () {
this.map.clear()
this.$refs.map.classList.add('change')
this.mapName = 'china'
this.map.clear()
this.chinaConfigure(this.mapName, china)
this.pid = null
this.mapData = []
this.visualMapRange = []
this.getData(() => {
this.chinaConfigure(this.mapName, china)
this.$emit('mapclick', this.pid)
})
},
chinaConfigure (mapName, data) {
this.map.hideLoading()
echarts.registerMap(mapName, data)
window.onresize = this.map.resize
let options = 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
this.map.setOption(options)
setTimeout(() => {
......
......@@ -14,26 +14,34 @@
export default {
name: 'Rose',
props: {
data: null
list: {
type: Array,
default: []
}
},
data () {
return {
roseColors: ['#773ae6', '#372ef0', '#5242f3', '#0060ff', '#0096ff', '#00e5dd', '#36a8ff', '#0078f4']
roseColors: ['#773ae6', '#372ef0', '#5242f3', '#0060ff', '#0096ff', '#00e5dd', '#36a8ff', '#0078f4'],
canvas: null
}
},
mounted () {
this.createdCanvas()
watch: {
'list' (n, o) {
if (n.length > 0) {
this.createdCanvas()
}
}
},
methods: {
createdCanvas () {
if (this.canvas) this.canvas.clear()
let roseColors = []
let data = this.data.sort(function (a, b) {
return a.value - b.value
})
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])
})
let canvas = echarts.init(this.$refs.data)
this.canvas = echarts.init(this.$refs.data)
let options = {
series: [{
type: 'pie',
......@@ -41,19 +49,21 @@ export default {
center: ['50%', 120],
color: roseColors,
data: data,
minAngle: 270,
roseType: 'radius',
label: {
normal: {
show: false,
formatter: ['{b|{b}}', '{c|{c}}'].join('\n'),
formatter: ['{b|{b}}', '{d|{d}%}'].join('\n'),
rich: {
c: {
d: {
color: '#fff',
fontSize: 16,
},
b: {
color: '#fff',
fontSize: 16,
lineHeight: 20
},
},
}
......@@ -76,22 +86,23 @@ export default {
}
}]
}
canvas.on('mouseover', params => {
options.series[0].data[params.dataIndex].labelLine = options.series[0].data[params.dataIndex].label = {
let option = options.series[0]
this.canvas.on('mouseover', params => {
option.data[params.dataIndex].labelLine = option.data[params.dataIndex].label = {
normal: {
show: true
}
}
canvas.setOption(options)
this.canvas.setOption(options)
})
canvas.on('mouseout', params => {
options.series[0].data[params.dataIndex].label = options.series[0].data[params.dataIndex].labelLine = {
this.canvas.on('mouseout', params => {
option.data[params.dataIndex].label = option.data[params.dataIndex].labelLine = {
normal: {
show: false
}
}
})
canvas.setOption(options)
this.canvas.setOption(options)
}
}
}
......
......@@ -4,12 +4,12 @@
<div>
<img src="~@a/man.png">
男
<span>{{list.man.percent}}</span>
<span>{{manPercent}}</span>
</div>
<div style="padding-left:130px;">
<img src="~@a/women.png">
女
<span>{{list.women.percent}}</span>
<span>{{womenPercent}}</span>
</div>
</div>
<div
......@@ -25,21 +25,47 @@ export default {
name: 'User',
data () {
return {
labelData: ['00后', '90后', '80后', '70后', '60后']
labelData: ['00后', '90后', '80后', '70后', '60后'],
manPercent: '0%',
womenPercent: '0%'
}
},
props: {
list: null
list: {
type: Object,
default: {}
}
},
mounted () {
this.createdCanvas()
},
watch: {
'list' (n, o) {
if (n) {
let data = n
let female = n.women.total
let male = n.man.total
let womenPercent = (female / (male + female) * 100).toFixed(1)
let manPercent = 100 - womenPercent
this.manPercent = `${manPercent}%`
this.womenPercent = `${womenPercent}%`
this.createdCanvas(male, female)
}
}
},
methods: {
createdCanvas () {
createdCanvas (male, female) {
let obj = this.list
let manData = []
this.list.man.data.forEach(e => {
let womenData = []
obj.man.data.forEach(e => {
e = (e / male * 100).toFixed(1)
manData.push(e * -1)
})
obj.women.data.forEach(e => {
e = (e / female * 100).toFixed(1)
womenData.push(e)
})
let canvas = echarts.init(this.$refs.data)
let options = {
xAxis: [{
......@@ -170,12 +196,10 @@ export default {
show: true,
formatter: val => {
let value = 0
let sum = 0
this.list.man.data.forEach((e, index) => {
sum = sum + e
manData.forEach((e, index) => {
if (index == val.dataIndex) value = e
})
return ((value * -1) / (sum * -1) * 100).toFixed(2) + '%'
return `${value * -1}%`
}
},
itemStyle: {
......@@ -203,7 +227,7 @@ export default {
borderColor: '#333',
}
},
data: this.list.women.data
data: womenData
},
{
name: 'womenBorder',
......@@ -219,12 +243,10 @@ export default {
offset: [36, 0],
formatter: (val, index) => {
let value = ''
let sum = 0
this.list.women.data.forEach((e, index) => {
sum = sum + e
womenData.forEach((e, index) => {
if (index == val.dataIndex) value = e
})
return (value / sum * 100).toFixed(2) + '%'
return `${value}%`
}
},
itemStyle: {
......
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'
Vue.prototype.axios = axios
Vue.prototype.domain = domain
Vue.config.productionTip = false
Vue.use(components)
new Vue({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!