实现正负值及多条Y轴 Echarts柱状图
正负值及多条Y轴
话不多说,直接上代码
let xData = ['语文', '数学', '英语', '地理', '物理', '化学', '生物']
let yData = [320, 302, -341, -374, 390, 450, -420]
let max = Math.max(...yData)
// 区分正负值
let emptyData = yData.map((v, i) => {
let xColor = null
if (v >= 0) {
xColor = '#3B2C79'
} else {
xColor = '#F23B6B'
}
let item = {
value: max,
label: {
formatter: '{a|' + v + '}',
共有 0 条评论