Passing along the mouse event to the containing canvas element that utilizes chart.js

Recently, I created a custom tooltip for my chart.js chart by implementing a div that moves above the chart. While it works well, I noticed that the tooltip is capturing mouse events rather than propagating them to the parent element (the chart) for updating data points and repositioning the tooltip accordingly. This behavior was unexpected as most people usually face the opposite issue. Despite trying to trigger bubbling by calling emit directly on the chart element or through other methods in the code, I haven't been able to achieve the desired result.

The structure of the tooltip template is as follows:

<template>
<div :style="computedStyle" class="tooltip" @mouseover="$emit('mouseover')" @mousemove="$emit('mousemove')">
    <div ref="tooltip-background" v-html="svg" class="tooltip-background"/>
    <div class="tooltip-content">
        <div v-for="item of this.items">
            <div class="tooltip-content-values">
                <span class="">User activity: </span>
                <span class="tooltip-content-values-value">{{item.value}}</span>
            </div>
        </div>
        <div class="tooltip-content-date">{{date}}</div>
    </div>
</div>
</template>

<style scoped>
.tooltip {
    position: absolute;
    width: 300px;
}

.tooltip-background {
    width: 300px;
    position: absolute;
    z-index: 1
}

.tooltip-content {
    position: absolute;
    z-index: 2;
    margin-left: 25px;
    margin-top: 3px;
    padding: 15px;
}

.tooltip-content-values {
    font-family: Work Sans, sans-serif;
    font-style: normal;
    font-weight: normal;
    font-size: 16px;
    line-height: 20px;
    color: #666666;
}

.tooltip-content-values-value {
    font-family: Work Sans, sans-serif;
    font-style: normal;
    font-weight: normal;
    font-size: 16px;
    line-height: 20px;
    color: #111111;
}

.tooltip-content-date {
    margin-top: 5px;
    font-family: Work Sans, sans-serif;
    font-style: normal;
    font-weight: 500;
    font-size: 12px;
    line-height: 24px;
    color: #666666;
    opacity: 0.5;
}
</style>

Answer №1

To prevent mouse events from affecting your elements and allow them to interact with the element behind, you can use the CSS property pointer-events.

In your specific scenario, just add the following line to your tooltip class:

.tooltip {
    pointer-events: none;
    position: absolute;
    width: 300px;
}

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

What is the most effective way to determine the data type of a value associated with a key in an interface?

In my TypeScript interface, I have defined the following structure: MyInterface { 'key1': number | string; 'key2': string; 'key3': SomeOtherInterface; } I am looking to create a new type that utilizes the properties of ...

Tips on adjusting a standard CSS layout with JavaScript and jQuery to generate a unique ID for the updated style

My CSS contains IDs that look like this: <style> .HIDE-DISPLAY-k { background-color: orange; position: fixed; width: 100%; height: 100%; top: 10px; bottom: 0px; left: 10px; right: 0px; overflow: hidden; } #SHOW- ...

Retrieving information from an API and transferring it to the state in a React component

I am currently working on a random quote generator project, and I'm facing some difficulties in passing the API data to my state and also accessing it in the QuoteComponent through props. Despite following all the correct procedures, whenever I try to ...

The API response appears to be a successful 200 status code, however the actual result is a

I'm currently working with a VUEJS / VUEJS Resources code snippet that retrieves data from an API service. fetchData: function(name){ var self = this; self.$http.get('http://www.apiservice.com/', { params: { ...

Template URI parameters are being used in a router call

Utilizing the useRouter hook in my current project. Incorporating templated pages throughout the application. Implementing a useEffect hook that responds to changes in the router and makes an API call. Attempting to forward the entire URL to /api/${path ...

Warning: Promise rejection not handled in error

I've been working with nodejs, express, and argon2 in my project. However, I encountered an error that has left me puzzled as to why it's happening. Strangely, even though I don't have any callbacks in my code, this error keeps popping up. H ...

Using a click event to target the next div and apply a CSS class using Typescript

I am trying to create a Typescript function that will locate the next div and apply a CSS class to it. Here is what I have attempted: <ul> <li><a href="#" onclick="toggle()">Item 1</a></li> <div class="content hide ...

Innovative react route

Currently, I am in the process of learning about dynamic react routes. In the code example I am working on, there are different buttons for each task. The goal is to render the WorkDetails component when a button is clicked. However, it seems to not be fun ...

Tips for detecting when the scrollbar disappears during a webpage load in Selenium

Encountering a problem with the page loader during the automation of a web application. The scrolling bar is clicking on all Web elements while each page loads. How can I wait until the scrolling bar disappears? Your suggestions are appreciated. https:// ...

Selecting the appropriate v-model for Vue.js draggable in the case of a nested list

My Vue Component <div id="main"> <h1>Vue Dragable For</h1> <div class="drag"> <ul> <li v-for="category in data"> <draggable id="category" v-model="category" :move="checkMo ...

Move the footer to the bottom of the page

Is there a way to position my footer at the bottom of the screen and make it extend to the full width in a responsive manner? Custom CSS for Footer: * { margin: 0; } html, body { height: 100%; } .page-wrap { min-height: 100%; margin-bottom: -142p ...

Obtain the title of the text generated by clicking the button using a script function

I am working on a piece of code that generates a text box within a button's onclick function. My goal is to retrieve the name value of each text box using PHP. <script language="javascript"> var i = 1; function changeIt() ...

Is there a way to obtain the guild ID during the createGuild event?

Can someone please help me figure out how to get the guild id in the event guildCreate.js? I have tried using guild.id but it returns undefined. Even when I use console.log(guild), it shows a blank space. Using client.guild.id throws an error for id. cons ...

How can I effectively exclude API keys from commits in Express by implementing a .gitignore file?

Currently, my API keys are stored in the routes/index.js file of my express app. I'm thinking that I should transfer these keys to an object in a new file located in the parent directory of the app (keys.js), and then include this file in my routes/in ...

Creating a custom dynamic favicon and title in NextJS

Hello there! I am in the process of creating a web constructor. Currently, my application functions as follows: I verify the URL that the user is visiting (such as localhost:3000) I identify their project name within my web constructor (localhost:3000 -&g ...

Concentrate on the input for the newly added item

I am currently working on a project where I have a list of items and corresponding inputs that are linked using v-for and v-model. When I click a button, a new item is added to the list. My goal is to automatically focus on the input field associated with ...

Having difficulty loading Angular2/ Tomcat resources, specifically the JS files

I am currently in the process of deploying my Angular2 web application on a Tomcat server. After running the ng build command, I have been generating a dist folder and uploading it to my Tomcat server. However, whenever I try to run my web app, I encounte ...

The basic function is ineffective when used within an if-condition

I am currently dealing with a JSON file that has some nesting: { "name": "1370", "children": [ { "name": "Position X", "value": -1 }, {...} ] "matches": [ { "certainty": 100, "match": { "name": "1370 ...

"Enhance your forms with RadixUI's beautiful designs for

New to Radix UI and styling components, I encountered difficulties while trying to adapt a JSX component to Radix UI: Utilizing Radix UI Radio Groups, I aim to style my component similar to this example from Hyper UI with grid layout showing stacked conte ...

Bootstrap-vue modal fails to appear on screen

setup dotnet core 2.1.0 "bootstrap-vue": "^2.0.0-rc.11", "nuxt": "^1.4.1", "vue": "^2.5.16", "vue-axios": "^2.1.1", "vue-router": "^3.0.1", "vue-server-renderer": "^2.1.8", "vue-template-compiler": "^2.5.16", "vue-toasted": "^1.1.24", "vuex": "^3.0.1", " ...