Commit 8dba2d4f by 王志慧

commit

1 parent 7a2b6a49
......@@ -17,7 +17,6 @@
</div>
</div>
</template>
<script>
import datas from '@/utils/data'
import * as echarts from 'echarts'
......@@ -63,7 +62,6 @@ export default {
}
}
},
data() {
return {
directionTimer: datas.DefaultData.directionTimer,
......@@ -80,17 +78,14 @@ export default {
timer: null
}
},
created() {
this.lineOptions = getLineOptions({ tooltipFormatter: this.tooltipFormatter })
},
mounted() {
this.lineDom = document.getElementById(this.domId)
this[this.domId] = echarts.init(this.lineDom)
this.chartBindEvent()
},
methods: {
resetRankList() {
this.rankList = new Array(5).fill({ label: '- -', value: '- -' })
......@@ -107,19 +102,16 @@ export default {
})
return txt
},
chartBindEvent() {
// resize
window.addEventListener('resize', () => {
this[this.domId].resize()
})
// 鼠标划入
this[this.domId].on('mouseover', data => {
this.moveAttr.dataIndex = data.dataIndex
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
})
// 绑定点击事件
this[this.domId].getZr().on('mouseover', params => {
const pointInPixel = [params.offsetX, params.offsetY]
......@@ -130,13 +122,11 @@ export default {
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
}
})
// 移除图表
// this[this.domId].on('globalout', () => {
// this.chartAction()
// })
},
// chartAction(type) {
// this[this.domId].dispatchAction({
// type: type || 'showTip',
......@@ -144,28 +134,21 @@ export default {
// dataIndex: +this.moveAttr.dataIndex
// })
// },
getRankList(idx, attrName = 'topList') {
this.dataList[idx][attrName].length ? this.$set(this, 'rankList', this.dataList[idx][attrName]) : this.resetRankList()
},
drawLine() {
this.lineOptions.xAxis.data = []
this.dataList.map(e => {
let month = new Date(e.statDate).getMonth()
this.lineOptions.xAxis.data.push(this.queryType == 0 ? `${month == 0 ? '1月' : `${Number(month) + 1}月`}` : e.statDate.split('-').slice(1).join('-'))
})
this.lineOptions.series[0].data = this.dataList.map(item => item.num)
this[this.domId].setOption(this.lineOptions)
// 默认展示tooltip
// this.chartAction()
this.getRankList(0)
},
handleRankChange(value) {
this.rankFlag = value
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
......@@ -173,7 +156,6 @@ export default {
}
}
</script>
<style lang="scss" scoped>
p {
margin: 0 0;
......@@ -241,18 +223,4 @@ p {
}
}
}
::v-deep.line-chart {
width: 100%;
height: 100%;
div {
&:nth-child(1) {
width: 100% !important;
height: 100% !important;
canvas {
width: 100% !important;
height: 100% !important;
}
}
}
}
</style>
</style>
\ No newline at end of file
......@@ -4,7 +4,7 @@ function getLineOptions(obj) {
tooltip: {
trigger: 'axis',
borderWidth: 0,
show: false,
show: true,
backgroundColor: 'rgba(68,68,68,0.80)',
textStyle: {
color: '#FFFFFF',
......@@ -34,7 +34,7 @@ function getLineOptions(obj) {
color: '#606266'
}
},
splitNumber: 3
splitNumber: 4
},
series: [
{
......@@ -43,7 +43,6 @@ function getLineOptions(obj) {
itemStyle: {
color: '#F5AA01'
},
// 平滑曲线
smooth: true,
showSymbol: false,
......@@ -73,5 +72,4 @@ function getLineOptions(obj) {
}
return lineOptions
}
export default getLineOptions
export default getLineOptions
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!