ui.Chart.setChartType
Sets the chartType of this chart.
Returns this chart.
Usage | Returns |
---|
Chart.setChartType(chartType) | ui.Chart |
Argument | Type | Details |
---|
this: ui.chart | ui.Chart | The ui.Chart instance. |
chartType | String | The chart type; e.g 'ScatterChart', 'LineChart', and 'ColumnChart'. For the complete list of charts, see: https://developers.google.com/chart/interactive/docs/gallery |
Examples
// 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'));
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["`setChartType` defines the visual representation of data in a ui.Chart, such as 'ScatterChart', 'LineChart', or 'ColumnChart'."],["This function is called on a ui.Chart instance and takes a string argument representing the desired chart type."],["Calling `setChartType` returns the modified ui.Chart, enabling method chaining for further customization."],["A comprehensive list of supported chart types is available in the Google Charts documentation (linked in the details)."],["The provided examples demonstrate how to apply different chart types to a data table using `setChartType`."]]],["The `setChartType` method sets the type of a `ui.Chart` instance and returns the modified chart. It accepts a string argument (`chartType`) that specifies the desired chart type, such as 'ScatterChart', 'LineChart', or 'ColumnChart'. A data table is used to exemplify different chart types. Various chart examples include scatter, line, column, bar, pie, area and tables, and the complete list of chart types is found in the provided url.\n"]]