Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
chart.js axes tick callback function doesn't receive any global data

When i try to use a global variable in this function i always get undefined. On the y axis I need to have fixed values, for example: Fault and Healthy, but chart.js work dynamically and add values.

ticks: {
  beginAtZero: true,
  max: this.numberOfMax,
  // autoSkip: false,
  callback: function(value, index, values) {
    console.log(value)
    if (values.length == 7) {
      console.log(this.currentClicked)
      switch(value) {
        case 0: 
        return "Healthy"
        case 1.0:
          return "Inner Race Fault"
        case 2.0:
          return "Outer Race Fault"
        case 3.0:
          return "Roller Element Fault"
      }
    } else if (values.length == 11) {
      switch(value) {
        case 0: 
        return "Healthy"
        case 1.0:
          return "Fault"
      }
    }              
  }

So when for example i set max: 1, then values have length 11 or when i set max: 3 then is 7. Maybe is there a way to set number of Values this same as max property?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!