title: Printing a list by clicking chart Chart js + react
body: <p>Hi i'm having troubles printing in a alert (by clicking one of the portions), a list of users for a specific answer in chart.js + react here's my chart component</p>
  <p><strong>Piechart.js</strong></p>
  <pre><code>import React,{ Component } from 'react';
  import {Chart} from 'react-chartjs-2';
  
  class Piechart extends Component {
      constructor(props){
          super(props)
          this.chartReference = React.createRef();
          this.state = {
              data:[]
          };
      }
  
      async componentDidMount(){
          const url = &quot;https://api-tesis-marco.herokuapp.com/api/v1/questiondata/&quot;+this.props.title;
          const data = await fetch(url)
          .then(response =&gt; response.json());
          this.setState({data:data});
  
          this.myChart = new Chart(this.chartReference.current,{
              type: 'pie',
              data:{
                  labels: this.state.data.map(d=&gt;d.Respuesta),
                  datasets: [{
                      data: this.state.data.map(d=&gt;d.porcentaje),
                      backgroundColor: this.props.colors
                  }], 
              },
              options: {
                  title: {
                      display: true,
                      text: this.props.title,
                      fontSize: 20,
                      fontStyle: 'bold'
                  },
                  legend: {
                      position:'right'
                  },
                  onClick: clicked
              }
          });
  
          function clicked(evt){
              var element = this.getElementAtEvent(evt);
              if(element[0]){
                  
                  alert();
              }
          }
      }
      
  
      
      render(){
          return(
              &lt;canvas ref={this.chartReference} /&gt;
          )
      }
  }
  
  
  export default Piechart;
  </code></pre>
  <pre><code>//i having troubles passing the lists data of my request
  
  function clicked(evt){
              var element = this.getElementAtEvent(evt);
              if(element[0]){
                  //i don't know what to do here
                  alert();
              }
          }
  </code></pre>
  <p>Here is the json response of my request:</p>
  <p><strong>Data:</strong></p>
  <pre><code>[
    {
      &quot;Respuesta&quot;: &quot;A&quot;,
      &quot;porcentaje&quot;: 7,
      &quot;quien&quot;: [
        &quot;1&quot;,
        &quot;visita1&quot;
      ]
    },
    {
      &quot;Respuesta&quot;: &quot;B&quot;,
      &quot;porcentaje&quot;: 3,
      &quot;quien&quot;: [
        &quot;coco&quot;
      ]
    },
    {
      &quot;Respuesta&quot;: &quot;C&quot;,
      &quot;porcentaje&quot;: 3,
      &quot;quien&quot;: [
        &quot;Dani3l&quot;
      ]
    },
    {
      &quot;Respuesta&quot;: &quot;D&quot;,
      &quot;porcentaje&quot;: 10,
      &quot;quien&quot;: [
        &quot;Gabi&quot;,
        &quot;test&quot;,
        &quot;visita prueba&quot;
      ]
    },
    {
      &quot;Respuesta&quot;: &quot;No ha respondido&quot;,
      &quot;porcentaje&quot;: 76,
      &quot;quien&quot;: [
        &quot;9punto5&quot;,
        &quot;Colita de algodón&quot;,
        &quot;KarmenQueen&quot;,
        &quot;Prueba&quot;,
        &quot;ancova&quot;,
        &quot;cehum2&quot;,
        &quot;chuky&quot;,
        &quot;dev&quot;,
        &quot;felipe&quot;,
        &quot;gabs&quot;,
        &quot;icom2019&quot;,
        &quot;invunche&quot;,
        &quot;john&quot;,
        &quot;laura&quot;,
        &quot;marian&quot;,
        &quot;marti&quot;,
        &quot;pablazozka&quot;,
        &quot;prueba&quot;,
        &quot;test1&quot;,
        &quot;titicaco&quot;,
        &quot;visita 1&quot;,
        &quot;visita test&quot;
      ]
    }
  ]
  </code></pre>
  <p>in my clicked function how can i pass the &quot;quien&quot; lists for the specific portion of my pie chart?, so in the alert i can print the list of that portion , i'm using this as guide <a href="https://jsfiddle.net/u1szh96g/208/" rel="nofollow noreferrer">https://jsfiddle.net/u1szh96g/208/</a> but is difficult for me adapt this to react</p>