React-chartjs-2: [question] Example for Events provided in docs?

Created on 4 Jan 2017  路  5Comments  路  Source: reactchartjs/react-chartjs-2

I'm not sure how I need to use the events specified in the docs like getElementsAtEvent. Are there any examples on this? Or can you provide one?

Most helpful comment

Hello,

Example would be similar to Bar example just you would add:

getElementsAtEvent: (elems) => {}

To the list of defined properties for the Bar component, so it would look like:

<Bar
  data={data}
  width={100}
  height={50}
  getElementsAtEvent={(elems) => {
    console.log(elems);
  }}
  options={{
    maintainAspectRatio: false
  }}
/>

Kr,

All 5 comments

i would like to know more too

Hello,

Example would be similar to Bar example just you would add:

getElementsAtEvent: (elems) => {}

To the list of defined properties for the Bar component, so it would look like:

<Bar
  data={data}
  width={100}
  height={50}
  getElementsAtEvent={(elems) => {
    console.log(elems);
  }}
  options={{
    maintainAspectRatio: false
  }}
/>

Kr,

@gor181 and what is the event that triggers it? I mean is it when the chart changes or you click on the chart or ... ?

As seen in this jsfiddle, (not rcjs2 but shows chart.js functionality) https://jsfiddle.net/f417uxcx/ it shows that this function is called from a user clicking on an active point. Hope this helps!

@jerairrest Yes it does thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Holychung picture Holychung  路  4Comments

jbbae picture jbbae  路  5Comments

davidcalhoun picture davidcalhoun  路  5Comments

pkellner picture pkellner  路  4Comments

alexchoiweb picture alexchoiweb  路  3Comments