olliejjc16 olliejjc16 - 1 month ago 16
Javascript Question

Google Charts: Chart within tooltip not displaying

I am trying to display a chart within a chart using Google Charts and have been using this link for assistance under the section: Placing charts in tooltips


I am almost finished but the issue I have is that when I hover over my main chart, the image for my tooltip chart isn't displaying, the actual src= link is displaying instead. For example:


is appearing where the image should be. Using console.log I printed the links displayed in the image out and clicked on the links. The graphs displayed fine so they are just not showing within the tooltip. This is my current code:

var data6Array = [
[auditsTotal, <?php echo $audits_total;?>, 'blue'],
[auditsInProgess, <?php echo $audits_inprogress;?>, 'orange'],
[auditsCompleted, <?php echo $audits_completed;?>, 'green']

<?php }?>

var data6ToolTipArray = [['User','auditsTotal', 'auditsInProgress', 'auditsComplete']];

var products = <?php echo json_encode($convertedAuditDataObjectsToArrays) ?>;
for (var i =0; i < products.length; i++){
var product = products[i];
var tempArray = [product["userName"], product["auditsTotal"], product["auditsInProgress"], product["auditsComplete"]];

var options6= {'title':'Audits',
hAxis: {title: 'Audits', titleTextStyle: {color: 'green'}},
vAxis: {title: 'Amount', titleTextStyle: {color: 'green'}},
tooltip: {isHTML: true}};

var tooltipOptions = {
title: 'User Audits',
legend: 'none'

var data6ToolTipData = new google.visualization.arrayToDataTable(data6ToolTipArray);
var data6ToolTipView = new google.visualization.DataView(data6ToolTipData);

for (var i = 0; i < data6Array.length; i++) {

// Set the view for each event's data
data6ToolTipView.setColumns([0, i + 1]);

var hiddenDiv = document.getElementById('chart_div6_hidden_div');
var tooltipChart = new google.visualization.ColumnChart(hiddenDiv);

google.visualization.events.addListener(tooltipChart, 'ready', function() {

// Get the PNG of the chart and set is as the src of an img tag.
var tooltipImg = '<img src="' + tooltipChart.getImageURI() + '">';

// Add the new tooltip image to your data rows.
data6Array[i][3] = tooltipImg;

tooltipChart.draw(data6ToolTipView, tooltipOptions);

var data6 = new google.visualization.DataTable();
data6.addColumn('string', 'Audits3');
data6.addColumn('number', 'Audits2');
data6.addColumn({type:'string', role: 'style'});

// Add a new column for your tooltips.
type: 'string',
label: 'Tooltip Chart',
role: 'tooltip',
'p': {'html': true}

var chart6 = new google.visualization.ColumnChart(document.getElementById('chart_div6'));
chart6.draw(data6, options6);

Just need to figure out why the tooltip graph isn't displaying when I hover over my original graph, its been driving me crazy!


in the chart options, isHTML is the wrong case

it should be --> tooltip: {isHtml: true}