可视化添加echart自动滚动

dev_2022-04-07
yujialong 3 years ago
parent c9dd5a4701
commit c62cb6c9da
  1. 106
      src/pages/screen/list/index.vue

@ -391,6 +391,19 @@ export default {
}, },
// //
renderChart() { renderChart() {
const animateChart = (chart, option, data, num = 6) => {
//
if (option.dataZoom[0].endValue == data.length ) {
option.dataZoom[0].endValue = num
option.dataZoom[0].startValue = 0
}
else {
option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1
option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1
}
chart.setOption(option)
}
// //
this.$get(`${this.api.visualPreview}?tableName=hg_zg_zhongguohongguanganggan&tableId=14`).then(res => { this.$get(`${this.api.visualPreview}?tableName=hg_zg_zhongguohongguanganggan&tableId=14`).then(res => {
const { comment, data } = res const { comment, data } = res
@ -403,7 +416,7 @@ export default {
data: data.map(n => n[e.field]) data: data.map(n => n[e.field])
}) })
}) })
echarts.init(document.querySelector(`#chart1`)).setOption({ const option = {
title: { title: {
text: '' text: ''
}, },
@ -424,6 +437,15 @@ export default {
bottom: '3%', bottom: '3%',
containLabel: true containLabel: true
}, },
dataZoom: [//
{
xAxisIndex: 0,//X0
show: false,//使
type: 'slider', // dataZoom slider dataZoom
startValue: 0, //
endValue: 6 // 6
}
],
color: ['#FF4949','#FFA74D','#FFEA51','#4BF0FF','#44AFF0','#4E82FF','#584BFF','#BE4DFF','#F845F1'], color: ['#FF4949','#FFA74D','#FFEA51','#4BF0FF','#44AFF0','#4E82FF','#584BFF','#BE4DFF','#F845F1'],
xAxis: { xAxis: {
type: 'category', type: 'category',
@ -451,13 +473,19 @@ export default {
} }
}, },
series series
}) }
const myChart = echarts.init(document.querySelector(`#chart1`))
myChart.setOption(option)
setInterval(function () {
animateChart(myChart, option, series)
}, 1500)
}).catch(res => {}) }).catch(res => {})
// //
this.$get(`${this.api.visualPreview}?tableName=hg_zg_jr_quanguoshuishoushouru&tableId=33`).then(res => { this.$get(`${this.api.visualPreview}?tableName=hg_zg_jr_quanguoshuishoushouru&tableId=33`).then(res => {
const { comment, data } = res const { comment, data } = res
echarts.init(document.querySelector(`#chart3`)).setOption({ const option = {
title: { title: {
text: '' text: ''
}, },
@ -473,6 +501,15 @@ export default {
}, },
data: data.map(e => e.quarter) data: data.map(e => e.quarter)
}, },
dataZoom: [//
{
xAxisIndex: 0,//X0
show: false,//使
type: 'slider', // dataZoom slider dataZoom
startValue: 0, //
endValue: 6 // 6
}
],
yAxis: { yAxis: {
type: 'value', type: 'value',
axisLine: { axisLine: {
@ -520,7 +557,12 @@ export default {
} }
} }
] ]
}) }
const myChart = echarts.init(document.querySelector(`#chart3`))
myChart.setOption(option)
setInterval(function () {
animateChart(myChart, option, data)
}, 1500)
}).catch(res => {}) }).catch(res => {})
// //
@ -597,7 +639,7 @@ export default {
// //
this.$get(`${this.api.previewData}?tableName=hg_zg_jr_yanghanghuobidangjuzichanfuzhai&tableId=55`).then(res => { this.$get(`${this.api.previewData}?tableName=hg_zg_jr_yanghanghuobidangjuzichanfuzhai&tableId=55`).then(res => {
const { comment, data } = res const { comment, data } = res
echarts.init(document.querySelector(`#chart4`)).setOption({ const option = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
@ -617,10 +659,19 @@ export default {
grid: { grid: {
left: '10', left: '10',
top: '30', top: '30',
right: '10', right: '30',
bottom: '10', bottom: '10',
containLabel: true containLabel: true
}, },
dataZoom: [//
{
xAxisIndex: 0,//X0
show: false,//使
type: 'slider', // dataZoom slider dataZoom
startValue: 0, //
endValue: 3 // 6
}
],
xAxis: [{ xAxis: [{
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
@ -737,7 +788,12 @@ export default {
data: data.map(e => e.reserve_money) data: data.map(e => e.reserve_money)
} }
] ]
}) }
const myChart = echarts.init(document.querySelector(`#chart4`))
myChart.setOption(option)
setInterval(function () {
animateChart(myChart, option, data, 3)
}, 1500)
}).catch(res => {}) }).catch(res => {})
// //
@ -757,7 +813,7 @@ export default {
// //
this.$get(`${this.api.previewData}?tableName=hg_zg_jr_xinzengxindaishuju&tableId=34`).then(res => { this.$get(`${this.api.previewData}?tableName=hg_zg_jr_xinzengxindaishuju&tableId=34`).then(res => {
const { comment, data } = res const { comment, data } = res
echarts.init(document.querySelector(`#chart5`)).setOption({ const option = {
title: { title: {
text: '', text: '',
subtext: '', subtext: '',
@ -772,6 +828,15 @@ export default {
right: '8%', right: '8%',
bottom: '12%' bottom: '12%'
}, },
dataZoom: [//
{
xAxisIndex: 0,//X0
show: false,//使
type: 'slider', // dataZoom slider dataZoom
startValue: 0, //
endValue: 3 // 6
}
],
xAxis: { xAxis: {
type: 'category', type: 'category',
axisLine: { axisLine: {
@ -883,13 +948,18 @@ export default {
data: data.map(e => e.mmomi.replace('%', '')) data: data.map(e => e.mmomi.replace('%', ''))
} }
] ]
}) }
const myChart = echarts.init(document.querySelector(`#chart5`))
myChart.setOption(option)
setInterval(function () {
animateChart(myChart, option, data, 3)
}, 1500)
}).catch(res => {}) }).catch(res => {})
// //
this.$get(`${this.api.visualPreview}?tableName=hg_zg_my_yimeiyuanjisuanjinkounianlv&tableId=22`).then(res => { this.$get(`${this.api.visualPreview}?tableName=hg_zg_my_yimeiyuanjisuanjinkounianlv&tableId=22`).then(res => {
const { comment, data } = res const { comment, data } = res
echarts.init(document.querySelector(`#chart6`)).setOption({ const option = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
}, },
@ -911,6 +981,15 @@ export default {
color: '#fff' color: '#fff'
} }
}, },
dataZoom: [//
{
xAxisIndex: 0,//X0
show: false,//使
type: 'slider', // dataZoom slider dataZoom
startValue: 0, //
endValue: 6 // 6
}
],
xAxis: [{ xAxis: [{
type: 'category', type: 'category',
axisLine: { axisLine: {
@ -976,7 +1055,12 @@ export default {
data: data.map(e => e.value) data: data.map(e => e.value)
} }
] ]
}) }
const myChart = echarts.init(document.querySelector(`#chart6`))
myChart.setOption(option)
setInterval(function () {
animateChart(myChart, option, data)
}, 1500)
}).catch(res => {}) }).catch(res => {})

Loading…
Cancel
Save