Change the x-axis length of time in a time series graph (YTD, past week, 1yr, 5yrs, etc)?

I am creating a time series line graph in plotly to track performance of a stock. Is there an easy way to change the minimum and maximum boundaries of the graph’s x-axis? I’m thinking of a drop-down menu with choices “YTD,” “3 years,” “past week” or “past month.” Is this possible?

This codepen http://codepen.io/etpinard/pen/xZPVzp

could help you get started. Let me know if you have questions about it.