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开始,而是从最小值开始