Vue-chartjs: [help wanted] Custom positioners

Created on 26 Mar 2019  ยท  2Comments  ยท  Source: apertureless/vue-chartjs

How to create a custom positioner in vue-chartjs?
I'm trying to do this: https://stackoverflow.com/questions/38072572/position-tooltip-based-on-mouse-position in the vue way

This is my closest guess

                this.$data._chart.Tooltip.positioners = {

                    cursor: function (chartElements, coordinates) {
                        console.log(chartElements, coordinates);
                        return coordinates;
                    },

                };

except this still results in a Chart.js?30ef:7874 Uncaught TypeError: Cannot read property 'call' of undefined

Environment

  • vue.js version: 2.6.10
  • vue-chart.js version: 3.4.2 (chartjs 2.8.0)
  • npm version: 6.9.0
โ“ question

Most helpful comment

Well, if you want it on a global Level you can pretty much copy and paste the stackoverflow stuff.

import Chart from 'chart.js'
import { Bar } from 'vue-chartjs'

Chart.Tooltip.positioners.cursor = function(chartElements, coordinates) {
      return coordinates;
};

export default {
// Vue stuff
}

All 2 comments

Well, if you want it on a global Level you can pretty much copy and paste the stackoverflow stuff.

import Chart from 'chart.js'
import { Bar } from 'vue-chartjs'

Chart.Tooltip.positioners.cursor = function(chartElements, coordinates) {
      return coordinates;
};

export default {
// Vue stuff
}

Unfortunately the stack overflow question doesn't fulfill my needs, but your answer solves the issue i had with it, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

m-jooibar picture m-jooibar  ยท  4Comments

bdeanindy picture bdeanindy  ยท  3Comments

rzb picture rzb  ยท  4Comments

aido179 picture aido179  ยท  3Comments

ihrankouski picture ihrankouski  ยท  3Comments