Commit faeb3e8d by chenwq

折线图

1 parent 9fe4756f
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
</div> </div>
<div class="rank-block"> <div class="rank-block">
<div class="rank-line" v-for="(item, index) in rankList" :key="index"> <div class="rank-line" v-for="(item, index) in rankList" :key="index">
<marquee class="line-item" :direction="directionTimer" :delay="delayTimer" :text="item.label"></marquee> <div class="line-item">
<marquee :direction="directionTimer" :delay="delayTimer" :text="item.label"></marquee>
</div>
<p class="line-item txt-orange">{{ item.value }}</p> <p class="line-item txt-orange">{{ item.value }}</p>
</div> </div>
</div> </div>
...@@ -67,9 +69,9 @@ export default { ...@@ -67,9 +69,9 @@ export default {
rankList: [], rankList: [],
echartsLine: '', echartsLine: '',
moveAttr: { moveAttr: {
speed: 900, // speed: 900,
seriesIndex: 0, seriesIndex: 0,
dataIndex: -1 dataIndex: 0
}, },
timer: null timer: null
} }
...@@ -81,12 +83,12 @@ export default { ...@@ -81,12 +83,12 @@ export default {
mounted() { mounted() {
this.lineDom = document.getElementById(this.domId) this.lineDom = document.getElementById(this.domId)
this.echartsLine = echarts.init(this.lineDom) this[this.domId] = echarts.init(this.lineDom)
}, },
methods: { methods: {
resetRankList() { resetRankList() {
this.rankList = new Array(5).fill({ label: '-', value: '-' }) this.rankList = new Array(5).fill({ label: '- -', value: '- -' })
}, },
tooltipFormatter(obj) { tooltipFormatter(obj) {
var currentItem = this.dataList[obj[0].dataIndex] var currentItem = this.dataList[obj[0].dataIndex]
...@@ -100,41 +102,44 @@ export default { ...@@ -100,41 +102,44 @@ export default {
return txt return txt
}, },
autoMove() { // autoMove() {
clearInterval(this.timer) // clearInterval(this.timer)
this.timer = setInterval(() => { // this.timer = setInterval(() => {
this.moveAttr.dataIndex = this.moveAttr.dataIndex + 1 // this.moveAttr.dataIndex = this.moveAttr.dataIndex + 1
if (this.moveAttr.dataIndex === this.dataList.length) { // if (this.moveAttr.dataIndex === this.dataList.length) {
this.moveAttr.dataIndex = 0 // this.moveAttr.dataIndex = 0
} // }
this.chartAction() // this.chartAction()
this.autoMove() // this.autoMove()
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List') // this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
}, this.moveAttr.speed) // }, this.moveAttr.speed)
}, // },
chartBindEvent() { chartBindEvent() {
// resize // resize
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.echartsLine.resize() this[this.domId].resize()
}) })
// 鼠标划入 // 鼠标划入
this.lineDom.addEventListener('mouseover', () => { this[this.domId].on('mouseover', data => {
clearInterval(this.timer) this.moveAttr.seriesIndex = data.dataIndex
this.chartAction('downplay') this.getRankList(this.moveAttr.seriesIndex, this.rankFlag + 'List')
}) })
// 鼠标划出 // 鼠标划出
this.lineDom.addEventListener('mouseout', () => { this[this.domId].on('mouseout', () => {
this.moveAttr.dataIndex = -1 console.log('0000000000')
this.autoMove() setTimeout(() => {
this.chartAction()
}, 1000)
}) })
}, },
chartAction(type) { chartAction(type) {
this.echartsLine.dispatchAction({ console.log(this.moveAttr, '???/cwq')
this[this.domId].dispatchAction({
type: type || 'showTip', type: type || 'showTip',
seriesIndex: this.moveAttr.seriesIndex, seriesIndex: this.moveAttr.seriesIndex,
dataIndex: this.moveAttr.dataIndex dataIndex: this.moveAttr.dataIndex
...@@ -150,26 +155,16 @@ export default { ...@@ -150,26 +155,16 @@ export default {
this.lineOptions.series[0].data = this.dataList.map(item => item.num) this.lineOptions.series[0].data = this.dataList.map(item => item.num)
this.echartsLine.setOption(this.lineOptions) this[this.domId].setOption(this.lineOptions)
// // 鼠标划入
// this.echartsLine.on('click', data => {
// clearInterval(this.timer)
// this.chartAction('downplay')
// })
// // 鼠标划出
// this.echartsLine.on('mouseout', () => {
// this.moveAttr.dataIndex = -1
// this.autoMove()
// })
// console.log(this.echartsLine)
this.chartBindEvent() this.chartBindEvent()
// 默认展示tooltip
this.chartAction()
this.getRankList(0) this.getRankList(0)
this.autoMove() // this.autoMove()
}, },
handleRankChange(value) { handleRankChange(value) {
...@@ -232,6 +227,7 @@ p { ...@@ -232,6 +227,7 @@ p {
border-left: 1px solid rgba(96, 98, 102, 0.4); border-left: 1px solid rgba(96, 98, 102, 0.4);
.line-item { .line-item {
height: 1.8vh; height: 1.8vh;
width: 100%;
font-size: 10px; font-size: 10px;
padding-bottom: 0.6vh; padding-bottom: 0.6vh;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!