vue3+lime-echart各种图表使用【懒人专用,建议收藏】
你好呀,我的老朋友!我是老寇,欢迎来到老寇云平台!
跟我一起学习使用uni-app集成lime-echarts
# 安装软件
## HBuilderX地址 (opens new window)
## 微信开发者工具地址 (opens new window)
# 导入Echarts
echart推荐使用lime-echart (opens new window)
# 安装echarts
npm install echarts --save
npm install echarts-stat --save
# 导入lime-echart插件
插件地址,自行导入到uni-modules (opens new window)
# 例子展示
# 创建page/pie.vue【vue3写法】
<template>
<view style="height: 750rpx">
<lEchart ref="chartRef"></lEchart>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import * as echarts from 'echarts';
import lEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';
const chartRef = ref(null);
onMounted(() => {
// 确保组件已经挂载后再初始化
if (chartRef.value) {
chartRef.value.init(echarts, (chart) => {
const option = {
title: {
text: '某站点用户访问来源',
subtext: '纯属虚构',
left: 'center'
},
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
left: 'left',
},
series: [
{
name: '访问来源',
type: 'pie',
radius: '50%',
data: [
{ value: 1048, name: '搜索引擎' },
{ value: 735, name: '直接访问' },
{ value: 580, name: '邮件营销' },
{ value: 484, name: '联盟广告' },
{ value: 300, name: '视频广告' }
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
chart.setOption(option);
});
}
});
</script>
# 配置page.json
{
"path": "pages/index/pie",
"style": {
"navigationBarTitleText": "饼图"
}
}
# 运行效果

# 更多例子

需要更多地址,请查看Github (opens new window)
我是老寇,我们下次再见啦!
上次更新: 5/21/2025, 11:57:43 AM