Commit 49d0d3e8 by liimin

优化折线图组件的滚动效果

1 parent 4b78c1d1
# 忽略目录
build/
tests/
node_modules/
# node 覆盖率文件
coverage/
# 忽略文件
**/*-min.js
**/*.min.js
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevent
// ion consider switching to `plugin:vue/strongly-recommended` or
// `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: ['vue'],
globals: {
NODE_ENV: false,
_:false,
echarts:false
},
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// 添加,分号必须
// semi: ['error', 'always'],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
}],
'no-unexpected-multiline': 'off',
'space-before-function-paren': ['error', 'never'],
quotes: [
'error',
'single',
{
avoidEscape: true
}
]
}
};
\ No newline at end of file \ No newline at end of file
...@@ -2883,7 +2883,8 @@ ...@@ -2883,7 +2883,8 @@
"version": "4.6.0", "version": "4.6.0",
"resolved": "https://registry.npm.taobao.org/co/download/co-4.6.0.tgz", "resolved": "https://registry.npm.taobao.org/co/download/co-4.6.0.tgz",
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
"dev": true "dev": true,
"optional": true
}, },
"coa": { "coa": {
"version": "2.0.2", "version": "2.0.2",
...@@ -5259,7 +5260,8 @@ ...@@ -5259,7 +5260,8 @@
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
...@@ -5280,12 +5282,14 @@ ...@@ -5280,12 +5282,14 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
...@@ -5300,17 +5304,20 @@ ...@@ -5300,17 +5304,20 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
...@@ -5427,7 +5434,8 @@ ...@@ -5427,7 +5434,8 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
...@@ -5439,6 +5447,7 @@ ...@@ -5439,6 +5447,7 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
...@@ -5453,6 +5462,7 @@ ...@@ -5453,6 +5462,7 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
...@@ -5460,12 +5470,14 @@ ...@@ -5460,12 +5470,14 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
...@@ -5484,6 +5496,7 @@ ...@@ -5484,6 +5496,7 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
...@@ -5564,7 +5577,8 @@ ...@@ -5564,7 +5577,8 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
...@@ -5576,6 +5590,7 @@ ...@@ -5576,6 +5590,7 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
...@@ -5661,7 +5676,8 @@ ...@@ -5661,7 +5676,8 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
...@@ -5697,6 +5713,7 @@ ...@@ -5697,6 +5713,7 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
...@@ -5716,6 +5733,7 @@ ...@@ -5716,6 +5733,7 @@
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
...@@ -5759,12 +5777,14 @@ ...@@ -5759,12 +5777,14 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.3", "version": "3.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
} }
} }
}, },
...@@ -9793,7 +9813,8 @@ ...@@ -9793,7 +9813,8 @@
"version": "4.0.8", "version": "4.0.8",
"resolved": "http://registry.npm.taobao.org/rx-lite/download/rx-lite-4.0.8.tgz", "resolved": "http://registry.npm.taobao.org/rx-lite/download/rx-lite-4.0.8.tgz",
"integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=",
"dev": true "dev": true,
"optional": true
}, },
"rx-lite-aggregates": { "rx-lite-aggregates": {
"version": "4.0.8", "version": "4.0.8",
......
...@@ -14,7 +14,9 @@ export default { ...@@ -14,7 +14,9 @@ export default {
data () { data () {
return { return {
canvas: null, canvas: null,
index: 6 index: 6,
labels:[],
values:[]
} }
}, },
props: { props: {
...@@ -45,17 +47,17 @@ export default { ...@@ -45,17 +47,17 @@ export default {
}, },
methods: { methods: {
createdCanvas () { createdCanvas () {
let days = [] // let days = []
let data = [] // let data = []
for (let i = 0; i < this.index; i++) { for (let i = 0; i < this.index; i++) {
days.push(this.days[i]) this.labels.push(this.days[i])
data.push(this.data[i]) this.values.push(this.data[i])
} }
let canvas = echarts.init(this.$refs.canvas) let canvas = echarts.init(this.$refs.canvas)
let options = { let options = {
xAxis: { xAxis: {
type: 'category', type: 'category',
data: days, data: this.labels,
axisLabel: { axisLabel: {
show: true, show: true,
margin: 33, margin: 33,
...@@ -98,7 +100,7 @@ export default { ...@@ -98,7 +100,7 @@ export default {
}, },
series: [ series: [
{ {
data: data, data: this.values,
name: '出行次数', name: '出行次数',
type: this.type, type: this.type,
barWidth: '60px', barWidth: '60px',
...@@ -162,39 +164,29 @@ export default { ...@@ -162,39 +164,29 @@ export default {
}, },
barGap: '-100%', barGap: '-100%',
z: 0, z: 0,
data: data data: this.values
}) })
} }
canvas.setOption(options) canvas.setOption(options)
setInterval(() => { setInterval(() => {
this.moveCanvas(options, canvas) this.moveCanvas(options, canvas)
}, this.speed * 1000) }, 5 * 1000)
}, },
moveCanvas (options, canvas) { moveCanvas (options, canvas) {
let index = this.index if (this.index > this.days.length-1) {
let days = [] this.index = 0
let data = [] }
if (index > this.days.length) { this.labels.shift()
index = 6 this.values.shift()
for (let i = 0; i < index; i++) { this.labels.push(this.days[this.index])
days.push(this.days[i]) this.values.push(this.data[this.index])
data.push(this.data[i])
}
} else {
++index
for (let i = index - 6; i < index - 1; i++) {
days.push(this.days[i])
data.push(this.data[i])
}
}
if (this.type != 'bar') { if (this.type != 'bar') {
options.series[1].data = data options.series[1].data = this.values
} }
options.xAxis.data = days options.xAxis.data = this.labels
options.series[0].data = data options.series[0].data = this.values
this.index++
canvas.setOption(options) canvas.setOption(options)
this.index = index
} }
}, },
} }
......
...@@ -83,7 +83,6 @@ export default { ...@@ -83,7 +83,6 @@ export default {
this.map.showLoading() this.map.showLoading()
this.chinaConfigure(this.mapName, china) this.chinaConfigure(this.mapName, china)
this.map.on('click', even => { this.map.on('click', even => {
console.log(even)
if (this.mapName == 'china') { if (this.mapName == 'china') {
this.$refs.map.classList.add('test') this.$refs.map.classList.add('test')
...@@ -109,12 +108,12 @@ export default { ...@@ -109,12 +108,12 @@ export default {
this.$refs.map.classList.add('test1') this.$refs.map.classList.add('test1')
} }
}, 500) }, 500)
setInterval(() => { // setTimeout(() => {
let num = Math.floor(Math.random() * (80 - 1)) + 1 // let num = Math.floor(Math.random() * (80 - 1)) + 1
options.series[0].viewControl.alpha = num // options.series[0].viewControl.alpha = num
options.series[0].viewControl.beta = num // options.series[0].viewControl.beta = num
this.map.setOption(options) // this.map.setOption(options)
}, 5000) // }, 5000)
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!