Google Charts – Organization Chart

Google Charts – Organization Chart ”; Previous Next Organization chart helps in rendering a hierarchy of nodes, used to portray superior/subordinate relationships in an organization. For example, A family tree is a type of org chart.. We”ve already seen the configuration used to draw this chart in Google Charts Configuration Syntax chapter. So, let”s see the complete example. Configurations We”ve used OrgChart class to show organization based chart. //organization chart var chart = new google.visualization.OrgChart(document.getElementById(”container”)); Example googlecharts_organization_chart.htm Live Demo <html> <head> <title>Google Charts Tutorial</title> <script type = “text/javascript” src = “https://www.gstatic.com/charts/loader.js”> </script> <script type = “text/javascript”> google.charts.load(”current”, {packages: [”orgchart”]}); </script> </head> <body> <div id = “container” style = “width: 550px; height: 400px; margin: 0 auto”> </div> <script language = “JavaScript”> function drawChart() { // Define the chart to be drawn. var data = new google.visualization.DataTable(); data.addColumn(”string”, ”Name”); data.addColumn(”string”, ”Manager”); data.addColumn(”string”, ”ToolTip”); // For each orgchart box, provide the name, manager, and tooltip to show. data.addRows([ [{v:”Robert”, f:”Robert<div style=”color:red; font-style:italic”>President</div>”},””, ”President”], [{v:”Jim”, f:”Jim<div style=”color:red; font-style:italic”>Vice President</div>”},”Robert”, ”Vice President”], [”Alice”, ”Robert”, ””], [”Bob”, ”Jim”, ”Bob Sponge”], [”Carol”, ”Bob”, ””] ]); // Set chart options var options = {allowHtml:true}; // Instantiate and draw the chart. var chart = new google.visualization.OrgChart(document.getElementById(”container”)); chart.draw(data, options); } google.charts.setOnLoadCallback(drawChart); </script> </body> </html> Result Verify the result. Print Page Previous Next Advertisements ”;

Google Charts – Maps

Google Charts – Maps ”; Previous Next A Google Map Chart uses Google Maps API to display Map. Data values are displayed as markers on the map. Data values may be coordinates (lat-long pairs) or actual addresses. The map will be scaled accordingly so that it includes all the identified points. Sr.No. Chart Type & Description 1 Basic Map Basic Google Map. 2 Map using Latitude/Longitude Map having locations specified using Latitude and Longitude. 3 Customizing markers Customized Markers in Map. Print Page Previous Next Advertisements ”;

Google Charts – Column Charts

Google Charts – Column Charts ”; Previous Next Column charts are used to draw column based charts. In this section we”re going to discuss following types of column based charts. Sr.No. Chart Type & Description 1 Basic Column Basic Column chart. 2 Grouped Column Grouped Column chart. 3 Stacked Column Column chart having column stacked over one another. 4 Negative Stacked Column Column chart with negative stack. 5 Percentage Stacked Column Column Chart with data in percentage terms. 6 Material Column Chart A Material Design inspired column chart. 7 Column Chart with data labels Column chart with data labels. Print Page Previous Next Advertisements ”;

Google Charts – Trendline Charts

Google Charts – Trendlines Charts ”; Previous Next A trendline is a line superimposed on a chart to reveal the overall direction of the data. Google Charts can automatically generate trendlines for Sankey Charts, Scatter Charts, Stepped area charts, Table, Timelines, TreeMap, Trendlines, Bar Charts, Column Charts, and Line Charts.. We”re going to discuss following types of trendlines charts. Sr.No. Chart Type & Description 1 Basic Trendlines Chart Basic Trendlines Chart. 2 Exponential Trendlines Chart Exponential Trendlines Chart. 3 Polynomial Trendlines Chart Polynomial Trendlines Chart. Print Page Previous Next Advertisements ”;

Google Charts – Combination Chart

Google Charts – Combination Chart ”; Previous Next Combination chart helps in rendering each series as a different marker type from the following list: line, area, bars, candlesticks, and stepped area. To assign a default marker type for series, use the seriesType property. Series property is to be useed to specify properties of each series individually. We”ve already seen the configuration used to draw this chart in Google Charts Configuration Syntax chapter. So, let”s see the complete example. Configurations We”ve used ComboChart class to show combination based chart. //combination chart var chart = new google.visualization.ComboChart(document.getElementById(”container”)); Example googlecharts_combination_chart.htm Live Demo <html> <head> <title>Google Charts Tutorial</title> <script type = “text/javascript” src = “https://www.gstatic.com/charts/loader.js”> </script> <script type = “text/javascript”> google.charts.load(”current”, {packages: [”corechart”]}); </script> </head> <body> <div id = “container” style = “width: 550px; height: 400px; margin: 0 auto”> </div> <script language = “JavaScript”> function drawChart() { // Define the chart to be drawn. var data = google.visualization.arrayToDataTable([ [”Fruit”, ”Jane”, ”John”, ”Average”], [”Apples”, 3, 2, 2.5], [”Oranges”, 2, 3, 2.5], [”Pears”, 1, 5, 3], [”Bananas”, 3, 9, 6], [”Plums”, 4, 2, 3] ]); // Set chart options var options = { title : ”Fruits distribution”, vAxis: {title: ”Fruits”}, hAxis: {title: ”Person”}, seriesType: ”bars”, series: {2: {type: ”line”}} }; // Instantiate and draw the chart. var chart = new google.visualization.ComboChart(document.getElementById(”container”)); chart.draw(data, options); } google.charts.setOnLoadCallback(drawChart); </script> </body> </html> Result Verify the result. Print Page Previous Next Advertisements ”;

Google Charts – Calendar Charts

Google Charts – Calendar Charts ”; Previous Next Calendar charts are used to draw activities over the course of long span of time like months or years. In this section we”re going to discuss following types of calendar based charts. Sr.No. Chart Type & Description 1 Basic Calendar Basic Calendar chart. 2 Calendar with customized colors Customized Calendar Chart. Print Page Previous Next Advertisements ”;

Configuration Syntax

Google Charts – Configuration Syntax ”; Previous Next In this chapter we”ll showcase the configuration required to draw a chart using Google Chart API. Step 1: Create HTML Page Create an HTML page with the Google Chart libraries. googlecharts_configuration.htm <html> <head> <title>Google Charts Tutorial</title> <script type = “text/javascript” src = “https://www.gstatic.com/charts/loader.js”> </script> <script type = “text/javascript”> google.charts.load(”current”, {packages: [”corechart”]}); </script> </head> <body> <div id = “container” style = “width: 550px; height: 400px; margin: 0 auto”> </div> </body> </html> Here container div is used to contain the chart drawn using Google Chart library. Here we are loading the latest version of corecharts API using google.charts.load method. Step 2: Create configurations Google Chart library uses very simple configurations using json syntax. // Instantiate and draw the chart. var chart = new google.visualization.PieChart(document.getElementById(”container”)); chart.draw(data, options); Here data represents the json data and options represents the configuration which Google Chart library uses to draw a chart withing container div using draw() method. Now we”ll configure the various parameter to create the required json string. title Configure the options of the chart. // Set chart options var options = {”title”:”Browser market shares at a specific website, 2014”, ”width”:550, ”height”:400}; DataTable Configure the data to be displayed on the chart. DataTable is a special table structured collection which contains the data of the chart. Columns of data table represents the legends and rows represents the corresponding data. addColumn() method is used to add a column where first parameter represents the data type and second parameter represents the legend. addRows() method is used to add rows accordingly. // Define the chart to be drawn. var data = new google.visualization.DataTable(); data.addColumn(”string”, ”Browser”); data.addColumn(”number”, ”Percentage”); data.addRows([ [”Firefox”, 45.0], [”IE”, 26.8], [”Chrome”, 12.8], [”Safari”, 8.5], [”Opera”, 6.2], [”Others”, 0.7] ]); Step 3: Draw the chart // Instantiate and draw the chart. var chart = new google.visualization.PieChart(document.getElementById(”container”)); chart.draw(data, options); Example Following is the complete example − googlecharts_configuration.htm Live Demo <html> <head> <title>Google Charts Tutorial</title> <script type = “text/javascript” src = “https://www.gstatic.com/charts/loader.js”> </script> <script type = “text/javascript”> google.charts.load(”current”, {packages: [”corechart”]}); </script> </head> <body> <div id = “container” style = “width: 550px; height: 400px; margin: 0 auto”> </div> <script language = “JavaScript”> function drawChart() { // Define the chart to be drawn. var data = new google.visualization.DataTable(); data.addColumn(”string”, ”Browser”); data.addColumn(”number”, ”Percentage”); data.addRows([ [”Firefox”, 45.0], [”IE”, 26.8], [”Chrome”, 12.8], [”Safari”, 8.5], [”Opera”, 6.2], [”Others”, 0.7] ]); // Set chart options var options = {”title”:”Browser market shares at a specific website, 2014”, ”width”:550, ”height”:400}; // Instantiate and draw the chart. var chart = new google.visualization.PieChart(document.getElementById (”container”)); chart.draw(data, options); } google.charts.setOnLoadCallback(drawChart); </script> </body> </html> Following code call drawChart function to draws chart when Google Chart library get loaded completely. google.charts.setOnLoadCallback(drawChart); Result Verify the result. Print Page Previous Next Advertisements ”;

Google Charts – TreeMap Chart

Google Charts – TreeMap Chart ”; Previous Next TreeMap is a visual representation of a data tree, where each node may have zero or more children, and one parent (except for the root). Each node is displayed as a rectangle, can be sized and colored according to values that we assign. Sizes and colors are valued relative to all other nodes in the graph. Following is an example of a treemap chart. We”ve already seen the configuration used to draw this chart in Google Charts Configuration Syntax chapter. So, let”s see the complete example. Configurations We”ve used TreeMap class to show treemap diagram. //TreeMap chart var chart = new google.visualization.TreeMap(document.getElementById(”container”)); Example googlecharts_treemap.htm Live Demo <html> <head> <title>Google Charts Tutorial</title> <script type = “text/javascript” src = “https://www.gstatic.com/charts/loader.js”> </script> <script type = “text/javascript” src = “https://www.google.com/jsapi”> </script> <script type = “text/javascript”> google.charts.load(”current”, {packages: [”treemap”]}); </script> </head> <body> <div id = “container” style = “width: 550px; height: 400px; margin: 0 auto”> </div> <script language = “JavaScript”> function drawChart() { // Define the chart to be drawn. var data = new google.visualization.DataTable(); var data = google.visualization.arrayToDataTable([ [”Location”, ”Parent”, ”Market trade volume (size)”, ”Market increase/decrease (color)”], [”Global”, null, 0, 0], [”America”, ”Global”, 0, 0], [”Europe”, ”Global”, 0, 0], [”Asia”, ”Global”, 0, 0], [”Australia”, ”Global”, 0, 0], [”Africa”, ”Global”, 0, 0], [”USA”, ”America”, 52, 31], [”Mexico”, ”America”, 24, 12], [”Canada”, ”America”, 16, -23], [”France”, ”Europe”, 42, -11], [”Germany”, ”Europe”, 31, -2], [”Sweden”, ”Europe”, 22, -13], [”China”, ”Asia”, 36, 4], [”Japan”, ”Asia”, 20, -12], [”India”, ”Asia”, 40, 63], [”Egypt”, ”Africa”, 21, 0], [”Congo”, ”Africa”, 10, 12], [”Zaire”, ”Africa”, 8, 10] ]); var options = { minColor: ”#f00”, midColor: ”#ddd”, maxColor: ”#0d0”, headerHeight: 15, fontColor: ”black”, showScale: true }; // Instantiate and draw the chart. var chart = new google.visualization.TreeMap(document.getElementById(”container”)); chart.draw(data, options); } google.charts.setOnLoadCallback(drawChart); </script> </body> </html> Result Verify the result. Print Page Previous Next Advertisements ”;

Google Charts – Bar Charts

Google Charts – Bar Charts ”; Previous Next Bar charts are used to draw bar based charts. In this section we”re going to discuss following types of bar based charts. Sr.No. Chart Type & Description 1 Basic Bar Basic bar chart 2 Grouped Bar Chart Grouped Bar chart. 3 Stacked Bar Bar chart having bar stacked over one another. 4 Negative Stacked bar Bar chart with negative stack. 5 Percentage Stacked bar Bar Chart with data in percentage terms. 6 Material Bar Chart A Material Design inspired bar chart. 7 Bar Chart with data labels Bar chart with data labels. Print Page Previous Next Advertisements ”;

Google Charts – Area Charts

Google Charts – Area Charts ”; Previous Next Area charts are used to draw area based charts. In this section we”re going to discuss following types of area based charts. Sr.No. Chart Type & Description 1 Basic Area Basic area chart 2 Area with negative values Area chart having negative values. 3 Stacked area Chart having areas stacked over one another. 4 Percentage area Chart with data in percentage terms. 5 Area with missing points Chart with missing points in the data. 6 Inverted axes Area using inverted axes. Print Page Previous Next Advertisements ”;