This is a migrated thread and some comments may be shown as answers.

Chart visual function scope

1 Answer 48 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jacky
Top achievements
Rank 1
Jacky asked on 08 Mar 2019, 09:04 PM
I am trying to modify the style of x-axis labels by using the Visual function.  How can I access "this" scope within that function so I can access variables in my component?  Currently, the Visual function only provides AxisLabelVisualArgs.  

1 Answer, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 12 Mar 2019, 11:02 AM
Hi Jacky,

The visual function is used as a callback and will be called in the context of the Chart.

To bind to the original scope, use either bind or an arrow function (types omitted for brevity):
constructor() {
  this.visual = this.visual.bind(this);
}

public visual(e) {
  ...
}

// or declare as and arrow function in a field

public visual = (e) => {
  ...
};


Both will result in this referring to the component instance.

Best Regards,
T. Tsonev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Jacky
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or