Giter Club home page Giter Club logo

Comments (7)

akashrajkn avatar akashrajkn commented on May 3, 2024 18

@maxfarseer in my case, I wanted to show data1, data2, data3 below the "data" (same index) in the tooltip (all the four have same number of elements). So you can modify the graph_data as below

graph_data: {
  labels: [],
  datasets: [{
      label: '',
      data: [],
      data1: [],
      data2: [],
      data3: [],
  }]
}

under tooltips config, you can use callbacks

tooltips: {
    mode: 'label',
    callbacks: {

        title: function(tooltipItem, data) {
            return data.labels[tooltipItem[0].index];
        },

        beforeLabel: function(tooltipItem, data) {
            return 'Data1: ' + data.datasets[tooltipItem.datasetIndex].data1[tooltipItem.index];
        },

        label: function(tooltipItem, data) {
            return 'Data2: ' + data.datasets[tooltipItem.datasetIndex].data2[tooltipItem.index];
        },
    },
}

Hope this helps.

from react-chartjs-2.

akashrajkn avatar akashrajkn commented on May 3, 2024 1

I was able to figure it out. Thanks anyway :)

from react-chartjs-2.

maxfarseer avatar maxfarseer commented on May 3, 2024

@akashrajkn can you show example? Thx!

from react-chartjs-2.

jbwebpro avatar jbwebpro commented on May 3, 2024

Your amazing!.

from react-chartjs-2.

perumalprabhu avatar perumalprabhu commented on May 3, 2024

could you please help me out while using Angular I need to pass the external array of data to populate at tooltip. If I am using the above it is not reflecting inside the "options" keyword in Chart js

from react-chartjs-2.

perumalprabhu avatar perumalprabhu commented on May 3, 2024

@maxfarseer in my case, I wanted to show data1, data2, data3 below the "data" (same index) in the tooltip (all the four have same number of elements). So you can modify the graph_data as below

graph_data: {
  labels: [],
  datasets: [{
      label: '',
      data: [],
      data1: [],
      data2: [],
      data3: [],
  }]
}

under tooltips config, you can use callbacks

tooltips: {
    mode: 'label',
    callbacks: {

        title: function(tooltipItem, data) {
            return data.labels[tooltipItem[0].index];
        },

        beforeLabel: function(tooltipItem, data) {
            return 'Data1: ' + data.datasets[tooltipItem.datasetIndex].data1[tooltipItem.index];
        },

        label: function(tooltipItem, data) {
            return 'Data2: ' + data.datasets[tooltipItem.datasetIndex].data2[tooltipItem.index];
        },
    },
}

Hope this helps.

It is not working it out is Angular 7 can you please help me out

from react-chartjs-2.

akashrajkn avatar akashrajkn commented on May 3, 2024

@perumalprabhu maybe you should try angular based chartjs wrappers.

from react-chartjs-2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.