uni-app 微信小程序 使用echarts

推荐使用插件市场 echarts-for-wx 插件 小程序中几乎可以完美使用 用法和echarts用法一致
在这里插入图片描述
使用方法

<uni-ec-canvas class="uni-ec-canvas" id="line-chart" canvas-id="multi-charts-line" :ec="ec"></uni-ec-canvas>
import uniEcCanvas from '@/components/uni-ec-canvas/uni-ec-canvas.vue'
data() {
			return {
				ec: {
					option: {
						tooltip: {
							// formatter:'{b}:{c}',
							trigger: 'axis',
							axisPointer: { // 坐标轴指示器,坐标轴触发有效
								type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
							}
						},
						grid: {
							left: '14%',
							right: '16%',
							top: '1%',
							bottom: '7%'
						},
						xAxis: {
							type: 'value',
							position: 'bottom',
							minInterval: 1,
							axisLine: {
								lineStyle: {
									color: "#333333"
								}
							},
							splitLine: {
								lineStyle: {
									type: 'dashed'
								}
							}
						},
						yAxis: {
							type: 'category',
							nameTextStyle: {
								color: "#333333",
								textBorderColor: "#333333"
							},
							axisLine: {
								lineStyle: {
									color: "#333333"
								}
							},
							data: ['离线', '停机', '保养', '维修', '待料', '故障', '运行']
						},
						series: [{
							type: 'bar',
							label: {
								show: true,
								formatter: '{c}台',
								textBorderColor: 'transparent',
								position: 'right',
								color: '#3f3f3f'
							},
							itemStyle: {
								normal: {
									color: function(params) {
										var colorList = ['#aaaaaa', '#6F7072', '#009de0', '#f04864', '#F7B233', '#ffeb00', '#009036'];
										return colorList[params.dataIndex]
									},
								}
							},
							data: [{
									value: 18,
									name: '离线',
									itemStyle: {
										normal: { color: "#aaaaaa" },
										emphasis: { color: "#aaaaaa" }
									}
								},
								{
									value: 0,
									name: "",
									itemStyle: {
										normal: { color: "#6F7072" },
										emphasis: { color: "#6F7072" }
									}
								},
								{
									value: 1,
									name: "",
									itemStyle: {
										normal: { color: "#009de0" },
										emphasis: { color: "#009de0" }
									}
								},
								{
									value: 0,
									name: "",
									itemStyle: { color: "#f04864" }
								},
								{
									value: 0,
									name: "",
									itemStyle: { color: "#E7CB84" }
								},
								{
									value: 1,
									name: "",
									itemStyle: { color: "#ffeb00" }
								},
								{ value: 1, name: "", itemStyle: { color: "#009036" } }
							]
						}]
					},
				}

			}
		},

效果在这里插入图片描述
使用渐变色需引入

import * as echarts from '../../components/uni-ec-canvas/echarts';

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值