In: Computer Science
Language Javascript and HTML
Google Treemap Chart is not displaying information and I don't know why.
Index.html
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['treemap']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['State', 'Region', 'Housing', 'Utilities'],
['Global', null, 0, 0],
['AK', 'Southeast', 150, 167],
['AL', 'Southeast', 79, 99],
['AR', 'Southeast', 83, 92],
['AZ', 'Southwest', 110, 95],
['CA', 'West', 184, 107],
['CO)', 'West', 103, 94],
['CT', 'Northeast', 161, 122],
['DC', 'Northeast', 248, 103],
['DE', 'Northeast', 101, 122],
['FL', 'Southeast', 92, 99],
['GA', 'Southeast', 80, 98],
['HI', 'West', 236, 167],
['IA', 'Midwest', 92, 90],
['ID', 'West', 79, 93],
['IL', 'Midwest', 89, 102],
['IN', 'Midwest', 82, 87],
['KS', 'Midwest', 85, 87],
['KY', 'Southeast', 78, 95],
['LA', 'Southeast', 91, 84],
['MA', 'Northeast', 130, 120],
['MD', 'Northeast', 175, 109],
['ME', 'Northeast', 133, 109],
['MI', 'Midwest', 86, 103],
['MN', 'Midwest', 96, 101],
['MO', 'Midwest', 80, 103],
['MS', 'Southeast', 83, 108],
['MT', 'West', 97, 88],
['NC', 'Southeast', 83, 98],
['ND', 'Midwest', 100, 82]
['NE', 'Midwest', 82, 99]
['NH', 'Northeast', 128, 125]
['NJ', 'Northeast', 166, 135]
['NM', 'Southwest', 97, 92]
['NV', 'West', 87, 84]
['NY', 'Northeast', 188, 117]
['OH', 'Midwest', 83, 97]
['OK', 'Southwest', 80, 93]
['OR', 'West', 117, 99]
['PA', 'Northeast', 98, 109]
['RI', 'Northeast', 132, 124]
['SC', 'Southeast', 83, 107]
['SD', 'Midwest', 98, 94]
['TN', 'Southeast', 78, 89]
['TX', 'Southwest', 83, 96]
['UT', 'West', 82, 85]
['VA', 'Southeast', 93, 97]
['VT', 'Northeast', 138, 128]
['WA', 'West', 102, 85]
['WI', 'Midwest', 91, 104]
['WV', 'Southeast', 86, 100]
['WY', 'West', 117, 95]
]);
tree = new google.visualization.TreeMap(document.getElementById('chart_div'));
tree.draw(data, {
minColor: '#f00',
midColor: '#ddd',
maxColor: '#0d0',
headerHeight: 15,
fontColor: 'black',
showScale: true
});
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
commas are missingin few lines:
edited code:
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['treemap']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['State', 'Region', 'Housing', 'Utilities'],
['Global', null, 0, 0],
['AK', 'Southeast', 150, 167],
['AL', 'Southeast', 79, 99],
['AR', 'Southeast', 83, 92],
['AZ', 'Southwest', 110, 95],
['CA', 'West', 184, 107],
['CO)', 'West', 103, 94],
['CT', 'Northeast', 161, 122],
['DC', 'Northeast', 248, 103],
['DE', 'Northeast', 101, 122],
['FL', 'Southeast', 92, 99],
['GA', 'Southeast', 80, 98],
['HI', 'West', 236, 167],
['IA', 'Midwest', 92, 90],
['ID', 'West', 79, 93],
['IL', 'Midwest', 89, 102],
['IN', 'Midwest', 82, 87],
['KS', 'Midwest', 85, 87],
['KY', 'Southeast', 78, 95],
['LA', 'Southeast', 91, 84],
['MA', 'Northeast', 130, 120],
['MD', 'Northeast', 175, 109],
['ME', 'Northeast', 133, 109],
['MI', 'Midwest', 86, 103],
['MN', 'Midwest', 96, 101],
['MO', 'Midwest', 80, 103],
['MS', 'Southeast', 83, 108],
['MT', 'West', 97, 88],
['NC', 'Southeast', 83, 98],
['ND', 'Midwest', 100, 82],
['NE', 'Midwest', 82, 99],
['NH', 'Northeast', 128 ,99],
['NJ', 'Northeast', 166, 135],
['NM', 'Southwest', 97, 92],
['NV', 'West', 87, 84],
['NY', 'Northeast', 188, 117],
['OH', 'Midwest', 83, 97],
['OK', 'Southwest', 80, 93],
['OR', 'West', 117, 99],
['PA', 'Northeast', 98, 109],
['RI', 'Northeast', 132, 124],
['SC', 'Southeast', 83, 107],
['SD', 'Midwest', 98, 94],
['TN', 'Southeast', 78, 89],
['TX', 'Southwest', 83, 96],
['UT', 'West', 82, 85],
['VA', 'Southeast', 93, 97],
['VT', 'Northeast', 138, 128],
['WA', 'West', 102, 85],
['WI', 'Midwest', 91, 104],
['WV', 'Southeast', 86, 100],
['WY', 'West', 117, 95],
]);
tree = new google.visualization.TreeMap(document.getElementById('chart_div'));
tree.draw(data, {
minColor: '#f00',
midColor: '#ddd',
maxColor: '#0d0',
headerHeight: 15,
fontColor: 'black',
showScale: true
});
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>