在Echarts中,有些属性是通用的属性,如果在组件中重复使用,不便于调整且容易造成代码冗余,建议使用变量,然后统一传入。
使用示例如下:
定义变量var labelRight = {
normal: {
position: 'right'
}
};
统一调用
data: [{
value: -0.07,
label: labelRight
},
{
value: -0.09,
label: labelRight
},
{
value: -0.23,
label: labelRight
},
{
value: -0.17,
label: labelRight
},
{
value: -0.36,
label: labelRight
}
]
Done !