配置项
option = {
tooltip: {
trigger: ‘axis’,
axisPointer: {
type: ‘shadow’
}
},
title: {
text: ‘区间图’
},
legend: {
data: [‘平均值’]
},
xAxis: {
type: ‘value’,
},
yAxis: {
data:categoryData
},
series: [
{
type: ‘scatter’,
name: ‘average’,
data: pointData,
seriesLayoutBy:‘row’,
encode: {
x: [2,3],
y: 1
},
itemStyle: {
color: ‘#77bef7’
}
},
{
type: ‘custom’,
name: ‘平均值’,
renderItem: function renderItem(params, api) {
var yValue = api.value(0); //对应几个y轴上的项
var lowPoint = api.coord([api.value(2),yValue]); // 左起点【15,‘平均数’】【20,中位数】
var highPoint = api.coord([api.value(3),yValue]); // 右终点【156,‘平均数’】【180,中位数】
var halfWidth = 15
var style = api.style({
stroke: api.visual(‘color’),
fill: null
});
return {
type: 'group', //左边
children: [
{
type: 'line',
shape: {
x1: lowPoint[0],
y1: lowPo