Is there a way to move the tooltip above the chart?

I currently have a Google chart similar to the one shown below.

Now, I am looking to reposition the tooltip to the top of the chart without it being dependent on the location of my mouse cursor.

How can I achieve this?

Below is the code snippet:

var chartData = new google.visualization.DataTable();
chartData.addColumn('string', 'Time');
chartData.addColumn('number', 'Average Score');
chartData.addColumn({ 'type': 'string', 'role': 'tooltip', 'p': { 'html': true } });

chartData.addRows(data);

var options = {
    chartArea: { left: 0, top: 100, width: "100%", height: "100%" },
    title: '',
    opacity: 100,
    backgroundColor : {fill: '#000'},
    hAxis: {
        textPosition: 'none', 
        titleTextStyle: {color: '#333'},  
        titleTextStyle: {color: '#2902A3'},
    },
    vAxis: {
        textPosition: 'none',
        opacity: 100,
        minValue: 0,
        gridlines: { color: '#0D2B56', count: 10 },
        baselineColor: 'white',
    },
    series:{
        0:{
            color: '#3C93FF',
            areaOpacity: '0.68'
        }
    },
    crosshair: {
        orientation: 'vertical',
        trigger: 'focus',
        color: '#fff'
    },
    legend: 'none',
    tooltip: {isHtml: true},
};


google.load("visualization", "1", { packages: ["corechart"] });
var chart = new google.visualization.AreaChart(document.getElementById('chart'));
chart.draw(chartData, options);

I have also implemented the following function to generate the content for tooltips:

var createToolTip = function (name, value) {
    return '<div class="googletooltip" ><span>' + name + ':</span><span style="padding-left:20px" >' + value + '</span></div>';
}

Additionally, here is the accompanying style:

.googletooltip{
    color:#fff;
    border-style: solid;
    border-width: 2px;
    border-color: #3882C4;
    background: #000;
    padding:2px 15px 2px 15px;
    font-weight: bold;
}

Thank you very much.

Answer №1

To improve the positioning of the tooltip, consider adding a top property and a position property to the .googletooltip class. If these adjustments do not yield the desired result, experiment with the margin property. By working with these three properties in different ways, you may find success in moving the tooltip up. Please let me know if this solution does not resolve the issue.

.googletooltip{
 color:#fff;
 border-style: solid;
 border-width: 2px;
 border-color: #3882C4;
 background: #000;
 padding:2px 15px 2px 15px;
 font-weight: bold;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a circular border around a specific letter: What's the trick?

Can someone guide me on how to create a circular background behind the letter "A" using CSS? Check out the example below: ...

What is the technique to link a sidebar to the body so that it moves when the navbar

Currently, I am working on implementing Bootstrap with sidebars positioned on the left and right. While using Bootstrap works effectively in pushing the body down on mobile devices, I have encountered an issue with the sidebar not being pushed down as expe ...

What could be the reason for my onChange event not functioning properly?

The issue I'm experiencing involves my onchange event not properly copying the text from the current span to the hidden field. Any ideas on why this might be happening? Check out my code at this link. ...

Responsive mode causing navbar to break

After creating my web portfolio, I encountered an issue when viewing it on my phone. The navbar collapses but is not properly aligned and there is extra space on the right side of the viewport in the hero section that I can't seem to fix. Portfolio L ...

What impact does the margin have on the alignment of my inline-block divs at the top using flex-start?

Embarking on my journey with CSS and HTML, I am eager to enhance my understanding. While attempting to align 3 divs in an inline block at the top of the flexbox section, I expected "align-items: flex-start;" to work, but unfortunately, the divs did not re ...

Utilizing Bootstrap to allow for seamless text wrapping around a text input field

I am trying to implement a "fill-in-the-blank" feature using Bootstrap, where users need to enter a missing word to complete a sentence. Is there a way to align the text input horizontally and have the rest of the sentence wrap around it? This is my curr ...

Changing the link color in the WordPress header: A step-by-step guide

I have customized my menu at the top and I want the "Contact Us" link to appear in white. Here is what I have added so far: .cta-button { border: 2px solid red; border-radius: 15px; padding: 5px; background-color: red; top: -6px; co ...

Troubleshooting problems with Z-Index div hover overlay on [windows] and Webkit browsers (Safari, Opera, etc)

Note: This issue is specific to Windows Webkit and does not affect Macs I am attempting to create a grid with fixed-size cells containing background images. When hovered over, the background image changes and the cell's height increases, overlaying t ...

Activate SVG graphics upon entering the window (scroll)

Can anyone assist me with a challenging issue? I have numerous SVG graphics on certain pages of my website that start playing when the page loads. However, since many of them are located below the fold, I would like them to only begin playing (and play onc ...

Tips on disregarding events within an html table

I have a see-through table with a width set to 100% that houses various HTML content. I am utilizing the table to properly center a particular element on the screen. However, the table is intercepting mouse events and preventing users from clicking on lin ...

Unable to make changes to my JavaScript-enabled TO-DO List application

I am having trouble with the edit function in my code. Despite defining it, I keep getting an error message that says "Uncaught TypeError: edit is not a function". I have tried different methods to fix this issue but nothing seems to work. While the add a ...

Elevate your website design with Bootstrap by placing a fixed horizontal navigation bar above all

I am facing an issue with my vertical Bootstrap sidemenu that transitions to horizontal layout responsively. When the sidemenu switches to a horizontal display, it ends up being hidden behind other elements, particularly on smaller devices. The example de ...

Is there a way to reset the dynamic flexslider when a click event occurs?

Seeking a way to refresh the flexslider on a click event. I have embedded the flexslider in a Bootstrap pop-up and need it to update when the user clicks. The issue arises when I try to refresh the slider as it fails to display properly, likely due to losi ...

Designing the footer for small devices using Bootstrap 4, including layout, responsiveness, and hiding functionalities

Just diving into the world of Bootstrap 4 and facing a challenge with my page footer layout. I have a mockup that I'm trying to replicate: https://i.sstatic.net/pXyMR.png This is what I've come up with so far: index.html (snippet): <!-- foo ...

Using Angular 6 to load external HTML files with CSS inside a router-outlet

I'm currently working on creating a json-based dynamic template using Angular 6. There are certain scenarios where I need to fetch external html content (which could be stored in a database) along with its corresponding css (also stored separately in ...

Modify the center table cell to match the width of its content

Is there a way to make the middle table cell adjust its width based on the content inside it? I've managed to do this for a table cell at the end using: width:1px; white-space:nowrap; But I can't seem to achieve the same effect for a middle tab ...

Numerous Divs Expanding to Fit Window Size

I successfully managed to make one div expand to the size of the window, filling the screen completely. However, I am facing an issue where the other divs are overlapping each other and only displaying thing 3. How can I ensure that they do not overlap and ...

Detecting collisions on a tile map using only JavaScript

Currently, I am developing a tile-based game using a traditional method (utilizing two for loops) and struggling with writing collision detection. I want the blue square to remain on the screen and appear on top of the tiles once the start button is clicke ...

Align Horizontal Fixed Element

<html> <head> <style> #rectangle { position: absolute; right: 0; bottom: 0; width: 150px; height: 200px; } </st ...

What is the best method for creating a pop-up image with CSS3?

Hey there, I've been struggling to create a pop-up image effect using CSS and CSS3. Unfortunately, I'm facing some issues with pseudo-classes like (visited, actived, and focus) as they don't seem to work for me. The only one that works is ho ...