uni-app中实现echarts图表

1.进入uni-app插件市场,登录账号后将插件导入项目中
插件市场地址:百度图表 echarts - DCloud 插件市场

2.在要使用的页面引入echarts组件

html:

<view class="canvasView">
			 
	<l-echart ref="chart" @finished="init"></l-echart>
		  
</view>

 js:

// 引入echarts文件
	import * as echarts from '@/uni_modules/lime-echart/static/echarts.min'
	import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';


//使用LEchart组件
export default {
		components:{
			LEchart
		},
        data(){
         return{
option: {
								title: {
									text: '特性示例:渐变色 阴影 点击缩放',
									subtext: 'Feature Sample: Gradient Color, Shadow, Click Zoom'
								},
								xAxis: {
									data: ['海燕', '马小梅', '罗永浩', '卫绍强', '李凤兰', '木管琴', '周少华'],
									type: 'category',
									axisTick: {
									        alignWithLabel: true
									      },
									// axisLine: {
									// 	show: false
									// },
									z: 10
								},
								yAxis: {
									axisLine: {
										show: false
									},
									axisTick: {
										show: false
									},
									axisLabel: {
										color: '#999'
									}
								},
								dataZoom: [
									{
										type: 'inside'
									}
								],
								series: [
									{
										 label: {
										        show: true,
										        position: 'top'
										      },
										type: 'bar',
										showBackground: true,
										stack: 'Total',
										itemStyle: {
											color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
												{ offset: 0, color: '#83bff6' },
												{ offset: 0.5, color: '#188df0' },
												{ offset: 1, color: '#188df0' }
											])
										},
										emphasis: {
											itemStyle: {
												color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
													{ offset: 0, color: '#2378f7' },
													{ offset: 0.7, color: '#2378f7' },
													{ offset: 1, color: '#83bff6' }
												])
											}
										},
										data: [4, 7, 9, 10, 8, 6, 5]
									}
								]
							},
      }
    }
}
  methods: {
        init() {
            this.$refs.chart.init(echarts, chart => {
                chart.setOption(this.option);
            });
        }
    }

效果图:

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值