|
@@ -1,9 +1,10 @@
|
|
|
<template>
|
|
|
-<div id="hard" :style="{width: '100%', height: '100%'}"></div>
|
|
|
+<div id="hard" style="width: 140px;height: 240px;"></div>
|
|
|
</template>
|
|
|
|
|
|
<script >
|
|
|
- var showValue = new Array()
|
|
|
+ // var showValue = new Array()
|
|
|
+ var showValue = [7,-6,7,6,7,-6,7,6,7,-6,7,6];
|
|
|
const colors = ['#5470C6', '#91CC75', '#EE6666'];
|
|
|
export default {
|
|
|
data(){
|
|
@@ -20,18 +21,18 @@ const colors = ['#5470C6', '#91CC75', '#EE6666'];
|
|
|
},
|
|
|
mounted(){
|
|
|
this.initChart() //函数调用
|
|
|
- this.getData()
|
|
|
+ this.updateChart()
|
|
|
// 对窗口大小变化的事件进行监听
|
|
|
// window.addEventListener('resize', this.screenAdapter)
|
|
|
},
|
|
|
// Vue生命周期 - 销毁时
|
|
|
- destroyed () {
|
|
|
- clearInterval(this.timerId)
|
|
|
- // 在组件销毁的时候, 需要将监听器取消掉
|
|
|
- // window.removeEventListener('resize', this.screenAdapter)
|
|
|
+ // destroyed () {
|
|
|
+ // clearInterval(this.timerId)
|
|
|
+ // // 在组件销毁的时候, 需要将监听器取消掉
|
|
|
+ // // window.removeEventListener('resize', this.screenAdapter)
|
|
|
|
|
|
|
|
|
- },
|
|
|
+ // },
|
|
|
methods:{
|
|
|
initChart(){
|
|
|
this.chartInstance = this.$echarts.init(document.getElementById('hard'))
|
|
@@ -44,39 +45,43 @@ const colors = ['#5470C6', '#91CC75', '#EE6666'];
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- async getData () {
|
|
|
- // 请求数据
|
|
|
- const { data: ret } = await this.$http.get('hbase/getJSON')
|
|
|
- const { data1:ret1 } = await this.$http.get('engine/start/?mode=mode3')
|
|
|
- this.allData = ret
|
|
|
- // 对数据排序
|
|
|
- this.allData.sort((a,b) => {{
|
|
|
- return a.value-b.value //从小到大排序
|
|
|
- }})
|
|
|
- // 每1个元素显示一页
|
|
|
- this.totalPage = this.allData.length % 1 ===0 ? this.allData.length /1 : this.allData.length / 1 +1
|
|
|
+ // async getData () {
|
|
|
+ // // 请求数据
|
|
|
+ // const { data: ret } = await this.$http.get('hbase/getJSON')
|
|
|
+ // const { data1:ret1 } = await this.$http.get('engine/start/?mode=mode3')
|
|
|
+ // this.allData = ret
|
|
|
+ // // 对数据排序
|
|
|
+ // this.allData.sort((a,b) => {{
|
|
|
+ // return a.value-b.value //从小到大排序
|
|
|
+ // }})
|
|
|
+ // // 每1个元素显示一页
|
|
|
+ // this.totalPage = this.allData.length % 1 ===0 ? this.allData.length /1 : this.allData.length / 1 +1
|
|
|
|
|
|
- // 获取完数据, 更新图标
|
|
|
- this.updateChart()
|
|
|
+ // // 获取完数据, 更新图标
|
|
|
+ // this.updateChart()
|
|
|
|
|
|
- // // 启动定时器, 每隔三秒改变currentPage, 进而更新图表
|
|
|
- this.startInterval()
|
|
|
+ // // // 启动定时器, 每隔三秒改变currentPage, 进而更新图表
|
|
|
+ // this.startInterval()
|
|
|
|
|
|
- },
|
|
|
+ // },
|
|
|
updateChart(){
|
|
|
// 每一页显示1个数据, 获取1个数据
|
|
|
- const start = (this.currentPage - 1) * 1
|
|
|
- const end = this.currentPage * 1
|
|
|
- const showData = this.allData.slice(start, end)
|
|
|
- const tempDate = showData[0].gejieguiji
|
|
|
- showValue.push(tempDate)
|
|
|
- if(showValue.length>=12){
|
|
|
- for(let i=1; i<=showValue.length; i++){
|
|
|
- showValue.pop()
|
|
|
- }
|
|
|
- }
|
|
|
+ // const start = (this.currentPage - 1) * 1
|
|
|
+ // const end = this.currentPage * 1
|
|
|
+ // const showData = this.allData.slice(start, end)
|
|
|
+ // const tempDate = showData[0].gejieguiji
|
|
|
+ // showValue.push(tempDate)
|
|
|
+ // if(showValue.length>=12){
|
|
|
+ // for(let i=1; i<=showValue.length; i++){
|
|
|
+ // showValue.pop()
|
|
|
+ // }
|
|
|
+ // }
|
|
|
// const testData = [7,-6,7,6,7,-6,7,6,7,-6,7,6]
|
|
|
var option = {
|
|
|
+ // title: {
|
|
|
+ // text: '行走状态',
|
|
|
+ // show: true
|
|
|
+ // },
|
|
|
color: colors,
|
|
|
tooltip: {
|
|
|
trigger: 'axis',
|
|
@@ -233,22 +238,22 @@ const colors = ['#5470C6', '#91CC75', '#EE6666'];
|
|
|
// 启动定时器, 每隔三秒改变currentPage, 进而更新图表
|
|
|
// this.startInterval()
|
|
|
},
|
|
|
- startInterval () {
|
|
|
- // 每个3秒执行一次
|
|
|
- setInterval(() => {
|
|
|
- // 保险操作
|
|
|
- if(this.timeId){
|
|
|
- clearInterval(this.timerId)
|
|
|
- }
|
|
|
- this.currentPage++
|
|
|
- // 当页数超过总页数是, 从头开始
|
|
|
- if(this.currentPage > this.totalPage){
|
|
|
- this.currentPage = 1
|
|
|
- }
|
|
|
- //this.getData()
|
|
|
- this.updateChart()
|
|
|
- },3000)
|
|
|
- }
|
|
|
+ // startInterval () {
|
|
|
+ // // 每个3秒执行一次
|
|
|
+ // setInterval(() => {
|
|
|
+ // // 保险操作
|
|
|
+ // if(this.timeId){
|
|
|
+ // clearInterval(this.timerId)
|
|
|
+ // }
|
|
|
+ // this.currentPage++
|
|
|
+ // // 当页数超过总页数是, 从头开始
|
|
|
+ // if(this.currentPage > this.totalPage){
|
|
|
+ // this.currentPage = 1
|
|
|
+ // }
|
|
|
+ // //this.getData()
|
|
|
+ // this.updateChart()
|
|
|
+ // },3000)
|
|
|
+ // }
|
|
|
}
|
|
|
}
|
|
|
</script>
|