Obtaining the heatmapInstance in heatmap-vue: A Step-by-Step Guide

I am currently utilizing the Vue-Wrapper for heatmap.js, which can be found at this link. However, I am encountering an issue where I am unable to call the heatmapInstance "h337" in my Vue-Component. While I can utilize the functionality, I am struggling with calling methods like getValueAt because I do not have access to the instance.

UPDATE: I have included some code below. Below is a snippet of my component where I intend to invoke these methods. Particularly, within the mouseposition() function, I need to call the method "getValueAt" (referred to as heatmapInstance), and the heatmap-vue.js has been imported into my main.js using webpack.

<template>
      <v-container>
        <v-row>
          <v-col cols="6">
            <v-card min-height="46.5em" elevation="3">
              <v-card-text class="px-0">
                <v-col cols="12" xl="6">
                  <span class="tooltip" style="display: none">tooltip</span>
                  <heatmapjs-vue
                    class="heatmapjs-container"
                    :max="max"
                    :min="min"
                    :data="heatData"
                  >
                    <v-img
                      contain
                      height="100%"
                      class="feet"
                      src="../assets/test_links_fuss-cutOut.svg"
                    ></v-img>
                  </heatmapjs-vue>
                </v-col>
       ...
   

     </template>
        <script>
        export default {
          data: () => ({
            min: null,
            max: null,
            heatData: [],
            ...
          }),
          methods: {
           ...
            mouseposition() {
              this.demoWrapper = document.querySelector(".heatmapjs-container");
              this.tooltip = document.querySelector(".tooltip");
              this.demoWrapper.onmousemove = (ev) => {
                var x = ev.layerX;
                var y = ev.layerY;
        
                // getValueAt gives us the value for a point p(x/y)
                var value = heatmapInstance.getValueAt({
                  x: x,
                  y: y,
                });
                console.log(value);
              };
            },
          },
          mounted() {
            this.mouseposition();
          },
          created() {},
        };
        </script>
        <style>
        ...
        </style>

Answer №1

I finally cracked the code without even considering using "refs" in vue.js. Despite that, here is the ultimate solution

    <vue-heatmapjs class="heatmapjsContainer" :data="heatData" ref="heatmap">
    </vue-heatmapjs>
    ...
    this.$refs.heatmap.findValue({
      x: x,
      y: y,
    });

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

Vue JS encounters difficulties when attempting to lazy load various images from a randomized image URL

I've implemented a code snippet for lazy loading images with different URLs: <img src="https://source.unsplash.com/1600x900/?hotel,booking.com?v=1" loading="lazy" /> <img src="https://source.unsplash.com/1600x900/?hot ...

Are the root options for Vue Resource being neglected?

I have set a root option in my main.js file using Vue-Resource, but the request does not seem to use this root option. Can anyone help me figure out what I am missing? Below is the code snippet: Main.js: Vue.http.options.root = 'http://api.domain.c ...

What are the steps for implementing videojs vr in a Vue.js project?

After installing the videojs vr with npm install --save videojs-vr, I attempted to use it in my project: https://i.stack.imgur.com/lSOqF.png However, I encountered this error message: https://i.stack.imgur.com/QSe1g.png Any assistance would be greatly ...

Which symbol is preferable to use in JS imports for Vue.js/Nuxt.js - the @ symbol or the ~ symbol?

I am seeking guidance on a matter that I have not been able to find a clear answer to. Webapck typically uses the ~ symbol as an alias for the root directory. However, I have noticed that some developers use the @ symbol when importing modules using ES6 s ...

The "model" feature appears to be inactive

I discovered a fiddle with a simple radio button functionality that I forked and made some modifications to. The changes worked perfectly, you can check it out in this fiddle: Vue.component('radio-button', { props: ['id', 'v ...

Incorporate the newest version of SASS in your Nuxt project using the @

Currently, I am implementing Sass into my project. I have successfully installed "node-sass" and "sass-loader", allowing me to utilize imports, variables, and other features of Sass. However, I am encountering an issue with using "@use" to employ a @mixin ...

Struggling to track user handler events of success or failure in Amazon Cognito

Seeking guidance as a newcomer to VueJS and Amazon-cognito, I am attempting to sign in through my straightforward VueJS application. Utilizing NPM and webpack, I have diligently followed the instructions detailed in amazon-cognito-auth-js Displayed below ...

Discovering the process of using Vitest in Vue 3 to test examples involving haveBeenCalledWith

Despite my struggles, including purchasing a course on testing Vitest in Vue 3 on Udemy, nothing seemed to work. However, I finally found a solution that might be helpful for others facing the same issue. ...

What is the most efficient way to retrieve API data in Laravel without using Models or resources?

Is there an API available to validate email uniqueness without the need to create a model or resource middleman? Here is my approach: customer.vue fetch(`api/validateEmail/${email}`) .then(res => res.json) .then(res => this.isEmailDuplicated = res.da ...

Validating uploaded files in Vue and Laravel: A guide for frontend file validation

I am currently working on a Vue app that has an image uploader feature allowing users to upload multiple files. I want to implement validation to ensure that only images of a specific size are uploaded. If the uploaded files do not meet the requirements, I ...

Unveiling the Nuxt/Vue frontend and Laravel backend in a local environment using Ngrok

I'm currently working on a local Vue and Nuxt environment that communicates with another local Laravel API route. I'm attempting to expose the ports using ngrok for testing purposes. Within my Nuxt/Vue setup Nuxt configuration // Configuration ...

VueJS List Animations: JavaScript hooks not triggered for all elements in the list

I've arranged a grid of divs in rows and columns, along with a transition group that looks like this: <div class="row" v-for="row in grid"> <div class="col-md-3" v-for="col in row"> <transition-group v- ...

Vue Server-Side Rendering does not retain the URL hash during redirection

Having an issue with Vue.js application and Server-side Rendering (SSR). For example, I have a page with URL anchors like this http://localhost/faq#question5 However, when running SSR, the hash part of the URL is lost. According to the documentation: r ...

Guide on removing a row from el-table using Vue.js

Below is the code for my el-table: <div class="row"> <div class="col-sm-12"> <el-table :data="membersList"> <el-table-column label="Name" prop="member_name" align="cent ...

Tips for resolving the error message: 'The "path" argument must be a string. Received type undefined' that occurs when executing 'vue add vuetify'

After successfully creating a new app using 'vue create agenda', I proceeded to cd into the project folder and run 'vue add vuetify' to integrate Vuetify. However, I encountered an unexpected error. I attempted to search for solutions ...

Need to import Vue from a JavaScript file

I am relatively new to modern frontend development tools. After installing Nodejs and NPM, I successfully downloaded packages such as "jquery" and everything was working fine. However, when I installed Webpack (version 2) and created a demo configuration f ...

What is the method for integrating my SVG icons with q-btn-toggle?

I'm currently integrating SVG icons into my project using Quasar and I am facing an issue with the q-btn-toggle component. The documentation suggests providing a direct path to the SVG file, but in reality, the icon does not display. Below is a snippe ...

Patience is key when awaiting a state update in the Vue.js router's beforeEnter guard

My goal is to control access to specific pages in my vue router. Instead of embedding authentication logic in each component, I would prefer to have a 'hasUserAccess' check in my child-routes only where it's necessary. { path: 'admi ...

Guide on implementing router view in VUEJS3 for a google chrome extension within a production build

I've been working on creating a Chromium extension using VueJS3 and everything looks great locally. However, when I export it as a Chrome extension, only the first component in my App.js is displayed. What could be causing this issue? ❤︎ Here is ...

Guide on how to verify user identities with Azure AD in a Vue.js interface and backend developed with .Net 5

Our team is currently in the process of transitioning from .Net MVC to a Vue.js front-end. We had originally implemented a custom Attribute in our MVC version that utilized Azure AD for user authentication on specific pages. This attribute verified if user ...