echarts之散点图

var scatterDiagramChartB = echarts.init(document.getElementById("scatterDiagramB"));
var data = [
	['2018-01-01',-10],['2018-01-05',-8],['2018-01-10',-7],['2018-01-15',-6],['2018-01-20',-5],['2018-01-25',-6],
	['2018-02-01',-7],['2018-02-05',-7],['2018-02-10',-6],['2018-02-15',-8],['2018-02-20',-5],['2018-01-25',-9],
	['2018-03-01',-2],['2018-03-05',-8],['2018-03-10',-4],['2018-03-15',-8],['2018-03-20',-6],['2018-03-25',-12],
	['2018-04-01',-7],['2018-04-05',-6],['2018-04-10',-9],['2018-04-15',-6],['2018-04-20',-7],['2018-04-25',-9],
	['2018-05-01',-8],['2018-05-05',-6],['2018-05-10',-5],['2018-05-15',-6],['2018-05-20',-4],['2018-05-25',-5],
	['2018-06-01',-8],['2018-06-05',-10],['2018-06-10',-9],['2018-06-15',-8],['2018-06-20',-7],['2018-06-25',-6],
	['2018-07-01',-3],['2018-07-05',-6],['2018-07-10',-7],['2018-07-15',5],['2018-07-20',-6],['2018-07-25',-10],
	['2018-08-01',-8],['2018-08-05',-7],['2018-08-10',-8],['2018-08-15',-8],['2018-08-20',-4],['2018-08-25',-6],
	['2018-09-01',-6],['2018-09-05',5],['2018-09-10',-7],['2018-09-15',-6],['2018-09-20',-4],['2018-09-25',-6],
	['2018-10-01',-6],['2018-10-05',-7],['2018-10-10',-8],['2018-10-15',7],['2018-10-20',-6],['2018-10-25',-6],
	['2018-11-01',-7],['2018-11-06',-6]
];
scatterDiagramBoption = {
	title: {
		text: '',
	},
	tooltip: {
		trigger: 'axis',
		textStyle: {
			lineHeight: 150
		}
	},
	grid: {
		left: '3%',
		right: '7%',
		containLabel: true
	},
	legend: {
		data: ['OBS'],
		left: 'right',
		textStyle: {
			fontSize: 16,
			color: '#F1F1F3'
		}
	},
	xAxis: [
	{
		type: 'category',
		name: 'M/D',
		scale: true,
		splitLine: {
			show: false
		},
		axisLine: {
			lineStyle: {
				color: '#F1F1F3'
			},
			onZero:false
		},
		axisLabel: {
			interval: 0,
			textStyle: {
				fontSize: 10
			},
			showMinLabel: true,
			showMaxLabel: true,
			rotate: 50
		},
		axisPointer:{
			show:false
		},
		data: ['01/01','02/01','03/01','04/01','05/01','06/01','07/01','08/01','09/01','10/01','11/06']
	},{
		show: false,
		type: 'time',
		name: 'M/D',
		scale: true,
		splitLine: {
			show: false
		},
		axisLine: {
			lineStyle: {
				color: '#F1F1F3'
			},
			onZero:false
		},
		axisPointer:{
			show:true,
			type:'none'
		},
		axisLabel: {
			interval: 0,
			textStyle: {
				fontSize: 10
			},
			showMinLabel: true,
			showMaxLabel: true,
			rotate: 50
		}
	}
	],
	yAxis: [{
		type: 'value',
		scale: true,
		axisLine: {
			lineStyle: {
				color: '#F1F1F3'
			}
		},
		max: 20,
        min: -15,
		splitLine: {
			show: false
		}
	}],
	series: [

		{
			xAxisIndex: 1,
			name: 'OBS',
			type: 'scatter',
			data: data,

		}

	]

};

scatterDiagramChartB.setOption(scatterDiagramBoption);
window.addEventListener('resize', function() {
	scatterDiagramChartB.resize();
	console.info(screen.availHeight);
	console.log("散点图2resize了====>"+ new Date())
});

x轴为双轴,在xAxis中配置show: false/true,使type: 'category'的x轴显示,type: 'time'的x轴不显示,这样可以解决时间轴分布不均,无法不显示年的问题;在xAxis中配置axisPointer:{show:false/true },鼠标提示不会同时触发两个X轴。

y轴从负数开始,在x轴中配置axisLine: { onZero:false },这样X轴就不会从0开始,而是从最小值开始
          
      
            
      

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值