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

Can a client component in NextJs retrieve data from a server component?

Apologies for the way the question is phrased. I have a server component named auth.ts that retrieves user details after they log in. This server side component is located at //auth.ts export const validateRequest = cache( async (): Promise< { use ...

Angular JS Tab Application: A Unique Way to Organize

I am in the process of developing an AngularJS application that includes tabs and dynamic content corresponding to each tab. My goal is to retrieve the content from a JSON file structured as follows: [ { "title": "Hello", "text": "Hi, my name is ...

Is there a way to incorporate a text box in javascript that displays the retrieved reference count from the database?

I'm currently working on creating a functionality that retrieves rows with the same ID from a database and displays them in a text box. Below is the PHP code I've written for retrieving all the rows: PHP: <?php include_once('pConfig ...

Customizing Vue Router Parameters by Adding a Suffix

I am running into an issue with this route path /custom/:length(\\d+-letter-)?words Even though it matches the following routes as expected ✅ /custom/3-letter-words /custom/words The problem arises when this.$route.params.length returns 3-let ...

Retrieving JSON data with Vue-xlsx

I've been using a unique vue xlsx library to handle excel sheet data, but I'm facing issues while trying to access the returned JSON in my methods. My goal is to utilize this data from the collection displayed in the template within the sendJson ...

Adjust the text size of a label in material-ui

Hey everyone, I'm struggling with something here. I need to adjust the font size of the label that goes along with my textfield. So far, I've only been able to change the font size of the input itself and not the label. Here's the code for ...

Simple request results in an error

I have been experimenting with the Electrolyte dependency injection library, but I am encountering an error even when trying a simple script that requires it. I haven't come across any discussions or problems similar to mine in relation to this issue ...

Stopping npm private organization from releasing public packages

Is there a method to restrict the publication of public packages within an npm organization? It appears that this scenario would often arise (ensuring that no member of an organization accidentally publishes a package as public when it should be private b ...

Using either Canvas.toBlob or Canvas.toDataURL results in me obtaining an image with a transparent

Hey there! I'm currently working on a project that requires the user to crop and upload images. For cropping, I am utilizing react-cropper. My challenge lies in dealing with Chrome's limitation on dataURL to 65529 pixels as mentioned in this M ...

What are some strategies for breaking down large components in React?

Picture yourself working on a complex component, with multiple methods to handle a specific task. As you continue developing this component, you may consider refactoring it by breaking it down into smaller parts, resembling molecules composed of atoms (it ...

Ways to update all URLs on a page with ajax functionality

My userscript is designed to modify the href of specific links on an IP-direct Google search page: // ==UserScript== // @name _Modify select Google search links // @include http://YOUR_SERVER.COM/YOUR_PATH/* // @include http://62.0.54.118/* // ==/Us ...

Challenges with ExpressJS 4 middleware

Trying to grasp the concept of middleware in ExpressJS 4 has been quite a challenge for me. As far as I understand, middleware are applied based on the order they are declared and can be "bound" at different levels. My current focus is on binding a middl ...

Is there a point in bundling NPM packages if they are ultimately going to be bundled by the project

I'm in the process of creating a TypeScript package for publication on NPM. My plan is to utilize this package in upcoming web development endeavors, most likely utilizing Vite. As I look ahead to constructing a future website with this module, I am c ...

What sets apart !$scope.variableName from $scope.variableName in AngularJS?

Greetings to all my fellow coders! As a newcomer in the field, I often find myself pondering over things like this. Would someone be kind enough to elucidate the dissimilarity between these two elements in AngularJs? $scope.variableName and !$scope.var ...

How to implement dynamic aggregate functions with parameters in Express and Mongoose

I have implemented an aggregate function in mongoose to fetch some data, with a static implementation. app.get("/male",function (req,res) { Record.aggregate([ { $match: {"gender": "male"} }, { $group:{ _i ...

Selenium is encountering an issue where it is unable to automatically download files, as the download confirmation

While reviewing someone else's code, I encountered an issue with automatically downloading PDF files from a web page using selenium. Despite setting the browser.helperApps.neverAsk.saveToDisk property to the PDF mime type, I am still getting the fire ...

Encountering a difficulty in sending data to the server through ajax with Cordova

I am currently working on a Phonegap Cordova project and I'm trying to send data to the server using AJAX but I'm encountering an error. Here is an example of my code: $(document).ready(function() { $('#frm').submit(function() ...

Failed to cast value "undefined" to ObjectId in the "_id" path for the model "User"

I've been encountering an issue that I can't seem to resolve despite searching on Stack and Google. My ProfileScreen.js is meant to display a user's profile, but when attempting to view the profile, I receive this error: "Cast to ObjectId fa ...

Encountering an error: Module missing after implementing state syntax

My browser console is showing the error message: Uncaught Error: Cannot find module "./components/search_bar" As I dive into learning ReactJS and attempt to create a basic component, this error pops up. It appears after using the state syntax within my ...

Creating dynamic components in Vue.js using VueJS and jQuery synergistically

New to Vue.js and in the process of building a Vue component inspired by this custom select menu. I want to include an ionicon with each list item. Typically, I can add the icon in Vue.js using: <component class="icon" :is="name-of-icon& ...