Echart新版本v5弃用的一些方法警告解决方案
normal警告
[ECharts] DEPRECATED: 'normal' hierarchy in itemStyle has been removed since 4.0. All style properties are configured in itemStyle directly now.
原写法
const types = [...]
let data = []
for (let i = 0; i < types.length; i++) {
data.push({
name: types[i].name,
value: [1, types[i].start, types[i].end],
itemStyle: {
normal: {
color: types[i].color
}
}
})
}
改为直接写在 itemStyle 里面
const types = [...]
let data = []
for (let i = 0; i < types.length; i++) {
data.push({
name: types[i].name,
value: [1, types[i].start, types[i].end],
itemStyle: {
color: types[i].color
}
})
}
api.style警告
[ECharts] DEPRECATED: "api.style" has been deprecated. Please write literal style directly instead.
原写法
series: [
{
type: 'custom',
renderItem: (params, api) => {
return {
type: 'rect',
style: api.style()
}
},
data: data
}
]
改为
series: [
{
type: 'custom',
renderItem: (params, api) => {
return {
type: 'rect',
style: {
fill: api.visual('color')
}
}
},
data: data
}
]