How to change the chart type dynamically?