I am trying to render a highchart chart to a jquery tooltip. I also want to pass the ID of the element being hovered, so that it is passed directly to highcharts as a variable to the renderTo argument. Right now I cannot get this to work. Please click here for the JS fiddle:
My code is as follows.
$(document).tooltip({
open: function() {
var widget = $(this).data("ui-tooltip");
var widget = $(widget.element[0]).attr("id")
Highcharts.chart({
chart: {
renderTo: widget,
type: 'bar'
},
Edit
I need the ID of the hovered element. At least I think I do. The reason is that I need to feed an array specific to this ID to the highchart function. Also, I may want to hover a class and generate the graph to a div with a prefix. Here is another jsfiddle with pseudo code.
HTML
<p>
<label for="age">Your age:</label>
<input id="age" title="<div class='container' id='containerX'>
<div id='chart_containerX' style='width:500px;height:500px;background:red'>
</div>
</div>"/>
</p>
<p>Hover the field to see the tooltip.</p>
JScript
$(function() {
$(".container").tooltip({
<pseudo> get ID and generate array so that it can be passed to highcharts </pseudo>
<pseudo> get ID and add 'chart_' prefix so that it can be passed to renderTo </pseudo>
open: function(event, ui) {
ui.tooltip.highcharts({
data: { <<'array specific to this chart'>>},
chart: {
renderTo: <<chart_container (with prefix!)>>
type: 'bar'
},