Trying to build a bar chart in Business Charts. I want this chart to be one color if below RUN
and another when above. Below is my code
let AVG_RATE_PER_HOUR = [];
let FullName = [];
let RUN;
let RUN_PLUS;
context.panel.data.series.map((s) => {
if (s.refId === "AVG_RATE") {
AVG_RATE_PER_HOUR = s.fields.find((f) => f.name === 'AVG_RATE_PER_HOUR').values;
FullName = s.fields.find((f) => f.name === 'FullName').values;
} else if (s.refId === "WO_INFO") {
RUN = s.fields.find((f) => f.name === 'RUN').values;
RUN_PLUS = s.fields.find((f) => f.name === 'RUN_PLUS').values;
}
});
return {
xAxis: {
type: 'category',
data: FullName
},
yAxis: {
type: 'value'
},
visualMap: [{
pieces: [{
gte: 5,
label: ">= " + RUN,
color: "green"
}, {
lt: 5,
gt: 0,
label: "< " + RUN,
color: "red"
}],
}],
series: [
{
data: AVG_RATE_PER_HOUR,
label: {
show: true,
position: 'top',
formatter: function (data) {
return (data.value.toFixed(2))
}
},
type: 'bar'
}
]
};
When I try to use the value of RUN
for the gte
or the lt
I get an error
ECharts Execution Error
e.indexOf is not a function
but it works just fine in the lable: