Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:35:56+00:00 2026-06-07T08:35:56+00:00

I wrote a nice heatmap in javascript, and that worked pretty nice so far.

  • 0

I wrote a nice heatmap in javascript, and that worked pretty nice so far. The heatmap is basically a table with a coloring variation, based on the threshold of the value displayed in the table. I used JavaScript to create the table, and to set up the colors. However, I wanted to show a nice pop up window, so when the user hover over the table’s cell, some additional information is displayed. I found this library qTip2

$(document).ready(function(){
        
        $('#mytable td').qtip({
            overwrite : false,              // make sure it can't be overwritten
            content : {
                text : function(api){
                    return "Time spent: " + $(this).html();
                }
            },
            position : {
                my : 'top left',
                target : 'mouse',
                viewport : $(window),       //keep it on-screen at all time if possible
                adjust : {
                    x : 10, y : 10
                }
            },
            hide : {
                fixed : true                // Helps to prevent the tooltip from hiding occassionaly when tracking!
            },
            style : 'ui-tooltip-tipsy ui-tooltip-shadow'
        });
    });

This function creates the heatmap:

function makeTable(data)
    {
        var row = new Array();
        var cell = new Array();
        
        var row_num = 26;
        var cell_num = 44;
        
        var tab = document.createElement('table');
        tab.setAttribute('id', 'mytable');
        tab.border = '1px';
        
        var tbo = document.createElement('tbody');
        
        for(var i = 0; i < row_num; i++){
            row[i] = document.createElement('tr');
            
            var upper = (i+1)*44;
            var lower = i*44;
            for(var j = lower; j < upper; j++){
                cell[j] = document.createElement('td');
                //cell[j].setAttribute('class', 'selector');
                if(data[j] != undefined){
                    var count = document.createTextNode(data[j].diff);
                    cell[j].appendChild(count);
                    var index = parseInt(data[j].diff);
                    /* specify which color better suits the heatmap */
                    if(index >= 0 && index <= 100){
                        cell[j].style.backgroundColor = '#00BFFF';
                    }
                    else if(index > 100 && index <= 1000){
                        cell[j].style.backgroundColor = "#6495ED";
                    }
                    else if(index > 1000 && index <= 4000){
                        cell[j].style.backgroundColor = "#4682B4";
                    }
                    else if(index > 4000 && index <= 6000){
                        cell[j].style.backgroundColor = "#0000FF";
                    }
                    else{
                        cell[j].style.backgroundColor = "#00008B";
                    }
                    row[i].appendChild(cell[j]);
                }
            }
            
            tbo.appendChild(row[i]);
        }
        
        tab.appendChild(tbo);
        document.getElementById('mytable').appendChild(tab);
    }

Inside of my <body> tag I have:

 <div id="body">
       <div id="mytable"></div>
    </div>

However, when I load the page, I expect to see the pop up box when I hover the mouse over the table’s cell, however something happens. Also, when I execute that $(document).ready part from firebug’s terminal, then the program starts to execute as suppose to. I also made sure the library is being loaded into my page before I used it. I also don’t see any errors in the firebug’s terminal.
<script src="http://localhost/heatmap/javascript/jquery.qtip.js">

Could someone please give me a clue why is this happening?
The main function of my javascript is

function OnLoad() {
         $.post('index.php/heatmap/getDatalines', 
                function(answer){
                    var data = eval('(' + answer + ')');
                    var list = [];
                    makeTable(data);
                });
    }

Thanks

whis is called on load: google.setOnLoadCallback(OnLoad);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:35:58+00:00Added an answer on June 7, 2026 at 8:35 am

    You need to create the qtip after you have loaded the table like this:

    function OnLoad() {
        $.post('index.php/heatmap/getDatalines', 
            function(answer){
                var data = eval('(' + answer + ')');
                var list = [];
    
                makeTable(data);
    
                $('#mytable td').qtip({
                    overwrite : false,         // make sure it can't be overwritten
                    content : {
                        text : function(api){
                            return "Time spent: " + $(this).html();
                        }
                    },
                    position : {
                        my : 'top left',
                        target : 'mouse',
                        viewport : $(window),  // keep it on-screen at all time if possible
                        adjust : {
                            x : 10, y : 10
                        }
                    },
                    hide : {
                        fixed : true    // Helps to prevent the tooltip from hiding occassionaly when tracking!
                    },
                    style : 'ui-tooltip-tipsy ui-tooltip-shadow'
                });
            });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a program that simulates soft bodies using springs. It looks nice but
I wrote a nice little array class in C++ that uses void* to save
I just started with python and wrote myself a nice, small script that uses
I wrote a nice little app that gets Yahoo weather info and posts it
I wrote a function named absD that i want to return the absolute value
I wrote a nice little game which works well in its .fla form. Because
I wrote a nice little program. At some point, it is required to load
I wrote a nice ARM assembler routine a few years back and it has
I have wrote this little script which generates a nice random password. The problem
I wrote an extension in C++ that uses libtidy, and it runs perfectly under

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.