I am having trouble getting the hoverOffset feature to work with doughnut charts in vue-charts.js

It appears that no matter what I try, the hoverOffset property is not working on my doughnut charts.

Here's the component code:

<script>
import { Doughnut } from 'vue-chartjs'

export default {
  extends: Doughnut,
  props: {
      chartData: {type: Object, default: null},
      options: {type: Object, default: null}
},
  mounted () {
    this.renderChart(this.chartData, this.options)
  }
}
</script>

This is the testing data I'm using:

tempChartDataOne: {
        labels: [
          'something',
          'something',
          'something',
          'something',
          'something'
        ],
        datasets: [{
          label: 'My First Dataset',
          data: [20, 4, 7, 5, 2],
          backgroundColor: [
            'rgb(38, 153, 0)',
            'rgb(153, 204, 0)',
            'rgb(255, 153, 0)',
            'rgb(230, 0, 0)',
            'rgb(153, 0, 0)'
          ],
          hoverOffset: 4
        }]
      },
      tempChartDataTwo: {
        labels: [
          'something',
          'something',
          'something'
        ],
        datasets: [{
          label: 'My First Dataset',
          data: [3, 5, 10],
          backgroundColor: [
            'rgb(38, 153, 0)',
            'rgb(255, 205, 86)',
            'rgb(230, 0, 0)',
          ],
          hoverOffset: 4
        }],
        
      },
      tempChartOptions: {
        cutoutPercentage: 70,
        maintainAspectRatio: false,
      },

And here is the front-end implementation:

<div class="flex-chart-container">
            <div class="flex-chart-left">
              <doughnut-chart :chartData="tempChartDataOne" :options="tempChartOptions" ></doughnut-chart>
            </div>
            <div class="flex-chart-right">
              <doughnut-chart :chartData="tempChartDataTwo" :options="tempChartOptions"></doughnut-chart>
            </div>
</div>

In summary, I have two doughnut charts in a container side by side, but modifying the hoverOffset property does not produce any visible change.

Answer №1

The hoverOffset feature was introduced in version 3 of chart.js library. Unfortunately, since Vue-chartjs currently supports version 2 of the library, you won't be able to utilize the hoverOffset functionality in your charts until the wrapper is updated.

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

Ensuring Element-UI table column sizes accommodate content without causing text to wrap to the next line

Is there a way to adjust the column size of an Element-UI table without causing words to break onto the next line? If you take a look at the address column in this example: https://codepen.io/rameezcubet/pen/QWLoMbr I've tried using min-width="100" ...

Is it the right time to implement a JavaScript framework?

Is there a need for using JavaScript frameworks like Angular or React if you are not developing single-page websites or components that receive live updates? ...

Conceal location labels in maps provided by tilehosting.com

I am currently in the initial stages of developing a maps web application and I want to incorporate maps from tilehosting.com along with the leaflet library (leafletjs.com). Overall, it seems to be working fine, but I'm struggling with hiding the def ...

javascript + react - managing state with a combination of different variable types

In my React application, I have this piece of code where the variable items is expected to be an array based on the interface. However, in the initial state, it is set as null because I need it to be initialized that way. I could have used ?Array in the i ...

Encountering an issue where rendering a component named Exercise within the ExerciseList component is not allowed

The ExerciseList component is designed to display all the exercises that can be edited or deleted from the list. It returns the Exercise Component or function for this purpose. If anyone could take a look and help identify any mistakes in my code, it would ...

Is it appropriate to use localStorage in the createSlice "reducers" parameter of React Redux Toolkit?

I'm working on implementing a basic favorites list feature. Currently, there is no backend functionality in place so this will be stored in the localStorage. It might potentially switch to an API call in the future. Would it be considered acceptable ...

Sending the axios fetched property from the parent component to the child component results in the error message "TypeError: Cannot read property 'x' of undefined"

I've noticed that this question has been asked before, but none of the solutions provided seem to work for my situation. Parent component import axios from "axios"; import { useEffect, useState } from "react"; import Child from &q ...

Mastering the art of maximizing efficiency with the Jquery Chosen Plugin

Currently, I'm facing an issue with the jQuery chosen plugin due to my large datasets causing the select box to hang and slow down. Below is my implementation of the plugin: var request = $.ajax({ method: "POST", url: "ajaxRequest.php", d ...

The URL provided for the Ajax HTTP request is not accurate

Consider the following JavaScript code: <script type="text/javascript" charset="utf-8> function goForLogin() { var xmlhttp; xmlhttp=new XMLHttpRequest(); xmlhttp.open("POST","/account/login",true); xmlhttp.s ...

Implementing database queries using an API in Nuxt/Vue: A step-by-step guide

Recently, I delved into Vue/Nuxt and started playing around with API integration. My goal is to transfer the logic from my NuxtServerInit function to an API. nuxtServerInit(vuexContext, context) { return context.app.$axios .$get(process.env.baseUrl ...

What are the differences between using the open prop and conditionally rendering a Material-UI Modal component?

Is there a difference in using the open prop or conditionally rendering Material-UI's Modal component and its built components? The closing transition may be lost, but are there any performance advantages when dealing with multiple Modals? Example wi ...

Linking an intricate property in ExtJS to a text field

Here is an example of JSON data: { name: { firstname: 'First Name', lastname: 'Last Name' } } How do I go about loading this data into a form field in ExtJS? First Name: [ First Name ] Last Name: [ Last Name ] UPDATE: After imp ...

Attempting to test a Jasmine directive in Angular results in failure

After creating a simple directive that throws an error when the input is invalid, I encountered an issue with my testing. When attempting to test for the thrown error using expect().toThrow(), it succeeded as expected. However, the same result occurred w ...

Unable to scroll to the top of the page with JavaScript

I tried the code below but it didn't quite do the trick. Can someone assist me with refreshing the page to the top every time it loads? window.addEventListener('load', function(){ window.scrollTo(0,0) }) window.onload = (event) => { ...

The Jquery calculation is giving unexpected results by returning NaN instead of an integer

Hello, I'm attempting to create a calculation that will add up the values from multiple text inputs and then display the total in another text input field. Below is the code that I have put together for this purpose. However, when I test it out, I see ...

Uncovering the Secrets of Retrieving Nested Objects with MongoDB and Mongoose

I have a collection of documents stored in my mongodb database, each structured like this: { "current" : { "aksd" : "5555", "BullevardBoh" : "123" }, "history" : { "1" : { "deleted" : false, ...

Automatically insert nested object keys and values from jQuery into their respective div elements

Below is a sample object that I am working with: "experience": { "1": { "jobtitle": "job_title", "companyname": "company_name", "companytown": "company_town", "companycountry": "company_country", "summary": "Sum ...

Guide on Fetching an Image from a Server with Vue Js

I am trying to fetch an image from the server using Vue.js and Laravel. Below is my code: Controller public function index() { $posts = Post::all(); return response()->json(["posts" => $posts]); } Router Route::get('test','Mas ...

Angular $watch | obtaining the result from a function

I'm curious why I consistently have to use this $scope.$watch( function() { return $scope.someData; }, function( value ) { console.log( value ); }); in Angular in order for it to watch the data. It's frustrating to me because it seems un ...

Unlock the potential of HTML5 Datalist: A comprehensive guide on integrating it with

The latest version of HTML, HTML5, has introduced a new tag called datalist. This tag, when connected to <input list="datalistID">, allows for autocomplete functionality on web forms. Now the question arises - what is the most efficient approach to ...