Making basic charts with the "viz" library is pretty easy. Let's get started.
1 - Find the following Javascript in your code.js file.
This generates a bar chart (chartType: "BarChart"
) using data specified by the SQL statement(sql: "SELECT Major, StartingMedianSalary FROM Degrees"
) and places the chart in an HTML element with an id of "chart1" (containerId:"chart1"
). Notice that you should have a <div> tag with that id in your HTML file.
2 - Change the chartType to "ColumnChart"
In your Javascript, change the chart type to "ColumnChart". Run the web app and notice how the chart changes. It may not look good since there are so many columns squished together. Choosing the right way to visualize the data will be part of the project challenge.
3 - Change the chartType to "Histogram"
In your Javascript, change the chart type to "Histogram". Run the web app and notice how the chart changes.
4 - Add Another Chart that Uses a Different Data Table
Copy and add the following Javascript into your composeCharts( ) function.
You will also want to add the following HTML to your index.html file to provide a place for your chart.
Run your web app and you should see your new chart. This chart uses data from the "Trend" table in our database (Example Google Sheets File) to create a scatter plot (also called scatter chart).
See the Code Examples section for different charts and options you may want to use in your final dashboard, like titles and colors.