can each series.data data in the bar chart be set to a different itemStyle style in echarts?
//
let todayData = [3709, 2500, 2000, 2610, 1719, 433, 2644, 4205, 3372, 4384, 4078, 5227]
//
let yesterdayData = [4000, 2417, 755, 2710, 1819, 483, 2544, 4245, 3572, 2484, 4378, 5177]
let data1 = getMinExpend()
let data2 = getEconomyExpend()
let option = {
title: {
text: "",
left: "center",
top: "10px",
subtext: " VS "
},
tooltip: {},
xAxis: {
type: "category",
data: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]
},
yAxis: {},
series: [
{
name: getName(),
type: "bar",
data: data1.value,
barWidth: 40,
stack: "hours",
itemStyle: {
color: "-sharp00BFFF"
},
emphasis: {
itemStyle: {
color: "-sharp1A2F44",
borderColor: "-sharpfff"
}
}
},
{
name: "economyExpend",
type: "bar",
data: data2,
barWidth: 40,
stack: "hours",
itemStyle: {
}
}
]
}
function getMinExpend() {
let data = {
name: [],
value: []
}
for (let i=0; i<12; iPP) {
if (todayData[i] < yesterdayData[i]) {
data.value.push(todayData[i])
data.name.push("today")
} else if (todayData[i] === yesterdayData[i]){
data.value.push(todayData[i])
data.name.push("today")
} else {
data.value.push(yesterdayData[i])
data.name.push("yesterdayData")
}
}
console.log("data1", data)
return data
}
function getEconomyExpend() {
let data = []
for (let i=0;i<12;iPP) {
data.push(Math.abs(todayData[i] - yesterdayData[i]))
}
console.log("data2", data)
return data
}