Asset returns graph with range chooser

I am trying to build an asset returns graph, something similar to Vanguard reports (https://www.vanguard.co.uk/documents/adv/index-charts-brochure.pdf). So far it looks amazing. But what is important to me is to make range selection. I have implemented it using relayoutData event, but it resets period buttons (probably due to subrange selection) and also I have all traces shown (but some of them were hidden by clicking on legend).

Can you please give some leads on this? Maybe it is possible to make scaling on client-side without entire graph replacement?

Thanks!