1 $(document).ready(function() {
2 var previousPoint = null;
3 $("#histogram_graph").bind("plothover", function (event, pos, item) {
4 $("#x").text(pos.x.toFixed(2));
5 $("#y").text(pos.y.toFixed(2));
8 if (previousPoint != item.datapoint) {
9 previousPoint = item.datapoint;
11 $("#tooltip").remove();
12 var x = item.datapoint[0].toFixed(0),
13 y = item.datapoint[1].toFixed(0);
15 showTooltip(item.pageX, item.pageY,
16 item.series.label + ": " + y + " (" + get_label(x) + ")");
17 //item.series.label + " of " + get_label(x) + " = " + y);
20 $("#tooltip").remove();
25 $('#show_all_objects').click(function() {
26 $('#all_objects').toggle('slow');
29 var choiceContainer = $('#choices');
30 $.each(datasets, function(key, val) {
31 choiceContainer.append('<br/><input type="checkbox" name="' + key +
32 '" checked="checked" id="id' + key + '">' +
33 '<label for="id' + key + '">'
34 + val.label + '</label>');
36 choiceContainer.find("input").click(plotAccordingToChoices);
38 function plotAccordingToChoices() {
41 choiceContainer.find("input:checked").each(function () {
42 var key = $(this).attr("name");
43 if (key && datasets[key])
44 data.push(datasets[key]);
48 $.plot($('#histogram_graph'), data, graph_options);
51 plotAccordingToChoices();
56 return graph_xlables[x];
59 function showTooltip(x, y, contents) {
60 $('<div id="tooltip">' + contents + '</div>').css( {
65 border: '1px solid #fdd',
67 'background-color': '#fee',
69 }).appendTo("body").fadeIn(200);