echarts 仪表盘参数

在这里插入图片描述

var dataArr = 44;
var colorSet = {
	color: 'rgba(238, 238, 238, 1)'
};

var color1 = {
	type: "linear",
	x: 0,
	y: 0,
	x2: 1,
	y2: 1,
	colorStops: [
		{
			offset: 0,
			color: "rgba(238, 238, 238, 1)"
		},
		{
			offset: 1,
			color: "rgba(238, 238, 238, 1)"
		}
	],
	global: false
}

var color2 = color2 = [
	[1 / 6, '#41D5A4'],
	[2 / 6, '#FBC436'],
	[3 / 6, '#FD9522'],
	[4 / 6, '#FA5F5D'],
	[5 / 6, '#B47BF7'],
	[1, '#C43458'],
]

option = {
	// backgroundColor: '#0E1327',
	backgroundColor: '#ffffff',
	tooltip: {
		show: false
	},

	series: [
		{
			name: "内部进度条",
			type: "gauge",
			// center: ['20%', '50%'],
			radius: '62%',

			splitNumber: 10,
			axisLine: {
				lineStyle: {
					color: [
						[0, colorSet.color],
						[1, colorSet.color]
					],
					width: 2
				}
			},
			axisLabel: {
				show: false,
			},
			axisTick: {
				show: false,

			},
			splitLine: {
				show: false,
			},
			itemStyle: {
				color: "rgba(234, 234, 234, 1)"
			},
			detail: {
				show: false,
				formatter: function (value) {
					if (value !== 0) {
						var num = Math.round(value);
						return parseInt(num).toFixed(0) + "%";
					} else {
						return 0;
					}
				},
				offsetCenter: [0, 67],
				textStyle: {
					padding: [0, 0, 0, 0],
					fontSize: 18,
					fontWeight: '700',
					color: '#ffffff'
				}
			},
			title: { //标题
				show: false,
				offsetCenter: [0, 46], // x, y,单位px
				textStyle: {
					color: "rgba(0,0,0,0)",
					fontSize: 14, //表盘上的标题文字大小
					fontFamily: 'PingFangSC'
				}
			},
			data: [{
				name: "",
				value: dataArr,
			}],
			pointer: {
				show: true,
				length: '70%',
				radius: '20%',
				width: 3 //指针粗细

			},
			animationDuration: 4000,
		},
		{
			name: "内部小圆",
			type: "gauge",
			// center: ['20%', '50%'],
			radius: '56%',

			splitNumber: 30,
			axisLine: {
				lineStyle: {
					color: color2,
					width: 30
				}
			},
			axisLabel: {
				show: false,
			},
			axisTick: {
				show: false,

			},
			splitLine: {
				show: false,
			},
			itemStyle: {
				show: false,
			},
		},
		{
			name: '外部刻度',
			type: 'gauge',
			//  center: ['20%', '50%'],
			radius: '40%',
			min: 0, //最小刻度
			max: 100, //最大刻度
			splitNumber: 5, //刻度数量
			startAngle: 225,
			endAngle: -45,
			axisLine: {
				show: false,
			}, //仪表盘轴线
			axisLabel: {
				show: false,
			}, //刻度标签。
			axisTick: {
				show: true,
				splitNumber: 3,
				lineStyle: {
					color: color1, //用颜色渐变函数不起作用
					width: 1,
				},
				length: -6
			}, //刻度样式
			splitLine: {
				show: true,
				length: -12,
				lineStyle: {
					color: color1, //用颜色渐变函数不起作用
				}
			}, //分隔线样式
			detail: {
				show: false
			}
		},
		{ //指针上的圆
			type: 'pie',
			tooltip: {
				show: false
			},
			hoverAnimation: false,
			legendHoverLink: false,
			radius: ['0%', '10%'],
			center: ['50%', '50%'],
			label: {
				normal: {
					show: false
				}
			},
			labelLine: {
				normal: {
					show: false
				}
			},
			data: [{
				value: 120,
				itemStyle: {
					normal: {
						color: "rgba(238, 238, 238, 1)",
					},
				}
			}]
		},
		{
			name: "内部进度条",
			type: "gauge",
			// center: ['20%', '50%'],
			radius: '40%',

			splitNumber: 10,
			axisLine: {
				lineStyle: {
					color: [
						[dataArr / 100, colorSet.color],
						[1, colorSet.color]
					],
					width: 1
				}
			},
			axisLabel: {
				show: false,
			},
			axisTick: {
				show: false,

			},
			splitLine: {
				show: false,
			},
			itemStyle: {
				color: "#ffffff"
			},
			detail: {
				formatter: function (value) {
					return 'AQI'
				},
				offsetCenter: [0, 200],
				textStyle: {
					padding: [0, 0, 0, 0],
					fontSize: 32,
					color: "#B6B6B6"
				}
			},
			title: { //标题
				show: true,
				offsetCenter: [0, 140], // x, y,单位px
				textStyle: {
					color: "#404040",
					fontSize: 66, //表盘上的标题文字大小
					fontWeight: 500,
					fontFamily: 'MicrosoftYaHei'
				}
			},
			data: [{
				name: dataArr,
				value: dataArr,
				itemStyle: {
					color: "rgba(174, 174, 174, 1)",
					fontFamily: "MicrosoftYaHei",
					fontSize: 14
				}
			}],
			pointer: {
				show: true,
				length: '80%',
				radius: '20%',
				width: 4 //指针粗细

			},
			animationDuration: 4000,
		}
	]
};
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
ECharts是一个基于JavaScript的开源可视化库,用于构建交互式的图表和数据可视化。它提供了丰富的图表类型和灵活的配置选项,可以满足各种数据展示需求。 关于ECharts仪表盘逆时针的功能,ECharts提供了一个名为"仪表盘(Gauge)"的图表类型,可以通过设置相关参数实现逆时针显示。具体实现步骤如下: 1. 首先,引入ECharts库和相关的样式文件。 2. 创建一个DOM容器,用于显示仪表盘图表。 3. 初始化ECharts实例,并将DOM容器传入。 4. 定义仪表盘的配置项,包括图表类型、数据、样式等。 5. 在配置项中设置逆时针显示的参数,例如设置`clockwise: false`。 6. 调用ECharts实例的`setOption`方法,将配置项应用到图表中。 7. 最后,调用ECharts实例的`resize`方法,使图表自适应容器大小。 下面是一个示例代码,演示了如何使用ECharts实现逆时针显示的仪表盘: ```javascript // 引入ECharts库和样式文件 import echarts from 'echarts'; import 'echarts/lib/chart/gauge'; import 'echarts/lib/component/title'; // 创建DOM容器 const container = document.getElementById('chart-container'); // 初始化ECharts实例 const chart = echarts.init(container); // 定义仪表盘的配置项 const option = { series: [ { type: 'gauge', data: [{ value: 50, name: '指标' }], clockwise: false, // 设置逆时针显示 axisLine: { lineStyle: { width: 10, color: [[0.2, '#ff4500'], [0.8, '#48b'], [1, '#228b22']], }, }, // 其他配置项... }, ], }; // 应用配置项到图表中 chart.setOption(option); // 自适应容器大小 chart.resize(); ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

David凉宸

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值