ui.Chart.setChartType

設定這個圖表的 chartType。

傳回這個圖表。

用量傳回
Chart.setChartType(chartType)ui.Chart
引數類型詳細資料
這個:ui.chartui.Chartui.Chart 執行個體。
chartType字串圖表類型,例如「ScatterChart」、「LineChart」和「ColumnChart」。如需完整圖表清單,請參閱:https://developers.google.com/chart/interactive/docs/gallery

範例

程式碼編輯器 (JavaScript)

// A data table of population for selected states.
var dataTable = [
  [{role: 'domain', label: 'State'}, {role: 'data', label: 'Population'}],
  ['CA', 37253956],
  ['NY', 19378102],
  ['IL', 12830632],
  ['MI', 9883640],
  ['OR', 3831074],
];

// Chart the data using accepted chart types.
print('Scatter chart', ui.Chart(dataTable).setChartType('ScatterChart'));
print('Line chart', ui.Chart(dataTable).setChartType('LineChart'));
print('Column chart', ui.Chart(dataTable).setChartType('ColumnChart'));
print('Bar chart', ui.Chart(dataTable).setChartType('BarChart'));
print('Pie chart', ui.Chart(dataTable).setChartType('PieChart'));
print('Area chart', ui.Chart(dataTable).setChartType('AreaChart'));
print('Table', ui.Chart(dataTable).setChartType('Table'));