echarts叠堆折线图的标题的位置颜色

主要实现代码

legend: {
					y: '35px',
					textStyle: { //图例文字的样式
						color: 'red',

					},
				},
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<!-- 折线统计图 -->
		<div class="row">
			<div id="main" style="width: 900px; height: 350px;  margin-top:80px;"></div>
		</div>
	</body>
	<script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.min.js" type="text/javascript"></script>
	<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
	<script type="text/javascript">
		// 折线图
		$.ajax({
			url: "test.json",
			data: {},
			type: 'GET',
			success: function(data) {
				console.log(JSON.stringify(data))
				bloodFun(data.echatX, data.echatY, data.echatY2);

			},
		});
		// 基于准备好的dom,初始化echarts实例
		var bloodChart = echarts.init(document.getElementById('main'));
		// 指定图表的配置项和数据
		function bloodFun(x_data, y_data, y2_data) {
			bloodChart.setOption({
				title: {
					text: ''
				},
				tooltip: {
					trigger: 'axis',
					axisPointer: {
						type: 'cross',
						label: {
							backgroundColor: '#6a7985'
						}
					}
				},
				legend: {
					y: '35px',
					textStyle: { //图例文字的样式
						color: 'red',

					},
				},
				toolbox: {
					feature: {
						saveAsImage: {}
					}
				},
				grid: {
					left: '3%',
					right: '4%',
					bottom: '3%',
					containLabel: true
				},
				xAxis: [{
					type: 'category',
					boundaryGap: false,
					data: x_data,
				}],
				yAxis: [{
					type: 'value'
				}],
				series: [{
						name: '高血压',
						type: 'line',
						areaStyle: {
							normal: {
								color: '#fff' //改变区域颜色
							}
						},
						itemStyle: {
							normal: {
								color: '#8cd5c2', //改变折线点的颜色
								lineStyle: {
									color: '#8cd5c2' //改变折线颜色
								}
							}
						},
						data: y_data
					},
					{
						name: '低血压',
						type: 'line',
						areaStyle: {
							normal: {
								color: '#fff' //改变区域颜色
							}
						},
						itemStyle: {
							normal: {
								color: '#8cd5c2', //改变折线点的颜色
								lineStyle: {
									color: '#8cd5c2' //改变折线颜色
								}
							}
						},
						data: y2_data
					}
				]
			});
		}
	</script>
</html>

json

{
    "echatX": [
        "2019-07-02",
        "2019-07-03",
        "2019-07-04",
        "2019-07-05",
        "2019-07-06",
        "2019-07-07",
        "2019-07-08",
        "2019-07-09",
        "2019-07-10",
        "2019-07-11",
        "2019-07-12",
        "2019-07-13",
        "2019-07-14",
        "2019-07-15"
    ],
    "echatY": [
        120,121,123,123,125,127,128,129,120,123,122,126,129,122
    ],
    "echatY2": [
        60,64,63,63,65,67,68,69,61,66,65,68,69,65
    ]
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值