I'm wondering if you shouldn't just rethink your solution. In my opinion, you're adding an unnecessary post back to the page. Instead of having the server re-write your JavaScript, include both charts on the page and use CSS to layer them on top of each other. Hide the second chart using CSS, and then use a simple JavaScript function to switch between the two charts when they click on the radio buttons. The user will experience a smaller delay between switching, and it won't require loading an entire SharePoint page over again, which is already a slow process.