Reputation: 1364
I am using the following code to make my chart initially. But I want to provide users with set of Charts options list like 'SteppedAreaChart', 'LineChart', 'ColumnChart'
var barChart = new google.visualization.ChartWrapper({
'chartType': 'BarChart',
'containerId': 'chart1',
'options': {
'width': '100%',
'height': 800,
'chartArea': {top: 0, right: 0, bottom: 0}
}
});
I am looking a workaround for 1. ControlWrapper to accept Chart Type 2. Then redraw the below chart accordingly
I tried using statechange no luck still.
barChart.setView({chartType: 'LineChart'});
barChart.draw();
Upvotes: 0
Views: 1337
Reputation: 3260
There is currently no control that will let you change the chart type of a chart, so your (1) is not possible. However, you should be able to make that change yourself outside of controls. What you tried could potentially work, but I don't see where you specified the data. E.g.
barChart.setDataTable(myTable);
The view_spec that you provide to setView() must contain the entire view, since you are replacing whatever had been specified previously.
Alternatively, you can just call setChartType() to change the type of the chart in the chart wrapper, like this:
barChart.setChartType('LineChart');
barChart.draw()
The docs for ChartWrapper are at: https://google-developers.appspot.com/chart/interactive/docs/reference#chartwrapperobject
Upvotes: 1