结束时间:'+params.value[4].substr(5,16);;
},//数据的值
textStyle: {
fontSize: 10
}
},
legend: {//图例
data: xData,
bottom: '1%',
selectedMode: false, // 图例设为不可点击
textStyle: {
color: '#000'
}
},
toolbox:{
feature: {
saveAsImage: {}
}
},
grid: {//绘图网格
left: '3%',
right: '3%',
top: '20px',
bottom: '10%',
containLabel: true
},
xAxis: {
data: xData
},
yAxis: {
type: 'time',
interval: 3600 * 1000, //以一个小时递增
min: '2020-12-01 00:00:00', //将data里最小时间的整点时间设为min,否则min会以data里面的min为开始进行整点递增
max: '2020-12-02 08:00:00',
axisLabel: {
formatter: function (value) {
var date = new Date(value);
return getzf(date.getHours()) + ':00';
},
}
},
series: [
{
type: 'custom',
renderItem: function (params, api) {//开发者自定义的图形元素渲染逻辑,是通过书写 renderItem 函数实现的
var categoryIndex = api.value(0);//这里使用 api.value(0) 取出当前 dataItem 中第一个维度的数值。
var start = api.coord([categoryIndex, api.value(1)]); // 这里使用 api.coord(...) 将数值在当前坐标系中转换成为屏幕上的点的像素值。
var end = api.coord([categoryIndex, api.value(2)]);
var width = 70;
return {
type: 'rect',// 表示这个图形元素是矩形。还可以是 'circle', 'sector', 'polygon' 等等。
shape: echarts.graphic.clipRectByRect({ // 矩形的位置和大小。
x: start[0] - width / 2,
y: end[1],
width: width,
height: start[1] - end[1]
}, { // 当前坐标系的包围盒。
x: params.coordSys.x,
y: params.coordSys.y,
width: params.coordSys.width,
height: params.coordSys.height
}),
style: api.style()
};
},
encode: {
x: 0, // data 中『维度1』和『维度2』对应到 X 轴
y: [1, 2]// data 中『维度0』对应到 Y 轴
},
data: seriesData
}
]
};