Configure chart legend using function

is there anyway how to configure chart legend using function?

i have this code below but it doesn’t work

legend: function(obj){

return obj.align = “left”, obj.valign = “middle”, obj.values = [{text:“Absent” ,color:"#51c2d6"},{text:“Tardy”,color:"#4db891"},{text:“Undertime”,color:"#eeea36"}]

}

is it possible or no? thanks

this is solved.