-
How to do the callback on x-axis to get the label I read the docs but I struggle to create a working model. The category axis, which is the default x-axis for line and bar charts, uses the index as internal data format. For accessing the label, use this.getLabelForValue(value). API: getLabelForValue I understand the value and index on the x-axis is reference to the labels[index].
If I add return this.getLabelForValue(value) // it gives error. As it does not recognize the 'this'. Is there maybe additional explanation somewhere? Because now I can only do it by making a new array outside the chart object. Which clearly indicates my lack of knowledge of this precious JS library. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Arrow functions don't have So, // no this
callback: (value, index) => ...
// this ok
callback(value, index) {...} |
Beta Was this translation helpful? Give feedback.
Arrow functions don't have
this
. I'm guessing that is the problem.So,