A legend can't be shown when you use a colour expression. This functionality is not yet available. If its a must have requirement, there is a workaround. I would suggest you to create a legend else were and add a image using the text object.
You can even develop an extension to achieve this and can be handled dynamically based on the colour expression of the visualisation.