uni-app 使用Echarts展示折线图(axisLabel展示不全)以及uCharts展示圆环图 (附代码)(仅支持H5 和APP)

项目过程中发现Echarts 使用时 日期展示有很大问题

 如图所示  左右提示文字以及下方日期均展示不全(使用的逍遥模拟器)。原因是因为xAxis、yAxis 对象中的axisLabel对象使用了 formatter: ()=> {} 方法导致出现上述图片问题,根据查找资料以及实际观察ECharts 实例对象,确实发现,当ECharts更新后,对象中所有的formatter: ()=> {} 方法均被移除。(后面会讲到解决办法,亲测有效)

这里先说明下如果uni-app要使用ECharts 是不能直接在JS中直接引用的,需要借助renderjs进行使用,当然项目中非vue文件还是可以直接在JS中使用的

在vue文件中使用ECharts(引入,并简单使用)

先拿官网上的示例代码做个说明

官网链接:https://ext.dcloud.net.cn/plugin?id=1207

如图所示,当前Echarts 引入后直接展示为以上效果 

代码结构为

 上图所述为项目路径,其中static文件最为重要(不要乱动或改名,会引起引入错误)

我们接着来看下index中是如何使用echarts的

<template>
	<view class="content">
		<!-- #ifdef APP-PLUS || H5 -->


        <!-- option 为绑定数据源,只要option更新则会自动触发updateEcharts 函数 -->


		<view @click="echarts.onClick" :prop="option" :change:prop="echarts.updateEcharts" id="echarts" class="echarts"></view>
		<button @click="changeOption">更新数据</button>
		<!-- #endif -->
		<!-- #ifndef APP-PLUS || H5 -->
		<view>非 APP、H5 环境不支持</view>
		<!-- #endif -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				option: {
					title: {
						text: 'ECharts 入门示例'
					},
					tooltip: {},
					legend: {
						data: ['销量']
					},
					xAxis: {
						data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
					},
					yAxis: {},
					series: [{
						name: '销量',
						type: 'bar',
						data: [5, 20, 36, 10, 10, 20]
					}]
				}
			}
		},
		onLoad() {

		},
		methods: {
			changeOption() {
				const data = this.option.series[0].data
				// 随机更新示例数据
				data.forEach((item, index) => {
					data.splice(index, 1, Math.random() * 40)
				})
			},
			onViewClick(options) {
				console.log(options)
			}
		}
	}
</script>

<script module="echarts" lang="renderjs">
	let myChart
	export default {
		mounted() {
			if (typeof window.echarts === 'function') {
				this.initEcharts()
			} else {
				// 动态引入较大类库避免影响页面展示
				const script = document.createElement('script')
				// view 层的页面运行在 www 根目录,其相对路径相对于 www 计算
				script.src = 'static/echarts.js' // 展示核心文件路径,不要乱动
				script.onload = this.initEcharts.bind(this)
				document.head.appendChild(script)
			}
		},
		methods: {
			initEcharts() {
				myChart = echarts.init(document.getElementById('echarts'))
				// 观测更新的数据在 view 层可以直接访问到
				myChart.setOption(this.option)
			},
			updateEcharts(newValue, oldValue, ownerInstance, instance) {
				// 监听 service 层数据变更
				myChart.setOption(newValue)
			},
			onClick(event, ownerInstance) {
				// 调用 service 层的方法
				ownerInstance.callMethod('onViewClick', {
					test: 'test'
				})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.echarts {
		margin-top: 100px;
		width: 100%;
		height: 300px;
	}
</style>

其中 <script module="echarts" lang="renderjs"> 以及上面 定义的

<view @click="echarts.onClick" :prop="option" :change:prop="echarts.updateEcharts" id="echarts" class="echarts"></view>

使其显示,随后我们就可以随心所欲的在项目中使用Echarts进行绘图了

说回正题,formatter: ()=> {} 方法不生效解决办法可在   updateEcharts() 方法中重新给对象赋值。

updateEcharts(newValue, oldValue, ownerInstance, instance) {
				// 监听 service 层数据变更
				newValue.xAxis.axisLabel.formatter = function formatter(value) {
				  return dateformat.format(new Date(value)).replace(" ", "\n");
				}

				try{
                     // newValue 是当前最新的Echarts 对象  对axisLabel 对象重新挂载formatter 函数
					newValue.yAxis[0].axisLabel.formatter = function formatter (value) {
						 return parseFloat(value.toFixed(newValue.yAxis[0].fixedLeftNum));
					}
					newValue.yAxis[1].axisLabel.formatter = function formatter (value) {
						 return parseFloat(value.toFixed(newValue.yAxis[1].fixedNum));
					}
				}catch(e){}
				setTimeout(() => {
					myChart.setOption(newValue, true)
				}, 500);
			},

重新挂载formatter对象后完美解决axisLabel展示问题(如图)

 

 因当前数据量很大,所以感觉有些拥挤,可使用dataZoom属性进行调整

上图完整代码以及数据可查看https://download.csdn.net/download/weixin_46021159/86406324?spm=1001.2014.3001.5503

uCharts的使用

相比较于Echarts的使用  ucharts就简单很多了,下载一个ucharts的js文件,在进行引入即可

下载地址https://gitee.com/uCharts/uCharts/tree/master

下载完成后在JS 文件中引用,  html中定义对应标签即可

// .vue 文件
<view class="charts">
  <canvas canvas-id="canvasArcbar1" id="canvasArcbar1" class="charts" bindtouchend="tap"/>
</view>
// .js 文件
import uCharts from '../../js_sdk/u-charts.js';
data() {
    return: {
        	cWidth: null, //圆环展示宽度
			cHeight: null, //圆环展示高度
			pixelRatio: 1, // 像素化,
            arcbarWidth: null // 圆弧宽度
    }
},
onLoad() {
		this.cWidth = uni.upx2px(144); // 将rpx单位值转换成px
		this.cHeight = uni.upx2px(144); // 将rpx单位值转换成px
		this.arcbarWidth = uni.upx2px(16); // 将rpx单位值转换成px
},
// 取得数据后定义战术数据
getServerData(series1) {
			let Arcbar1 = {
				series: []
			};
			Arcbar1.series = [{
				title: this.convertNum(series1[0]),
				color: series1[0] != '0' ? "#17B770":'#e8e8e8',
				data: series1[1] != '0' ? String(Number(series1[0] / series1[1]).toFixed(2)) : '0.00',
				index: 0,
				legendShape: "circle",
				name: `/${series1[1]}`,
				pointShape: "circle",
				show: true,
				type: "arcbar"
			}];

			this.showArcbar("canvasArcbar1", Arcbar1, 1.5, series1);

		},
		// 环形图配置
		showArcbar(canvasId, chartData, startrotate, data) {
			let titX = 0,titY = 0,subX = 0, subY = 0; // 设置文字偏移量 用于展示
			if(data[0]>99||data[1]>99){
				titX = 0;
				titY = 0;
				subX = 0;
				subY = 0;
			}else if(data[0]>99){
				titX = -12;
				titY = 5;
				subX = 15;
				subY = -10;
			}else if(data[0]>9){
				titX = -10;
				titY = 5;
				subX = 10;
				subY = -10;
			}else{
				titX = -5;
				titY = 5;
				subX = 10;
				subY = -10;
			}
			let canvaArcbar1 = new uCharts({
					$this: this,
					canvasId: canvasId,
					type: 'arcbar',
					fontSize: 8,
					legend: {
						show: false
					},
					// loadingType: 0,
					background: '#e8e8e8',
					pixelRatio: this.pixelRatio,
					series: chartData.series,
					animation: true,
					width: this.cWidth * this.pixelRatio,
					height: this.cHeight * this.pixelRatio,
					dataLabel: true,
					title: {
						name: chartData.series[0].title,
						color: "#17B770",
						fontSize: 14 * this.pixelRatio,
						offsetX: titX * this.pixelRatio,
						offsetY: titY * this.pixelRatio,
					},
					subtitle: {
						name: chartData.series[0].name,
						color: '#929292',
						fontSize: 8 * this.pixelRatio,
						offsetX: subX * this.pixelRatio,
						offsetY: subY * this.pixelRatio,
					},
					extra: {
						arcbar: {
							gap: 2,
							direction: "ccw",
							backgroundColor: '#e8e8e8',
							type: 'circle', //整圆类型进度条图
							width: this.arcbarWidth * this.pixelRatio, //圆弧的宽度
							startAngle: startrotate, //整圆类型只需配置起始角度即可
							endAngle: 0.25, 
						}
					}
				});
			if (this.timer !== null) {
			      clearTimeout(this.timer);
				  this.timer = null
			}
		},
		// 数值转换
		convertNum(num) {
			if (num >= 10000) {
				if (num > 10000) {
					return Math.floor(num / 10000) + 'W+';
				} else {
					return Math.floor(num / 10000) + 'W';
				}
		
			} else {
				return num + '';
			}
		},

上述代码完成效果图

 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
app.title = '气泡'; var data = [ [['2015/1/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/1/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/2/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/3/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/4/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/5/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/6/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/7/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/8/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/9/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/10/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/11/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2015/12/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2016/5/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2017/6/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2018/9/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2019/2/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2019/5/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"'], ['2019/7/1',10,'0','系列"游戏1"点"2015/01/01(2015/01/01,0.6)"']], [['2015/1/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/1/6',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/2/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/3/24',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/4/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/5/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/6/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/7/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/8/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/9/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/10/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/11/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/12/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2016/1/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2017/1/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2018/1/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2019/1/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2019/1/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2019/1/1',20,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"']], [['2015/1/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/2/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/3/23',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/4/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/5/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/6/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/7/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/8/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/9/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/10/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/11/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/12/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2016/1/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2016/2/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2016/3/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2016/4/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2017/5/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2018/6/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2019/7/1',30,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"']], [['2015/1/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/2/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/3/23',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/4/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/5/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/6/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/7/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/8/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/9/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/10/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/11/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2015/12/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2016/1/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2016/2/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2016/3/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2016/4/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2017/5/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2018/6/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"'], ['2019/7/1',40,'0','系列"游戏2"点"2015/01/01(2015/01/01,0.6)"']], [['2015/1/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/2/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/3/23',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/4/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/5/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/6/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/7/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/8/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/9/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/10/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/11/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2015/12/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2016/1/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2016/2/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2016/3/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2016/4/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2017/5/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2019/6/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"'], ['2019/7/1',50,'0','系列"游戏3"点"2015/01/01(2015/01/01,0.6)"']], [['2015/1/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/2/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/3/23',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/4/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/5/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/6/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/7/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/8/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/9/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/10/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/11/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/12/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2016/1/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2016/2/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2016/3/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2016/4/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2017/5/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2018/6/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2019/7/1',60,'0','系列"在游戏2范围内"点"2015/01/01(2015/01/01,0.6)"']], [['2015/1/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/2/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/3/23',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/4/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/5/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/6/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/7/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/8/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/9/14',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/10/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/11/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2015/12/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2016/1/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2016/2/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2016/3/16',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2016/4/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2017/5/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2018/6/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"'], ['2019/7/1',70,'0','系列"在游戏3范围内"点"2015/01/01(2015/01/01,0.6)"']] ]; option = { backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [{ offset: 0, color: '#f7f8fa' }, { offset: 1, color: '#cdd0d5' }]), title: { text: '2015年装备重大游戏1与/游戏2情况统计', subtext:'', x:'center', y:'top', textAlign:'center' }, legend: { orient: 'horizontal', // 'vertical' x: 'center', // 'center' | 'left' | {number}, y: 'bottom', // 'center' | 'bottom' | {number} //backgroundColor: '#fff', // borderColor: 'rgba(178,34,34,0.8)', // borderWidth: 4, padding: 5, // [5, 10, 15, 20] itemGap: 20, data: ['游戏1', '游戏2', '游戏3', '游戏2', '游戏3', '在游戏2范围内', '在游戏3范围内'] }, xAxis: { type: 'time', name:'时间', splitLine: { show: true, lineStyle:{ color: ['#315070'], width: 1, type: 'solid' }   } }, yAxis: { type: 'value', name:'类型', axisLabel:{ formatter : function(params){ return ""; } }, splitLine: { show: true, lineStyle:{ color: ['#4c5055'], width: 1, show:false, type: 'solid' }   } }, series: [{ //形 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow' name: '游戏1', data: data[0], type: 'scatter', symbol:"triangle", symbolSize:12, label: { emphasis: { show: true, formatter: function (param) { return param.data[3]; }, position: 'top' } }, itemStyle: { normal: { shadowBlur: 10, shadowColor: 'rgba(80, 56, 50, 0.5)', shadowOffsetY: 5, color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ offset: 0, color: 'rgb(76, 80, 85)' }, { offset: 1, color: 'rgb(85, 85, 72)' }]) } } }, { name: '游戏2', data: data[1], type: 'scatter', symbol:"rect", symbolSize: 12, label: { emphasis: { show: true, formatter: function (param) { return param.data[3]; }, position: 'top' } }, itemStyle: { normal: { shadowBlur: 10, shadowColor: 'rgba(250, 196, 122, 0.5)', shadowOffsetY: 5, color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ offset: 0, color: 'rgb(250, 139, 35)' }, { offset: 1, color: 'rgb(246, 144, 25)' }]) } } }, { name: '游戏3', data: data[2], type: 'scatter', symbol:"rect", symbolSize:12, label: { emphasis: { show: true, formatter: function (param) { return param.data[3]; }, position: 'top' } }, itemStyle: { normal: { shadowBlur: 10, shadowColor: 'rgba(25, 100, 150, 0.5)', shadowOffsetY: 5, color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ offset: 0, color: 'rgb(63, 167, 228)' }, { offset: 1, color: 'rgb(62, 157, 207)' }]) } } }, { name: '游戏2', data: data[3], type: 'scatter', symbol:"circle", symbolSize:12, label: { emphasis: { show: true, formatter: function (param) { return param.data[3]; }, position: 'top' } }, itemStyle: { normal: { shadowBlur: 10, shadowColor: 'rgba(250, 196, 122, 0.5)', shadowOffsetY: 5, color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ offset: 0, color: 'rgb(250, 139, 35)' }, { offset: 1, color: 'rgb(246, 144, 25)' }]) } } }, { name: '游戏3', data: data[4], type: 'scatter', symbol:"circle", symbolSize: 12, label: { emphasis: { show: true, formatter:15, position: 'top' } }, itemStyle: { normal: { shadowBlur: 10, shadowColor: 'rgba(25, 100, 150, 0.5)', shadowOffsetY: 5, color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ offset: 0, color: 'rgb(63, 167, 228)' }, { offset: 1, color: 'rgb(62, 157, 207)' }]) } } }, { name: '在游戏2范围内', data: data[5], type: 'scatter', symbol:"diamond", symbolSize: 12, label: { emphasis: { show: true, formatter: function (param) { return param.data[3]; }, position: 'top' } }, itemStyle: { normal: { shadowBlur: 10, shadowColor: 'rgba(250, 196, 122, 0.5)', shadowOffsetY: 5, color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ offset: 0, color: 'rgb(250, 139, 35)' }, { offset: 1, color: 'rgb(246, 144, 25)' }]) } } }, { name: '在游戏3范围内', data: data[6], type: 'scatter', symbol:"diamond", symbolSize: 12, label: { emphasis: { show: true, formatter: function (param) { return param.data[3]; }, position: 'top' } }, itemStyle: { normal: { shadowBlur: 10, shadowColor: 'rgba(25, 100, 150, 0.5)', shadowOffsetY: 5, color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ offset: 0, color: 'rgb(63, 167, 228)' }, { offset: 1, color: 'rgb(62, 157, 207)' }]) } } } ] };

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值