-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
34 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
google.charts.load('current', {'packages':['treemap']}); | ||
google.charts.setOnLoadCallback(drawChart); | ||
|
||
let chart; | ||
let data; | ||
let options = { | ||
minColor: '#D3EFF4', // Light blue | ||
midColor: '#9BC8CF', // Medium blue | ||
maxColor: '#007385', // Dark blue | ||
headerHeight: 25, | ||
fontColor: 'black', | ||
showScale: true, | ||
useWeightedAverageForAggregation: true | ||
const itemDescriptions = { | ||
'Item1': 'Description for Item 1', | ||
'Item2': 'Description for Item 2', | ||
'Item3': 'Description for Item 3', | ||
// Add more items and descriptions as needed | ||
}; | ||
|
||
function drawChart() { | ||
var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1nKfr0JKhdzhHCMK1ilWhLRfPzgBd5fbpZTtXtOdglsg/gviz/tq?sheet=Sheet1'); | ||
query.send(handleQueryResponse); | ||
} | ||
|
||
function handleQueryResponse(response) { | ||
if (response.isError()) { | ||
console.error('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage()); | ||
return; | ||
} | ||
query.send(function(response) { | ||
if (response.isError()) { | ||
console.error('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage()); | ||
return; | ||
} | ||
|
||
data = response.getDataTable(); | ||
chart = new google.visualization.TreeMap(document.getElementById('chart_div')); | ||
var data = response.getDataTable(); | ||
var chart = new google.visualization.TreeMap(document.getElementById('chart_div')); | ||
|
||
google.visualization.events.addListener(chart, 'select', function() { | ||
var selection = chart.getSelection(); | ||
if (selection.length > 0) { | ||
var item = data.getValue(selection[0].row, 0); | ||
document.getElementById('info').innerText = 'You selected: ' + item; | ||
chart.setSelection([]); // Clear the selection to prevent zooming | ||
} | ||
}); | ||
google.visualization.events.addListener(chart, 'select', function() { | ||
var selection = chart.getSelection(); | ||
if (selection.length > 0) { | ||
var item = data.getValue(selection[0].row, 0); | ||
var description = itemDescriptions[item] || 'No description available for ' + item; | ||
document.getElementById('info').innerText = description; | ||
chart.setSelection([]); // Clear the selection to prevent zooming | ||
} | ||
}); | ||
|
||
chart.draw(data, options); | ||
var options = { | ||
minColor: '#D3EFF4', // Light blue | ||
midColor: '#9BC8CF', // Medium blue | ||
maxColor: '#007385', // Dark blue | ||
headerHeight: 25, | ||
fontColor: 'black', | ||
showScale: true, | ||
useWeightedAverageForAggregation: true | ||
}; | ||
|
||
// Redraw chart on window resize | ||
window.addEventListener('resize', function() { | ||
chart.draw(data, options); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters