Got it. I was returning the wrong values from the boundingRect() method of the PlotItem.

But the other part (legend titles) is not solved.