title: How to access vuejs method from inside an object ? (Vuejs 2 )
body: <p>I want to access getValue method from Chart object, but I get function undefined.</p>
  
  <pre><code>&lt;template&gt;
      &lt;div&gt;
          &lt;canvas width="600" height="400" ref="canvas"&gt;&lt;/canvas&gt;
      &lt;/div&gt;
  &lt;/template&gt;
  &lt;script&gt;
      import Vue from 'vue';
      import Chart from 'chart.js';
      import Axios from 'axios';
  
      export default {
          mixins: [DateRangeMixin],
          props: {
            // other props...
              callback: false,
          },
  
          data() {
              return {
                  chart: '',
              };
          },
  
          mounted() {
         // ...
          },
  
          methods: {
  
        //other methods...,
                 getValue(data) {
                      if (data === 1) {
                          return 'Up'
                      } else if(data === 0) {
                          return 'Down';
                      }
                  },
              render(data) {
                  this.chart = new Chart(this.$refs.canvas, {
                      type: 'line',
                      data: {
  
                          labels: Object.keys(data),
                          datasets: [{
                             // a lot of data ....                   
                              data: Object.values(data),
  
                          }]
  
                      },
                      options: {
                          scales: {
                              yAxes: [{
                                  ticks: {
                                      beginAtZero: true,
                                      callback(label, index, labels) {
                                          return this.getValue(label); // &lt;-- Tried this and got: 'this.getValue is not a function'. I understand it bounces to new Chart object, but how to resolve this?
                                      }
                                  }
                              }]
                          }
                      }
  
                  });
  
              },
          },
      };
  &lt;/script&gt;
  </code></pre>
  
  <p>I understand that it's because Chart is an object and <code>this</code> is pointing to it, but how do I resolve this and access my method from the callback ?</p>
  
  <p>I imagine if that <code>export default</code>... would be set to a <code>variable</code>, then I could access my method via <code>variable.methods.getValue</code> , but in this scenario How can I achieve my goal ?</p>