Hi. I apologize for the delayed response.
You can nest the colors column in the legend field well, but a much better option would be to add another field well to take that column, and it's not very difficult:
You add a new "color" role to your dataRoles array in your capabilities object. It has to be of kind "Grouping" since you want to pass the color as a string. E.g:
{ displayName: "Colors", name: 'colors', kind: powerbi.VisualDataRoleKind.Grouping, }
And then, in you dataViewMappings array, you add the mappings for the new field in the dataViewMappings[index].categorical.categories.select[] property. E.g:
dataViewMappings: [{ categorical: { categories: { select: [{for: { in: "category" }}, {for: { in: "colors"}}], }, values: { select: [{ for: { in: "values"}}] }, }, }]
Notice that if you already set the "for" property in your categories object, instead of the "select" property, you'll have to replace it as shown in the example above.
Now, when you look inside the dataview object received by your visual, you should see that the categorical.categories[] array is populated with two objects, one for the category field well and one for the colors field well, both containing a values[] array of the same size and with corresponding indices.
EDITED:
And by "category" I mean "legend"...