[Chartjs]-Chart.js label with if statement

1👍

What you need is a ternary operator, it works like this:

let isTrue = true
let a = isTrue ? 1 : 0

if isTrue is true, then a is 1, if false, a is 0

In your case, you can pass following as a label:

document.getElementById('tag4').textContent == 'ITEMS IN DIFFICULTY' ? 'label if true' : 'label if false'

Leave a comment