<template>
<view class="content">
<view
class="echarts"
style="width: 100%; height: 800rpx"
:prop="option"
:change:prop="echarts.updateEcharts"
id="echarts"
></view>
</view>
</template>
<script>
import to from 'await-to-js'
export default {
data() {
return {
dataFlag: true,
orgName: '',
orgRole: 'agent',
option: {
// ECharts 配置项
series: [
{
type: 'pie',
data: [
{ value: 335, name: '直接访问' },
{ value: 310, name: '邮件营销' },
{ value: 234, name: '联盟广告' },
{ value: 135, name: '视频广告' },
{ value: 1548, name: '搜索引擎' }
]
}
]
}
}
},
mounted() {
setTimeout(() => {
this.getEcharsData()
}, 1000)
},
methods: {
async getEcharsData() {
//此处调用后台接口把数据塞进来
this.$nextTick(() => {
this.option = {
tooltip: {
trigger: 'axis'
},
legend: {
color: ['#F58080', '#47D8BE'],
data: ['XXXX集团有限公司', 'XXXX股份有限公司'],
left: 'center',
bottom: 'bottom'
},
grid: {
top: 'middle',
left: '3%',
right: '4%',
bottom: '3%',
height: '80%',
containLabel: true
},
xAxis: {
type: 'category',
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
axisLabel: {
rotate: 45 // 将标签旋转45度
},
axisLine: {
lineStyle: {
color: '#999'
}
}
},
yAxis: {
type: 'value',
splitLine: {
lineStyle: {
type: 'dashed',
color: '#DDD'
}
},
axisLine: {
show: false,
lineStyle: {
color: '#333'
}
},
nameTextStyle: {
color: '#999'
},
splitArea: {
show: false
}
},
series: [
{
name: 'XXXX集团有限公司',
type: 'line',
data: [800, 900, 220, 130, 660, 289, 800, 900, 220, 130, 660, 289],
color: '#F58080',
smooth: true
},
{
name: 'XXXX股份有限公司',
type: 'line',
data: [123, 568, 111, 222, 123, 56, 568, 111, 222, 123, 56, 800],
smooth: true
}
]
}
})
}
}
}
</script>
<script module="echarts" lang="renderjs">
import * as echarts from 'echarts'
export default {
mounted() {
this.myChart = echarts.init(document.getElementById('echarts'))
},
methods: {
//监听配置数据变化,并重新渲染
updateEcharts(newValue) {
if (this.myChart) {
this.myChart.setOption(newValue)
}
}
}
}
</script>
<style lang="scss" scoped>
.echarts {
width: 100%;
height: 600rpx;
}
</style>
uniapp中 使用echart 打包成app
最新推荐文章于 2024-11-01 14:50:14 发布
1210

被折叠的 条评论
为什么被折叠?



