如题
配置项如下
var data1 = [
[0, 23],
[1, 33],
[2, 53],
[3, 23],
[4, 23],
[5, 23],
[9, 64],
[6, 64],
[7, 3],
[8, 25]
]
function renderItem(params, api) {
var yValue = api.value(1);
var start = api.coord([api.value(0), yValue]);
var size = api.size([1, yValue]);
var style = api.style();
console.log(size)
if (yValue > 40) {
style.fill = 'red'
} else if (yValue > 10) {
style.fill = 'green'
} else {
style.fill = 'blue'
}
return {
// 当type = 'polyline'时,shape的值应该是什么。。。
type: 'rect',
shape: {
x: start[0],
y: start[1],
width: size[0],
height: size[1]
},
style: style
};
}
option = {
title: {
text: 'Profit',
left: 'center'
},
tooltip: {},
xAxis: {
scale: true
},
yAxis: {},
series: [{
type: 'custom',
renderItem: renderItem,
label: {
normal: {
show: true,
position: 'top'
}
},
dimensions: ['from', 'to', 'profit'],
encode: {
x: [0],
y: 1,
tooltip: [0, 1],
itemName: 1
},
data: data1
}]
};