I'm working with Google Charts to create an Organization Chart for the company I work for. We want to make it mildly interactive and I would like to be able to have a tooltip appear once the user selects a person. This tooltip would have a link to send an email directly to the person that is selected.
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('string', 'Manager');
// For each orgchart box, provide the name, manager, and tooltip to show.
data.addRows([
[{v:'Mary', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Sr. V.P. & C.F.O.</div>'},
''],
[{v:'Lois', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Admin/Tech Asst.</div>'},
'Mary'],
[{v:'Steven', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">V.P., Controller & Asst. Treasurer'}, 'Lois'],
[{v:'Pamela', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Gen. Accounting Supv.'}, 'Steven'],
[{v:'Linda', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Financial Assistant'}, 'Steven'],
[{v:'Natalie', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Sr. Accounting Supv.'}, 'Steven'],
[{v:'Doris', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Accounting Supv.'}, 'Steven'],
[{v:'Phyllis', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Accounting Assistant'}, 'Pamela'],
[{v:'Connie', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Accts. Receivable Clerk'}, 'Pamela'],
[{v:'Betty', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Staff Accountant'}, 'Natalie'],
[{v:'Williene', f:'FirstName LastName<div style="color:#7dbcf1; font-style:italic; font-size:11px;">Accts. Payable Clerk'}, 'Natalie'],
]);
//Set Chart options
var options = {'allowHtml': true,
'size':'medium',
'nodeClass':'orgNode',
'selectedNodeClass':'orgNodeSelect',
tooltip: {trigger: 'selection'}};
// Create the chart.
var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
// Set Action
/*chart.setAction({
id: 'emailSelect',
text: 'Send email'
});*/
// Draw the chart, setting the options
chart.draw(data, options);
}
Here is a jsfiddle of the code with what I have right now. I'm not entirely sure where to go from here in order to create the tooltip and create the email link.
As of now, assume we're not using database as the chart will be small.
Also, side note. Is there a way to create a dotted line from the Accounting Supv. to the Staff Accountant? Keeping the line intact from the Sr. Accounting Supervisor to the Staff Accountant, that is.
Thanks for your help!